com.ibm.portal.model.controller
Class CreationContextBuilderFactory

java.lang.Object
  extended by com.ibm.portal.model.controller.CreationContextBuilderFactory
Direct Known Subclasses:
CPCreationContextBuilderFactory

public abstract class CreationContextBuilderFactory
extends java.lang.Object

A factory for creating and combining CreationContexts.

The factory offers a set of methods (new...) to create individual contexts for all contexts which extend CreationContext. In addition, the combine(CreationContext[]) method allows to create a context which exposes all interfaces of the individual contexts provided to it.

Example use to create a context which supports both IdentifiableCreationContext and ContentPageCreationContext:

 final CreationContextBuilderFactory factory = CreationContextBuilderFactory
                .getInstance();
 final CreationContext[] arr = new CreationContext[2];
 arr[0] = factory.newContentPageCreationContext(false);
 arr[1] = factory.newIdentifiableCreationContext(predefinedID);
 return factory.combine(arr);
 

Example how to use a CreationContext object to create a private page

 final CreationContextBuilderFactory factory = CreationContextBuilderFactory
                .getInstance();
 final ContentPageCreationContext ctx = factory
                .newContentPageCreationContext(true);
 // See ContentModelControllerHome for how to obtain the controller itself
 final ContentModelController<ContentNode, ModifiableContentNode> ctrl = getController(
                req, resp);
 try {
        // Use the context to create the private page
        final ModifiableContentPage newPage = (ModifiableContentPage) ctrl.create(
                        ContentPage.class, ctx);
        // Insert the new page under the node with unique name "parent"
        final ContentNode parent = ctrl.getLocator().findByUniqueName("parent");
        if (parent != null) {
                ctrl.insert(newPage, parent, null);
                // Commit, i. e. persist the changes.
                ctrl.commit();
        }
 } finally {
        // Dispose the Controller.
        ctrl.dispose();
 }
 

Example how to use a CopyCreationContext object to copy an existing content node

 // See ContentModelControllerHome for how to obtain the controller itself
 final ContentModelController<ContentNode, ModifiableContentNode> ctrl = getController(
                req, resp);
 try {
        // Get the node to copy
        final ContentPage template = (ContentPage) ctrl.getLocator()
                        .findByUniqueName("template");
        if (template != null) {
                // Insert the new page under the node with unique name "parent"
                final ContentNode parent = ctrl.getLocator().findByUniqueName("parent");
                if (parent != null) {
                        final CreationContextBuilderFactory factory = CreationContextBuilderFactory
                                        .getInstance();
                        // The new (copied) node should not get a unique name:
                        final UniqueNameStrategy strategy = UniqueNameStrategy.NULL;
                        // We have to obtain the portlet model because for pages the layout
                        // will be copied, too.
                        // See com.ibm.portal.model.PortletModelProvider for how to obtain a
                        // PortletModel object
                        final PortletModel portletModel = getPortletModel(req, resp);
                        // Create the context that allows to copy the template node
                        final ContentNodeCopyCreationContext<ContentNode> ctx = factory
                                        .newContentNodeCopyCreationContext(template, ctrl,
                                                        portletModel, strategy);
                        final ModifiableContentPage newPage = (ModifiableContentPage) ctrl
                                        .create(ContentPage.class, ctx);
                        ctrl.insert(newPage, parent, null);
                        // Commit, i. e. persist the changes.
                        ctrl.commit();
                }
        }
 } finally {
        // Dispose the Controller.
        ctrl.dispose();
 }
 

Since:
6.1.0

Constructor Summary
protected CreationContextBuilderFactory()
           
 
Method Summary
abstract  CreationContext combine(CreationContext... contexts)
          Combines the given contexts into one creation context which implements all interfaces of the individual contexts.
static CreationContextBuilderFactory getInstance()
          Returns an instance of the factory.
abstract  ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc, ContentModel<ContentNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy)
          Returns a creation context allowing to copy a content node.
abstract  ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc, ContentModel<ContentNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy, Identifiable aDomainProvder)
          Returns a creation context allowing to copy a content node.
abstract  ContentNodeCreationContext newContentNodeCreationContext(boolean isPrivate)
          Creates a ContentNodeCreationContext.
abstract  ContentPageCreationContext newContentPageCreationContext(boolean isPrivate)
          Creates a ContentPageCreationContext.
abstract
<T> CopyCreationContext<T>
newCopyCreationContext(T anAspectProvider, java.lang.Class... theAspects)
          Returns a creation context allowing to copy certain aspects of a node.
abstract  DecorationCreationContext newDecorationCreationContext(java.lang.String resourceRoot, java.lang.String contextRoot)
          Creates a DecorationCreationContext.
abstract  DerivedContentPageCreationContext newDerivedContentPageCreationContext(boolean isPrivate, ContentPage aDerivationParent)
          Creates a DerivedContentPageCreationContext.
abstract  DerivedLayoutControlCreationContext newDerivedLayoutControlCreationContext(Identifiable portletDefinition, Identifiable portletEntity, Identifiable control)
          Creates a DerivedLayoutControlCreationContext.
abstract  IdentifiableCreationContext newIdentifiableCreationContext(ObjectID anObjectID)
          Creates a IdentifiableCreationContext.
abstract  IWidgetWrapperCreationContext newIWidgetWrapperURICreationContext(Context context, java.net.URI iWidgetURI)
          Creates a IWidgetWrapperCreationContext.
abstract  IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context, java.lang.String iWidgetURL)
          Creates a URL based IWidgetWrapperURLCreationContext.
abstract  IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context, java.lang.String iWidgetURL, ObjectID pageID)
          Creates a IWidgetWrapperURLCreationContext for an IWidget that wants to serve resources relative to a static content page.
abstract  LayoutControlCreationContext newLayoutControlCreationContext(Identifiable portletDefinition, Identifiable portletEntity)
          Creates a LayoutControlCreationContext.
abstract  LayoutNodeCopyCreationContext<LayoutNode> newLayoutNodeCopyCreationContext(LayoutNode aSrc, LayoutModel<LayoutNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy)
          Returns a creation context allowing to copy a content node.
abstract  MetaDataCopyCreationContext<MetaDataProvider> newMetaDataCopyCreationContext(MetaDataProvider aMetaDataProvider, java.util.List<java.lang.String> protectedNamesToCopy)
          Returns a creation context for copying the meta data.
abstract  PortletDefinitionCloningContext newPortletDefinitionCloningContext(ObjectID portletDefinitionID, Identifiable domainProvider)
          Creates a PortletDefinitionCloningContext.
abstract  PortletEntityCopyCreationContext newPortletEntityCopyCreationContext(PortletEntity sourceEntity, PortletModel srcPortletModel, UniqueNameStrategy uniqueNameStrategy, Identifiable domainProvider)
          Creates a PortletEntityCreationContext.
abstract  PortletEntityCreationContext newPortletEntityCreationContext(ObjectID parentID, Identifiable domainProvider)
          Creates a PortletEntityCreationContext.
abstract  TemplatingCreationContext newTemplatingCreationContext(boolean isTemplateInstantiation)
          Creates a TemplatingCreationContext.
abstract  WireCreationContext newWireCreationContext(Identifiable aTargetPage, Identifiable aSourceLayoutControl, Identifiable aTargetLayoutControl, Identifiable aSourceEndpoint, Identifiable aTargetEndpoint)
          Creates a WireCreationContext.
abstract  WireCreationContext newWireCreationContext(Identifiable aTargetPage, Identifiable aSourceLayoutControl, Identifiable aTargetLayoutControl, Identifiable aSourceEndpoint, Identifiable aTargetEndpoint, Identifiable aUser)
          Deprecated. since 6.1.0.1 Support for private wires will be removed in a future release of WebSphere Portal, use newWireCreationContext(Identifiable, Identifiable, Identifiable, Identifiable, Identifiable) instead
protected static void setInstance(CreationContextBuilderFactory aFactory)
          Initializes the factory with the given instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreationContextBuilderFactory

protected CreationContextBuilderFactory()
Method Detail

getInstance

public static CreationContextBuilderFactory getInstance()
Returns an instance of the factory.

Returns:
an instance of the factory, never null
Throws:
java.lang.IllegalStateException - in case the factory has not been initialized

setInstance

protected static void setInstance(CreationContextBuilderFactory aFactory)
Initializes the factory with the given instance.

Parameters:
aFactory - an implementation of the factory, must not be null

combine

public abstract CreationContext combine(CreationContext... contexts)
Combines the given contexts into one creation context which implements all interfaces of the individual contexts.

Parameters:
contexts - an array of creation contexts, no context of the array may implement more than one creation context, and the array must not contain null objects.
Returns:
a creation context which combines all individual contexts

newContentNodeCreationContext

public abstract ContentNodeCreationContext newContentNodeCreationContext(boolean isPrivate)
Creates a ContentNodeCreationContext.

Parameters:
isPrivate - indicates whether the resource is to be created as a private node or a page that may be accessible to multiple users.
Returns:
a new creation context

newContentNodeCopyCreationContext

public abstract ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc,
                                                                                              ContentModel<ContentNode> aSrcModel,
                                                                                              PortletModel aSrcPortletModel,
                                                                                              UniqueNameStrategy aUniqueNameStrategy)
Returns a creation context allowing to copy a content node. The returned creation context will contain all necessary information about the content node itself including the active, shareable and bookmarkable flag, localized information, meta data, associated themes and markups. Further the layout of pages as well as the layout controls will be contained in this context.

Parameters:
aSrc - The source node to copy, also known as template node, must not be null
aSrcModel - The source content model, i. e. the content model in which the given node aSrc can be found in, must not be null.
aSrcPortletModel - The source portlet model, i. e. the portlet model applicable to the source node. If the given node (aSrc) is a ContentPage, i. e. true == ContentNodeType.PAGE.equals(contentNode.getContentNodeType()) || ContentNodeType.STATICPAGE.equals(contentNode.getContentNodeType()); this parameter must not be null. In all other cases this parameter may be null.
aUniqueNameStrategy - The strategy how to proceed with the unique names of the new node(s), must not be null.
Returns:
creation context allowing to copy the given content node, never null.
Since:
6.1.0.1

newLayoutNodeCopyCreationContext

public abstract LayoutNodeCopyCreationContext<LayoutNode> newLayoutNodeCopyCreationContext(LayoutNode aSrc,
                                                                                           LayoutModel<LayoutNode> aSrcModel,
                                                                                           PortletModel aSrcPortletModel,
                                                                                           UniqueNameStrategy aUniqueNameStrategy)
Returns a creation context allowing to copy a content node. The returned creation context will contain all necessary information about the content node itself including the active, shareable and bookmarkable flag, localized information, meta data, associated themes and markups. Further the layout of pages as well as the layout controls will be contained in this context.

Parameters:
aSrc - The source node to copy, also known as template node, must not be null
aSrcModel - The source content model, i. e. the content model in which the given node aSrc can be found in, must not be null.
aSrcPortletModel - The source portlet model, i. e. the portlet model applicable to the source node. If the given node (aSrc) is a ContentPage, i. e. true == LayoutNodeType.PAGE.equals(LayoutNode.getLayoutNodeType()) || LayoutNodeType.STATICPAGE.equals(LayoutNode.getLayoutNodeType()); this parameter must not be null. In all other cases this parameter may be null.
aUniqueNameStrategy - The strategy how to proceed with the unique names of the new node(s), must not be null.
Returns:
creation context allowing to copy the given content node, never null.
Since:
8.5

newContentNodeCopyCreationContext

public abstract ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc,
                                                                                              ContentModel<ContentNode> aSrcModel,
                                                                                              PortletModel aSrcPortletModel,
                                                                                              UniqueNameStrategy aUniqueNameStrategy,
                                                                                              Identifiable aDomainProvder)
Returns a creation context allowing to copy a content node. The returned creation context will contain all necessary information about the content node itself including the active, shareable and bookmarkable flag, localized information, meta data, associated themes and markups. Further the layout of pages as well as the layout controls will be contained in this context.

Parameters:
aSrc - The source node to copy, also known as template node, must not be null
aSrcModel - The source content model, i. e. the content model in which the given node aSrc can be found in, must not be null.
aSrcPortletModel - The source portlet model, i. e. the portlet model applicable to the source node. If the given node (aSrc) is a ContentPage, i. e. true == ContentNodeType.PAGE.equals(contentNode.getContentNodeType()) || ContentNodeType.STATICPAGE.equals(contentNode.getContentNodeType()); this parameter must not be null. In all other cases this parameter may be null.
aUniqueNameStrategy - The strategy how to proceed with the unique names of the new node(s), must not be null.
aDomainProvder - an identifiable object providing the target domain for the new created node (including dependent nodes, e. g. LayoutNodes, can be null.
Returns:
creation context allowing to copy the given content node, never null.
Since:
6.1.0.3

newCopyCreationContext

public abstract <T> CopyCreationContext<T> newCopyCreationContext(T anAspectProvider,
                                                                  java.lang.Class... theAspects)
Returns a creation context allowing to copy certain aspects of a node. The returned creation context will contain all necessary information to copy these aspects.
As of WebSphere Portal Server version 6.1.0.1 supported aspects are:

Example how to use this method to copy the titles and descriptions and the active flag of an existing content node

 // See ContentModelControllerHome for how to obtain the controller itself
 final ContentModelController<ContentNode, ModifiableContentNode> ctrl = getController(
                req, resp);
 try {
        // Get the node to copy
        final ContentNode template = ctrl.getLocator().findByUniqueName("template");
        if (template != null) {
                // Insert the new node under the node with unique name "parent"
                // It does not matter what type the template is as all content nodes
                // have Localized information
                // as well as provide the active flag.
                final ContentNode parent = ctrl.getLocator().findByUniqueName("parent");
                if (parent != null) {
                        final CreationContextBuilderFactory factory = CreationContextBuilderFactory
                                        .getInstance();
                        // The new (copied) node should not get a unique name:
                        final UniqueNameStrategy strategy = UniqueNameStrategy.NULL;
                        // We do not need a portlet model here because the new node will be
                        // a content label.
                        final PortletModel portletModel = null;
                        // Create the context that allows to copy the titles and
                        // descriptions and the active flag
                        final CopyCreationContext<ContentNode> ctx = factory
                                        .newCopyCreationContext(template,
                                                        com.ibm.portal.Localized.class,
                                                        com.ibm.portal.ActiveFlag.class);
                        final ModifiableContentLabel newLabel = (ModifiableContentLabel) ctrl
                                        .create(ContentLabel.class, ctx);
                        ctrl.insert(newLabel, parent, null);
                        // Commit, i. e. persist the changes.
                        ctrl.commit();
                }
        }
 } finally {
        // Dispose the Controller.
        ctrl.dispose();
 }
 

Parameters:
theAspects - The aspects to copy
anAspectProvider - The node which implements the given aspect and that should be copied.
Returns:
creation context allowing to copy the given aspect of the given node.
Since:
6.1.0.1

newMetaDataCopyCreationContext

public abstract MetaDataCopyCreationContext<MetaDataProvider> newMetaDataCopyCreationContext(MetaDataProvider aMetaDataProvider,
                                                                                             java.util.List<java.lang.String> protectedNamesToCopy)
Returns a creation context for copying the meta data. The returned creation context may trigger to copy all meta data of the given meta data provider that are exposed through MetaData.getNames(). Meta data values that are only accessible through calls on MetaData.getValue(String) have to be specified in the additional parameter protectedNamesToCopy. By default all names starting with com.ibm.portal are not exposed in the list of meta data names.
Example: The meta data for remote cache expiry is not exposed in the list of meta data names, the according key is: com.ibm.portal.remote-cache-expiry.
If you wish to copy the remote cache expiry you should pass in a list containing the according name:
 final CreationContextBuilderFactory ctxFactory = ... // Obtain the factory as documented
 // Get the meta data provider, e. g. a content node.
 final MetaDataProvider mdProvider = ... 
 final java.util.List<String> protectedName = java.util.Collections.singletonList("com.ibm.portal.remote-cache-expiry");
 ctxFactory.newMetaDataCopyCreationContext(mdProvider, protectedName);
 
 

Parameters:
aMetaDataProvider - The meta data provider
protectedNamesToCopy - A list containing all protected meta data names, must not be null but may be empty if no protected names should be copied.
Returns:
creation context allowing to copy the meta data of a node.

newContentPageCreationContext

public abstract ContentPageCreationContext newContentPageCreationContext(boolean isPrivate)
Creates a ContentPageCreationContext.

Parameters:
isPrivate - indicates whether the resource is to be created as a private page or a page that may be accessible to multiple users.
Returns:
a new creation context

newDerivedContentPageCreationContext

public abstract DerivedContentPageCreationContext newDerivedContentPageCreationContext(boolean isPrivate,
                                                                                       ContentPage aDerivationParent)
Creates a DerivedContentPageCreationContext.

Parameters:
isPrivate - indicates whether the resource is to be created as a private page or a page that may be accessible to multiple users.
aDerivationParent - a content page which serves as the derivation parent for the page to be created, must not be null.
Returns:
a new creation context

newIdentifiableCreationContext

public abstract IdentifiableCreationContext newIdentifiableCreationContext(ObjectID anObjectID)
Creates a IdentifiableCreationContext.

Parameters:
anObjectID - the ID to use for the created resource, must not be null.
Returns:
a new creation context

newLayoutControlCreationContext

public abstract LayoutControlCreationContext newLayoutControlCreationContext(Identifiable portletDefinition,
                                                                             Identifiable portletEntity)
Creates a LayoutControlCreationContext.

Parameters:
portletDefinition - a portlet definition or its ID, must not be null.
portletEntity - a portlet entity or its ID, may be null.
Returns:
a new creation context

newDerivedLayoutControlCreationContext

public abstract DerivedLayoutControlCreationContext newDerivedLayoutControlCreationContext(Identifiable portletDefinition,
                                                                                           Identifiable portletEntity,
                                                                                           Identifiable control)
Creates a DerivedLayoutControlCreationContext.

Parameters:
portletDefinition - a portlet definition or its ID, must not be null.
portletEntity - a portlet entity or its ID, may be null.
control - a control or its ID, may be null. *
Returns:
a new creation context
Since:
8.5

newPortletDefinitionCloningContext

public abstract PortletDefinitionCloningContext newPortletDefinitionCloningContext(ObjectID portletDefinitionID,
                                                                                   Identifiable domainProvider)
Creates a PortletDefinitionCloningContext.

Parameters:
portletDefinitionID - an object id instance that provides the id of a portlet definition which should be cloned, must not be null.
domainProvider - an identifiable object providing the target domain, can be null.
Returns:
a new creation context

newIWidgetWrapperURICreationContext

public abstract IWidgetWrapperCreationContext newIWidgetWrapperURICreationContext(Context context,
                                                                                  java.net.URI iWidgetURI)
Creates a IWidgetWrapperCreationContext.

Parameters:
context - The content operations context, must not be null.
iWidgetURI - The uri pointing to the iwidget definition, must not be null.
Returns:
a new creation context

newIWidgetWrapperURLCreationContext

public abstract IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context,
                                                                                     java.lang.String iWidgetURL)
Creates a URL based IWidgetWrapperURLCreationContext.

Parameters:
context - The content operations context, must not be null.
iWidgetURL - the URL pointing to the iwidget definition, must not be null.
Returns:
a new creation context

newIWidgetWrapperURLCreationContext

public abstract IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context,
                                                                                     java.lang.String iWidgetURL,
                                                                                     ObjectID pageID)
Creates a IWidgetWrapperURLCreationContext for an IWidget that wants to serve resources relative to a static content page.

Parameters:
context - The content operations context, must not be null.
iWidgetURI - The uri pointing to the iwidget definition, must not be null.
pageID - The ObjectID of the static content page, may be null.
Returns:
a new creation context

newPortletEntityCreationContext

public abstract PortletEntityCreationContext newPortletEntityCreationContext(ObjectID parentID,
                                                                             Identifiable domainProvider)
Creates a PortletEntityCreationContext. This context can be used to create a new PortletEntity

Parameters:
parentID - ObjectID of another PortletEntity that acts as a parent, must not be null. In current versions of WebSphere Portal parents can either be a PortletDefinition or another PortletEntity. If the parent is another PortletEntity the new created entity must be a user customized entity and the parent entity acts as a so called shared entity. In other words if the parent is a portlet entity then this entity has to be located in the RELEASE or COMMUNITY database domain and the new created entity will be located in the CUSTOMIZATION database domain.
domainProvider - an identifiable object providing the target domain, can be null.
Returns:
a new creation context

newPortletEntityCopyCreationContext

public abstract PortletEntityCopyCreationContext newPortletEntityCopyCreationContext(PortletEntity sourceEntity,
                                                                                     PortletModel srcPortletModel,
                                                                                     UniqueNameStrategy uniqueNameStrategy,
                                                                                     Identifiable domainProvider)
Creates a PortletEntityCreationContext. This context can be used to create a new PortletEntity

Parameters:
sourceEntity - source entity to be copied
srcPortletModel - the portlet model that contains the entity
domainProvider - an identifiable object providing the target domain, can be null.
uniqueNameStrategy - The strategy how to proceed with the unique names of the new node(s), must not be null.
Returns:
a new creation context

newWireCreationContext

public abstract WireCreationContext newWireCreationContext(Identifiable aTargetPage,
                                                           Identifiable aSourceLayoutControl,
                                                           Identifiable aTargetLayoutControl,
                                                           Identifiable aSourceEndpoint,
                                                           Identifiable aTargetEndpoint,
                                                           Identifiable aUser)
Deprecated. since 6.1.0.1 Support for private wires will be removed in a future release of WebSphere Portal, use newWireCreationContext(Identifiable, Identifiable, Identifiable, Identifiable, Identifiable) instead

Creates a WireCreationContext.

Parameters:
aTargetPage - the target page or null. If null is passed, the wire to be created will be an in - page wire. For it�s creation of which the ObjectID of the layout model that served the wire model controller used for creation of wires is used as source and target page.
aSourceLayoutControl - the source layout control, must not be null.
aTargetLayoutControl - the target layout control, must not be null.
aSourceEndpoint - the source end point, must not be null.
aTargetEndpoint - the target end point, must not be null.
aUser - the owner of the wire. For a public wire the anonymous user or null can be set.
Returns:
a new creation context

newWireCreationContext

public abstract WireCreationContext newWireCreationContext(Identifiable aTargetPage,
                                                           Identifiable aSourceLayoutControl,
                                                           Identifiable aTargetLayoutControl,
                                                           Identifiable aSourceEndpoint,
                                                           Identifiable aTargetEndpoint)
Creates a WireCreationContext.

Parameters:
aTargetPage - the target page or null. If null is passed, the wire to be created will be an in - page wire. For it�s creation of which the ObjectID of the layout model that served the wire model controller used for creation of wires is used as source and target page.
aSourceLayoutControl - the source layout control, must not be null.
aTargetLayoutControl - the target layout control, must not be null.
aSourceEndpoint - the source end point, must not be null.
aTargetEndpoint - the target end point, must not be null.
Returns:
a new creation context
Since:
6.1.0.1

newDecorationCreationContext

public abstract DecorationCreationContext newDecorationCreationContext(java.lang.String resourceRoot,
                                                                       java.lang.String contextRoot)
Creates a DecorationCreationContext.

Parameters:
resourceRoot - The resource root of the new Decoration, must not be null.
contextRoot - The context root of the new Decoration, may be null.
Returns:
a new creation context

newTemplatingCreationContext

public abstract TemplatingCreationContext newTemplatingCreationContext(boolean isTemplateInstantiation)
Creates a TemplatingCreationContext. Needs to be combined with a CopyCreationContext.

Parameters:
isTemplateInstantiation - Flag indicating if the copy operation is a template instantiation.
Returns:
a new creation context