AnsweredAssumed Answered

Ricerca full-text su documenti creati con web-service

Question asked by phil on Sep 7, 2011
Latest reply on Oct 7, 2011 by openpj
Se carico un file pdf o open-office tramite l'interfaccia di Alfresco Explorer ed effettuo una ricerca di una determinata parola, riesco a trovare i documenti in cui sono presenti le parole ricercate.
Se invece carico un file attraverso web-service utililizzando il codice qui sotto riportato la ricerca con Alfresco Explorer non funziona.
Suggerimenti?

    1000 Grazie

               Phil

*************************************************************

         String alfrescoWsUrl = "http://localhost:8080/alfresco/api";
         WebServiceFactory.setEndpointAddress(alfrescoWsUrl);
         AuthenticationUtils.startSession("admin", "alfresco");

         String path = "c:/filealfresco.pdf";
         String fileName = "filealfresco.pdf";
         Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
         String destinationPath = "/app:company_home/cm:" + ISO9075.encode("spazio1") + "/cm:" + ISO9075.encode("spazio2");
         ParentReference companyHomeParent = new ParentReference(storeRef, null, destinationPath, Constants.ASSOC_CONTAINS, null);

         RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
         ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
         NamedValue[] contentProps = new NamedValue[1];
         NamedValue[] titledProps = new NamedValue[2];

         companyHomeParent.setChildName("{http://www.alfresco.org/model/content/1.0}" + fileName);

         contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, fileName);
         titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, "titolo");
         titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, "descrizione");
         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);
         CML cml = new CML();
         cml.setCreate(new CMLCreate[]
         { create });
         cml.setAddAspect(new CMLAddAspect[]
         { addAspect });
         UpdateResult[] result = repositoryService.update(cml);
         Reference content = result[0].getDestination();

         String ref = result[0].getDestination().getUuid();

         Reference reference = new Reference(storeRef, ref, null);

         Predicate sourcePredicate = new Predicate(new Reference[]
         { reference }, storeRef, null);

         CMLAddAspect aspect = new CMLAddAspect();
         aspect.setAspect(Constants.ASPECT_VERSIONABLE);
         aspect.setWhere(sourcePredicate);
         CMLUpdate update = new CMLUpdate();
         update.setWhere(sourcePredicate);
         CML cmlUpdate = new CML();
         cmlUpdate.setAddAspect(new CMLAddAspect[]
         { aspect });
         cmlUpdate.setUpdate(new CMLUpdate[]
         { update });
         WebServiceFactory.getRepositoryService().update(cmlUpdate);

         FileInputStream is = new FileInputStream(path);
         byte[] bytes = ContentUtils.convertToByteArray(is);

         ContentFormat format = new ContentFormat("application/pdf", "UTF-8");
         contentService.write(content, Constants.PROP_CONTENT, bytes, format);

         AuthenticationUtils.endSession();
      } catch (Exception e) //
      {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         e.printStackTrace(pw);
      }

Outcomes