Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Created November 11, 2013 13:54
Show Gist options
  • Save cfalzone/7413516 to your computer and use it in GitHub Desktop.
Save cfalzone/7413516 to your computer and use it in GitHub Desktop.
Relationship handling in dotCMS 2.5
private void createContent(
Map<String, String> properties, // The properties to set on the contentlet
String stInode, // The inode of the structure
String stHostId, // The identifier of the host
long languageId, // the language id
List<Category> cats, // list of the categories
Map<Relationship, List<Contentlet>> cRels // Maps relationship to the related content
) {
// Create a new contentlet
Contentlet contentlet=new Contentlet();
contentlet.setStructureInode(stInode);
contentlet.setHost(stHost.getIdentifier());
contentlet.setLanguageId(languageId);
// Set the properties
for(String key : properties.keySet()) {
String val = propeties.get(key);
contentlet.setStringProperty(key, val)
}
// Now checkin and publish this contentlet
try {
contentlet = conAPI.checkin(contentlet, cRels, cats, new ArrayList<Permission>(), userAPI.getSystemUser(), false);
conAPI.publish(contentlet, userAPI.getSystemUser(), false);
} catch (Exception e) {
Logger.error(this, "Exception checking in contentlet", e);
throw new Exception(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment