<!–Classe fattura–>
<type name="fe:fattura">
<title>Fattura</title>
<parent>fe:documento</parent>
<properties>
<property name="fe:numeroFattura">
<title>Numero fattura</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fe:annoFattura">
<title>Anno fattura</title>
<type>d:int</type>
<mandatory>true</mandatory>
</property>
<property name="fe:nazioneFattura">
<title>Nazione</title>
<type>d:int</type>
<mandatory>true</mandatory>
</property>
<property name="fe:registroIvaFattura">
<title>Registro IVA</title>
<type>d:int</type>
<mandatory>true</mandatory>
</property>
<property name="fe:cliforPfxFattura">
<title>Cliente/Fornitore Fattura</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fe:cliforCodFattura">
<title>Codice cliente/fornitore fattura</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="fe:cliforRgsFattura">
<title>Descrizione cliente/fornitore fattura</title>
<type>d:text</type>
<mandatory>true</mandatory>
</property>
</properties>
<mandatory-aspects>
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
<aspects>
<aspect name="cm:versionable">
<title>Versionable</title>
<properties>
<property name="cm:versionLabel">
<title>Version Label</title>
<type>d:text</type>
<protected>true</protected>
</property>
<property name="cm:initialVersion">
<title>Initial Version</title>
<type>d:boolean</type>
<default>false</default>
</property>
<property name="cm:autoVersion">
<title>Auto Version</title>
<type>d:boolean</type>
<default>true</default>
</property>
<property name="cm:autoVersionOnUpdateProps">
<title>Auto Version - on update properties only</title>
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
</aspect>
</aspects>
public boolean uploadFile(File fileUpload,File fileXML) throws Exception
{
String metaDati[][];
try
{
// Avvio sessione
AuthenticationUtils.startSession(user, password);
// 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:" + fileUpload.getName());
//metaDati2(percorsoFile);
String valori[][]=metaDati(fileXML.getPath());
//Vettori delle proprietà
NamedValue[] customProps = new NamedValue[numeroProprieta(valori)];
NamedValue[] standardProps = new NamedValue[3];
//Assegnazione ai vettori delle proprietà
int i=0;
while(i<=customProps.length - 1)
{
customProps = Utils.createNamedValue(Constants.createQNameString("http://www.feniceevo.it/model/content/1.0',valori[0]),valori[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, fileUpload.getName());
standardProps[1] = Utils.createNamedValue(Constants.PROP_NAME, fileUpload.getName());
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();
//Scrittura del contenuto
ContentFormat contentFormat = new ContentFormat(this.mimeType(fileUpload.getName()), "UTF-8");
Content contentRef = contentService.write(content, Constants.PROP_CONTENT, this.readFromFile(new File(fileUpload.getPath())), contentFormat);
System.out.println("File caricato: " + fileUpload.getName());
System.out.println();
JOptionPane.showMessageDialog(null,"File " + fileUpload.getName() + " caricato con successo.","Operazione eseguita.",JOptionPane.INFORMATION_MESSAGE);
return true;
}
catch(Throwable e)
{
JOptionPane.showMessageDialog(null,"Attenzione, file non caricato o sistema non raggiungibile.","Errore",JOptionPane.ERROR_MESSAGE);
System.out.println(e.toString());
return false;
}
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.