tsgrp / OpenContent

TSG's Web Services for ECM Repositories
8 stars 4 forks source link

AlfrescoEmbContentImpl.updateObject - major flaw in updating of properties #24

Closed cmlewis closed 10 years ago

cmlewis commented 10 years ago

The ViewEditPropertiesExecuter (what View Properties action in HPI uses) calls the newish AlfrescoEmbContentImpl.updateObject. This method is currently grabbing the properties from the OCO (just the props that were edited by HPI) and then looping over a constant called AlfrescoEmbUtil.internalAlfrescoProperties to add system properties to the map. Then it updates the node with only those properties using nodeService.setProperties().

nodeService.setProperties takes the map you give it and removes ALL existing properties on the node and replaces it with your map. The current logic is flawed because it removes any properties that weren't passed in by HPI and don't exist in the constant. Current example is the hpi:rendition/tsg:rendition getting removed when updating properties on the doc in HPI.

The props should instead be updated like so:

cmlewis commented 10 years ago

Committed in rev 8854:

UPDATE CONTENT: Alfresco bug when updating object properties - nodeService.setProperties(NodeRef, Map) takes the map you pass in and COMPELTELY replaces any existing props on the map. So even though we weren't updating all properties all the time, properties were getting removed from the node unexpectedly. The proper way to do this is to get all the props currently on the node in a map, then update that map with your changed props. A second solution as seen in enhancedUpdateObject might be to use nodeService.addProperties.

CRed by Dan. Closes https://github.com/tsgrp/OpenContent/issues/24

cmlewis commented 10 years ago

@mkolas See fix, may need to deploy for your client.