09-05-2008 09:21 AM
CMLCreate create = new CMLCreate();
create.setId("1");
create.setParent(foldref);
create.setProperty(contentProps);
create.setType(contentType);
NamedValue[] titledProps = new NamedValue[2];
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, fileName);
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "Content di prova GG WS");
CML cml = new CML();
cml.setCreate(new CMLCreate[] {create});
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
System.out.println("Reference node created");
Reference content = result[0].getDestination();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
FileInputStream is = new FileInputStream(srcName);
byte[] bytes = ContentUtils.convertToByteArray(is);
ContentFormat format = new ContentFormat(mimeType, "UTF-8");
System.out.println("Begin uploading…");
Content cnt = contentService.write(content, Constants.PROP_CONTENT, bytes, format);
09-06-2008 08:30 AM
public void setAddAspect(org.alfresco.webservice.types.CMLAddAspect[] addAspect)
public void setRemoveAspect(org.alfresco.webservice.types.CMLRemoveAspect[] removeAspect)
public void testAddRemoveAspect()
{
CMLAddAspect addAspect = new CMLAddAspect();
addAspect.setAspect(ContentModel.ASPECT_VERSIONABLE.toString());
addAspect.setWhere(createPredicate(this.nodeRef));
CML cml = new CML();
cml.setAddAspect(new CMLAddAspect[]{addAspect});
UpdateResult[] result = this.cmlUtil.executeCML(cml);
assertNotNull(result);
assertEquals(1, result.length);
UpdateResult updateResult = result[0];
assertEquals("addAspect", updateResult.getStatement());
assertNotNull(updateResult.getSource());
assertNotNull(updateResult.getDestination());
assertTrue(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE));
// TODO should test with properties set as well
CMLRemoveAspect removeAspect = new CMLRemoveAspect();
removeAspect.setAspect(ContentModel.ASPECT_VERSIONABLE.toString());
removeAspect.setWhere(createPredicate(this.nodeRef));
CML cml2 = new CML();
cml2.setRemoveAspect(new CMLRemoveAspect[]{removeAspect});
UpdateResult[] results2 = this.cmlUtil.executeCML(cml2);
assertNotNull(results2);
assertEquals(1, results2.length);
UpdateResult result2 = results2[0];
assertEquals("removeAspect", result2.getStatement());
assertNotNull(result2.getDestination());
assertNotNull(result2.getSource());
assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE));
}
03-05-2009 02:44 PM
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.