12-28-2010 12:15 AM
12-28-2010 03:41 AM
try {
space = new Reference(WORKSPACE_STORE, null, pathToNode); // Example: /app:company_home/cm:folder1/cm:folder11
Node[] nodeArray = getRepositoryService().get(new Predicate(new Reference[] { space }, WORKSPACE_STORE, null));
space = nodeArray[0].getReference();
// If you get to here node already exists
} catch (Exception e) {
// If Exception is thrown node with that name/path does not exist.
}
12-28-2010 04:29 AM
12-28-2010 04:52 AM
Reference space = null;
try {
space = new Reference(WORKSPACE_STORE, null, "/app:company_home/cm:TestSpace");
Node[] nodeArray = getRepositoryService().get(new Predicate(new Reference[] { space }, WORKSPACE_STORE, null));
space = nodeArray[0].getReference();
System.out.println("Space " + space.getPath() + " exists. No need to create it.");
} catch (Exception e) {
System.out.println("Space doesn't exist… Lets create it.");
ParentReference companyHome = new ParentReference(WORKSPACE_STORE, null, "/app:company_home", Constants.ASSOC_CONTAINS, null);
companyHome.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, "TestSpace"));
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, "TestSpace")) };
CMLCreate create = new CMLCreate("1", companyHome, null, Constants.ASSOC_CONTAINS, null, spaceTypeQName, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
UpdateResult[] results = getRepositoryService().update(cml);
System.out.println("Space " + results[0] + " created.");
}
System.out.println("I got reference to " + space.getPath());
12-28-2010 05:58 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.