04-13-2006 05:38 AM
16:56:14,484 WARN [org.alfresco.repo.node.integrity.IntegrityChecker] Found 1 integrity violations:
The association child multiplicity has been violated:
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 child Multiplicity: 1..1
Actual child Multiplicity: 0
AssocTypeQName = {http://www.alfresco.org/model/forum/1.0}discussion
sourceNodeRef = 4c5b13ad-cacb-11da-95ba-993a183228c0
javax.faces.el.EvaluationException: Exception while invoking expression #{ForumsBean.discuss}
caused by:
java.lang.IllegalStateException: Node has the discussable aspect but does not have 1 child, it has 0 children!
Association association = new Association();
association.setAssociationType(Constants.ASSOC_DISCUSSION);
association.setDirection(AssociationDirectionEnum.target);
children = repositoryService.queryAssociated(ref, new Association[] {association});
results is :
<?xml version="1.0" encoding="UTF-8" ?>
- <Node NodeType="{http://www.alfresco.org/model/content/1.0}content">
- <Properties>
<Property>modifier=admin</Property>
<Property>editInline=true</Property>
<Property>modified=2006-04-13T16:56:14.468+08:00</Property>
<Property>description=</Property>
<Property>node-uuid=4c5b13ad-cacb-11da-95ba-993a183228c0</Property>
<Property>creator=admin</Property>
<Property>store-protocol=workspace</Property>
<Property>content=contentUrl=store://2006/4/13/16/4c623f9f-cacb-11da-95ba-993a183228c0.bin|mimetype=text/html|size=1318|encoding=UTF-8</Property>
<Property>title=a.htm</Property>
<Property>name=a.htm</Property>
<Property>store-identifier=SpacesStore</Property>
<Property>created=2006-04-13T16:55:46.921+08:00</Property>
</Properties>
- <Aspects>
<Aspect>{http://www.alfresco.org/model/content/1.0}auditable</Aspect>
<Aspect>{http://www.alfresco.org/model/content/1.0}titled</Aspect>
<Aspect>{http://www.alfresco.org/model/system/1.0}referenceable</Aspect>
<Aspect>{http://www.alfresco.org/model/forum/1.0}discussable</Aspect>
<Aspect>{http://www.alfresco.org/model/application/1.0}inlineeditable</Aspect>
</Aspects>
- <Children>
- <Node NodeType="{http://www.alfresco.org/model/forum/1.0}forum">
- <Properties>
<Property>modifier=admin</Property>
<Property>modified=2006-04-13T16:56:16.187+08:00</Property>
<Property>icon=forum_large</Property>
<Property>node-uuid=5c3c04c6-cacb-11da-95ba-993a183228c0</Property>
<Property>creator=admin</Property>
<Property>store-protocol=workspace</Property>
<Property>name=update.html discussion</Property>
<Property>store-identifier=SpacesStore</Property>
<Property>created=2006-04-13T16:56:13.593+08:00</Property>
</Properties>
- <Aspects>
<Aspect>{http://www.alfresco.org/model/content/1.0}auditable</Aspect>
<Aspect>{http://www.alfresco.org/model/application/1.0}uifacets</Aspect>
<Aspect>{http://www.alfresco.org/model/system/1.0}referenceable</Aspect>
</Aspects>
</Node>
</Children>
</Node>
// uuid is the id of resource.
public String post(String uuid, String author, String title, String content) {
String child_uuid = null;
try {
Node node=getNode(uuid);
if(!hasAspect(node,Constants.ASPECT_DISCUSSABLE)) {
makeDiscussable(uuid,title);
}
// get topic uuid ,if does not exit, create a topic child node
String topic_id = getOrCreateTopic(repositoryService, uuid, title);
//add a content node for title and cotent
child_uuid = post_helper(topic_id, author, title, content);
} catch (Exception e) {
e.printStackTrace();
}
return child_uuid;
}
public void makeDiscussable(String uuid, String title) {
try {
// add discussable aspect
addAspect(repositoryService, Constants.ASPECT_DISCUSSABLE, null,
uuid);
// add forum
String forum_id = WebServiceUtil.createNode(Constants.TYPE_FORUM,
uuid, "admin", title + " discussion", null).getUuid();
// add association
addDiscussionAssociation(uuid,forum_id);
// add uifacets aspect
NamedValue[] props = new NamedValue[] { new NamedValue(
Constants.PROP_ICON, "forum_large") };
addAspect(repositoryService, Constants.ASPECT_UIFACETS, props,
forum_id);
} catch (Exception e) {
e.printStackTrace();
}
}
public void addDiscussionAssociation(String uuid uuid, String forum_id) throws Exception {
// add DISCUSSION association from Forum to Discussable Node
CML cml = new CML();
CMLCreateAssociation discusstion = new CMLCreateAssociation();
discusstion.setAssociation(Constants.ASSOC_DISCUSSION);
discusstion.setFrom(WebServiceUtil.createPredicate(uuid));
discusstion.setTo(WebServiceUtil.createPredicate(forum_id));
cml.setCreateAssociation(new CMLCreateAssociation[] { discusstion });
UpdateResult[] updateResults = repositoryService.update(cml);
if(updateResults!=null) {
for(UpdateResult r:updateResults) {
Reference source=r.getSource();
Reference target=r.getDestination();
System.out.println("source = " + source.getUuid());
System.out.println("target = " + target.getUuid());
}
}
}
04-14-2006 04:17 AM
ChildAssociationRef childRef = this.nodeService.createNode(this.discussingNodeRef,
ForumModel.ASSOC_DISCUSSION,
QName.createQName(ForumModel.FORUMS_MODEL_URI, "discussion"),
ForumModel.TYPE_FORUM, forumProps);
forumNodeRef = childRef.getChildRef();
/**
* Creates a new, non-abstract, real node as a primary child of the given parent node.
*
* @param parentRef the parent node
* @param assocTypeQName the type of the association to create. This is used
* for verification against the data dictionary.
* @param assocQName the qualified name of the association
* @param nodeTypeQName a reference to the node type
* @param properties optional map of properties to keyed by their qualified names
* @return Returns a reference to the newly created child association
* @throws InvalidNodeRefException if the parent reference is invalid
* @throws InvalidTypeException if the node type reference is not recognised
*
* @see org.alfresco.service.cmr.dictionary.DictionaryService
*/
public ChildAssociationRef createNode(
NodeRef parentRef,
QName assocTypeQName,
QName assocQName,
QName nodeTypeQName,
Map<QName, Serializable> properties)
throws InvalidNodeRefException, InvalidTypeException;
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.