cancel
Showing results for 
Search instead for 
Did you mean: 

Getting an error while deleting a version of a document

sepgs2004
Star Contributor
Star Contributor
Environment details:
Alfresco 5.0.d Community (free) Edition - No configuration changes done after installation
API: OpenCMIS - CMIS 1.1
URL used to connect: http://dev-alfresco:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom
Libraries:

<dependency>
  <groupId>org.apache.chemistry.opencmis</groupId>
  <artifactId>chemistry-opencmis-client-api</artifactId>
  <version>0.13.0</version>
</dependency>
<dependency>
  <groupId>org.apache.chemistry.opencmis</groupId>
  <artifactId>chemistry-opencmis-client-impl</artifactId>
  <version>0.13.0</version>
</dependency>



The Error Message is
Unexpected: current version does not appear to be 1st version in the list 


Stack trace

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: Unexpected: current version does not appear to be 1st version in the list
[workspace://version2Store/dfcb5494-1267-4131-b015-279644ad3938, versionStore://version2Store/61e2a602-0ecf-49c6-8241-cb4c42efb854]
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:506)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.delete(AbstractAtomPubService.java:701)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.deleteObject(ObjectServiceImpl.java:461)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.delete(SessionImpl.java:1353)
at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.delete(AbstractCmisObject.java:331)


Code:

try {
   Document cmisDocument = (Document) cmisSession.getObject(document.getObjectId());
   if (cmisDocument != null) {
      versionLabel = cmisDocument.getVersionLabel();
      boolean deleted = false;
      List<Document> versions = cmisDocument.getAllVersions();
      for(int j=0; j<versions.size() && !deleted; j++) {
         Document version = versions.get(j);
         if (versionLabel.equals(version.getVersionLabel())) {
            version.delete(false);
            deleted = true;
         }
      }
   }
}
catch (Exception exc) {
   message = "Error while deleting the document - " + exc.getMessage();
   exc.printStackTrace();
}


Earlier I tried just like cmisDocument.delete(false), that did not work, even though the objectId of the object matches the objectId of the version I was trying to delete.
Then I thought may be we have to explicitly hold on to the version document. That is why I came up with this code. Still getting the same error.

Another note:
In the repository, I have three versions of the same document. Error happened when I am trying to delete the oldest, that is the first one.
For some reason, deleting from the latest to oldest, seems not getting this error.
Is there any restriction on deleting the versions of a document?
Gnanasekaran Sakthivel
1 REPLY 1

sepgs2004
Star Contributor
Star Contributor
Either it has to do with the way I code to do delete a version of a document
Or it has to do with some (CmisSession) caching issues that I am not aware of
Or it may be that the 5.0.d community free edition does not have certain features
Or …

I am just putting this behind for now until I am assigned some time to debug this.


Gnanasekaran Sakthivel