AnsweredAssumed Answered

How to retrieve the version content?

Question asked by raymond on Jun 22, 2006
Hi there,

How do I retrieve the version content with the versionNodeId returned from a call to the checkin() of the authoring service?

I tried with the following steps,
1) search for the VersionHistory instance that has the provided versionNodeId
2) search for the Version instances that are children of the above VersionHistory instance
3) locate the appropriate version instance
4) call the to get a Content object with the version reference returned in step 3.

However there was an "Access denied" exception occured in step 4 and in step 4 only. Does the approach outlined above make any sense at all?

Following is the code snippet that implements the scenario.

Any help would be much appreciated.

Thanks in advance


    // create a query object, looking for the version history node
    String searchString = "@ver\\:versionedNodeId:\"" + versionNodeId + "\"";   
    Query query = new Query(QueryLanguageEnum.lucene, searchString);

    // execute the query
    QueryResult queryResult = null;

    // execute the query
    queryResult = repositoryService.query(STORE_VERSIONS, query, true);

    // check the query result
    ResultSet resultSet = queryResult.getResultSet();
    ResultSetRow[] rows = resultSet.getRows();
    String versionHistoryUuid = rows[0].getNode().getId();
    // Create a query object, looking for all the version items
    searchString = "+PARENT:\"workspace://lightWeightVersionStore/" + versionHistoryUuid +"\"";
    query = new Query(QueryLanguageEnum.lucene, searchString);
    queryResult = repositoryService.query(STORE_VERSIONS, query, true);
    // check the query result
    resultSet = queryResult.getResultSet();
    rows = resultSet.getRows();
    if (rows == null || rows.length != 2) {
      throw new SystemException();

    String versionUuid = rows[0].getNode().getId();
    Reference versionReference = new Reference(STORE_VERSIONS, versionUuid, null);

    Predicate predicate = new Predicate(new Reference[] {
    }, STORE_VERSIONS, null);
    Content[] contentResult = null;

    // get the content
    contentResult =, Constants.PROP_CONTENT);