Package org.glassfish.jersey.media.multipart

Examples of org.glassfish.jersey.media.multipart.BodyPartEntity


            } catch (IllegalArgumentException ex) {
                throw new BadRequestException(ex);
            }

            // Copy data into a BodyPartEntity structure.
            bodyPart.setEntity(new BodyPartEntity(mimePart));

            // Add this BodyPart to our MultiPart.
            multiPart.getBodyParts().add(bodyPart);
        }
View Full Code Here


            } catch (IllegalArgumentException ex) {
                throw new BadRequestException(ex);
            }

            // Copy data into a BodyPartEntity structure.
            bodyPart.setEntity(new BodyPartEntity(mimePart));

            // Add this BodyPart to our MultiPart.
            multiPart.getBodyParts().add(bodyPart);
        }
View Full Code Here

        BodyPart part1 = multiPart.getBodyParts().get(1);
        if (!(part1.getMediaType().equals(new MediaType("x-application", "x-format")))) {
            return Response.ok("FAILED:  Second media type is " + part1.getMediaType()).build();
        }

        BodyPartEntity bpe = (BodyPartEntity) part0.getEntity();
        StringBuilder sb = new StringBuilder();
        InputStream stream = bpe.getInputStream();
        InputStreamReader reader = new InputStreamReader(stream);
        char[] buffer = new char[2048];
        while (true) {
            int n = reader.read(buffer);
            if (n < 0) {
View Full Code Here

        if (!(mp.getBodyParts().size() == 2)) {
            return Response.ok("FAILED:  Body part count is " + mp.getBodyParts().size() + " instead of 2").build();
        } else if (!(mp.getBodyParts().get(1).getEntity() instanceof BodyPartEntity)) {
            return Response.ok("FAILED:  Second body part is " + mp.getBodyParts().get(1).getClass().getName() + " instead of BodyPartEntity").build();
        }
        BodyPartEntity bpe = (BodyPartEntity) mp.getBodyParts().get(1).getEntity();
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            InputStream stream = bpe.getInputStream();
            byte[] buffer = new byte[2048];
            while (true) {
                int n = stream.read(buffer);
                if (n < 0) {
                    break;
View Full Code Here

    @Path("eleven")
    @PUT
    @Consumes("multipart/mixed")
    @Produces("multipart/mixed")
    public Response eleven(MultiPart multiPart) throws IOException {
        BodyPartEntity bpe = (BodyPartEntity) multiPart.getBodyParts().get(0).getEntity();
        StringBuilder sb = new StringBuilder();
        InputStream stream = bpe.getInputStream();
        InputStreamReader reader = new InputStreamReader(stream);
        char[] buffer = new char[2048];
        while (true) {
            int n = reader.read(buffer);
            if (n < 0) {
View Full Code Here

            }
            Object entity = bodyPart.getEntity();
            if (entity == null) {
                parts.add(PayloadImpl.Part.newInstance(mimeType, name, props, (InputStream) null));
            } else if (entity instanceof BodyPartEntity) {
                BodyPartEntity bpe = (BodyPartEntity) entity;
                parts.add(PayloadImpl.Part.newInstance(mimeType, name, props, bpe.getInputStream()));
            } else if (entity instanceof String) {
                parts.add(PayloadImpl.Part.newInstance(mimeType, name, props, (String) entity));
            } else {
                throw new WebApplicationException(new Exception("Unsupported entity " + entity.getClass().getName()), Response.Status.BAD_REQUEST);
            }
View Full Code Here

            } catch (IllegalArgumentException ex) {
                throw new BadRequestException(ex);
            }

            // Copy data into a BodyPartEntity structure.
            bodyPart.setEntity(new BodyPartEntity(mimePart));

            // Add this BodyPart to our MultiPart.
            multiPart.getBodyParts().add(bodyPart);
        }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.media.multipart.BodyPartEntity

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.