Package com.sun.jersey.core.header

Examples of com.sun.jersey.core.header.FormDataContentDisposition


            String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";

            FormDataMultiPart mp = new FormDataMultiPart();
            for (FileForImport fileForImport : files) {
                mp.field("visibilitySource", fileForImport.getVisibilitySource(), MediaType.MULTIPART_FORM_DATA_TYPE);
                FormDataContentDisposition dispo = FormDataContentDisposition
                        .name("file")
                        .fileName(fileForImport.getFileName())
                        .size(fileForImport.getFile().length())
                        .build();
                FormDataBodyPart bodyPart = new FormDataBodyPart(dispo, fileForImport.getFile(), MediaType.MULTIPART_FORM_DATA_TYPE);
View Full Code Here


    logger.debug( "setData: " + fullName );

    final String name = fullName.getBaseName();
    final String parent = fullName.getParent().getPath();
    final ByteArrayInputStream stream = new ByteArrayInputStream( data );
    final FormDataContentDisposition fd = FormDataContentDisposition
      .name( name )
      .fileName( name )
      .build();
    Response response = this.importRes.doPostImport( parent, stream, "true", null, "true", "true", null, "WARN", fd, null );
    throwExceptionOnBadResponse( response );
View Full Code Here

    public ContentDisposition getContentDisposition() {
        if (cd == null) {
            String scd = getHeaders().getFirst("Content-Disposition");
            if (scd != null) {
                try {
                    cd = new FormDataContentDisposition(scd, fileNameFix);
                } catch (ParseException ex) {
                    throw new IllegalArgumentException("Error parsing content disposition: " + scd, ex);
                }
            }
        }
View Full Code Here

     * Get the control name.
     *
     * @return the control name.
     */
    public String getName() {
        FormDataContentDisposition fdcd = getFormDataContentDisposition();
        if (fdcd == null)
            return null;

        return fdcd.getName();
    }
View Full Code Here

    public void setName(String name) {
        if(name == null) {
            throw new IllegalArgumentException("Name can not be null.");
        }
        if (getFormDataContentDisposition() == null) {
            FormDataContentDisposition contentDisposition;
            contentDisposition = FormDataContentDisposition.name(name)
                .build();
            super.setContentDisposition(contentDisposition);
        } else {
            FormDataContentDisposition _cd = FormDataContentDisposition.name(name).
                    fileName(cd.getFileName()).
                    creationDate(cd.getCreationDate()).
                    modificationDate(cd.getModificationDate()).
                    readDate(cd.getReadDate()).
                    size(cd.getSize()).
View Full Code Here

        for (AttachmentInput attachment : myAttachments) {
          BodyPart bp = new BodyPart(attachment.getInputStream(), MediaType.APPLICATION_OCTET_STREAM_TYPE);
          FormDataContentDisposition.FormDataContentDispositionBuilder dispositionBuilder =
              FormDataContentDisposition.name(FILE_ATTACHMENT_CONTROL_NAME);
          dispositionBuilder.fileName(attachment.getFilename());
          final FormDataContentDisposition formDataContentDisposition = dispositionBuilder.build();
          bp.setContentDisposition(formDataContentDisposition);
          multiPartInput.bodyPart(bp);
        }

        postFileMultiPart(multiPartInput, attachmentsUri);
View Full Code Here

  @Test
  public void testWriteFile() throws Exception {
    String pathId = "pathId";
    InputStream fileContents = mock( InputStream.class );
    Boolean overwriteFile = Boolean.TRUE;
    FormDataContentDisposition mockFormDataContentDisposition = mock( FormDataContentDisposition.class );

    doNothing().when( repositoryPublishResource.repositoryPublishService )
      .writeFile( pathId, fileContents, overwriteFile );

    Response mockResponse = mock( Response.class );
View Full Code Here

  @Test
  public void testWriteFileError() throws Exception {
    String pathId = "pathId";
    InputStream fileContents = mock( InputStream.class );
    Boolean overwriteFile = Boolean.TRUE;
    FormDataContentDisposition mockFormDataContentDisposition = mock( FormDataContentDisposition.class );

    Response mockUnauthorizedResponse = mock( Response.class );
    doReturn( mockUnauthorizedResponse ).when( repositoryPublishResource )
      .buildStatusResponse( UNAUTHORIZED, PlatformImportException.PUBLISH_USERNAME_PASSWORD_FAIL );
View Full Code Here

        if (bucketName.equals("")) {
            throw new CollectionException(ErrorCodes.COLLECTION_NAME_EMPTY, "Bucket Name Empty");
        }

        JSONArray result = new JSONArray();
        FormDataContentDisposition fileData = formData.getFormDataContentDisposition();
        try {
            if (!databaseService.getDbList().contains(dbName)) {
                throw new DatabaseException(ErrorCodes.DB_DOES_NOT_EXISTS, "DB [" + dbName + "] DOES NOT EXIST");
            }

            GridFS gridFS = new GridFS(mongoInstance.getDB(dbName), bucketName);
            GridFSInputFile fsInputFile = gridFS.createFile(inputStream, fileData.getFileName());
            fsInputFile.setContentType(formData.getMediaType().toString());
            fsInputFile.save();
            String objectId = JSON.serialize(fsInputFile.getId());
            JSONObject obj = new JSONObject();
            obj.put("name", fsInputFile.getFilename());
View Full Code Here

    public ContentDisposition getContentDisposition() {
        if (cd == null) {
            String scd = getHeaders().getFirst("Content-Disposition");
            if (scd != null) {
                try {
                    cd = new FormDataContentDisposition(scd);
                } catch (ParseException ex) {
                    throw new IllegalArgumentException("Error parsing content disposition: " + scd, ex);
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.sun.jersey.core.header.FormDataContentDisposition

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.