cancel
Showing results for 
Search instead for 
Did you mean: 

Not getting CmisContentAlreadyExistsException

praveen33in
Champ in-the-making
Champ in-the-making
Hi,

I am using AtomPub URI to load documents to Alfresco. The code is working good, however when trying to load same document again I am getting "CmisConstraintException" instead of "CmisContentAlreadyExistsException". All the examples online are using "CmisContentAlreadyExistsException" and it would be great if i get the same so that I can take the count of documents already available. Kindly let me know what needs to be done to get "CmisContentAlreadyExistsException". My code is given below. Thanks in advance.


                  try {
         contentStream = session.getObjectFactory().
                 createContentStream(
                  sFileName,
                   file.length(),
                   sfileType,
                   new FileInputStream(file)
                 );

         Folder folder = (Folder) session.getObjectByPath(sTargetSpaceName);
         //document = folder.createDocument(props, contentStream, null);
         document = folder.createDocument(props, contentStream, null);
         //System.out.println("Created new document in Alfresco for: " + sFileName + ": " + document.getId());
         System.out.println("Created new document in Alfresco for: " + sFileName);
      } catch (CmisContentAlreadyExistsException ccaee) {       
         System.out.println("ERROR: Unable to Load - CmisContentAlreadyExistsException: " + sFileName);
      } catch (CmisConstraintException cce) {
         System.out.println("ERROR: Unable to Load - CmisConstraintException: " + sFileName);
      }

1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
CMIS check duplicate according to PropertyIds.NAME property.If you create two document with same PropertyIds.NAME value ,it will do throw CmisContentAlreadyExistsException.
Now you get CmisConstraintException ,it means your operation violate some repository constraint .for example
type not exist,property name not exist,vlue is out of range and so on
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.