Create resources

You create resources by using methods of controllers. Each controller type allows you to create specific resources for its type of model.

The following list shows the existing controllers and the resources that you can create by using them:

To create a resource...

  1. Optional. Obtain a creation context.

      To do this, take the following two steps:

      1. Obtain the creation context builder factory. For details about how to do this refer to Obtaining creation contexts.

      2. Obtain a creation context from the creation context builder. For details about how to do this refer to Obtaining creation contexts.

  2. Obtain a controller.

  3. Create a resource.

      To do this, use the create(Class, CreationContext) method of the controller and provide both arguments.


Notes:

  1. The created resource is not part of the topology, unless you insert it into the topology by using the insert() method of the controller.

  2. For content nodes, that is content pages, content labels, and content URLs, you need to set a supported markup. Otherwise they will not show in the read-only model.


Example 1 - Creating a resource by using the creation context builder: This example creates a new ContentPage that you can later insert into the content model.

// obtain creation context builder
final CreationContextBuilderFactory builder = CreationContextBuilderFactory.getInstance();
 
// obtain creation context
final CreationContext creationContext = builder.newIdentifiableCreationContext(objectID);
 
// create resource (which is not yet part of the topology of the controller!)
final Modifiable modifiable = controller.create(ContentPage.class, creationContext);

Example 2 - Cloning an existing portlet definition: To clone an existing portlet definition, create a portlet definition by using a portlet model controller and specify a PortletDefinitionCloningContext.

// obtain portlet definition cloning context; includes obtaining a portlet definition
final PortletDefinitionCloningContext context = ... (portletDefinition)
 
// create portlet definition
pmController.create(PortletDefinition.class, context);

The result of the create() method is a Modifiable instance of the created resource that you can cast to the type of the created resource as shown in the following example.
Example 3 - Casting a created resource to its type:

final ModifiableContentPage modifiableContentPage = (ModifiableContentPage) 
      controller.create(ContentPage.class, creationContext); 


Parent

Modify portal resources and topologies
Move or Inserting Nodes
Delete Nodes

 


+

Search Tips   |   Advanced Search