Android Open Source - msf-spaces-sdk-android Delete Request I Q






From Project

Back to project page msf-spaces-sdk-android.

License

The source code is released under:

Apache License

If you think the Android project msf-spaces-sdk-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.imc.mirror.sdk.android.packet;
/*  w ww .  ja  v a  2s  .  com*/
import java.util.Set;

import org.jdom2.Element;
import org.jdom2.output.XMLOutputter;
import org.jivesoftware.smack.packet.IQ;

import de.imc.mirror.sdk.config.NamespaceConfig;
import de.imc.mirror.sdk.exceptions.QueryException;

public class DeleteRequestIQ extends IQ {
  
  /**
   * Creates a request to delete a single data object.
   * @param objectId Identifier for the data object to delete.
   * @return IQ for the request.
   */
  public static DeleteRequestIQ createDeleteRequest(String objectId) {
    Element deleteElement = new Element("delete", NamespaceConfig.PERSISTENCE_SERVICE);
    Element objectElement = new Element("object", NamespaceConfig.PERSISTENCE_SERVICE);
    objectElement.setAttribute("id", objectId);
    deleteElement.addContent(objectElement);
    return new DeleteRequestIQ(deleteElement);
  }
  
  /**
   * Create a request to delete multiple data objects.
   * @param objectIds Set of identifiers for the data objects to delete.
   * @return IQ for the request.
   * @throws QueryException No valid query can be created based on the given paramters.
   */
  public static DeleteRequestIQ createDeleteRequest(Set<String> objectIds) throws QueryException {
    if (objectIds.isEmpty()) throw new QueryException(QueryException.Type.BAD_REQUEST, "At least one data object identifier is required to perform a delete request.");
    
    Element deleteElement = new Element("delete", NamespaceConfig.PERSISTENCE_SERVICE);
    Element objectsElement = new Element("objects", NamespaceConfig.PERSISTENCE_SERVICE);
    for (String objectId : objectIds) {
      Element objectElement = new Element("object", NamespaceConfig.PERSISTENCE_SERVICE);
      objectElement.setAttribute("id", objectId);
      objectsElement.addContent(objectElement);
    }
    deleteElement.addContent(objectsElement);
    return new DeleteRequestIQ(deleteElement);
  }

  private Element childElement;
  
  /**
   * Private constructor.
   * @param childElement Element representing the IQ packet.
   */
  private DeleteRequestIQ(Element childElement) {
    super.setType(IQ.Type.SET);
    this.childElement = childElement;
  }
  
  @Override
  public String getChildElementXML() {
    XMLOutputter out = new XMLOutputter();
    return out.outputString(childElement);
  }
}




Java Source Code List

de.imc.mirror.sdk.android.CDMDataBuilder.java
de.imc.mirror.sdk.android.CDMData.java
de.imc.mirror.sdk.android.CommandType.java
de.imc.mirror.sdk.android.ConnectionConfigurationBuilder.java
de.imc.mirror.sdk.android.ConnectionConfiguration.java
de.imc.mirror.sdk.android.ConnectionHandler.java
de.imc.mirror.sdk.android.DataHandler.java
de.imc.mirror.sdk.android.DataModel.java
de.imc.mirror.sdk.android.DataObjectBuilder.java
de.imc.mirror.sdk.android.DataObject.java
de.imc.mirror.sdk.android.DataWrapper.java
de.imc.mirror.sdk.android.NetworkInformation.java
de.imc.mirror.sdk.android.OrgaSpace.java
de.imc.mirror.sdk.android.PrivateSpace.java
de.imc.mirror.sdk.android.ProviderInitializer.java
de.imc.mirror.sdk.android.RequestFuture.java
de.imc.mirror.sdk.android.SpaceChannel.java
de.imc.mirror.sdk.android.SpaceConfiguration.java
de.imc.mirror.sdk.android.SpaceHandler.java
de.imc.mirror.sdk.android.SpaceMember.java
de.imc.mirror.sdk.android.Space.java
de.imc.mirror.sdk.android.SpacesProvider.java
de.imc.mirror.sdk.android.TeamSpace.java
de.imc.mirror.sdk.android.UserInfo.java
de.imc.mirror.sdk.android.cdm.CDMData_0_1.java
de.imc.mirror.sdk.android.cdm.CDMData_0_2.java
de.imc.mirror.sdk.android.cdm.CDMData_1_0.java
de.imc.mirror.sdk.android.cdm.CDMData_2_0.java
de.imc.mirror.sdk.android.cdm.CreationInfo.java
de.imc.mirror.sdk.android.cdm.Reference.java
de.imc.mirror.sdk.android.cdm.References.java
de.imc.mirror.sdk.android.cdm.Summary.java
de.imc.mirror.sdk.android.data.ChannelsTable.java
de.imc.mirror.sdk.android.data.DataDB.java
de.imc.mirror.sdk.android.data.DataTable.java
de.imc.mirror.sdk.android.data.MembersTable.java
de.imc.mirror.sdk.android.data.SendTable.java
de.imc.mirror.sdk.android.data.SpacesTable.java
de.imc.mirror.sdk.android.exceptions.InvalidBuildException.java
de.imc.mirror.sdk.android.exceptions.RequestException.java
de.imc.mirror.sdk.android.filter.AndFilter.java
de.imc.mirror.sdk.android.filter.DataModelFilter.java
de.imc.mirror.sdk.android.filter.NamespaceFilter.java
de.imc.mirror.sdk.android.filter.OrFilter.java
de.imc.mirror.sdk.android.filter.PeriodFilter.java
de.imc.mirror.sdk.android.filter.PublisherFilter.java
de.imc.mirror.sdk.android.filter.ReferencesFilter.java
de.imc.mirror.sdk.android.packet.DeleteRequestIQ.java
de.imc.mirror.sdk.android.packet.DeleteResponseIQ.java
de.imc.mirror.sdk.android.packet.PersistenceServiceDeleteProvider.java
de.imc.mirror.sdk.android.packet.PersistenceServiceQueryProvider.java
de.imc.mirror.sdk.android.packet.QueryRequestIQ.java
de.imc.mirror.sdk.android.packet.QueryResponseIQ.java
de.imc.mirror.sdk.android.utils.DatatypeConverter.java
de.imc.mirror.sdk.android.utils.DateToXsdDatetimeFormatter.java
org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.java
org.apache.xerces.jaxp.datatype.DurationImpl.java
org.apache.xerces.jaxp.datatype.SerializedDuration.java
org.apache.xerces.jaxp.datatype.SerializedXMLGregorianCalendar.java
org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.java
org.apache.xerces.util.DatatypeMessageFormatter.java