Package com.esri.gpt.framework.http.multipart

Examples of com.esri.gpt.framework.http.multipart.MultiPartContentProvider


   * @throws AgpPublishException publish exception
   */
  public String execute() throws AgpServerException, AgpPublishException {
    try {
      // prepare multi-part request
      MultiPartContentProvider provider = new MultiPartContentProvider();
      StringHandler handler = new StringHandler();
      HttpClientRequest request = new HttpClientRequest();
      request.setCredentialProvider(credentialProvider);
      request.setContentProvider(provider);
      request.setMethodName(HttpClientRequest.MethodName.POST);
      request.setContentHandler(handler);
      request.setUrl(getItemUrl(getFolderName(), getItemId()) + "/update");

      // extract ESRI item info from metadata and build map of attributes out of it
      Node esriItemInfo = extractItemInfo(getMetadata());
      Map<String, List<String>> attributes = extractEsriItemAttributes(esriItemInfo);

      // obtain security token from the server
      String token = fetchToken();
     
      // set predefined data
      provider.add("token", token);
      provider.add("f", "json");
     
      // go through the list of all attributes at push it to the multi-part request
      if (!getUpdateMetadataOnly()) {
        processEsriItemAttributes(provider, attributes);
      }

      // if attributes already contain something to upload do not upload metadata;
      // it has to be done in a second round
      if (!attributes.containsKey("file") || getUpdateMetadataOnly()) {
        // set metadata
        if (!getMetadata().isEmpty()) {
          provider.add("metadata", getMetadata().getBytes("UTF-8"), "metadata.xml", "text/xml", "UTF-8");
        }
      }

      // execute request and checks for errors
      execute(request);
View Full Code Here


   * @throws AgpPublishException publish exception
   */
  public String execute() throws AgpPublishException, AgpServerException {
    try {
      // prepare multi-part request
      MultiPartContentProvider provider = new MultiPartContentProvider();
      StringHandler handler = new StringHandler();
      HttpClientRequest request = new HttpClientRequest();
      request.setCredentialProvider(credentialProvider);
      request.setContentProvider(provider);
      request.setMethodName(HttpClientRequest.MethodName.POST);
      request.setContentHandler(handler);
      request.setUrl(getFolderUrl(getFolderName()) + "/addItem");

      // extract ESRI item info from metadata and build map of attributes out of it
      Node esriItemInfo = extractItemInfo(getMetadata());
      Map<String, List<String>> attributes = extractEsriItemAttributes(esriItemInfo);

      // obtain security token from the server
      String token = fetchToken();
     
      // set predefined data
      provider.add("token", token);
      provider.add("f", "json");
      provider.add("overwrite", Boolean.toString(getOverwrite()));

      // go through the list of all attributes at push it to the multi-part request
      processEsriItemAttributes(provider, attributes);
     
      // if attributes already contain something to upload do not upload metadata;
      // it has to be done in a second round
      if (!attributes.containsKey("file")) {
        // set metadata
        if (!getMetadata().isEmpty()) {
          provider.add("metadata", getMetadata().getBytes("UTF-8"), "metadata.xml", "text/xml", "UTF-8");
        }
      }

      // execute request and checks for errors
      execute(request);
View Full Code Here

TOP

Related Classes of com.esri.gpt.framework.http.multipart.MultiPartContentProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.