04-28-2010 10:34 AM
private static NodeRef createFolder(ServiceRegistry serviceRegistry, NodeRef node, String name) {
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
contentProps.put(ContentModel.PROP_NAME, name);
contentProps.put(ContentModel.PROP_DESCRIPTION, name);
NodeService nodeService = serviceRegistry.getNodeService();
ChildAssociationRef association = nodeService.createNode(node, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_FOLDER, contentProps);
return association.getChildRef();
}
ParentReference parentReference = new ParentReference(STORE, null, parentFolder, Constants.ASSOC_CONTAINS, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, realfolderName));
// Create folder
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, realfolderNameRepalced), Utils.createNamedValue(Constants.PROP_DESCRIPTION, realfolderNameRepalced) };
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_FOLDER, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
04-29-2010 06:21 AM
public static void main(String[] args) {
start();
}
private static void start() {
// initialise app content
ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
// get registry of services
final ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
// use TransactionWork to wrap service calls in a user transaction
TransactionService transactionService = serviceRegistry.getTransactionService();
RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>() {
public Object execute() throws Exception {
doExample(serviceRegistry);
return null;
}
};
System.out.println("Prepare to commit");
transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork);
System.out.println("Commit executed");
System.exit(0);
}
04-29-2010 12:45 PM
04-30-2010 06:39 AM
04-30-2010 08:46 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.