+

Search Tips   |   Advanced Search

Create resources


We create resources using methods of controllers. Each controller type allows us to create specific resources for its type of model.

The following list shows the existing controllers and the resources that we can create 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.

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

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

Example 1 - Creating a resource using the creation context builder: This example creates a new ContentPagthat we 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 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 we can cast to the type of the created resource .

Example 3 - Casting a created resource to its type:


Parent: Modify portal resources and topologies
Related:
Move or Inserting Nodes
Delete Nodes