cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] Content web service and Lucene

vsuarez
Champ in-the-making
Champ in-the-making
Hello.

I previously post this message in the "Repository Services" forum, but this could be a better place.

I'm working with Alfresco web services, and almost everything is working well. But I have a problem with the content web service, specially with de uploaded content: lucene is not indexing such content.

If I upload a document with the web client, I can search into its contents with the web client search tool, and with the methods of the repository web service too. But if I use the content web service ("write" method), I can not search into the uploaded contents in this way, either with web client nor with repository web service methods.

I think the indexing lack is due to the creation method: you first create a empty content with the repository web service "update" method (CML create) and then you upload the content with the content web service "write" method. I guess Lucene is not being triggered in the content upload.

Is this a Alfresco-bug? Is this a programmer-bug?
3 REPLIES 3

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

All content uploaded ultimately goes through the fundamental content service API which triggers the indexing of content.

Content uploaded via any route should be successfully indexed.

Could you provide a snipit of the web service code you are using to upload content.

Cheers,
Roy

vsuarez
Champ in-the-making
Champ in-the-making
Ok, let's go (I am not using the Axis client, I am using a JAX-WS client):


//First, I create the container
CML cml = new CML();
CML.Create create = new CML.Create();
create.setId("create_1");

List<NamedValue> propertyList = new ArrayList<NamedValue>();

//CM_NAME={http://www.alfresco.org/model/content/1.0}name
NamedValue nv = createNamedValue(CM_NAME, name);
propertyList.add(nv);

//CM_DESCRIPTION={http://www.alfresco.org/model/content/1.0}description
NamedValue nvd = createNamedValue(CM_DESCRIPTION, description);
propertyList.add(nvd);

//CM_TITLE={http://www.alfresco.org/model/content/1.0}title
NamedValue nvt = createNamedValue(CM_TITLE, title);
propertyList.add(nvt);

create.getProperty().addAll(propertyList);

Store store = createDefaultStore();

//creates a ParentReference
ParentReference parentReference =
      createParent(store, path, parentPath);

//JAX-WS annoying JAXBElement with nillable SOAP elements. This is the same in Axis client
//that create.setParent(parentReference);
create.setParent(
      new JAXBElement<ParentReference>(
         QName.valueOf(CML_PARENT),
         ParentReference.class,
         parentReference));

create.setType(type);

cml.getCreate().add(create);


List<UpdateResult> r = null;
try {
   r = repoPort.update(cml);
} catch (RepositoryFault_Exception e) {
   throw new RuntimeException(
         e.getFaultInfo().getErrorCode() + ", " +
         e.getFaultInfo().getMessage(), e);
}
//at this point, we can see the content in the web client, buy empty

//Now, I fill the containter with data (a curious Spanish "palíndromo")
byte[] data = "Dábale arroz a la zorra el abad".getBytes("utf-8");

//creates a Reference (in this case, with a valid path, id is ignored)
Reference reference = createReference(store, path, id);

ContentFormat format = new ContentFormat();
format.setMimetype("text/plain");
format.setEncoding("utf-8");

try {
//CM_CONTENT={http://www.alfresco.org/model/content/1.0}content
   contentPort.write(reference, CM_CONTENT, data, format);
} catch (ContentFault_Exception e) {
   throw new RuntimeException(
         e.getFaultInfo().getErrorCode() + ", " +
         e.getFaultInfo().getMessage(), e);
}
//at this point, we have uploaded the content, and we can access to it by the web client.


I cannot find the document with the search engine, but if I put the same text in other document by the web client interface, the search engine is able to find this document.

NOTE: I've found that there is a little difference between the way Alfresco web client manages the opening of the two document types:
  • SOAP uploaded document: force the download of the document.

  • Web client created document: open the document in another browser window/tab
Regards
Victor

vsuarez
Champ in-the-making
Champ in-the-making
Is this a Alfresco-bug? Is this a programmer-bug?

Programmer bug   Smiley Surprisedops:

I was using "plain/txt" as MIME type. The correct MIME type is "text/plain".

Now indexing is working.

Thank you.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.