Collaboration API Documentation

com.filenet.bso.api.util
Class BsoBaseUtil

java.lang.Object
  |
  +--com.filenet.bso.api.util.BsoBaseUtil

public class BsoBaseUtil
extends java.lang.Object

The BsoBaseUtil class provides a collection of static helper methods for the Content Java API.

See Also:
Content Java API documentation

Field Summary
static java.lang.String UTF8_ENCODING
          Value for UTF-8 encoding
 
Method Summary
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Boolean propertyValue)
          Generates a boolean-valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, byte[] propertyValue)
          Generates a byte array valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.util.Date propertyValue)
          Generates a date-valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Double propertyValue)
          Generates a Double valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Integer propertyValue)
          Generates an integer-valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Object propertyValue)
          Generates an object-valued Property object and adds it to the specified Properties collection.
static void addProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.String propertyValue)
          Generates a string-valued Property object and adds it to the specified Properties collection.
static com.filenet.wcm.api.Property buildProperty(java.lang.String name, java.lang.String strType, java.lang.String strValue)
          Constructs a Property object.
static java.lang.String convertBinaryToString(byte[] binary, java.lang.String encoding)
          Convert a binary property value which was originally a string back into a string.
static java.lang.Object convertStringValue(int dataType, java.lang.String strValue)
          Converts a given value from a string to an object.
static int[] documentType()
          Returns an int array object that specifies BaseObject.TYPE_DOCUMENT.
static com.filenet.wcm.api.Property findProperty(com.filenet.wcm.api.Properties props, java.lang.String propName)
          Finds a Property object with the given property name if present in a Properties collection.
static int[] folderType()
          Returns an int array object that specifies BaseObject.TYPE_FOLDER.
static java.lang.String formatPropertyValue(int datatype, java.lang.Object val)
          Converts the given Property value to a string representation.
static java.lang.String formatPropertyValueForXML(int datatype, java.lang.Object obj)
          Converts the given Property value to a string representation and encodes the string for XML.
static byte[] getBytes(java.io.InputStream is)
          Reads the given InputStream object and returns its equivalent byte array.
static com.filenet.wcm.api.ClassDescription getClassDescription(com.filenet.wcm.api.ObjectStore store, int[] objectTypes, java.lang.String classDisplayName)
          Given the class description's display name, returns the matching ClassDescription object from an object store.
static com.filenet.wcm.api.ClassDescription getClassDescription(java.lang.String classDisplayName, java.util.Iterator classDescriptions)
          Given a class name, returns the matching ClassDescription object from a collection.
static com.filenet.wcm.api.Folder getFolder(com.filenet.wcm.api.ObjectStore store, java.lang.String folderID)
          Generates a Folder object from the given GUID.
static com.filenet.wcm.api.ObjectStore getObjectStore(java.lang.String objectStoreID, com.filenet.wcm.api.Session session)
          Generates an ObjectStore object from the given GUID.
static com.filenet.wcm.api.Folder getParentFolder(com.filenet.wcm.api.ObjectStore store, java.lang.String folderID)
          Generates a Folder object from the given GUID.
static com.filenet.wcm.api.Property getProperty(com.filenet.wcm.api.ReadableMetadataObject object, java.lang.String propertyName, boolean refresh)
          Retrieves a property, specified by name, from a BaseObject object.
static java.lang.Object getPropertyDefaultValue(com.filenet.wcm.api.PropertyDescription propDesc)
          Returns the default value associated with the property specified by the PropertyDescription object, may return null.
static java.io.InputStream getStream(java.lang.String str, java.lang.String encoding)
          Convert a string into an InputStream using a given encoding.
static java.lang.String getString(java.io.InputStream is)
          Reads the given InputStream object and returns a String object.
static java.lang.String getString(java.io.InputStream is, java.lang.String encoding)
          Reads the given InputStream object and returns an encoded String object.
static void lockedIncrementCounterProperty(com.filenet.wcm.api.BaseObject object, java.lang.String counterPropertyName, int value)
          Perform locked increment of integer property.
static java.lang.String lockObject(com.filenet.wcm.api.LockableObject object)
          Lock a Content Engine object.
static void removeProperty(com.filenet.wcm.api.Properties props, java.lang.String propName)
          Removes the Property object with the given property name from the Properties collection, if present.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Boolean propertyValue)
          If the Property object exists in the Properties collection, sets a boolean value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, byte[] propertyValue)
          If the Property object exists in the Properties collection, sets a byte array value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.util.Date propertyValue)
          If the Property object exists in the Properties collection, sets a date value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Double propertyValue)
          If the Property object exists in the Properties collection, sets a double value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.Integer propertyValue)
          If the Property object exists in the Properties collection, sets an integer value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, java.lang.String propertyValue)
          If the Property object exists in the Properties collection, sets a string value on it.
static void setProperty(com.filenet.wcm.api.Properties properties, java.lang.String propertyName, com.filenet.wcm.api.ValueObject propertyValue)
          If the Property object exists in the Properties collection, sets an object value on it.
static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object, java.lang.String propertyName, boolean propertyValue)
          Persists the boolean-valued property, specified by name and value, to a BaseObject object.
static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object, java.lang.String propertyName, java.util.Date propertyValue)
          Persists the Date-valued property, specified by name and value, to a BaseObject object.
static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object, java.lang.String propertyName, int propertyValue)
          Persists the int-valued property, specified by name and value, to a BaseObject object.
static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object, java.lang.String propertyName, java.lang.String propertyValue)
          Persists the string-valued property, specified by name and value, to a BaseObject object.
static void setPropertyValue(com.filenet.wcm.api.Property prop, java.lang.Object val)
          Sets a Property object's value, first casting the Java object to the correct type.
static void setValueObjectValue(com.filenet.wcm.api.Value valObj, java.lang.Object val)
          Sets a Value object's value, first casting the Java object to the correct type.
static void unlockObject(com.filenet.wcm.api.LockableObject object, java.lang.String lockToken)
          Unlock a Content Engine object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8_ENCODING

public static final java.lang.String UTF8_ENCODING
Value for UTF-8 encoding
Method Detail

getObjectStore

public static com.filenet.wcm.api.ObjectStore getObjectStore(java.lang.String objectStoreID,
                                                             com.filenet.wcm.api.Session session)
Generates an ObjectStore object from the given GUID.

Parameters:
objectStoreID - A String representing the ID (in GUID format) of the object store on the Content Engine server.
session - The Session object that supplies logon credentials to the Content Engine server.

Returns:
An ObjectStore object.

getFolder

public static com.filenet.wcm.api.Folder getFolder(com.filenet.wcm.api.ObjectStore store,
                                                   java.lang.String folderID)
Generates a Folder object from the given GUID.

Parameters:
store - The ObjectStore object.
folderID - A String containing the ID (in GUID format) of the Folder object.

Returns:
A Folder object.

getParentFolder

public static com.filenet.wcm.api.Folder getParentFolder(com.filenet.wcm.api.ObjectStore store,
                                                         java.lang.String folderID)
Generates a Folder object from the given GUID. If you supply null for the folderID parameter, this method returns the root folder.

Parameters:
store - The ObjectStore object.
folderID - A String containing the ID (in GUID format) of the Folder object. If null, returns the root folder.

Returns:
A Folder object.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.String propertyValue)
Generates a string-valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.util.Date propertyValue)
Generates a date-valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               byte[] propertyValue)
Generates a byte array valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Boolean propertyValue)
Generates a boolean-valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Integer propertyValue)
Generates an integer-valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Double propertyValue)
Generates a Double valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

addProperty

public static void addProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Object propertyValue)
Generates an object-valued Property object and adds it to the specified Properties collection.

Parameters:
properties - A collection of Property objects.

propertyName - The name of the new property.

propertyValue - The value of the new property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.String propertyValue)
If the Property object exists in the Properties collection, sets a string value on it. Otherwise acts like addProperty(Properties, String, String)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Boolean propertyValue)
If the Property object exists in the Properties collection, sets a boolean value on it. Otherwise acts like addProperty(Properties, String, Boolean)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               byte[] propertyValue)
If the Property object exists in the Properties collection, sets a byte array value on it. Otherwise acts like addProperty(Properties, String, byte[])

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Double propertyValue)
If the Property object exists in the Properties collection, sets a double value on it. Otherwise acts like addProperty(Properties, String, Double)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.lang.Integer propertyValue)
If the Property object exists in the Properties collection, sets an integer value on it. Otherwise acts like addProperty(Properties, String, Integer)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               java.util.Date propertyValue)
If the Property object exists in the Properties collection, sets a date value on it. Otherwise acts like addProperty(Properties, String, Date)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

setProperty

public static void setProperty(com.filenet.wcm.api.Properties properties,
                               java.lang.String propertyName,
                               com.filenet.wcm.api.ValueObject propertyValue)
If the Property object exists in the Properties collection, sets an object value on it. Otherwise acts like addProperty(Properties, String, Object)

Parameters:
properties - A collection of Property objects.

propertyName - The name of the property.

propertyValue - The value of the property.

getClassDescription

public static com.filenet.wcm.api.ClassDescription getClassDescription(java.lang.String classDisplayName,
                                                                       java.util.Iterator classDescriptions)
Given a class name, returns the matching ClassDescription object from a collection.

Parameters:
classDisplayName - The name of the ClassDescription object to return.
classDescriptions - A collection of ClassDescription objects.

Returns:
A ClassDescription object.

getClassDescription

public static com.filenet.wcm.api.ClassDescription getClassDescription(com.filenet.wcm.api.ObjectStore store,
                                                                       int[] objectTypes,
                                                                       java.lang.String classDisplayName)
Given the class description's display name, returns the matching ClassDescription object from an object store. In the objectTypes parameter, specify the object types to retrieve as Content Java API BaseObject objects. If the objectTypes parameter is not null, this method limits the search of the ClassDescriptions collection to the specified object types; otherwise, all class descriptions are searched for a matching name.

Parameters:
store - An ObjectStore object.

objectTypes - An int array of BaseObject objects.

classDisplayName - A String containing the name of the ClassDescription object to return.

Returns:
A ClassDescription object.

folderType

public static int[] folderType()
Returns an int array object that specifies BaseObject.TYPE_FOLDER.

Returns:
An int array object.

documentType

public static int[] documentType()
Returns an int array object that specifies BaseObject.TYPE_DOCUMENT.

Returns:
An int array object.

getString

public static java.lang.String getString(java.io.InputStream is)
Reads the given InputStream object and returns a String object.

Parameters:
is - An InputStream object.

Returns:
A String object.

getString

public static java.lang.String getString(java.io.InputStream is,
                                         java.lang.String encoding)
Reads the given InputStream object and returns an encoded String object.

Parameters:
is - An InputStream object.
encoding - An String that specifies the encoding to apply to the output, such as "UTF-8"..

Returns:
A String object.

getBytes

public static byte[] getBytes(java.io.InputStream is)
Reads the given InputStream object and returns its equivalent byte array.

Parameters:
is - An InputStream object.

Returns:
A byte array.

getStream

public static java.io.InputStream getStream(java.lang.String str,
                                            java.lang.String encoding)
Convert a string into an InputStream using a given encoding.
Parameters:
str - the string
encoding - the encoding to use. If this is null then UTF-8 encoding is used.
Returns:
the InputStream

buildProperty

public static com.filenet.wcm.api.Property buildProperty(java.lang.String name,
                                                         java.lang.String strType,
                                                         java.lang.String strValue)
Constructs a Property object.

Based on a given property type, converts the string-valued parameter to the requested property type. Types supported are:

      TYPE_BINARY
      TYPE_BOOLEAN
      TYPE_DATE
      TYPE_DOUBLE
      TYPE_INTEGER
      TYPE_STRING
      TYPE_GUID
 

Parameters:
name - The name of the property.

strType - A String representation of the property type's int value, for example, Property.TYPE_BINARY.

strValue - A String representation of the property value; may be null. If null, the method builds a property whose value is not set.

Returns:
A Property object.

convertStringValue

public static java.lang.Object convertStringValue(int dataType,
                                                  java.lang.String strValue)
Converts a given value from a string to an object. For example, if you pass in a string of "five" and a data type of Property.TYPE_INTEGER, this method returns an integer value of 5.

Parameters:
dataType - The data type of the input string. You can specify data type by using constants defined in the Content Java API Property interface, for example, Property.TYPE_BINARY.
strValue - The String to be converted.

Returns:
A Java Object that represents the converted string.

setValueObjectValue

public static void setValueObjectValue(com.filenet.wcm.api.Value valObj,
                                       java.lang.Object val)
Sets a Value object's value, first casting the Java object to the correct type. Types supported are:

      Integer
      String
      Double
      Values
      Date
      Boolean
      BaseObject
 

Parameters:
valObj - The Value object.
val - A Java Object representing the new value to be assigned to this Value object.

Throws:
BsoRuntimeException - Thrown when an unsupported object type is specified as input to this method.

setPropertyValue

public static void setPropertyValue(com.filenet.wcm.api.Property prop,
                                    java.lang.Object val)
Sets a Property object's value, first casting the Java object to the correct type. Supported types are:

      Integer
      String
      Double
      Values
      Date
      Boolean
      BaseObject
 

Parameters:
prop - The Property object whose value is to be set.
val - A Java Object representing the new value to be assigned to this Property object.

Throws:
BsoRuntimeException - Thrown when an unsupported object type is specified as input to this method.

getProperty

public static com.filenet.wcm.api.Property getProperty(com.filenet.wcm.api.ReadableMetadataObject object,
                                                       java.lang.String propertyName,
                                                       boolean refresh)
Retrieves a property, specified by name, from a BaseObject object. If the refresh parameter is true, any underlying property cache will be bypassed and the value will be retrieved from the Content Engine, resulting in a round-trip.

Parameters:
object - A BaseObject object that supports readable metadata.

propertyName - The name of the Property to be retrieved.

refresh - If true, refresh cached properties from Content Engine.

Returns:
A Property object, or null if the property does not exist.

formatPropertyValueForXML

public static java.lang.String formatPropertyValueForXML(int datatype,
                                                         java.lang.Object obj)
Converts the given Property value to a string representation and encodes the string for XML. (To simply convert the value to a string representation without encoding for XML, refer to the formatPropertyValue method.) The supported data types are:
      Boolean
      Date
      Double
      Integer
      GUID
      String
 

Parameters:
datatype - An integer that represents the type of data.

obj - A Java Object that represents the property value.

Returns:
A String representation of the property value.

formatPropertyValue

public static java.lang.String formatPropertyValue(int datatype,
                                                   java.lang.Object val)
Converts the given Property value to a string representation. (To convert the value to a string representation and encode for XML, refer to the formatPropertyValueForXML method.) The supported data types are:
      Boolean
      Date
      Double
      Integer
      GUID
      String
 

Parameters:
datatype - An integer that represents the type of data.

val - A Java Object that represents the property value.

Returns:
String representation of property value.

setProperty

public static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object,
                               java.lang.String propertyName,
                               java.lang.String propertyValue)
Persists the string-valued property, specified by name and value, to a BaseObject object.

Parameters:
object - An object that supports writeable metadata.

propertyName - A String specifying the property name.

propertyValue - A String specifying the property value.

setProperty

public static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object,
                               java.lang.String propertyName,
                               boolean propertyValue)
Persists the boolean-valued property, specified by name and value, to a BaseObject object.

Parameters:
object - An object that supports writeable metadata.

propertyName - A String specifying the property name.

propertyValue - A boolean specifying the property value.

setProperty

public static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object,
                               java.lang.String propertyName,
                               int propertyValue)
Persists the int-valued property, specified by name and value, to a BaseObject object.

Parameters:
object - An object that supports writeable metadata.

propertyName - A String specifying the property name.

propertyValue - An int specifying the property value.

setProperty

public static void setProperty(com.filenet.wcm.api.WriteableMetadataObject object,
                               java.lang.String propertyName,
                               java.util.Date propertyValue)
Persists the Date-valued property, specified by name and value, to a BaseObject object.

Parameters:
object - An object that supports writeable metadata.

propertyName - A String specifying the property name.

propertyValue - An int specifying the property value.

getPropertyDefaultValue

public static java.lang.Object getPropertyDefaultValue(com.filenet.wcm.api.PropertyDescription propDesc)
                                                throws java.lang.Exception
Returns the default value associated with the property specified by the PropertyDescription object, may return null.

Parameters:
propDesc - The PropertyDescription object for the requested property.

Returns:
A Java Object that represents the default value of the property.

Throws:
java.lang.Exception - Thrown if an error occurs retrieving the default value.

findProperty

public static com.filenet.wcm.api.Property findProperty(com.filenet.wcm.api.Properties props,
                                                        java.lang.String propName)
Finds a Property object with the given property name if present in a Properties collection.
Returns:
The Property object or null if not present.

removeProperty

public static void removeProperty(com.filenet.wcm.api.Properties props,
                                  java.lang.String propName)
Removes the Property object with the given property name from the Properties collection, if present.

lockedIncrementCounterProperty

public static void lockedIncrementCounterProperty(com.filenet.wcm.api.BaseObject object,
                                                  java.lang.String counterPropertyName,
                                                  int value)
Perform locked increment of integer property.

Parameters:
object - Content Engine BaseObject which holds proeprty to increment.

counterPropertyName - Name of integer property to increment.

value - Postive or negative value to increment counter.

lockObject

public static java.lang.String lockObject(com.filenet.wcm.api.LockableObject object)
Lock a Content Engine object.

Parameters:
object - Content Engine BaseObject to lock.

Returns:
A String value which contains the lock token.

unlockObject

public static void unlockObject(com.filenet.wcm.api.LockableObject object,
                                java.lang.String lockToken)
Unlock a Content Engine object.

Parameters:
object - Content Engine BaseObject to unlock.

lockToken - The lock token string returned from the lockObject() method call.

convertBinaryToString

public static java.lang.String convertBinaryToString(byte[] binary,
                                                     java.lang.String encoding)
Convert a binary property value which was originally a string back into a string. If the encoding paramter is null, "UTF-8" encoding is used.

Parameters:
binary - Binary value.

encoding - Specifies character encoding used for conversion, if null, default "UTF-8" is used.

Collaboration API Documentation

Copyright © 2002 - 2004 FileNet Corporation. All rights reserved.