08-21-2015 09:04 AM
public class Test
{
public static void main(String[] args)
{
Map<String, String> parameter = new HashMap<String, String>();
AlfrescoItemType itemType = null;
// Set the user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "root");
// Specify the connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8181/alfresco/api/-default-/public/cmis/versions/1.1/atom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// Create a session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
AlfrescoFolder dataLists = (AlfrescoFolder) session.getObjectByPath("/Sites/alerts/dataLists/262abf17-b519-48b2-91d8-1eadb919dae7");
System.out.println(" dataList object—"+dataLists.getName());
Map<String, Object> properties = new HashMap<String, Object>();
// properties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:dataListItem");
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:event");
String var_name_extension = "9";
properties.put(PropertyIds.NAME, "some name"+var_name_extension);
properties.put(PropertyIds.DESCRIPTION, "some description"+var_name_extension);
// properties.put("cm:title", "some title3");
// IF BELOW 4 LINES ARE USED, IT CREATES AN ITEM IN THE LIST BUT WITHOUT DESCRIPTION, I see an empty row IN THE LIST
// properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled");
// properties.put(PropertyIds.NAME, "some name"+var_name_extension);
// properties.put("cm:title", "some title");
// properties.put("cm:description", "some description");
ObjectId newItemId = session.createItem(properties, dataLists);
System.out.println("newItemId===="+newItemId);
AlfrescoDocument dLItem = (AlfrescoDocument) session.getObjectByPath("/Sites/alerts/dataLists/262abf17-b519-48b2-91d8-1eadb919dae7/some name"+var_name_extension);
// dLItem.addAspect("D:dl:dataListItem,P:cm:titled", "HELLO");
Map<String, Object> newProps = new HashMap<String, Object>();
newProps.put("cm:title", "HELLO");
dLItem.updateProperties(newProps,true);
}
}
08-24-2015 08: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.