In order to create content, create an instance of the IGenericCreator interface and execute the script.
● You have created well-formed and valid XML for the XML Content and Actions feature. For more information, see XML Content and Actions.
The XML can be a String or InputStream.
...
1. Get the IGenericCreator interface.
IGenericCreatorGatewayService
gwService = (IGenericCreatorGatewayService)
PortalRuntime.getRuntimeResources().getService(
IGenericCreatorGatewayService.KEY);
IGenericCreator genericCreator = gwService.getGenericCreator();
2. Create a GenericCreatorParams class that contains the current user and the XML.
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();
}
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.
IGenericCreatorResults gcResults = genericCreator.generate(gcParams);