Package org.apache.commons.httpclient.methods.multipart

Examples of org.apache.commons.httpclient.methods.multipart.StringPart


        if( nodeProperties.size() > 0) {
            if(multiPart) {
                final List<Part> partList = new ArrayList<Part>();
                for(NameValuePair e : nodeProperties) {
                    if (e.getValue() != null) {
                        partList.add(new StringPart(e.getName(), e.getValue(), "UTF-8"));
                    }
                }
                if  (localFile != null) {
                    partList.add(new FilePart(fieldName, localFile));
                    if (typeHint != null) {
                      partList.add(new StringPart(fieldName + "@TypeHint", typeHint));
                    }
                }
                final Part [] parts = partList.toArray(new Part[partList.size()]);
                post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
            } else {
View Full Code Here


        throws IOException {

        final Part[] parts = new Part[typeHint == null ? 1 : 2];
        parts[0] = new FilePart(fieldName, localFile);
        if (typeHint != null) {
            parts[1] = new StringPart(fieldName + "@TypeHint", typeHint);
        }
        final PostMethod post = new PostMethod(url);
        post.setFollowRedirects(false);
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
View Full Code Here

      List<Part> partsList = new ArrayList<Part>();
      for (int i=0; i < localFiles.length; i++) {
            Part filePart = new FilePart(fieldNames[i], localFiles[i]);
            partsList.add(filePart);
            if (typeHints != null) {
              Part typeHintPart = new StringPart(fieldNames[i] + "@TypeHint", typeHints[i]);
              partsList.add(typeHintPart);
            }
    }

        final Part[] parts = partsList.toArray(new Part[partsList.size()]);
View Full Code Here

                String p = iter.next();
                String[] vals = params.getParams(p);
                if (vals != null) {
                  for (String v : vals) {
                    if (this.useMultiPartPost || isMultipart) {
                      parts.add(new StringPart(p, v, "UTF-8"));
                    } else {
                      post.addParameter(p, v);
                    }
                  }
                }
View Full Code Here

      method = new PostMethod(buildBase + "/api/dependencies");
        try {
              String url = new URL(new URL(requestURL), "/maqetta/user/" + userID + "/ws/workspace/" + files[i].getPath()).toExternalForm();
              theLogger.finest("DWB: Analyse url="+url);
              Part[] parts = {
                new StringPart("value", url, "utf-8"),
                new StringPart("type", "URL")
              };
              method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams()));
              int statusCode = client.executeMethod(method);
              String body = method.getResponseBodyAsString();
              if (statusCode != HttpStatus.SC_OK) {
View Full Code Here

    PostMethod post = new PostMethod(ontologiesRestUrl);
    try {
      List<Part> partList = new ArrayList<Part>();
     
      partList.add(filePart);
      partList.add(new StringPart("sessionid", sessionId));
     
     
      // aquaportal version handling:
      if ontologyId != null ) {
        // put the ontologyId as reference for the creation of the new version
        partList.add(new StringPart("ontologyId", ontologyId));
      }
       
      String userId = _getUserId();
      partList.add(new StringPart("userId", userId));
     
      partList.add(new StringPart("urn", uri));
     
      String displayLabel = _getDisplayLabel();
      partList.add(new StringPart("displayLabel", displayLabel));
     
      String dateReleased = _getDateReleased();
      partList.add(new StringPart("dateReleased", dateReleased));

      String contactName = _getContactName();
      partList.add(new StringPart("contactName", contactName));

      String contactEmail = _getContactEmail();
      partList.add(new StringPart("contactEmail", contactEmail));

      String versionNumber = _getVersionNumber();
      partList.add(new StringPart("versionNumber", versionNumber));
     
      // FIXME: the following are hard-coded for now as they are NOT used by us (ORR)
      partList.add(new StringPart("format", "OWL-DL"));
      partList.add(new StringPart("isRemote", "0"));
      partList.add(new StringPart("statusId", "1"));
      partList.add(new StringPart("isReviewed", "1"));
      partList.add(new StringPart("codingScheme", "1"));
      partList.add(new StringPart("isManual", "1"));
      partList.add(new StringPart("isFoundry", "0"));

      // TODO: handle "categories" ?  For now, putting an arbitrary value
      // from the existing values in the default aquaportal database
      partList.add(new StringPart("categoryId", "2809"));

     
      // now, perform the POST:
      Part[] parts = partList.toArray(new Part[partList.size()]);
      post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
View Full Code Here

   
    PostMethod post = new PostMethod(action);
    try {
      List<Part> partList = new ArrayList<Part>();
     
      partList.add(new StringPart("sessionid", sessionId));
      partList.add(new StringPart("id", id));

      partList.add(new StringPart("method", "DELETE"));
      return _performPost(post, partList);
    }
    finally {
      post.releaseConnection();
    }
View Full Code Here

    }
   
    for (Entry<String, String> entry : vars.entrySet()) {
      String key = entry.getKey();
      String val = entry.getValue();
      partList.add(new StringPart(key, val));
    }
   
    // now, perform the POST:
    Part[] parts = partList.toArray(new Part[partList.size()]);
    meth.setRequestEntity(new MultipartRequestEntity(parts, meth.getParams()));
View Full Code Here

    System.out.println("Executing POST request to " +FORM_ACTION);
    PostMethod post = new PostMethod(FORM_ACTION);
    post.addRequestHeader("accept", "text/plain");
    try {
      Part[] parts = new Part[] {
          new StringPart("username", username),
          new StringPart("password", password),
          new StringPart("ontologyUri", ontologyUri),
          new FilePart("ontologyFile", partSource),
          new StringPart("graphId", graphId),
      };
      post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
      HttpClient client = new HttpClient();
      client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
View Full Code Here

            if (parameters[0] == null || parameters[0].length() == 0)
                logger.warning("Socialevent title is null!");
            else
                logger.finer("addEvent adding event title: " + parameters[0]);

            params.add(new StringPart("title", parameters[0])); //title
            params.add(new StringPart("summary", parameters[1])); // summary
            params.add(new StringPart("description", parameters[2])); // description
            params.add(new StringPart("submitter_user_name", parameters[3]));
            params.add(new StringPart("telephone", parameters[4])); //phone
            params.add(new StringPart("timezone", parameters[5])); //timezone
            params.add(new StringPart("year", parameters[6]));
            params.add(new StringPart("month", parameters[7]));
            params.add(new StringPart("day", parameters[8]));
            params.add(new StringPart("hour", parameters[9]));
            params.add(new StringPart("minute", parameters[10]));
            params.add(new StringPart("tags", parameters[11]));
           
            //add the address
            String[] addressArr = prepareAddress();
            params.add(new StringPart("street1", addressArr[0]));
            params.add(new StringPart("street2", addressArr[1]));
            params.add(new StringPart("city", addressArr[2]));
            params.add(new StringPart("state", addressArr[3]));
            params.add(new StringPart("zip", addressArr[4]));
            params.add(new StringPart("country", addressArr[5]));

            params.add(new FilePart("upload_event_image", eventImg));
            params.add(new FilePart("upload_event_literature",eventPdf));
            params.add(new StringPart("submit", "Create"));
            /****
            Part[] parts = new Part[params.size()];
            parts = params.toArray(parts);

            PostMethod post = new PostMethod(fileUploadEventURL);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.multipart.StringPart

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.