|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.portal.model.controller.CreationContextBuilderFactory
public abstract class CreationContextBuilderFactory
A factory for creating and combining CreationContext
s.
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(); }
Constructor Summary | |
---|---|
protected |
CreationContextBuilderFactory()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected CreationContextBuilderFactory()
Method Detail |
---|
public static CreationContextBuilderFactory getInstance()
null
java.lang.IllegalStateException
- in case the factory has not been initializedprotected static void setInstance(CreationContextBuilderFactory aFactory)
aFactory
- an implementation of the factory, must not be
null
public abstract CreationContext combine(CreationContext... contexts)
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.
public abstract ContentNodeCreationContext newContentNodeCreationContext(boolean isPrivate)
ContentNodeCreationContext
.
isPrivate
- indicates whether the resource is to be created as a private
node or a page that may be accessible to multiple users.
public abstract ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc, ContentModel<ContentNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy)
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
.
null
.public abstract LayoutNodeCopyCreationContext<LayoutNode> newLayoutNodeCopyCreationContext(LayoutNode aSrc, LayoutModel<LayoutNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy)
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
.
null
.public abstract ContentNodeCopyCreationContext<ContentNode> newContentNodeCopyCreationContext(ContentNode aSrc, ContentModel<ContentNode> aSrcModel, PortletModel aSrcPortletModel, UniqueNameStrategy aUniqueNameStrategy, Identifiable aDomainProvder)
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.
LayoutNode
s, can be null
.
null
.public abstract <T> CopyCreationContext<T> newCopyCreationContext(T anAspectProvider, java.lang.Class... theAspects)
ActiveFlag
Localized
ModifiableMetaDataProvider
ShareableFlag
BookmarkableFlag
ThemeProvider
MarkupCapable
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(); }
theAspects
- The aspects to copyanAspectProvider
- The node which implements the given aspect and that should be
copied.
public abstract MetaDataCopyCreationContext<MetaDataProvider> newMetaDataCopyCreationContext(MetaDataProvider aMetaDataProvider, java.util.List<java.lang.String> protectedNamesToCopy)
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. com.ibm.portal.remote-cache-expiry
.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);
aMetaDataProvider
- The meta data providerprotectedNamesToCopy
- A list containing all protected meta data names, must not be
null
but may be empty if no protected names
should be copied.
public abstract ContentPageCreationContext newContentPageCreationContext(boolean isPrivate)
ContentPageCreationContext
.
isPrivate
- indicates whether the resource is to be created as a private
page or a page that may be accessible to multiple users.
public abstract DerivedContentPageCreationContext newDerivedContentPageCreationContext(boolean isPrivate, ContentPage aDerivationParent)
DerivedContentPageCreationContext
.
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
.
public abstract IdentifiableCreationContext newIdentifiableCreationContext(ObjectID anObjectID)
IdentifiableCreationContext
.
anObjectID
- the ID to use for the created resource, must not be
null
.
public abstract LayoutControlCreationContext newLayoutControlCreationContext(Identifiable portletDefinition, Identifiable portletEntity)
LayoutControlCreationContext
.
portletDefinition
- a portlet definition or its ID, must not be null
.portletEntity
- a portlet entity or its ID, may be null
.
public abstract DerivedLayoutControlCreationContext newDerivedLayoutControlCreationContext(Identifiable portletDefinition, Identifiable portletEntity, Identifiable control)
DerivedLayoutControlCreationContext
.
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
. *
public abstract PortletDefinitionCloningContext newPortletDefinitionCloningContext(ObjectID portletDefinitionID, Identifiable domainProvider)
PortletDefinitionCloningContext
.
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
.
public abstract IWidgetWrapperCreationContext newIWidgetWrapperURICreationContext(Context context, java.net.URI iWidgetURI)
IWidgetWrapperCreationContext
.
context
- The content operations context, must not be null
.iWidgetURI
- The uri pointing to the iwidget definition, must not be
null
.
public abstract IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context, java.lang.String iWidgetURL)
IWidgetWrapperURLCreationContext
.
context
- The content operations context, must not be null
.iWidgetURL
- the URL pointing to the iwidget definition, must not be
null
.
public abstract IWidgetWrapperURLCreationContext newIWidgetWrapperURLCreationContext(Context context, java.lang.String iWidgetURL, ObjectID pageID)
IWidgetWrapperURLCreationContext
for an IWidget that
wants to serve resources relative to a static content page.
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
.
public abstract PortletEntityCreationContext newPortletEntityCreationContext(ObjectID parentID, Identifiable domainProvider)
PortletEntityCreationContext
. This context can be used
to create a new PortletEntity
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
.
public abstract PortletEntityCopyCreationContext newPortletEntityCopyCreationContext(PortletEntity sourceEntity, PortletModel srcPortletModel, UniqueNameStrategy uniqueNameStrategy, Identifiable domainProvider)
PortletEntityCreationContext
. This context can be used
to create a new PortletEntity
sourceEntity
- source entity to be copiedsrcPortletModel
- the portlet model that contains the entitydomainProvider
- 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
.
public abstract WireCreationContext newWireCreationContext(Identifiable aTargetPage, Identifiable aSourceLayoutControl, Identifiable aTargetLayoutControl, Identifiable aSourceEndpoint, Identifiable aTargetEndpoint, Identifiable aUser)
newWireCreationContext(Identifiable, Identifiable, Identifiable, Identifiable, Identifiable)
instead
WireCreationContext
.
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.
public abstract WireCreationContext newWireCreationContext(Identifiable aTargetPage, Identifiable aSourceLayoutControl, Identifiable aTargetLayoutControl, Identifiable aSourceEndpoint, Identifiable aTargetEndpoint)
WireCreationContext
.
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
.
public abstract DecorationCreationContext newDecorationCreationContext(java.lang.String resourceRoot, java.lang.String contextRoot)
DecorationCreationContext
.
resourceRoot
- The resource root of the new Decoration
, must not be
null
.contextRoot
- The context root of the new Decoration
, may be
null
.
public abstract TemplatingCreationContext newTemplatingCreationContext(boolean isTemplateInstantiation)
TemplatingCreationContext
. Needs to be combined with a
CopyCreationContext.
isTemplateInstantiation
- Flag indicating if the copy operation is a template instantiation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |