Revision: 22360
Updated Code
at January 11, 2010 02:47 by wearetherock
Updated Code
public static Reference createNewContent(ContentServiceSoapBindingStub contentService, String name, String contentString)
throws Exception
{
// Update name
name = System.currentTimeMillis() + "_" + name;
// Create a parent reference, this contains information about the association we are createing to the new content and the
// parent of the new content (the space retrived from the search)
ParentReference parentReference = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder", ASSOC_CONTAINS,
"{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name);
// Define the content format for the content we are adding
ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8");
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, name)};
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});
// [email protected], Sat Jan 9, 2010 {{
NamedValue custName = Utils.createNamedValue("{custom.model}CustomerName", "wearetherock");
NamedValue contName = Utils.createNamedValue("{custom.model}CustomerContactName", "Wk Ok");
NamedValue contPhone = Utils.createNamedValue("{custom.model}CustomerContactPhone", "000xxxxxx");
NamedValue projID = Utils.createNamedValue("{custom.model}CustomerProjectID", "3943");
NamedValue newCust = Utils.createNamedValue("{custom.model}NewCustomer", "true");
NamedValue[] ascProperties = new NamedValue[]{custName,contName,contPhone,projID,newCust};
CMLAddAspect addaspect = new CMLAddAspect();
addaspect.setAspect("{custom.model}CustomerDetails");
addaspect.setProperty(ascProperties);
addaspect.setWhere_id("1");
cml.setAddAspect(new CMLAddAspect[]{addaspect});
// }}
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference newContentNode = result[0].getDestination();
Content content = contentService.write(newContentNode, Constants.PROP_CONTENT, contentString.getBytes(), contentFormat);
// Get a reference to the newly created content
System.out.println("wk >> " + content.getNode());
return content.getNode();
}
Revision: 22359
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 11, 2010 02:46 by wearetherock
Initial Code
public static Reference createNewContent(ContentServiceSoapBindingStub contentService, String name, String contentString)
throws Exception
{
// Update name
name = System.currentTimeMillis() + "_" + name;
// Create a parent reference, this contains information about the association we are createing to the new content and the
// parent of the new content (the space retrived from the search)
ParentReference parentReference = new ParentReference(STORE, null, "/app:company_home/cm:sample_folder", ASSOC_CONTAINS,
"{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name);
// Define the content format for the content we are adding
ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8");
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, name)};
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[]{create});
// [email protected], Sat Jan 9, 2010 {{
NamedValue custName = Utils.createNamedValue("{custom.model}CustomerName", "wearetherock");
NamedValue contName = Utils.createNamedValue("{custom.model}CustomerContactName", "Somnuk Wongkhan");
NamedValue contPhone = Utils.createNamedValue("{custom.model}CustomerContactPhone", "000xxxxxx");
NamedValue projID = Utils.createNamedValue("{custom.model}CustomerProjectID", "3943");
NamedValue newCust = Utils.createNamedValue("{custom.model}NewCustomer", "true");
NamedValue[] ascProperties = new NamedValue[]{custName,contName,contPhone,projID,newCust};
CMLAddAspect addaspect = new CMLAddAspect();
addaspect.setAspect("{custom.model}CustomerDetails");
addaspect.setProperty(ascProperties);
addaspect.setWhere_id("1");
cml.setAddAspect(new CMLAddAspect[]{addaspect});
// }}
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference newContentNode = result[0].getDestination();
Content content = contentService.write(newContentNode, Constants.PROP_CONTENT, contentString.getBytes(), contentFormat);
// Get a reference to the newly created content
System.out.println("wk >> " + content.getNode());
return content.getNode();
}
Initial URL
Initial Description
Initial Title
Alfresco Upload Content with Custom Aspect
Initial Tags
Initial Language
Java