Hi, I have following structure in documentLibrary:
n sub folders (with documents) in 1 Folder
PATIENTS
| ---- Toto (cm:created = 20190526)
| ---- Titi (cm:created = 20190526)
| -----Tutu (cm:created = 20190424)
And I have to change this structure as following:
PATIENTS
| ---- 2019
| | -----04
| | | ------24
| | |-------Tutu
| | -----05
| | ------26
| |-------Toto
| |------- Titi
This is what I have tried :
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_XPATH,
"/app:company_home/st:sites/cm:" + coreServices.getDocumedSiteName() + "/cm:documentLibrary/cmATIENTS");
for (NodeRef patient : rs.getNodeRefs()) {Date datec = (Date) nodeService.getProperty(patient, ContentModel.PROP_CREATED);
String date = new SimpleDateFormat("yyyyMMdd").format(datec);
String aaaa = date.substring(0, 4);
String mm = date.substring(4, 6);
String jj = date.substring(6, 8);// contrôle si rep documentLibrary/PATIENTS/AAAA existe
NodeRef aaaaNodeRef = nodeService.getChildByName(coreServices.getfolderNode("PATIENTS"), ContentModel.ASSOC_CONTAINS, aaaa);
if (aaaaNodeRef == null)
aaaaNodeRef = coreServices.createFolder(coreServices.getfolderNode("PATIENTS"), aaaa, ContentModel.TYPE_FOLDER);
// contrôle si rep documentLibrary/PATIENTS/AAAA/MM existe
NodeRef mmNodeRef = nodeService.getChildByName(aaaaNodeRef, ContentModel.ASSOC_CONTAINS, mm);
if (mmNodeRef == null)
mmNodeRef = coreServices.createFolder(aaaaNodeRef, mm, ContentModel.TYPE_FOLDER);
// contrôle si rep documentLibrary/PATIENTS/AAAA/MM/JJ existe
NodeRef jjNodeRef = nodeService.getChildByName(mmNodeRef, ContentModel.ASSOC_CONTAINS, jj);
if (jjNodeRef == null)
jjNodeRef = coreServices.createFolder(mmNodeRef, jj, ContentModel.TYPE_FOLDER);
// On déplace le répertoire du patient dans la nouvelle architecture
fileFolderService.move(patient, jjNodeRef, null); ********** FAILED *******}
aaaa, mm and jj are well extrated but It fails in move instruction with following reason :
ERROR [node.ibatis.NodeDAOImpl] [http-nio-8080-exec-8] Cyclic parent-child relationship detected:
What is wrong ?
Question : will titi, toto and tutu nodeRef change ?
Thank you
OK , * character is missing:
rs = searchService.query(storeRef, SearchService.LANGUAGE_XPATH,
"/app:company_home/st:sites/cm:" + coreServices.getDocumedSiteName() + "/cm:documentLibrary/cmATIENTS/*")
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.