BEA Systems, Inc.

com.beasys.commerce.content
Class ContentHelper

java.lang.Object
  |
  +--com.beasys.commerce.content.ContentHelper

public class ContentHelper
extends java.lang.Object

Helper class for dealing with Content, ContentHomes, ContentManagers, and the possible subclasses.


Field Summary
static java.lang.String DEF_CONTENT_HOME
          The default ContentHome name.
static java.lang.String DEF_CONTENT_MANAGER_HOME
          The default ContentManagerHome name.
static boolean DEF_CONTENT_READONLY
          The default readonly flag for getting Content.
static java.lang.String DEF_CONTENT_SCHEMA_HOME
          The default Content SchemaHome name.
static java.lang.String DEF_DOCUMENT_HOME
          The default DocumentHome name.
static java.lang.String DEF_DOCUMENT_MANAGER_HOME
          The default DocumentManagerHome name.
static java.lang.String DEF_DOCUMENT_SCHEMA_HOME
          The default Document SchemaHome name.
static boolean USE_SOFT_HASH_MAP
          Should caches use a SoftHashMap or not.
 
Constructor Summary
ContentHelper()
           
 
Method Summary
static Content[] getContent(java.lang.String homeName, Search s)
          Return an array of Content from the ContentManager or ContentHome at the given name.
static Content[] getContent(java.lang.String homeName, Search s, boolean readOnly)
          Return an array of Content from the ContentManager or ContentHome at the given name.
static java.util.Enumeration getContentFromHome(java.lang.String homeName, javax.ejb.EJBHome home, Search s)
          Search for content from a ContentHome.
static java.util.Enumeration getContentFromManager(java.lang.String homeName, javax.ejb.EJBHome home, Search s, boolean readOnly)
          Search for content from a ContentManager.
static int getContentLength(long docSize, int bytesLen)
          Return the correct content length.
static java.lang.String pathInfoEncode(java.lang.String pathInfo)
          Correctly URLEncode a path-info string.
static Content[] toArray(java.util.Enumeration e)
          Turn an Enumeration of Content into an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_CONTENT_READONLY

public static final boolean DEF_CONTENT_READONLY
The default readonly flag for getting Content.

This will be initialized form the "commerce.content.defaultReadOnly" property in the weblogiccommerce.properties. It defaults to true.


DEF_CONTENT_HOME

public static final java.lang.String DEF_CONTENT_HOME
The default ContentHome name.

This will be initialized from the "commerce.home.content.ContentHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.content.Content".


DEF_CONTENT_MANAGER_HOME

public static final java.lang.String DEF_CONTENT_MANAGER_HOME
The default ContentManagerHome name.

This will be initialized from the "commerce.home.content.ContentManagerHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.content.ContentManager".


DEF_CONTENT_SCHEMA_HOME

public static final java.lang.String DEF_CONTENT_SCHEMA_HOME
The default Content SchemaHome name.

This will be initialized from the "commerce.home.content.ContentSchemaHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.content.ContentSchema".


DEF_DOCUMENT_HOME

public static final java.lang.String DEF_DOCUMENT_HOME
The default DocumentHome name.

This will be initialized from the "commerce.home.document.DocumentHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.document.Document".


DEF_DOCUMENT_MANAGER_HOME

public static final java.lang.String DEF_DOCUMENT_MANAGER_HOME
The default DocumentManagerHome name.

This will be initialized from the "commerce.home.document.DocumentManagerHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.document.DocumentManager".


DEF_DOCUMENT_SCHEMA_HOME

public static final java.lang.String DEF_DOCUMENT_SCHEMA_HOME
The default Document SchemaHome name.

This will be initialized from the "commerce.home.document.DocumentSchemaHome" property in the weblogiccommerce.properties file. It defaults to "com.beasys.commerce.axiom.document.DocumentSchema".


USE_SOFT_HASH_MAP

public static boolean USE_SOFT_HASH_MAP
Should caches use a SoftHashMap or not.

This will be initizlied from the "commerce.content.cache.useSoftHashMap" property in the weblogiccommerce.properties file. It defaults to false.

Constructor Detail

ContentHelper

public ContentHelper()
Method Detail

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s,
                                   boolean readOnly)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Return an array of Content from the ContentManager or ContentHome at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. If homeName points to a home for Content (or subclasses), then it's findBySearchParams() method will used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
getContentFromManager(java.lang.String, javax.ejb.EJBHome, com.beasys.commerce.foundation.expression.Search, boolean), getContentFromHome(java.lang.String, javax.ejb.EJBHome, com.beasys.commerce.foundation.expression.Search)

getContent

public static Content[] getContent(java.lang.String homeName,
                                   Search s)
                            throws javax.naming.NamingException,
                                   java.rmi.RemoteException,
                                   javax.ejb.FinderException,
                                   java.lang.IllegalArgumentException
Return an array of Content from the ContentManager or ContentHome at the given name.

If homeName points to a home for a ContentManager (or subclass), then the home's create() method will be invoked and the ContentManager's getContent() method will be used. If homeName points to a home for Content (or subclasses), then it's findBySearchParams() method will used. The resulting enumeration will be put into an array.

Throws:
javax.naming.NamingException - thrown if home cannot be found.
java.rmi.RemoteException - thrown on communications error.
javax.ejb.FinderException - thrown on error in findBySearchParams
java.lang.IllegalArgumentException - thrown on any other error.
See Also:
DEF_CONTENT_READONLY

getContentFromManager

public static java.util.Enumeration getContentFromManager(java.lang.String homeName,
                                                          javax.ejb.EJBHome home,
                                                          Search s,
                                                          boolean readOnly)
                                                   throws java.rmi.RemoteException,
                                                          java.lang.IllegalArgumentException
Search for content from a ContentManager.
Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the ContentManager.
s - the search parameters.
readOnly - the read-only flag.
Returns:
the Enumeration of Content which match the search.

getContentFromHome

public static java.util.Enumeration getContentFromHome(java.lang.String homeName,
                                                       javax.ejb.EJBHome home,
                                                       Search s)
                                                throws java.rmi.RemoteException,
                                                       javax.ejb.FinderException,
                                                       java.lang.IllegalArgumentException
Search for content from a ContentHome.
Parameters:
homeName - the JNDI home name (used for errors).
home - the EJBHome of the Content.
s - the search parameters.
Returns:
the Enumeration of Content which match the search.

toArray

public static Content[] toArray(java.util.Enumeration e)
Turn an Enumeration of Content into an array.
Parameters:
e - the Enumeration.
Returns:
an array of the Content objects.
Throws:
java.lang.ClassCastException - thrown if the objects in the Enumeration aren't Content objects.

getContentLength

public static int getContentLength(long docSize,
                                   int bytesLen)
Return the correct content length. Since the getContent() method of Document does not guarentee that the resulting array will be the correct size (it might be larger), this method will tell what the actual number of bytes to use from that array is.
Parameters:
docSize - the value doc.getSize().
bytesLen - the length of the doc.getContent() array.
Returns:
the number of bytes in the content array which are valid.
See Also:
Document.getContent()

pathInfoEncode

public static java.lang.String pathInfoEncode(java.lang.String pathInfo)
Correctly URLEncode a path-info string.

This can be used to pass a contentId as Path-Info to the ShowDocServlet.

This will url encode the pathInfo, but will leave "/"'s alone.


BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved