Quantcast
Channel: Alfresco Forums - Alfresco API
Viewing all articles
Browse latest Browse all 252

Getting an error while deleting a version of a document

$
0
0

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?

5.0.d

Viewing all articles
Browse latest Browse all 252

Trending Articles