org.apache.chemistry.opencmis.client.util
Class FileUtils

java.lang.Object
  extended by org.apache.chemistry.opencmis.client.util.FileUtils

public class FileUtils
extends Object

A set of utility methods that simplify file and folder operations.


Method Summary
static Document createDocumentFromFile(String parentIdOrPath, File file, String type, VersioningState versioningState, Session session)
          Creates a document from a file.
static Folder createFolder(Folder parentFolder, String name, String type)
          Creates a child folder with the name specified of the type specified.
static Folder createFolder(String parentIdOrPath, String name, String type, Session session)
          Creates a folder using a String identifier.
static Document createTextDocument(String parentIdOrPath, String name, String content, String type, VersioningState versioningState, Session session)
          Creates a text document from a string.
static void delete(String pathOrIdOfObject, Session session)
          Deletes an object by path or id (string identifier).
static void download(Document doc, String destinationPath)
          Downloads the contentStream for the given doc to the specified path.
static void download(String docIdOrPath, String destinationPath, Session session)
          Downloads a document by its id or path.
static Folder getFolder(String pathOrIdOfObject, Session session)
          Gets a folder by path or object id.
static CmisObject getObject(String pathOrIdOfObject, Session session)
          Gets an object by path or object id.
static void printProperties(CmisObject object)
          Prints out all of the properties for this object to System.out.
static void printProperties(CmisObject object, PrintStream out)
          Prints out all of the properties for this object to the given PrintStream.
static void printProperty(Property<?> prop)
           
static void printProperty(Property<?> prop, PrintStream out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getObject

public static CmisObject getObject(String pathOrIdOfObject,
                                   Session session)
Gets an object by path or object id.

Parameters:
pathOrIdOfObject - the path or object id
session - the session
Returns:
the object
Throws:
CmisBaseException

getFolder

public static Folder getFolder(String pathOrIdOfObject,
                               Session session)
Gets a folder by path or object id.

Parameters:
pathOrIdOfObject - the path or folder id
session - the session
Returns:
the folder object
Throws:
CmisBaseException

createDocumentFromFile

public static Document createDocumentFromFile(String parentIdOrPath,
                                              File file,
                                              String type,
                                              VersioningState versioningState,
                                              Session session)
                                       throws FileNotFoundException
Creates a document from a file.

Parameters:
parentIdOrPath - the id or path of the parent folder
file - the source file
type - the document type (defaults to cmis:document)
versioningState - the versioning state or null
Returns:
the newly created document
Throws:
FileNotFoundException
CmisBaseException

createTextDocument

public static Document createTextDocument(String parentIdOrPath,
                                          String name,
                                          String content,
                                          String type,
                                          VersioningState versioningState,
                                          Session session)
Creates a text document from a string.

Parameters:
parentIdOrPath - the id or path of the parent folder
name - the document name
content - the content string
type - the document type (defaults to cmis:document)
versioningState - the versioning state or null
session - the session
Returns:
the newly created document

createFolder

public static Folder createFolder(Folder parentFolder,
                                  String name,
                                  String type)
Creates a child folder with the name specified of the type specified. If type is null then will default to cmis:folder.

Parameters:
parentFolder - the parent folder
name - the folder name
type - the folder type (defaults to cmis:folder)
Returns:
the newly created folder
Throws:
CmisBaseException

createFolder

public static Folder createFolder(String parentIdOrPath,
                                  String name,
                                  String type,
                                  Session session)
Creates a folder using a String identifier.

Parameters:
parentIdOrPath - the id or path of the parent folder
name - the folder name
type - the folder type (defaults to cmis:folder)
session - the session
Returns:
the newly created folder
Throws:
CmisBaseException

download

public static void download(Document doc,
                            String destinationPath)
                     throws IOException
Downloads the contentStream for the given doc to the specified path.

Parameters:
doc - the document
destinationPath - the destination path
Throws:
IOException
CmisBaseException

download

public static void download(String docIdOrPath,
                            String destinationPath,
                            Session session)
                     throws IOException
Downloads a document by its id or path.

Parameters:
docIdOrPath - the id or path of the document
destinationPath - the destination path
session - the session
Throws:
IOException
CmisBaseException

delete

public static void delete(String pathOrIdOfObject,
                          Session session)
Deletes an object by path or id (string identifier).

Parameters:
pathOrIdOfObject - the id or path of the object
session - the session
Throws:
CmisBaseException

printProperties

public static void printProperties(CmisObject object)
Prints out all of the properties for this object to System.out.

Parameters:
object - the object

printProperties

public static void printProperties(CmisObject object,
                                   PrintStream out)
Prints out all of the properties for this object to the given PrintStream.

Parameters:
object - the object

printProperty

public static void printProperty(Property<?> prop)

printProperty

public static void printProperty(Property<?> prop,
                                 PrintStream out)


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.