02-29-2008 08:49 AM
public static CategoryDTO createCategory(String name, String descripcion, String uuidParent) {
Store store = null; // almacen
CategoryDTO cat = new CategoryDTO();
String newCategoryUuid = null;
String subcategory = "subcategories";
String uuid2 = null;
try {
store = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
loginWSAlfresco();
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, name), Utils.createNamedValue(Constants.PROP_DESCRIPTION, descripcion) };
if ((uuidParent != null) && (!uuidParent.equals("")))
uuid2 = uuidParent;
else {
// get de root category reference
Query q2 = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"" + "/cm:generalclassifiable/cm:SDK/cm:SDK_ST" + "\"");
RepositoryServiceSoapBindingStub repoService2 = WebServiceFactory.getRepositoryService();
QueryResult r2 = repoService2.query(store, q2, true);
ResultSet result2 = r2.getResultSet();
ResultSetRow[] rows2 = result2.getRows();
uuid2 = rows2[0].getNode().getId();
}
Reference cateRootRef2 = new Reference(store, uuid2, null);
ParentReference parentRef = new ParentReference(store, cateRootRef2.getUuid(), null, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, subcategory), Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, name));
CMLCreate cmlCreate = new CMLCreate("12", parentRef, null, null, null, "{http://www.alfresco.org/model/content/1.0}category", properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { cmlCreate });
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
} catch (Exception e) {
e.printStackTrace();
} finally {
AuthenticationUtils.endSession();
}
}
07-01-2008 05:47 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.