Example creating items from the Java client
This example show how to create new Content Manager items from your Java proxy client by initializing an object factory singleton (do not use constructors for the various item types).
ObjectFactory objectFactory = new ObjectFactory();
Next, create a content item by calling the object factory's create<X> method, where <X> is the type of item you want to create. In this example, the thing being created is an array of Item Types, which is then used in an Items Filter, which itself is also created using the object factory. The resulting Items Filter is added to an Organizational Item Items Filter.
static OrganizationalItemItemsFilterData prepareFilter()
{
ArrayOfItemType itemTypes = objectFactory.createArrayOfItemType();
itemTypes.getItemType().add(ItemType.COMPONENT);
OrganizationalItemItemsFilterData filter = objectFactory.createOrganizationalItemItemsFilterData();
filter.setItemTypes(objectFactory.createItemsFilterDataItemTypes(itemTypes));
return filter;
}
The following code sample shows how to create a Component.
void createComponent(String title, String folderUri, String schemaUri) throws Exception
{
ComponentData newComponent = (ComponentData) endpoint.getDefaultData(ItemType.COMPONENT, folderUri);
LinkToSchemaData schema = objectFactory.createLinkToSchemaData();
schema.setIdRef(objectFactory.createLinkIdRef(schemaUri));
String xmlContent = "<Content xmlns='uuid:99273436-1bfd-49a5-941e-64f115fbb565'/>";
newComponent.getTitle().setValue(title);
newComponent.setSchema(objectFactory.createComponentDataSchema(schema));
newComponent.setContent(objectFactory.createComponentDataContent(xmlContent));
endpoint.create(newComponent, null);
}