public void search(docEv document, String path) {
try {
WebServiceFactory.setEndpointAddress("http://...:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "admin");
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
.getRepositoryService("http://...:8080/alfresco/api");
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"" +path + "AND TYPE:\"@ev\\:IDdoc:" + document.getIDdoc());
QueryResult queryResult = repositoryService.query(storeRef, query, false);
// Display the results
ResultSet results = queryResult.getResultSet();
ResultSetRow[] rows = results.getRows();
System.out.println("La busqueda da algo asi:");
if(rows != null){
for(ResultSetRow row : rows){
for (NamedValue namedValue : row.getColumns()){
if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true)
System.out.println(namedValue.getValue());
if (namedValue.getName().endsWith(Constants.PROP_NAME) == true)
System.out.println(namedValue.getValue());
else if (namedValue.getName().endsWith(document.getDescripcio())== true)
System.out.println(namedValue.getValue());
}
}
}
}catch (Exception e) {
e.printStackTrace();
} finally {
// tanca sessió
System.out.println("Desconectant…");
AuthenticationUtils.endSession();
}
}
"PATH:\"" +path + "\" AND TYPE:\"@ev\\:IDdoc:" + document.getIDdoc()+"\""
Te faltaban los \" al final de PATH y TYPE. En cuanto al tipo que indicas no sabria decirte si es correcto, ya que entiendo devuelves el id de cada documento y si este varía deberías tener un tipo de contenido por cada id de documento ¿?.
iniciant sessio…
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
{http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>org.alfresco.repo.search.SearcherException: Invalid type: @ev:IDdoc:1445</ns1:message>
{http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault
{http://xml.apache.org/axis/}stackTrace:
at org.alfresco.repo.webservice.repository.RepositoryWebService.executeQuery(RepositoryWebService.java:176)
at org.alfresco.repo.webservice.repository.RepositoryWebService.query(RepositoryWebService.java:195)
at sun.reflect.GeneratedMethodAccessor659.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
{http://xml.apache.org/axis/}hostname:gd-alfresco-everis-vm
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
at org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.query(RepositoryServiceSoapBindingStub.java:753)
at com.ev.ad10.data.documents.dao.DocumentDAOAlfrescoImpl.search(DocumentDAOAlfrescoImpl.java:208)
at com.ev.ad10.data.documents.dao.testDocumentDaoAlfrescoImpl.main(testDocumentDaoAlfrescoImpl.java:39)
Desconectant…
Invalid type: @ev:IDdoc:1445Dudo mucho que tengas un "modelo de contenido" por cada id de documento.
"PATH:\"" +path + "\" AND @ev\\:IDdoc:" + document.getIDdoc()
( @ev\\:IDdoc: es una propiedad .. no un tipo)
public void create(docEv document, String path) {
try {
// definició de la api d'alfresco
// @IP de la maquina virtual
//WebServiceFactory.setEndpointAddress("http://...:8080/alfresco/api");
//AuthenticationUtils.startSession("admin", "admin");
// Creamos la referencia del nodo padre, donde se añadirá el
// contenido
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
ParentReference docParent = new ParentReference(storeRef, null,path, Constants.ASSOC_CONTAINS,
Constants.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,document.getTitol()));
// propietats del document
NamedValue titolValue = Utils.createNamedValue(Constants.PROP_NAME,document.getTitol());
NamedValue descripcioDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.DESCRIPCIO), document.getDescripcio());
NamedValue IDdocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.IDDOC), document.getIDdoc());
NamedValue estatDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.ESTAT), document.getEstat());
NamedValue vesrioDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.VERSIO), document.getVersio());
NamedValue dataCrDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.DATACR), ISO8601DateFormatter.format(document.getDataCr()));
NamedValue dataModDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.DATAMOD), ISO8601DateFormatter.format(document.getDataMod()));
NamedValue iniciVigDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.INICIVIG), ISO8601DateFormatter.format(document.getIniciVig()));
NamedValue fiVigDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.FIVIG), ISO8601DateFormatter.format(document.getFiVig()));
NamedValue tipusAccesDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.TIPUSACCES), document.getTipusAcces());
NamedValue objectesRelacionatsDocValue = Utils.createNamedValue(
Constants.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.OBJECTESRELACIONATS), document.getObjectesRelacionats());
NamedValue IDSignaturaDocValue = Utils.createNamedValue(Constants
.createQNameString(docEvModel.NAMESPACE_CONTENT_MODEL,
docEvModel.IDSIGNATURA), document.getIDSignatura());
// guardar propietats a l'array
NamedValue[] contentProps = new NamedValue[] { titolValue,
descripcioDocValue, IDdocValue, estatDocValue,
vesrioDocValue, dataCrDocValue, dataModDocValue,
iniciVigDocValue, fiVigDocValue, tipusAccesDocValue,
objectesRelacionatsDocValue, IDSignaturaDocValue };
// Contruimos CML Block, con el nodo y sus aspectos
CMLCreate create = new CMLCreate("1", docParent, null, null, null,Constants.TYPE_CONTENT, contentProps);
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED,contentProps, null, "1");
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
// Creamos y recuperamos el contenido vía Repository Web Service
UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
Reference content = results[0].getDestination();
dumpUpdateResults(results);
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
ContentFormat contentFormat = new ContentFormat("text/plain","UTF-8");
String text = "Este es el fichero de prueba de alfresco";
contentService.write(content, Constants.PROP_CONTENT, text.getBytes(), contentFormat);
} catch (Exception e) {
e.printStackTrace();
} finally {
// tanca sessió
System.out.println("Desconectant…");
AuthenticationUtils.endSession();
}
}
public void delete() {
}
/**
* Métode per donar de baixa un document al gestor documental
*/
public void delete(docEv document, String path){
try {
//WebServiceFactory.setEndpointAddress("http://...:8080/alfresco/api");
//AuthenticationUtils.startSession("admin", "admin");
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
.getRepositoryService("http://...:8080/alfresco/api");
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"" +path + "AND TYPE:\"@ev\\:IDdoc:" + document.getIDdoc());
// Execute the query
QueryResult queryResult = repositoryService.query(storeRef, query, false);
// Get the resultset
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
// if we found some rows, create an array of DeleteCML objects
if (rows != null) {
System.out.println("Found " + rows.length + " objects to delete.");
CMLDelete[] deleteCMLArray = new CMLDelete[rows.length];
for (int index = 0; index < rows.length; index++) {
ResultSetRow row = rows[index];
deleteCMLArray[index] = new CMLDelete(new Predicate(new Reference[] { new Reference(storeRef, row.getNode().getId(), null) }, null, null));
}
// Construct CML Block
CML cml = new CML();
cml.setDelete(deleteCMLArray);
// Execute CML Block
UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cml);
dumpUpdateResults(results);
}// end if
} catch (Exception e) {
e.printStackTrace();
} finally {
// tanca sessió
System.out.println("Desconectant…");
AuthenticationUtils.endSession();
}
}
public void search(docEv document, String path) {
try {
WebServiceFactory.setEndpointAddress("http://...:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "admin");
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
.getRepositoryService("http://...:8080/alfresco/api");
Query query = new Query(Constants.QUERY_LANG_LUCENE, "PATH:\"" +path + "\" AND @ev\\:IDdoc:" + document.getIDdoc());
QueryResult queryResult = repositoryService.query(storeRef, query, false);
// Display the results
ResultSet results = queryResult.getResultSet();
ResultSetRow[] rows = results.getRows();
boolean existedocumento = false;
System.out.println("La busqueda da algo asi:");
if(rows != null){
existedocumento=true;
System.out.println("EXISTE");
for(ResultSetRow row : rows){
for (NamedValue namedValue : row.getColumns()){
if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true)
System.out.println(namedValue.getValue());
if (namedValue.getName().endsWith(Constants.PROP_NAME) == true)
System.out.println(namedValue.getValue());
else if (namedValue.getName().endsWith(document.getDescripcio())== true)
System.out.println(namedValue.getValue());
}
}
}
else
{
existedocumento=false;
System.out.println("NO EXISTE");
}
}catch (Exception e) {
e.printStackTrace();
} finally {
// tanca sessió
System.out.println("Desconectant…");
AuthenticationUtils.endSession();
}
}
private void dumpUpdateResults(UpdateResult[] result) {
for (UpdateResult updateResult : result) {
String sourceId = "none";
Reference source = updateResult.getSource();
if (source != null) {
sourceId = source.getUuid();
}
String destinationId = "none";
Reference destination = updateResult.getDestination();
if (destination != null) {
destinationId = destination.getUuid();
}
System.out.println("Command=" + updateResult.getStatement()
+ ";Source=" + sourceId + ";Destination=" + destinationId);
}
}
Content from pre 2016 and from language groups that have been closed.
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.