01-20-2017 01:08 AM
Hi Experts!
My env:
- Java 8,
- Alfresco CE 5.1.x and 5.2.x.
- CMIS 1.1
My folder type definition in my-repo.AMP:
<type name="asisapcsf:aft_contract">
<title>SapSC Contract Folder</title>
<parent>asisapcsf:aft_year</parent>
<properties>
<property name="asisapcsf:dss_contract_number">
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="asisapcs:stringLength50"/>
</constraints>
</property>
<property name="asisapcsf:dss_balance_object">
<type>d:text</type>
<mandatory>true</mandatory>
<default>EM</default>
<constraints>
<constraint ref="asisapcs:adc_balance_objects_list"/>
</constraints>
</property>
<property name="asisapcsf:dss_department">
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="asisapcs:stringLength50"/>
</constraints>
</property>
</properties>
</type>
Also, this folder's type have a behaviour on "onCreate" event
If I create from JUnit tests in My-repo projects - the all right, all worked!
If I create from JUnit tests in My-repo projects with turn OFF my behaviour - the all right, all worked!
If I create from JUnit tests in My-cmis projects on full "charged" my custom Folder, with turn ON behaviour - I view (in folder's behavior class log out), that new Folder objects created without my custom attributes 8(((
My behavior's init code:
public AftContract() {
LOGGER.info("new Instance created. v{}, [{}]", VERSION, this);
}
/**
* realisation the behaviour's init()
*/
public void init() {
LOGGER.debug("Start");
// Create behaviours
this.onCreateNode = new JavaBehaviour(this, "onCreateNode", Behaviour.NotificationFrequency.FIRST_EVENT);
// Bind behaviours to node policies
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
I10nSapCSModelFolders.TYPE_CONTRACT,
this.onCreateNode
);
// namespacePrefixResolver
this.namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
namespacePrefixResolver.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI);
namespacePrefixResolver.registerNamespace(NamespaceService.APP_MODEL_PREFIX, NamespaceService.APP_MODEL_1_0_URI);
namespacePrefixResolver.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
namespacePrefixResolver.registerNamespace(I10nSapCSModelFolders.CONTENT_MODEL_PREFIX, I10nSapCSModelFolders.CONTENT_MODEL_URI);
LOGGER.debug("Finish");
}
My code in CMIS 1.1 client:
String folderName = "Test CMIS folder-5";
String folderTitle = "Test CMIS title";
String folderDescritpion = "Test CMIS description";
// Create a Map of objects with the props we want to set
Map<String, Object> properties = new HashMap<String, Object>();
List<String> aspects = new ArrayList<>();
aspects.add("P:cm:titled");
properties.put(PropertyIds.NAME, folderName);
properties.put(PropertyIds.OBJECT_TYPE_ID, "F:asisapcsf:aft_contract");
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects);
// fill cm:titled Aspect's attrs
properties.put("cm:title", folderTitle);
properties.put("cm:description", folderDescritpion);
// fill my Custom attrs
properties.put("asisapcsf:dss_contract_number", "00035");
properties.put("asisapcsf:dsi_contract_year", 2014);
properties.put("asisapcsf:dss_department", "11-06");
// create Folder
Folder newFolder = folder.createFolder(properties);
//Document doc = folder. createDocument(properties, contentStream, VersioningState.MAJOR);
assertNotNull("CMIS: Problem create new Folder: ", newFolder);
LOGGER.info("Succ create new Folder: [{}]: [{}]", newFolder.getPath(), newFolder);
Log output (from onCreateNode AFT_CONTRACT behavior):
2017-01-20 11:58:36,197 [http-apr-8080-exec-7] TRACE AftContract.onCreateNode - dump aftContractNode:
[node: workspace://SpacesStore/c11125c1-2be9-4586-a0af-616dafc7b054
node StoreRef: workspace://SpacesStore
node Path: /{http://www.alfresco.org/model/application/1.0}company_home/{http://www.alfresco.org/model/site/1.0}sites/{http://www.alfresco.org/model/content/1.0}emgsap/{http://www.alfresco.org/model/content/1.0}documentLibrary/{http://www.alfresco.org/model/content/1.0}Test_x0020_CMIS_x0020_folder-5
node Type: {http://folders.cs.sap.i10n.alf.asoft.kz/model/content/17.1.6}aft_contract
{http://www.alfresco.org/model/content/1.0}created: Fri Jan 20 11:58:36 ALMT 2017
{http://folders.cs.sap.i10n.alf.asoft.kz/model/content/17.1.6}dss_balance_object: EM
{http://www.alfresco.org/model/content/1.0}creator: admin
{http://www.alfresco.org/model/system/1.0}node-uuid: c11125c1-2be9-4586-a0af-616dafc7b054
{http://www.alfresco.org/model/content/1.0}name: Test CMIS folder-5
{http://www.alfresco.org/model/system/1.0}store-protocol: workspace
{http://www.alfresco.org/model/system/1.0}store-identifier: SpacesStore
{http://www.alfresco.org/model/system/1.0}node-dbid: 1750
{http://www.alfresco.org/model/system/1.0}locale: en_US
{http://www.alfresco.org/model/content/1.0}modifier: admin
{http://www.alfresco.org/model/content/1.0}modified: Fri Jan 20 11:58:36 ALMT 2017
]
2017-01-20 11:58:36,197 [http-apr-8080-exec-7] TRACE AftContract.validateSite - Invoke
This log show, what from CMIS to Alfresco was not sending no one attribute
- no title
- no description
- no my cust/ attrs (asisapcs:*)
one successfully attribute "dss_balance_object: EM" - it not from CMIS, "EM" - it is default value (look model def. early)
01-22-2017 09:23 AM
Although I have my problems fully understanding what has been written, I believe I know the source of your confusion. The "onCreateNode" behaviour / policy is called when the node is frist created with the property values as defined by the defauls in the model and overrides provided on the Java service API level. Now, the CMIS integration layer may perform a two step operation when creating a new folder instead of a single step: 1) create the folder, 2) set the supplied properties
In that case you will get an additional onUpdateProperties / onUpdateNode behaviour / policy being triggered.
Explore our Alfresco products with the links below. Use labels to filter content by product module.