AnsweredAssumed Answered

Problem while reading document content

Question asked by pavan_kumar on Aug 11, 2006
Latest reply on Aug 16, 2006 by pavan_kumar
Hi All,

Version details : Alfresco 1.3 / Tomcat 5.5.12 / JDK 1.5
environment (an Alfresco bundle - downloaded from alfresco site)

We have 2 spaces in the repository
  - test01
  - test02

There is a simple workflow setup such that content will be move from test01 to test02.
There is rule setup on space test02, whenever a new file/content arrives in test02,
it will trigger an action which calls an external java application and passes the
node-uuid of the document to it.

The application will query back the repository using the uuid reference
via WebServices API and gets the file from repository and saves it to the local file system.

Here the problem is that whenever the application queries and get the file
it always ended up with NULL value. But if i try with node reference
of a document which is there on the repository some time before, then
i am able to get the file and other meta data associated with it.

It is failing every other case like if the application queries the repository
using the uuid sent by the action set on space test02.

I expect that the problem is due to immediate querying of the alfresco
where it is not yet done with storing the file completely in the repository.

Can anybody give me some idea of how to handle this.

Following is the code snap i used and the *ed is the line where it throws me the NULL value.

AuthenticationUtils.startSession(user, pwd);
   Store store = new Store(StoreEnum.workspace, "SpacesStore");
   Reference reference = new Reference(store,uuid,null);
   Predicate predicate = new Predicate(new Reference[]{reference}, store, null);
  RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
//At this line it is not able to get the nodes.
  ***   Node[] nodes = repositoryService.get(predicate);
  ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
  Content[] readResult = contentService.read(predicate,Constants.PROP_CONTENT);
  fileName = Calendar.getInstance().getTime().toString()+".out";
  File filePath  = new File(dirName,fileName);
                            ContentUtils.copyContentToFile(readResult[0],finalFilePath);
AuthenticationUtils.endSession();


Thanks,
Pavan Ramadugula

Outcomes