Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.content.manager
Class ContentHelper

    java.lang.Object
      com.bea.content.manager.ContentHelper

    public class ContentHelper

extends Object

Helper class for dealing with Content

Field Summary
`static String` | `NODE_REQUEST_ATTRIBUTE_NAME` A name to be used for a common request attribute that a content node can be placed under.

Constructor Summary
`ContentHelper()`

Method Summary
`static Node` | `addFolder(ContentContext context, ObjectClass objectClass, String relPath, Property[] properties)` This method adds a new node to the repository of type folder.
`static Node` | `addFolder(ContentContext context, String relPath)` This method adds a new node to the repository of type ObjectClass.FOLDER.
`static String` | `pathInfoEncode(String pathInfo)` Correctly URLEncode a path-info string.
`static byte[]` | `toByteArray(InputStream inputStream)` Converts an InputStream to a byte[].
`static byte[]` | `toByteArray(InputStream inputStream, int maxSize)` Converts an InputStream to a byte[].
`static byte[]` | `toByteArray(InputStream inputStream, long start, long length)` Converts an InputStream to a byte[].
`static String` | `toHTML(String in)` Convert an arbitrary string to HTML which will display as the original string intended.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NODE_REQUEST_ATTRIBUTE_NAME

    public static final String NODE_REQUEST_ATTRIBUTE_NAME

  A name to be used for a common request attribute that a content node can be placed under. Mainly for use with the getNode and setNode tags (and the display template tags).

  See Also
    Constants Summary

Constructor Detail

### ContentHelper

    public ContentHelper()

Method Detail

### addFolder

    public static Node addFolder(ContentContext context,
                                 String relPath)
                          throws AuthorizationException,
                                 NodeExistsException,
                                 NoSuchObjectClassException,
                                 RepositoryException

  This method adds a new node to the repository of type ObjectClass.FOLDER. It assigns default properties to that node. This is the default folder for a WLP repository. For a non-WLP repository, it will be the name of the first folder listed in content-config.xml (property name = "folder_badge_objectClasses". Multiple folders are comma-separated).

  Parameters
    `context` - The ContentContext Object
    `relPath` - The absolute path to this node, appended with the node's name. For example /A/B/C indicates a node C being added under the parent node B.
  Returns
    The newly created node.
  Throws
    `AuthorizationException` - - if the user does not have CREATE capability on the parent node, or if the user does not have INSTANTIATE capability on the type of the node. This exception will also be thrown if the user is not authorizated by the repository.
    `NodeExistsException` - - if the parent Node already has a child with the same name.
    `NoSuchObjectClassException` - - if the node's ObjectClass doesn't exist.
    `RepositoryException` - - for any other exception

### addFolder

    public static Node addFolder(ContentContext context,
                                 ObjectClass objectClass,
                                 String relPath,
                                 Property[] properties)
                          throws AuthorizationException,
                                 NodeExistsException,
                                 NoSuchObjectClassException,
                                 RepositoryException

  This method adds a new node to the repository of type folder.

  This type must be derived from ObjectClass.FOLDER if this is a WLP repository, or must be declared in content-config.xml with the RepositoryConfig.FOLDER_BADGES_KEY property on the repository . todo: add an example

  Parameters
    `context` - The ContentContext Object
    `objectClass` - The ObjectClass of this folder. If it's ObjectClass.FOLDER, then use addFolder(ContentContext context, String relPath). Otherwise, this ObjectClass must be a child of NT_FOLDER
    `relPath` - The absolute path to this node, appended with the node's name. For example /A/B/C indicates a node C being added under the parent node B.
    `properties` - The properties of the node, which can be null
  Returns
    The newly created node.
  Throws
    `AuthorizationException` - - if the user does not have CREATE capability on the parent node, or if the user does not have INSTANTIATE capability on the type of the node. This exception will also be thrown if the user is not authorizated by the repository.
    `NodeExistsException` - - if the parent Node already has a child with the same name.
    `NoSuchObjectClassException` - - if the node's ObjectClass doesn't exist.
    `RepositoryException` - - for any other exception

### pathInfoEncode

    public static String pathInfoEncode(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.

  Parameters
    `pathInfo` - The path-info string.
  Returns
    the URLEncoded path-info string.

### toHTML

    public static String toHTML(String in)

  Convert an arbitrary string to HTML which will display as the original string intended.

  This will replace the characters '&', '"', '<', and '>' with '&amp;', &quot;', '&lt;', and '&gt;', respectively.

  Parameters
    `in` - The string to convert to HTML.
  Returns
    The string converted to HTML.

### toByteArray

    public static byte[] toByteArray(InputStream inputStream)

  Converts an InputStream to a byte[].

  Parameters
    `inputStream` - - the InputStream to convert to the byte[].
  Returns
    byte[] - the byte[] converted from the InputStream. todo: [CAM] why aren't we closing the inputStream here?

### toByteArray

    public static byte[] toByteArray(InputStream inputStream,
                                     int maxSize)
                              throws RepositoryException

  Converts an InputStream to a byte[]. If the input stream won't fit into the cache (maxSize is exceeded), then return null. For this case, the inputStream will remain open and unconsumed.

  Otherwise, we can fit the InputStream data into the cache, and will return that byte array instead of the InputStream. In this case, the InputStream will be consumed and closed.

  Parameters
    `inputStream` - - the InputStream to convert to the byte[].
    `maxSize` - The maximum size to convert.
  Returns
    byte[] - the byte[] converted from the InputStream, or null if the InputStream size is larger than maxSize.
  Throws
    `RepositoryException` - if the conversion fails.

### toByteArray

    public static byte[] toByteArray(InputStream inputStream,
                                     long start,
                                     long length)

  Converts an InputStream to a byte[].

  Parameters
    `inputStream` - - the InputStream to convert to the byte[].
    `start` - - the index to start at.
    `length` - - the index to end at.
  Returns
    byte[] - the byte[] converted from the InputStream.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.