Package com.ibm.sbt.services.client.ClientService

Examples of com.ibm.sbt.services.client.ClientService.Content


  @Override
  protected Content getFileContent(File file, long length, String fileName) {
    String fileExt = MIME.getFileExtension(fileName);
    String contentType = MIME.getMIMETypeFromExtension(fileExt);
    contentType = (StringUtil.isEmpty(contentType)) ? MIMETYPE_DEFAULT : contentType;
    Content content = new ContentFile(file, contentType);
    return content;
  }
View Full Code Here


            String contentType = uploadedFile.getContentType();
            if (StringUtil.isEmpty(contentType) || MIMETYPE_UNKNOWN.equalsIgnoreCase(contentType)) {
              String fileExt = MIME.getFileExtension(parameters.get("FileName"));
              contentType = MIME.getMIMETypeFromExtension(fileExt);
            }
            Content content = new com.ibm.sbt.services.client.ClientService.ContentStream(uploadedFile.getName(), uploadedFileContent, uploadedFile.getSize(), contentType);         
            Map<String, String> headers = createHeaders();           
            headers.put("Content-Type", contentType);
            xhr(request, response, url.getPath(), params, headers, content, getFormat());
          }
        } else if (smethod.equalsIgnoreCase("GET")) {
View Full Code Here

            throw new ClientServicesException(null, Messages.Invalid_Stream);
        }
        if (title == null) {
            throw new ClientServicesException(null, Messages.Invalid_Name);
        }
        Content contentFile = getContentObject(title, stream, length);
        String accessType = AccessType.AUTHENTICATED.getText();
        String requestUri = FileUrls.MYUSERLIBRARY_FEED.format(this, FileUrlParts.accessType.get(accessType));
        Map<String, String> headers = new HashMap<String, String>();
        headers.put(FileConstants.X_UPDATE_NONCE, getNonce()); // It is not clearly documented which Content Type requires Nonce, thus adding nonce in header for all upload requests.
        Response response = createData(requestUri, p, headers, contentFile);
View Full Code Here

     */
    public File updateFile(InputStream inputStream, File file, Map<String, String> params)
            throws ClientServicesException {
        String requestUrl = file.getEditMediaUrl();

        Content contentFile = getContentObject(file.getTitle(), inputStream);

        Map<String, String> headers = new HashMap<String, String>();
        headers.put(FileConstants.X_UPDATE_NONCE, getNonce()); // It is not clearly documented which Content Type requires Nonce, thus adding nonce in header for all upload requests.

        Response response = updateData(requestUrl, params, headers, contentFile, null);
View Full Code Here

            throw new ClientServicesException(null, "null name");
        }
        String accessType = AccessType.AUTHENTICATED.getText();
        String requestUri = FileUrls.COMMUNITYLIBRARY_FEED.format(this,
                FileUrlParts.accessType.get(accessType), FileUrlParts.communityId.get(communityId));
        Content contentFile = getContentObject(title, iStream, length);
        Map<String, String> headers = new HashMap<String, String>();
        headers.put(FileConstants.X_UPDATE_NONCE, getNonce()); // It is not clearly documented which Content Type requires Nonce, thus adding nonce in header for all upload requests.
        Response data = createData(requestUri, null, headers, contentFile);
        return getFileFeedHandler().createEntity(data);
    }
View Full Code Here

        }
        String accessType = AccessType.AUTHENTICATED.getText();
        String requestUri = FileUrls.MYUSERLIBRARY_DOCUMENT_ENTRY.format(this,
                FileUrlParts.accessType.get(accessType), FileUrlParts.fileId.get(fileId));

        Content contentFile = getContentObject(title, iStream);
        Map<String, String> headers = new HashMap<String, String>();
        headers.put(FileConstants.X_UPDATE_NONCE, getNonce()); // It is not clearly documented which Content Type requires Nonce, thus adding nonce in header for all upload requests.
        //TODO: check get data wrapping
        Response result = updateData(requestUri, params, headers, contentFile, null);
        return getFileFeedHandler().createEntity(result);
View Full Code Here

     * @param stream
     * @param length
     * @return Content
     */
    private Content getContentObject(String title, InputStream stream, long length) {
        Content contentFile;
        if (StringUtil.isNotEmpty(getMimeType(title))) {
            contentFile = new ContentStream(title, stream, length, getMimeType(title));
        } else {
            contentFile = new ContentStream(stream, length, title);
        }
View Full Code Here

TOP

Related Classes of com.ibm.sbt.services.client.ClientService.Content

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.