cancel
Showing results for 
Search instead for 
Did you mean: 

[Error]The association source type is incorrect. [Question] How to start the creation of a folder hierarchy of a Site?

mbel
Star Contributor
Star Contributor

Hello,

I am trying to create a Site and folders hierarchy programmatically using Java API.

After the new Site is created, I get the groupName and find the NodeRef of the authority (GROUP_site)

String groupSite = this.siteService.getSiteGroup(newSite.getShortName());
NodeRef groupSiteNodeRef = this.authorityService.getAuthorityNodeRef(groupSite);

And after that start creating the folders as assign them first to groupSiteNodeRef :

this.nodeService.createNode

                  ( groupSiteNodeRef ,
                  ContentModel.ASSOC_CONTAINS,
                   QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name),
                   ContentModel.TYPE_FOLDER,
                   properties);

However, I receive the following ERROR:

ERROR [node.integrity.IntegrityChecker] [http-bio-8080-exec-2] Found 1 integrity violations:
The association source type is incorrect:
Source Node: workspace://SpacesStore/3c68c987-c9af-4baa-8b6c-e0720f534cbc
Association: Association[ class=ClassDef[

name={http://www.alfresco.org/model/content/1.0}folder],

name={http://www.alfresco.org/model/content/1.0}contains,

target class={http://www.alfresco.org/model/system/1.0}base, source role=null, target role=null]
Required Source Type: {http://www.alfresco.org/model/content/1.0}folder
Actual Source Type: {http://www.alfresco.org/model/content/1.0}authorityContainer
at org.alfresco.repo.node.integrity.IntegrityChecker.checkIntegrity(IntegrityChecker.java:662)

So, obviously it doesn't like that I have a folder which is assign to the GROUP_site.

Could someone tells me what I did wrong?

How to start the creation of a folder hierarchy of a Site?

Thank you in advance.

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

You can only use the cm:contains / ASSOC_CONTAINS child-association to put files / folders inside of another folder. A group is not a folder and thus cannot contain anything via cm:contains.

The folder hierarchy for a site is typically contained in its document library. To get the document library you use the SiteService.getContainer(siteName, SiteService.DOCUMENT_LIBRARY) operation. You can then use the container as the parent of the new folder hierarchy. If the container does not yet exist you can create it using SiteService.createContainer(siteName, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null)

View answer in original post

1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator

You can only use the cm:contains / ASSOC_CONTAINS child-association to put files / folders inside of another folder. A group is not a folder and thus cannot contain anything via cm:contains.

The folder hierarchy for a site is typically contained in its document library. To get the document library you use the SiteService.getContainer(siteName, SiteService.DOCUMENT_LIBRARY) operation. You can then use the container as the parent of the new folder hierarchy. If the container does not yet exist you can create it using SiteService.createContainer(siteName, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null)