© 2004 BEA Systems, Inc.

com.bea.p13n.content.adapter
Class NodeOpsImpl

java.lang.Object
  extended bycom.bea.p13n.content.adapter.BaseOps
      extended bycom.bea.p13n.content.adapter.NodeOpsImpl
All Implemented Interfaces:
NodeOps, Serializable

public class NodeOpsImpl
extends BaseOps
implements NodeOps

A WLP Content Repository-to-ContentManager node ops.

The uid of IDs for Nodes from this will be the Content identifier.

The uid of IDs for Propertys from Nodes from this will be contentidentifier/propname

.

Additionlly, Documents will have a magic Property "content" which will refer to the bytes of the Document, plus getMimeType(), getProperty("encoding"), getSize(), and getName().

See Also:
Serialized Form

Field Summary
protected  ObjectClassOpsImpl objectClassOps
           
 
Fields inherited from class com.bea.p13n.content.adapter.BaseOps
CONTENT_MANAGER_HOME, credentials, PATH_IS_ID, PATH_STARTS_WITH_SLASH, pathIsId, pathStartsWithSlash, properties
 
Constructor Summary
NodeOpsImpl(Credentials credentials, Properties properties, ObjectClassOpsImpl objectClassOps)
           
 
Method Summary
 Node addNodeContent(ID nodeId, ID objectClassId, Property[] properties)
          Updates the node with the given id to contain the given objectClass and properties.
 Node convert(String reponame, Content content)
          Convert a Content object to a Node.
 Node copyNode(ID sourceId, ID destinationId)
          This method copies a Node to a new location (Folder) in the hierarchy along with all its descendants.
 Property createContentProperty(String reponame, String contentId, Document doc)
          Create a Property for the magic "content" property for a Document.
 Node createNode(ID parentId, String newNodeName, int type)
          This method creates a new Node underneath the parent.
 Node createNode(ID parentId, String newNodeName, int type, ID objectClassId, Property[] properties)
          This method creates a new Node underneath the parent.
 Property createProperty(String reponame, String contentId, String name, Object val)
          Create a Property object.
 Value createValue(Object val)
          Create a Value object for the given object value.
 void deleteNode(ID nodeId)
          This method performs a full cascade delete on a Node.
 Node getNode(ID nodeId)
          This method gets a particular Node based on its id.
 Node getNode(String path)
          This method gets a particular Node based on its id.
 Node[] getNodeChildren(ID parentId, int type)
          This method returns an array of Nodes based on the parent Folder.
 Node[] getNodes(ID[] nodeIds)
          This method gets the Node for each node ID passed in.
 String getPath(Content content)
          Get the new CM API path for a Content object.
 Property[] getProperties(ID nodeId)
          Gets all Properties for a Node.
 Property[] getProperties(String reponame, Content content)
          Get Property objects representing (potentially) all of the metadata attributes of the Node.
 InputStream getPropertyBytes(ID propertyId)
          Gets the Binary data for the given Property Id.
 Node moveNode(ID sourceId, ID destinationId)
          This method moves a Node to a new location (Folder) in the hierarchy along with all its descendants.
 Node removeNodeContent(ID nodeId)
          Removes the ObjectClass from the given Node.
 Node renameNode(ID nodeId, String newName)
          This method renames a node and implicitly all of its descendants paths.
 Node updateProperties(ID nodeId, Property[] properties)
          Updates the node with the given id with the given properties.
 
Methods inherited from class com.bea.p13n.content.adapter.BaseOps
getContentManager, unsupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectClassOps

protected ObjectClassOpsImpl objectClassOps
Constructor Detail

NodeOpsImpl

public NodeOpsImpl(Credentials credentials,
                   Properties properties,
                   ObjectClassOpsImpl objectClassOps)
Method Detail

addNodeContent

public Node addNodeContent(ID nodeId,
                           ID objectClassId,
                           Property[] properties)
Updates the node with the given id to contain the given objectClass and properties. If the node already contains Properties they will be updated with the given properties. If the node does not already contain properties then the given properties will be created and added to the node.

Specified by:
addNodeContent in interface NodeOps
Parameters:
nodeId - - the ID for the node to update.
Returns:
Node- the updated Node.

convert

public Node convert(String reponame,
                    Content content)
Convert a Content object to a Node.


copyNode

public Node copyNode(ID sourceId,
                     ID destinationId)
This method copies a Node to a new location (Folder) in the hierarchy along with all its descendants. Each Node will get a new Id, parent id and new Properties. A node may not be copied at or below itself in the hierarchy.s

Specified by:
copyNode in interface NodeOps
Parameters:
sourceId - - the id of the Node to be copied
destinationId - - the id of the Node under which the sourceId Node is copied
Returns:
Node- the copied Node- with a new path

createContentProperty

public Property createContentProperty(String reponame,
                                      String contentId,
                                      Document doc)
Create a Property for the magic "content" property for a Document.


createNode

public Node createNode(ID parentId,
                       String newNodeName,
                       int type)
                throws RepositoryException
This method creates a new Node underneath the parent. If the parent is null then the new Node is created under root.

Specified by:
createNode in interface NodeOps
Parameters:
parentId - - the id for the parent of the node. The uid is null if the parent is root.
newNodeName - - the name of Node to create.
type - - the type of node - either com.bea.content.Node.HIERARCHY or com.bea.content.Node.CONTENT.
Returns:
Node- the newly created node.
Throws:
NodeExistsException- - if the name for the node already exists as a child of the parent.
RepositoryException- - if system error occurs.
RepositoryException - - if validation error occurs.

createNode

public Node createNode(ID parentId,
                       String newNodeName,
                       int type,
                       ID objectClassId,
                       Property[] properties)
                throws RepositoryException
This method creates a new Node underneath the parent. If the parent is null then the new Node is created under root. It associates the ObjectClass with the given id to the new Node and adds the given properties (content and meta-content) to the Node. If there is a PropertyDefintion in the given ObjectClass with no corresponding Property in the properties array a Property will be created with a null value, unless the Property is required, in which case a validation exception will be thrown.

Specified by:
createNode in interface NodeOps
Parameters:
parentId - - the id for the parent of the node. It is null if the parent is root.
newNodeName - - the name of Node to create.
type - - the type of node- either HIERARCHY or CONTENT.
objectClassId - - the ID for the ObjectClass to associate the new Node to.
properties - - the properties to add to the new Node.
Returns:
Node - the newly created Node.
Throws:
RepositoryException - - if a system error occurs.

createProperty

public Property createProperty(String reponame,
                               String contentId,
                               String name,
                               Object val)
Create a Property object.


createValue

public Value createValue(Object val)
Create a Value object for the given object value.


deleteNode

public void deleteNode(ID nodeId)
This method performs a full cascade delete on a Node. As such, the node, all its descendant Nodes and each Nodes Properties are removed in the process.

Specified by:
deleteNode in interface NodeOps
Parameters:
nodeId - - the id of the Node to be deleted

getNode

public Node getNode(ID nodeId)
             throws NoSuchNodeException
This method gets a particular Node based on its id. The node that is returned contains all Properties associated with the node and also its ObjectClass.

Specified by:
getNode in interface NodeOps
Parameters:
nodeId - - the id for the node to get.
Returns:
Node- the retrieved Node.
Throws:
NoSuchNodeException- - if the node to get can't be found.
NoSuchNodeException - - if the node to get can't be found.

getNode

public Node getNode(String path)
             throws NoSuchNodeException
This method gets a particular Node based on its id. The node that is returned contains all Properties associated with the node and also its ObjectClass.

Specified by:
getNode in interface NodeOps
Parameters:
path - - the path for the node to get.
Returns:
Node- the retrieved Node.
Throws:
NoSuchNodeException- - if the node to get can't be found.
NoSuchNodeException - - if the node to get can't be found.

getNodeChildren

public Node[] getNodeChildren(ID parentId,
                              int type)
This method returns an array of Nodes based on the parent Folder. Empty array in this case.

Specified by:
getNodeChildren in interface NodeOps
Parameters:
parentId - - the Node which may have children
type - - the type of children to return, either com.bea.content.Node.HIERARCHY, com.bea.content.Node.CONTENT or or com.bea.content.Node.NODE. If the type is com.bea.content.Node.NODE then all children (both HIERARCHY and CONTENT) will be returned.
Returns:
array- empty array since we don't expose hierarchy.

getNodes

public Node[] getNodes(ID[] nodeIds)
                throws NoSuchNodeException
This method gets the Node for each node ID passed in. Each Node contains all Properties associated with it and also its ObjectClass.

Specified by:
getNodes in interface NodeOps
Parameters:
nodeIds - - the Node IDs to retrieve the Nodes for.
Returns:
Node[]- the retrieved Nodes.
Throws:
NoSuchNodeException- - if a node to get can't be found.
NoSuchNodeException - - if a node to get can't be found.

getPath

public String getPath(Content content)
Get the new CM API path for a Content object.


getProperties

public Property[] getProperties(ID nodeId)
                         throws NoSuchNodeException
Gets all Properties for a Node.

Specified by:
getProperties in interface NodeOps
Parameters:
nodeId - - the id for the node.
Returns:
Property[]- array of Node Properties.
Throws:
NoSuchNodeException- - if the node can't be found.
NoSuchNodeException - - if the node can't be found.

getProperties

public Property[] getProperties(String reponame,
                                Content content)
Get Property objects representing (potentially) all of the metadata attributes of the Node.

This only fully supports Content object from the old SPI implementation. If someone reimplemented the ContentManager/DocumentManager interface instead, then this will only return Property object representing the known getter methods on Content and/or Document.


getPropertyBytes

public InputStream getPropertyBytes(ID propertyId)
                             throws NoSuchPropertyException
Gets the Binary data for the given Property Id.

Specified by:
getPropertyBytes in interface NodeOps
Parameters:
propertyId - - the id for the Property that contains the binary data.
Returns:
InputStream - the binary data.
Throws:
NoSuchPropertyException- - if the Property does not exist.
NoSuchPropertyException - - if the Property does not exist.

moveNode

public Node moveNode(ID sourceId,
                     ID destinationId)
This method moves a Node to a new location (Folder) in the hierarchy along with all its descendants. The parent id for the source node will be changed, but all descendants of the source node will keep their parent relationships intact. A Node may not be moved at or below itself in the hierarchy.

Specified by:
moveNode in interface NodeOps
Parameters:
sourceId - - the id of the Node to be moved
destinationId - - the id of the Node under which the sourceId Node is moved
Returns:
Node- the moved Node- with a new path

removeNodeContent

public Node removeNodeContent(ID nodeId)
Removes the ObjectClass from the given Node. The Node's properties will also be removed for the node to be in a valid state.

Specified by:
removeNodeContent in interface NodeOps
Parameters:
nodeId - - the id for the Node to remove the ObjectClass from.
Returns:
Node- the updated Node.

renameNode

public Node renameNode(ID nodeId,
                       String newName)
This method renames a node and implicitly all of its descendants paths. A node may not be renamed to an existing name under the same parent node.

Specified by:
renameNode in interface NodeOps
Parameters:
nodeId - - the id for the node to rename
newName - - a String for the new node name
Returns:
Node- the renamed Node

updateProperties

public Node updateProperties(ID nodeId,
                             Property[] properties)
Description copied from interface: NodeOps
Updates the node with the given id with the given properties. The node must already have a ObjectClass and valid properties associated with it. All Properties are validated against their respective PropertyDefinition.

Specified by:
updateProperties in interface NodeOps
Parameters:
nodeId - - the ID of the node to update. The ID must include the repositoryName.
properties - - the properties to update on the Node.
Returns:
Node - the updated Node.

© 2004 BEA Systems, Inc.

Copyright © 2004 BEA Systems, Inc. All Rights Reserved