org.alfresco.webservice.util
Class ContentUtils

java.lang.Object
  extended by org.alfresco.webservice.util.ContentUtils

public class ContentUtils
extends java.lang.Object

Content Utils Class


Field Summary
static int BUFFER_SIZE
           
 
Constructor Summary
ContentUtils()
           
 
Method Summary
static byte[] convertToByteArray(java.io.InputStream inputStream)
          Convert an input stream to a byte array
static int copy(java.io.InputStream in, java.io.OutputStream out)
          Helper method to copy from one stream to another
static void copyContentToFile(org.alfresco.webservice.content.Content content, java.io.File file)
          Copy the content into a given file.
static java.io.InputStream getContentAsInputStream(org.alfresco.webservice.content.Content content)
          Get the content as an imput stream
static java.lang.String getContentAsString(org.alfresco.webservice.content.Content content)
          Get the content from the download servlet as a string
static java.lang.String putContent(java.io.File file)
          Streams content into the repository.
static java.lang.String putContent(java.io.File file, java.lang.String host, int port)
          Streams content into the repository.
static java.lang.String putContent(java.io.File file, java.lang.String host, int port, java.lang.String mimetype, java.lang.String encoding)
          Streams content into the repository.
static java.lang.String putContent(java.io.File file, java.lang.String host, int port, java.lang.String webAppName, java.lang.String mimetype, java.lang.String encoding)
          Streams content into the repository using nonSSL connection.
static java.lang.String putContent(java.io.File file, java.lang.String host, int port, java.lang.String webAppName, java.lang.String mimetype, java.lang.String encoding, boolean isSSL)
          Streams content into the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public static final int BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

ContentUtils

public ContentUtils()
Method Detail

convertToByteArray

public static byte[] convertToByteArray(java.io.InputStream inputStream)
                                 throws java.lang.Exception
Convert an input stream to a byte array

Parameters:
inputStream - the input stream
Returns:
the byte array
Throws:
java.lang.Exception

getContentAsString

public static java.lang.String getContentAsString(org.alfresco.webservice.content.Content content)
Get the content from the download servlet as a string

Parameters:
content - the content object
Returns:
the content as a string

getContentAsInputStream

public static java.io.InputStream getContentAsInputStream(org.alfresco.webservice.content.Content content)
Get the content as an imput stream

Parameters:
content -
Returns:

putContent

public static java.lang.String putContent(java.io.File file)
Streams content into the repository. Once done a content details string is returned and this can be used to update a content property in a CML statement. Uses the repository host and port details currently set in the WebServiceFactory based on the end point address.

Parameters:
file - the file to stream into the repository
Returns:
the content data that can be used to set the content property in a CML statement

putContent

public static java.lang.String putContent(java.io.File file,
                                          java.lang.String host,
                                          int port)
Streams content into the repository. Once done a content details string is returned and this can be used to update a content property in a CML statement.

Parameters:
file - the file to stream into the repository
host - the host name of the destination repository
port - the port name of the destination repository
Returns:
the content data that can be used to set the content property in a CML statement

putContent

public static java.lang.String putContent(java.io.File file,
                                          java.lang.String host,
                                          int port,
                                          java.lang.String mimetype,
                                          java.lang.String encoding)
Streams content into the repository. Once done a content details string is returned and this can be used to update a content property in a CML statement.

Parameters:
file - the file to stream into the repository
host - the host name of the destination repository
port - the port name of the destination repository
mimetype - the mimetype of the file, ignored if null
encoding - the encoding of the file, ignored if null
Returns:
the content data that can be used to set the content property in a CML statement

putContent

public static java.lang.String putContent(java.io.File file,
                                          java.lang.String host,
                                          int port,
                                          java.lang.String webAppName,
                                          java.lang.String mimetype,
                                          java.lang.String encoding)
Streams content into the repository using nonSSL connection. Once done a content details string is returned and this can be used to update a content property in a CML statement.

Parameters:
file - the file to stream into the repository
host - the host name of the destination repository
port - the port name of the destination repository
webAppName - the name of the target web application (default 'alfresco')
mimetype - the mimetype of the file, ignored if null
encoding - the encoding of the file, ignored if null
Returns:
the content data that can be used to set the content property in a CML statement

putContent

public static java.lang.String putContent(java.io.File file,
                                          java.lang.String host,
                                          int port,
                                          java.lang.String webAppName,
                                          java.lang.String mimetype,
                                          java.lang.String encoding,
                                          boolean isSSL)
Streams content into the repository. Once done a content details string is returned and this can be used to update a content property in a CML statement.

Parameters:
file - the file to stream into the repository
host - the host name of the destination repository
port - the port name of the destination repository
webAppName - the name of the target web application (default 'alfresco')
mimetype - the mimetype of the file, ignored if null
encoding - the encoding of the file, ignored if null
isSSL - true if HTTPS protocol is used
Returns:
the content data that can be used to set the content property in a CML statement

copyContentToFile

public static void copyContentToFile(org.alfresco.webservice.content.Content content,
                                     java.io.File file)
Copy the content into a given file.

Parameters:
content - the content object
file - the file

copy

public static int copy(java.io.InputStream in,
                       java.io.OutputStream out)
                throws java.io.IOException
Helper method to copy from one stream to another

Parameters:
in -
out -
Returns:
Throws:
java.io.IOException


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.