@Override protected String finishImpl(FacesContext context, String outcome) throws Exception { // find out what the parent type of the node being deleted Node node = this.browseBean.getActionSpace(); NodeRef parent = null; ChildAssociationRef assoc = this.getNodeService().getPrimaryParent(node.getNodeRef()); if (assoc != null) { // get the parent node parent = assoc.getParentRef(); // if the parent type is a forum space then we need the dialog to go // back to the forums view otherwise it will use the default of 'browse', // this happens when a forum being used to discuss a node is deleted. QName parentType = this.getNodeService().getType(parent); if (parentType.equals(ForumModel.TYPE_FORUMS)) { this.reDisplayForums = true; } } // delete the forum itself outcome = super.finishImpl(context, outcome); // remove the discussable aspect if appropriate if (assoc != null && parent != null) { // get the association type QName type = assoc.getTypeQName(); if (type.equals(ForumModel.ASSOC_DISCUSSION)) { // if the association type is the 'discussion' association we // need to remove the discussable aspect from the parent node this.getNodeService().removeAspect(parent, ForumModel.ASPECT_DISCUSSABLE); } } return outcome; }
/** * @see * org.alfresco.service.cmr.coci.CheckOutCheckInService#checkout(org.alfresco.service.cmr.repository.NodeRef) */ public NodeRef checkout(NodeRef nodeRef) { // Find the primary parent in order to determine where to put the copy ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(nodeRef); // Checkout the working copy to the same destination return checkout( nodeRef, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName()); }
/* (non-Javadoc) * @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.cmr.repository.ChildAssociationRef) */ public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef) { if (childAssocRef == null) { return null; } return new ChildAssociationRef( childAssocRef.getTypeQName(), getBaseName(childAssocRef.getParentRef()), childAssocRef.getQName(), getBaseName(childAssocRef.getChildRef()), childAssocRef.isPrimary(), childAssocRef.getNthSibling()); }
/** * Force copy recursion after copying a rules folder * * @return Returns {@link ChildAssocRecurseAction#FORCE_RECURSE} for {@link * RuleModel#ASSOC_RULE_FOLDER} */ @Override public ChildAssocRecurseAction getChildAssociationRecurseAction( QName classQName, CopyDetails copyDetails, CopyChildAssociationDetails childAssocCopyDetails) { ChildAssociationRef childAssocRef = childAssocCopyDetails.getChildAssocRef(); if (childAssocRef.getTypeQName().equals(RuleModel.ASSOC_RULE_FOLDER)) { return ChildAssocRecurseAction.FORCE_RECURSE; } else { super.throwExceptionForUnexpectedBehaviour(copyDetails, childAssocCopyDetails.toString()); return null; // Never reached } }
private CategoryPaths getCategoryPaths( NodeRef nodeRef, Set<QName> aspects, Map<QName, Serializable> properties) { ArrayList<Pair<Path, QName>> categoryPaths = new ArrayList<Pair<Path, QName>>(); ArrayList<ChildAssociationRef> categoryParents = new ArrayList<ChildAssociationRef>(); nodeDAO.setCheckNodeConsistency(); for (QName classRef : aspects) { AspectDefinition aspDef = dictionaryService.getAspect(classRef); if (!isCategorised(aspDef)) { continue; } LinkedList<Pair<Path, QName>> aspectPaths = new LinkedList<Pair<Path, QName>>(); for (PropertyDefinition propDef : aspDef.getProperties().values()) { if (!propDef.getDataType().getName().equals(DataTypeDefinition.CATEGORY)) { // The property is not a category continue; } // Don't try to iterate if the property is null Serializable propVal = properties.get(propDef.getName()); if (propVal == null) { continue; } for (NodeRef catRef : DefaultTypeConverter.INSTANCE.getCollection(NodeRef.class, propVal)) { if (catRef == null) { continue; } // can be running in context of System user, hence use input nodeRef catRef = tenantService.getName(nodeRef, catRef); try { Pair<Long, NodeRef> pair = nodeDAO.getNodePair(catRef); if (pair != null) { for (Path path : nodeDAO.getPaths(pair, false)) { aspectPaths.add(new Pair<Path, QName>(path, aspDef.getName())); } } } catch (InvalidNodeRefException e) { // If the category does not exists we move on the next } } } categoryPaths.addAll(aspectPaths); } // Add member final element for (Pair<Path, QName> pair : categoryPaths) { if (pair.getFirst().last() instanceof Path.ChildAssocElement) { Path.ChildAssocElement cae = (Path.ChildAssocElement) pair.getFirst().last(); ChildAssociationRef assocRef = cae.getRef(); ChildAssociationRef categoryParentRef = new ChildAssociationRef( assocRef.getTypeQName(), assocRef.getChildRef(), QName.createQName("member"), nodeRef); pair.getFirst().append(new Path.ChildAssocElement(categoryParentRef)); categoryParents.add(categoryParentRef); } } return new CategoryPaths(categoryPaths, categoryParents); }