<namespace uri="http://www.prova.it/model/content/1.0" prefix="fe" />
<type name="fe:fattura">
<title>Fattura</title>
<parent>fe:docCommerciale</parent>
<properties>
<property name="fe:importo">
<type>d:float</type>
<mandatory>true</mandatory>
</property>
<property name="fe:dataScadenza">
<type>d:date</type>
<mandatory>true</mandatory>
</property>
</properties>
</type>
// Referenza al nodo padre in cui inserire il documento
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
ParentReference companyHomeParent = new ParentReference(storeRef, null, percorsoRepository, Constants.ASSOC_CONTAINS, null);
//Richiesta del repository service e del contet service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
// Nome del documento
companyHomeParent.setChildName("cm:" + fileName);
//Vettori delle proprietà
NamedValue[] contentProps = new NamedValue[1];
NamedValue[] titledProps = new NamedValue[2];
//Assegnazione ai vettori delle proprietà
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, fileName);
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "");
//Costrutto CML per aggiungere titolo al file
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");
CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
// Blocco create CML
CML cml = new CML();
cml.setCreate(new CMLCreate[] {create});
cml.setAddAspect(new CMLAddAspect[] {addAspect});
//Creazione effettiva del nodo
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
//Scrittura del contenuto
ContentFormat contentFormat = new ContentFormat(this.mimeType(fileName), "UTF-8");
Content contentRef = contentService.write(content, Constants.PROP_CONTENT, this.readFromFile(new File(percorsoFile + fileName)), contentFormat);
System.out.println("File caricato: " + fileName);
public void uploadFile(String percorsoFile,String fileName) throws Exception
{
String metaDati[][];
// Avvio sessione
AuthenticationUtils.startSession(user, password);
try
{
// Referenza al nodo padre in cui inserire il documento
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
ParentReference companyHomeParent = new ParentReference(storeRef, null, percorsoRepository, Constants.ASSOC_CONTAINS, null);
//Richiesta del repository service e del contet service
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
// Nome del documento
companyHomeParent.setChildName("cm:" + fileName);
metaDati2(percorsoFile);
String valori[][]=metaDati2(percorsoFile);
//Vettori delle proprietà
NamedValue[] customProps = new NamedValue[numeroProprieta(valori)];
NamedValue[] standardProps = new NamedValue[3];
//Assegnazione ai vettori delle proprietà
int i=0;
//while(valori[i][0].compareToIgnoreCase("")!=0)
while(i<=customProps.length - 1)
{
customProps[i] = Utils.createNamedValue(Constants.createQNameString("http://www.feniceevo.it/model/content/1.0',valori[i][0]),valori[i][1]);
i++;
}
//customProps[0]= Utils.createNamedValue(Constants.createQNameString("http://www.feniceevo.it/model/content/1.0','tipo"),"fattura");
//customProps[1] = Utils.createNamedValue(Constants.createQNameString("http://www.feniceevo.it/model/content/1.0','data"),"2012-01-01T00:00:00.000Z");
standardProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, fileName);
standardProps[1] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
standardProps[2] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "");
//Costrutto CML per aggiungere titolo al file
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, standardProps, null, "1");
//Upload file standard
//CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, Constants.PROP_CONTENT, contentProps);
//Upload file custom
//CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, "{http://www.feniceevo.it/model/content/1.0}docCommerciale", contentProps);
CMLCreate create = new CMLCreate("1", companyHomeParent, companyHomeParent.getUuid(), Constants.ASSOC_CONTAINS, null, "{http://www.feniceevo.it/model/content/1.0}" + customProps[0].getValue(), customProps);
// Blocco create CML
CML cml = new CML();
cml.setCreate(new CMLCreate[] {create});
cml.setAddAspect(new CMLAddAspect[] {addAspect});
//Creazione effettiva del nodo
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
//File pdf
String fileUpload=percorsoFile;
fileUpload=fileUpload.substring(0,fileUpload.length()-3);
fileUpload=fileUpload + "pdf";
//Scrittura del contenuto
ContentFormat contentFormat = new ContentFormat(this.mimeType(fileName), "UTF-8");
Content contentRef = contentService.write(content, Constants.PROP_CONTENT, this.readFromFile(new File(fileUpload)), contentFormat);
System.out.println("File caricato: " + fileName);
}
catch(Throwable e)
{
System.out.println(e.toString());
}
finally
{
// Fine della sessione
AuthenticationUtils.endSession();
}
}
Archive content from product discussions in Italian.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.