Show TOC

Procedure documentationExecuting an XML Script Locate this document in the navigation structure

 

The package com.sap.portal.genericcreator contains the following interfaces and classes for creating content via an XML script:

IGenericCreatorGatewayService

An interface that represents a portal service that enables the creation of an IGenericCreator object

IGenericCreator

An interface that enables you to execute an XML script

GenericCreatorParams

A class that holds a reference to the user executing the script and the XML script

IGenericCreatorResults

An interface that contains the results from the execution of an XML script

GenericCreatorResult

A class that indicates whether the XML script was executed successfully, meaning that all objects and actions were created or performed successfully

To create content, create an instance of the IGenericCreator interface and execute the script.

Prerequisites

  • You have created well-formed and valid XML for the XML Content and Actions feature. More information: XML Content and Actions

Procedure

  1. Get the IGenericCreator interface.

    Syntax Syntax

    1. IGenericCreatorGatewayService gwService = (IGenericCreatorGatewayService)
          PortalRuntime.getRuntimeResources().getService(
              IGenericCreatorGatewayService.KEY);
      IGenericCreator genericCreator = gwService.getGenericCreator();
      
    End of the code.
  2. Create a GenericCreatorParams class that contains the current user and the XML.

    Syntax Syntax

    1. GenericCreatorParams gcParams = new GenericCreatorParams(
          request.getUser(),getGCString());
      
      private static String getGCString() {
          StringBuffer sb = new StringBuffer("<GenericCreator author="SAP" version="Testing" mode="clean,execute" report.level="success" createMode="1" default.locale="en" ignore="false">");
          sb.append("<Context parent="portal_content" name="test_folder" objectClass="com.sap.portal.pcd.gl.GlContext" title="Test folder">");
          sb.append("</Context></GenericCreator>");
      
          return sb.toString();
      }
    End of the code.

    There are various constructors so that you can specify the parameters in the following ways:

    • User: IUser or String (logon ID or unique ID)

    • XML: String or InputStream

  3. Execute the script and get the results, which indicate whether the script was executed successfully.

    Syntax Syntax

    1. IGenericCreatorResults gcResults = genericCreator.generate(gcParams);
      
    End of the code.