Package org.jboss.resteasy.plugins.providers.multipart

Examples of org.jboss.resteasy.plugins.providers.multipart.InputPart


                      .getStart());
      Assert.assertEquals("text/xml", multipart.getStartInfo());
      Assert.assertEquals(3, multipart.getParts().size());
      Iterator<InputPart> inputParts = multipart.getParts().iterator();
      Assert.assertEquals(inputParts.next(), multipart.getRootPart());
      InputPart rootPart = multipart.getRootPart();

      Assert.assertEquals("application", rootPart.getMediaType().getType());
      Assert.assertEquals("xop+xml", rootPart.getMediaType().getSubtype());
      Assert.assertEquals("UTF-8", rootPart.getMediaType().getParameters()
              .get("charset"));
      Assert.assertEquals("text/xml", rootPart.getMediaType().getParameters()
              .get("type"));
      Assert.assertEquals("<mymessage.xml@example.org>", rootPart
              .getHeaders().getFirst("Content-ID"));
      Assert.assertEquals("8bit", rootPart.getHeaders().getFirst(
              "Content-Transfer-Encoding"));
      Assert
              .assertEquals(
                      "<m:data xmlns:m='http://example.org/stuff'>"
                              + "<m:photo><xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' href='cid:http://example.org/me.png'/></m:photo>"
                              + "<m:sig><xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' href='cid:http://example.org/my.hsh'/></m:sig>"
                              + "</m:data>", rootPart.getBodyAsString());

      InputPart relatedPart1 = inputParts.next();
      Assert.assertEquals("image", relatedPart1.getMediaType().getType());
      Assert.assertEquals("png", relatedPart1.getMediaType().getSubtype());
      Assert.assertEquals("<http://example.org/me.png>", relatedPart1
              .getHeaders().getFirst("Content-ID"));
      Assert.assertEquals("binary", relatedPart1.getHeaders().getFirst(
              "Content-Transfer-Encoding"));
      Assert.assertEquals("// binary octets for png", relatedPart1
              .getBodyAsString());

      InputPart relatedPart2 = inputParts.next();
      Assert.assertEquals("application", relatedPart2.getMediaType()
              .getType());
      Assert.assertEquals("pkcs7-signature", relatedPart2.getMediaType()
              .getSubtype());
      Assert.assertEquals("<http://example.org/me.hsh>", relatedPart2
              .getHeaders().getFirst("Content-ID"));
      Assert.assertEquals("binary", relatedPart2.getHeaders().getFirst(
              "Content-Transfer-Encoding"));
      Assert.assertEquals("// binary octets for signature", relatedPart2
              .getBodyAsString());
   }
View Full Code Here


        String filename = "";
        Owner owner = findOwner(ownerKey);
        Map<String, Object> data = new HashMap<String, Object>();
        try {
            InputPart part = input.getParts().get(0);
            MultivaluedMap<String, String> headers = part.getHeaders();
            String contDis = headers.getFirst("Content-Disposition");
            StringTokenizer st = new StringTokenizer(contDis, ";");
            while (st.hasMoreTokens()) {
                String entry = st.nextToken().trim();
                if (entry.startsWith("filename")) {
                    filename = entry.substring(entry.indexOf("=") + 2, entry.length() - 1);
                    break;
                }
            }
            File archive = part.getBody(new GenericType<File>() {
            });
            log.info("Importing archive " + archive.getAbsolutePath() +
                " for owner " + owner.getDisplayName());
            data = importer.loadExport(owner, archive, overrides);
View Full Code Here

    String outcome = null;
   
    while(partNames.hasNext())
    {
      final String partName = partNames.next();
      final InputPart part = formData.get(partName);
      final MediaType mediaType = part.getMediaType();

      if(partName.equals("outcome"))
      {
        outcome = part.getBodyAsString();     
      }
      else if(MediaType.TEXT_PLAIN_TYPE.equals(mediaType))
      {
        // RFC2045: Each part has an optional "Content-Type" header
        // that defaults to "text/plain".
        // Can go into process without conversion
        processVars.put(partName, part.getBodyAsString());
      }
      else
      {
        // anything else turns into a DataHandler
        final byte[] data = part.getBodyAsString().getBytes();
        DataHandler dh = new DataHandler(
            new DataSource()
            {
              public InputStream getInputStream() throws IOException
              {
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.plugins.providers.multipart.InputPart

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.