[ https://issues.apache.org/jira/browse/CMIS-1117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrea Ligios updated CMIS-1117: -------------------------------- Description: I've met CMIS a couple of days ago, please forgive me in case the question is naive. I have a test case that is trying to create a document by passing the `cmis:folder` `ObjectTypeId` (instead of `cmis:document`), and expects the test to fail. * With *Browser binding*, {color:#00875a}it fails with a CmisConstraintException{color} * With *WebService binding*, {color:#00875a}it fails with a CmisConstraintException{color} * With *AtomPub binding*,{color:#de350b} it creates a Folder, and then fails later with a CmisRuntimeException{color} While debugging the code, I've seen that *Browser binding* (along with *WebService binding*) has a `createDocument()` method in its [ObjectService implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java#L88-L137]: !image-2021-05-18-00-03-11-323.png|width=984,height=914! The *AtomPub Binding*, instead, has a `create()` method in its [ObjectService implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java#L79-L158]: !image-2021-05-18-00-06-14-967.png|width=984,height=1609! While the `createDocument()` method can check if the `ObjectTypeId` passed is the proper one (`cmis:document`), and raise an error if an unexpected `ObjectTypeId` is passed, the `create()` method is agnostic about the object to create, and performs a Switch on the `ObjectTypeId` to detect the proper action to call. Hence, calling `createDocument()` with *AtomPub binding* and `cmis:folder` `ObjectTypeId` will result in calling the `create()` method, and then in the switch reading `cmis:folder` and calling the underlying `createFolder()` method, instead of the underlying `createDocument()` one. The folder will be created, then somewhere up in the chain[*] the error will be detected and will trigger a CmisRuntimeException, but that implies that, for the same test case, two different results should be expected according to the binding used. Could you please confirm me this is intended, and maybe shed some light on why the *AtomPub binding* is working with a different set of methods than the other bindings? [*]The fact that the object constructed in the `createDocument()` method is actually a document is checked in the [FolderImpl class|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java#L83-L103] makes me think this is the fallback for this problem, but I'd like some confirmation here: !image-2021-05-18-00-20-40-800.png|width=985,height=472! Thank you in advance was: I've met CMIS a couple of days ago, please forgive me in case the question is naive. I have a test case that is trying to create a document by passing the `cmis:folder` `ObjectTypeId` (instead of `cmis:document`), and expects the test to fail. * With *Browser binding*, {color:#00875a}it fails with a CmisConstraintException{color} * With *WebService binding*, {color:#00875a}it fails with a CmisConstraintException{color} * With *AtomPub binding*,{color:#de350b} it creates a Folder, and then fails later with a CmisRuntimeException{color} While debugging the code, I've seen that *Browser binding* (along with *WebService binding*) has a `createDocument()` method in its [ObjectService implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java#L88-L137]: !image-2021-05-18-00-03-11-323.png|width=984,height=914! The *AtomPub Binding*, instead, has a `create()` method in its [ObjectService implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java#L79-L158]: !image-2021-05-18-00-06-14-967.png! While the `createDocument()` method can check if the `ObjectTypeId` passed is the proper one (`cmis:document`), and raise an error if an unexpected `ObjectTypeId` is passed, the `create()` method is agnostic about the object to create, and performs a Switch on the `ObjectTypeId` to detect the proper action to call. Hence, calling `createDocument()` with *AtomPub binding* and `cmis:folder` `ObjectTypeId` will result in calling the `create()` method, and then in the switch reading `cmis:folder` and calling the underlying `createFolder()` method, instead of the underlying `createDocument()` one. The folder will be created, then somewhere up in the chain[*] the error will be detected and will trigger a CmisRuntimeException, but that implies that, for the same test case, two different results should be expected according to the binding used. Could you please confirm me this is intended, and maybe shed some light on why the *AtomPub binding* is working with a different set of methods than the other bindings? [*]The fact that the object constructed in the `createDocument()` method is actually a document is checked in the [FolderImpl class|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java#L83-L103] makes me think this is the fallback for this problem, but I'd like some confirmation here: !image-2021-05-18-00-20-40-800.png! Thank you in advance > Using AtomPub binding I can create Folders calling createDocument > ----------------------------------------------------------------- > > Key: CMIS-1117 > URL: https://issues.apache.org/jira/browse/CMIS-1117 > Project: Chemistry > Issue Type: Test > Components: opencmis-server > Affects Versions: OpenCMIS 1.1.0 > Reporter: Andrea Ligios > Priority: Minor > Attachments: image-2021-05-18-00-03-11-323.png, > image-2021-05-18-00-06-14-967.png, image-2021-05-18-00-20-40-800.png > > > I've met CMIS a couple of days ago, please forgive me in case the question is > naive. > I have a test case that is trying to create a document by passing the > `cmis:folder` `ObjectTypeId` (instead of `cmis:document`), and expects the > test to fail. > * With *Browser binding*, {color:#00875a}it fails with a > CmisConstraintException{color} > * With *WebService binding*, {color:#00875a}it fails with a > CmisConstraintException{color} > * With *AtomPub binding*,{color:#de350b} it creates a Folder, and then fails > later with a CmisRuntimeException{color} > While debugging the code, I've seen that *Browser binding* (along with > *WebService binding*) has a `createDocument()` method in its [ObjectService > implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java#L88-L137]: > !image-2021-05-18-00-03-11-323.png|width=984,height=914! > The *AtomPub Binding*, instead, has a `create()` method in its [ObjectService > implementation|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java#L79-L158]: > !image-2021-05-18-00-06-14-967.png|width=984,height=1609! > While the `createDocument()` method can check if the `ObjectTypeId` passed is > the proper one (`cmis:document`), and raise an error if an unexpected > `ObjectTypeId` is passed, the `create()` method is agnostic about the object > to create, and performs a Switch on the `ObjectTypeId` to detect the proper > action to call. > Hence, calling `createDocument()` with *AtomPub binding* and `cmis:folder` > `ObjectTypeId` will result in calling the `create()` method, and then in the > switch reading `cmis:folder` and calling the underlying `createFolder()` > method, instead of the underlying `createDocument()` one. > The folder will be created, then somewhere up in the chain[*] the error will > be detected and will trigger a CmisRuntimeException, but that implies that, > for the same test case, two different results should be expected according to > the binding used. > Could you please confirm me this is intended, and maybe shed some light on > why the *AtomPub binding* is working with a different set of methods than the > other bindings? > [*]The fact that the object constructed in the `createDocument()` method is > actually a document is checked in the [FolderImpl > class|https://github.com/apache/chemistry-opencmis/blob/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/FolderImpl.java#L83-L103] > makes me think this is the fallback for this problem, but I'd like some > confirmation here: > !image-2021-05-18-00-20-40-800.png|width=985,height=472! > Thank you in advance -- This message was sent by Atlassian Jira (v8.3.4#803005)