08-22-2007 04:26 AM
NodeRef nodeDiscussion = rs.getNodeRef(0); // from a lucene query to find the document…
ChildAssociationRef childRef;
NodeRef destinationForum;
if(!nodeService.hasAspect(nodeDiscussion, ForumModel.ASPECT_DISCUSSABLE)) {
nodeService.addAspect(nodeDiscussion, ForumModel.ASPECT_DISCUSSABLE, null);
String name = (String)this.nodeService.getProperty(nodeDiscussion,
ContentModel.PROP_NAME);
String forumName = I18NUtil.getMessage("coci_service.discussion_for", new Object[] {name});
Map<QName, Serializable> forumProps = new HashMap<QName, Serializable>(1);
forumProps.put(ContentModel.PROP_NAME, forumName);
childRef = this.nodeService.createNode(nodeDiscussion,
ForumModel.ASSOC_DISCUSSION,
QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussion"),
ForumModel.TYPE_FORUM, forumProps);
destinationForum = childRef.getChildRef();
// apply the uifacets aspect
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
uiFacetsProps.put(ApplicationModel.PROP_ICON, "forum");
this.nodeService.addAspect(destinationForum, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
} else {
List<ChildAssociationRef> destChildren = this.nodeService.getChildAssocs(nodeDiscussion,
ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL);
if (destChildren.size() != 1){
throw new IllegalStateException("Locked node has the discussable aspect but does not have 1 child, it has " +
destChildren.size() + " children!");
}
destinationForum = destChildren.get(0).getChildRef();
}
Map<QName, Serializable> topicProps = new HashMap<QName, Serializable>(1);
topicProps.put(ContentModel.PROP_NAME, "TopicName");
ChildAssociationRef topicChildRef = nodeService.createNode(destinationForum,
ForumModel.ASSOC_DISCUSSION,
QName.createQName(NamespaceService.FORUMS_MODEL_1_0_URI, "discussion"),
ForumModel.TYPE_TOPIC, topicProps);
NodeRef topicNode = topicChildRef.getChildRef();
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
uiFacetsProps.put(ApplicationModel.PROP_ICON, "topic");
this.nodeService.addAspect(topicNode, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
10:25:25,853 ERROR [node.integrity.IntegrityChecker] Found 2 integrity violation
s:
The association source is missing the aspect required for this association:
Source Node: workspace://SpacesStore/3bb8a352-5089-11dc-9cd2-3daa8b5bd1a3
Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/
forum/1.0}discussable], name={http://www.alfresco.org/model/forum/1.0}discussion
, target class={http://www.alfresco.org/model/forum/1.0}forum, source role=null,
target role=null]
Required Source Aspect: {http://www.alfresco.org/model/forum/1.0}discussable
Actual Source Aspects: [{http://www.alfresco.org/model/content/1.0}auditable,
{http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.o
rg/model/application/1.0}uifacets]
The association target type is incorrect:
Target Node: workspace://SpacesStore/3bc6fb34-5089-11dc-9cd2-3daa8b5bd1a3
Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/
forum/1.0}discussable], name={http://www.alfresco.org/model/forum/1.0}discussion
, target class={http://www.alfresco.org/model/forum/1.0}forum, source role=null,
target role=null]
Required Target Type: {http://www.alfresco.org/model/forum/1.0}forum
Actual Target Type: {http://www.alfresco.org/model/forum/1.0}topic
10:25:25,869 ERROR [util.transaction.SpringAwareUserTransaction] Transaction did
n't commit
08-22-2007 04:45 AM
FileInfo fileInfo = this.fileFolderService.create(containerNodeRef, fileName, ForumModel.TYPE_POST);
08-22-2007 05:47 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.