Package com.sun.jersey.multipart

Examples of com.sun.jersey.multipart.FormDataMultiPart


      } else {
         
          deploymentName = createDeploymentName(archive.getName());
          try {
              // Build up the POST form to send to Glassfish
              final FormDataMultiPart form = new FormDataMultiPart();
              form.field("target", this.configuration.getTarget(), MediaType.TEXT_PLAIN_TYPE);                       
              form.field("operation", DELETE_OPERATION, MediaType.TEXT_PLAIN_TYPE);
              glassFishClient.doUndeploy(this.deploymentName, form);
          } catch (GlassFishClientException e) {
              throw new DeploymentException("Could not undeploy " + archive.getName(), e);
          }
      }
View Full Code Here


     * @param pool AppThwackDevicePool which represents collection of devices to test on (native only)
     * @param optionalParams Map of optional parameters to configure this run
     * @return AppThwackRun which represents the scheduled run
     */
    private AppThwackRun scheduleRun(String name, String app, AppThwackDevicePool pool, HashMap<String, String> optionalParams) {
        FormDataMultiPart form = new FormDataMultiPart();
        form.field("project", Integer.toString(id));
        form.field("name", name);
        form.field("app", app);

        if(pool != null) {
            form.field("pool", Integer.toString(pool.id));
        }

        if(optionalParams != null) {
            for(Map.Entry<String, String> entry : optionalParams.entrySet()) {
                form.field(entry.getKey(), entry.getValue());
            }
        }

        AppThwackRun run = root.path("run").type(MediaType.MULTIPART_FORM_DATA).post(AppThwackRun.class, form);
        run.setRoot(root);
View Full Code Here

   * @param pool AppThwackDevicePool which represents collection of devices to test on (native only)
   * @param optionalParams Map of optional parameters to configure this run
   * @return AppThwackRun which represents the scheduled run
   */
  private AppThwackRun scheduleRun(String name, String app, AppThwackDevicePool pool, HashMap<String, String> optionalParams) {
    FormDataMultiPart form = new FormDataMultiPart();
    form.field("project", Integer.toString(id));
    form.field("name", name);
    form.field("app", app);
   
    if(pool != null) {
      form.field("pool", Integer.toString(pool.id));
    }
   
    if(optionalParams != null) {
      for(Map.Entry<String, String> entry : optionalParams.entrySet()) {
        form.field(entry.getKey(), entry.getValue());
      }
    }
   
    AppThwackRun run = root.path("run").type(MediaType.MULTIPART_FORM_DATA).post(AppThwackRun.class, form);
    run.setRoot(root);
View Full Code Here

  protected ClientResponse upload(WebResource webResource, File file,
      String description) throws UniformInterfaceException,
      ClientHandlerException, FileNotFoundException, ParseException,
      RequestException {
    FormDataMultiPart part = new FormDataMultiPart();
    if (description != null) {
      part.bodyPart(new FormDataBodyPart("description", description));
    }
    part.bodyPart(new FileDataBodyPart("file", file,
        MediaType.APPLICATION_OCTET_STREAM_TYPE));
    ClientResponse response = (ClientResponse) webResource
        .accept(MediaType.APPLICATION_XML)
        .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE))
        .header("description", description)
View Full Code Here

   * @param pool AppThwackDevicePool which represents collection of devices to test on (native only)
   * @param optionalParams Map of optional parameters to configure this run
   * @return AppThwackRun which represents the scheduled run
   */
  private AppThwackRun scheduleRun(String name, String app, AppThwackDevicePool pool, HashMap<String, String> optionalParams) {
    FormDataMultiPart form = new FormDataMultiPart();
    form.field("project", Integer.toString(id));
    form.field("name", name);
    form.field("app", app);
   
    if(pool != null) {
      form.field("pool", Integer.toString(pool.id));
    }
   
    if(optionalParams != null) {
      for(Map.Entry<String, String> entry : optionalParams.entrySet()) {
        form.field(entry.getKey(), entry.getValue());
      }
    }
   
    AppThwackRun run = root.path("run").type(MediaType.MULTIPART_FORM_DATA).post(AppThwackRun.class, form);
    run.setRoot(root);
View Full Code Here

    }
    if(!file.isFile()) {
      throw new AppThwackException("file cannot be a directory");
    }
   
    FormDataMultiPart form = new FormDataMultiPart();
    form.field("name", name);
    form.bodyPart(new FileDataBodyPart("file", file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
   
    return root.path("file").type(MediaType.MULTIPART_FORM_DATA).post(AppThwackFile.class, form);
  }
View Full Code Here

    @Test
    public void testPart() {
        WebResource webResource = resource().path("form/part");

        FormDataMultiPart mp = new FormDataMultiPart();
        FormDataBodyPart p = new FormDataBodyPart(FormDataContentDisposition.name("part").build(), "CONTENT");
        mp.bodyPart(p);

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("CONTENT", s);
    }
View Full Code Here

    @Test
    public void testPartWithFileName() {
        WebResource webResource = resource().path("form/part-file-name");

        FormDataMultiPart mp = new FormDataMultiPart();
        FormDataBodyPart p = new FormDataBodyPart(FormDataContentDisposition.name("part").fileName("file").build(), "CONTENT");
        mp.bodyPart(p);

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("CONTENT:file", s);
    }
View Full Code Here

    @Test
    public void testXmlJAXBPart() {
        WebResource webResource = resource().path("form/xml-jaxb-part");

        FormDataMultiPart mp = new FormDataMultiPart();
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("bean").fileName("bean").build(),
                new Bean("BEAN"),
                MediaType.APPLICATION_XML_TYPE));
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("string").fileName("string").build(),
                "STRING"));

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("STRING:string,BEAN:bean", s);
    }
View Full Code Here

   
    // create a WebResource to access the given url
    WebResource resource = Client.create().resource(url);
   
    // prepare form data for posting
    FormDataMultiPart form = new FormDataMultiPart();
   
    // set the output format to soap12
    // triggers the various outputs formats of the validator. If unset, the usual Web format will be sent.
    // If set to soap12,
    // the SOAP1.2 interface will be triggered. See the SOAP 1.2 response format description at
    //  http://validator.w3.org/docs/api.html#requestformat
    form.field("output", "soap12");
   
    // The document to validate, POSTed as multipart/form-data
    FormDataBodyPart fdp = new FormDataBodyPart("uploaded_file",
        IOUtils.toInputStream(html),
        // new FileInputStream(tmpHtml),
        MediaType.APPLICATION_OCTET_STREAM_TYPE);
   
    // attach the inputstream as upload info to the form
    form.bodyPart(fdp);
   
    // now post the form via the Internet/Intranet
    ClientResponse response = resource.type(MediaType.MULTIPART_FORM_DATA)
        .post(ClientResponse.class, form);
    // in debug mode show the response status
View Full Code Here

TOP

Related Classes of com.sun.jersey.multipart.FormDataMultiPart

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.