1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| public class ModificationDocument {
public String titre;
public String ID;
public String commentaire;
public String id_prosp1;
public int code_user;
public ModificationDocument(String s) {
this.titre = s;
}
public ModificationDocument(){
}
public String create_post_it(String k, String s, String doc1,String doc2, String id) throws Exception {
//Properties opp= new Properties();
//opp.load(this.getClass().getResourceAsStream("/alfresco.properties"));
//System.out.println(opp.getProperty("identifiant").toString());
AuthenticationUtils.startSession("admin","admin");
// Create a reference to the parent where we want to create content
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
String folderPath = "/app:company_home/cm:yassine_test";
ParentReference companyHomeParent = new ParentReference(storeRef, null,
folderPath, Constants.ASSOC_CONTAINS, Constants.createQNameString("http://www.alfresco.org/model/content/1.0",s));
// Assign name
String name = s;
System.out.println(name);
// Construct CML statement to create content node
// Note: Assign "1" as a local id, so we can refer to it in
// subsequent
// CML statements within the same CML block
NamedValue[] contentProps = new NamedValue[1];
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, name);
CMLCreate create = new CMLCreate("1", companyHomeParent, null, null,
null, Constants.TYPE_CONTENT, contentProps);
// Construct CML statement to add titled aspect
NamedValue[] titledProps = new NamedValue[2];
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, name);
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION,
doc2);
NamedValue nameValue = Utils
.createNamedValue(Constants.PROP_NAME, name);
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED,
titledProps, null, "1");
// Construct CML Block
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
// Issue CML statement via Repository Web Service and retrieve
// result
// Note: Batching of multiple statements into a single web call
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
//
// Write some content
//
ID = content.getUuid();
// ProspectService.addOrModifyReport(ID);
ContentServiceSoapBindingStub contentService = WebServiceFactory
.getContentService();
String text = k;
ContentFormat contentFormat = new ContentFormat("text/plain", "UTF-8");
Content contentRef = contentService.write(content,
Constants.PROP_CONTENT, text.getBytes(), contentFormat);
System.out.println("Content Length: " + contentRef.getLength());
System.out.println(ContentUtils.getContentAsString(contentRef));
return ID;
} |
Partager