AnsweredAssumed Answered

Can't create folder with custom attributes and BEHAVIOUR from CMIS

Question asked by progaman on Jan 20, 2017
Latest reply on Jan 22, 2017 by afaust

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>
                <property name="asisapcsf:dss_contract_number">
                        <constraint ref="asisapcs:stringLength50"/>
                <property name="asisapcsf:dss_balance_object">
                        <constraint ref="asisapcs:adc_balance_objects_list"/>
                <property name="asisapcsf:dss_department">
                        <constraint ref="asisapcs:stringLength50"/>


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() {"new Instance created. v{}, [{}]", VERSION, this);

* realisation the behaviour's init()
public void init() {
    // Create behaviours
    this.onCreateNode = new JavaBehaviour(this, "onCreateNode", Behaviour.NotificationFrequency.FIRST_EVENT);
    // Bind behaviours to node policies
            QName.createQName(NamespaceService.ALFRESCO_URI, "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);


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<>();

        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);"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: /{}company_home/{}sites/{}emgsap/{}documentLibrary/{}Test_x0020_CMIS_x0020_folder-5
node Type: {}aft_contract
{}created: Fri Jan 20 11:58:36 ALMT 2017
{}dss_balance_object: EM
{}creator: admin
{}node-uuid: c11125c1-2be9-4586-a0af-616dafc7b054
{}name: Test CMIS folder-5
{}store-protocol: workspace
{}store-identifier: SpacesStore
{}node-dbid: 1750
{}locale: en_US
{}modifier: admin
{}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)