cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS - Folder creation with namespace

iv0id
Champ in-the-making
Champ in-the-making
Hi everyone,

After upgrading alfresco environment from 3.4.d to 4.0.e if i create a folder with this code :


Folder rootFolder = getSession().getRootFolder();
Map<String, Object> lFolderProps = new HashMap<String, Object>();
lFolderProps.put(PropertyIds.NAME, "folder test");
lFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "F:test:folder");
rootFolder.createFolder(lFolderProps);


where "F:test:folder" is a folder type that i created :


<type name="test:folder">
    <title>Test type folder</title>
    <parent>cm:folder</parent>
</type>


this query returns empty result even though there is some documents inside the folder :
 SELECT * FROM cmis:document D WHERE CONTAINS(D,'PATH:"/app:company_home/test:folder_x0020_test//*"') 


But if i change "test" with "cm" the results are shown.

Thank you.
8 REPLIES 8

mrogers
Star Contributor
Star Contributor
I'm using 5.0  Its working for me.

SELECT * FROM test:folder

should work.

And does SELECT * FROM cmis:folder show your folder?

EDIT - Just spotted that your path is wrong.   Its a cm:contains relationship and by convention that name is used to make an assoc name of cm:{sanitised name}    
The app namespace for company home and a  few other folders is odd.  

Use the node browser if you are unsure of the fully qualified path.

PATH:"/app:company_home/cm:folder_x0020_test

iv0id
Champ in-the-making
Champ in-the-making
Yes both queries shows me the folder i created. the problem is only when i want to list documents with the query i posted.

EDIT : is there a solution to make my query work ? because we already have data from the version 3.4.d that's accessed with that query

kaynezhang
World-Class Innovator
World-Class Innovator

The correct query is

SELECT * FROM cmis:document D WHERE CONTAINS(D,'PATH:"/app:company_home/cm:folder_x0020_test//*"')

Your query is wrong ,it will not work,becuase:
test:folder_x0020_test
is the qualified name of the child association,it is made up using your PropertyIds.NAME("folder test") as local name and cm: as prefix.

iv0id
Champ in-the-making
Champ in-the-making
how come my query works with the existing folders (data from 3.4.d , we were using Alfresco WS to create folders and now CMIS) ?

mrogers
Star Contributor
Star Contributor
So you used a different interface!   That's a big difference.  

There is either a bug/feature in your code or alfresco's that its created an assoc with an unexpected namespace.    That's not necessarily wrong but there may be bits of alfresco (or your queries) expecting the cm namespace.

For the avoidance of doubt PATH:"/app:company_home/cm:folder_x0020_test is the correct path that I would expect and alfresco would create itself with "create folder" from one of the UIs.

iv0id
Champ in-the-making
Champ in-the-making
Thank you all for you replies.
i think i'm going to change the namespace of the already created folders with a sql script. is it possible ? if yes, which tables i have to use ?

EDIT : after looking into alfresco database the child associations are stored in the table : alf_child_assoc and the qname_ns_id define the id of the namespace.

kaynezhang
World-Class Innovator
World-Class Innovator
Folder name(in facts all nodes' name) are saved in alf_node_properties table,and parent-child relationship are saved in alf_child_assoc table.
So you can update "qname" related columns in alf_node_properties and alf_child_assoc table and then rebuild index.
And make sure you have make a backup of these tables before you update them.

iv0id
Champ in-the-making
Champ in-the-making
Great that confirms my thoughts.
thank you again kaynezhang & mrogers for your replies and your time.