use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class Repository method setupBreadcrumbLocation.
/**
* Sets up the breadcrumb location representation for the given node in
* the given list.
*
* @param context FacesContext
* @param navBean NavigationBean instance
* @param location The location list to setup
* @param node The Node being navigated to
*/
public static void setupBreadcrumbLocation(FacesContext context, NavigationBean navBean, List<IBreadcrumbHandler> location, NodeRef node) {
// make the sure the given list is empty
location.clear();
// get required services
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
DictionaryService dictionaryService = Repository.getServiceRegistry(context).getDictionaryService();
PermissionService permsService = Repository.getServiceRegistry(context).getPermissionService();
// add the given node to start
String nodeName = Repository.getNameForNode(nodeService, node);
location.add(navBean.new NavigationBreadcrumbHandler(node, nodeName));
// get the given node's parent node
NodeRef parent = nodeService.getPrimaryParent(node).getParentRef();
while (parent != null) {
// check the user can read the parent node
if (permsService.hasPermission(parent, PermissionService.READ) == AccessStatus.ALLOWED) {
// get the grand parent so we can check for the root node
NodeRef grandParent = nodeService.getPrimaryParent(parent).getParentRef();
if (grandParent != null) {
// check that the node is actually a folder type, content can have children!
QName parentType = nodeService.getType(parent);
if (dictionaryService.isSubClass(parentType, ContentModel.TYPE_FOLDER)) {
// if it's a folder add the location to the breadcrumb
String parentName = Repository.getNameForNode(nodeService, parent);
location.add(0, navBean.new NavigationBreadcrumbHandler(parent, parentName));
}
}
parent = grandParent;
} else {
// the user does not have Read permission above this point so stop!
break;
}
}
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class MultilingualUtils method canAddChildrenToPivotSpace.
/**
* Returns true if the current user has enough right to add a content to the space
* where the pivot translation is located in.
*
* @param multlingualDocument Node
* @param fc FacesContext
* @return boolean
*/
public static boolean canAddChildrenToPivotSpace(Node multlingualDocument, FacesContext fc) {
MultilingualContentService mlservice = getMultilingualContentService(fc);
NodeService nodeService = getNodeService(fc);
// get the pivot translation and get the space where it's located
NodeRef pivot = mlservice.getPivotTranslation(multlingualDocument.getNodeRef());
NodeRef space = nodeService.getPrimaryParent(pivot).getParentRef();
// return if the current user can add a content to the space of the pivot
return new Node(space).hasPermission(PermissionService.ADD_CHILDREN);
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class GuestTemplateContentServlet method buildModel.
@Override
protected Map<String, Object> buildModel(ServiceRegistry services, HttpServletRequest req, NodeRef templateRef) {
// setup the guest user to pass to the build model helper method
AuthenticationService auth = (AuthenticationService) services.getAuthenticationService();
PersonService personService = (PersonService) services.getPersonService();
NodeService nodeService = (NodeService) services.getNodeService();
NodeRef guestRef = personService.getPerson(AuthenticationUtil.getGuestUserName());
User guestUser = new User(AuthenticationUtil.getGuestUserName(), auth.getCurrentTicket(), guestRef);
NodeRef guestHomeRef = (NodeRef) nodeService.getProperty(guestRef, ContentModel.PROP_HOMEFOLDER);
if (nodeService.exists(guestHomeRef) == false) {
throw new InvalidNodeRefException(guestHomeRef);
}
guestUser.setHomeSpaceId(guestHomeRef.getId());
// build the default model
return DefaultModelHelper.buildDefaultModel(services, guestUser, templateRef, this.imageResolver);
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class DiscussNodeEvaluator method evaluate.
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node) {
boolean result = false;
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE)) {
NodeService nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
List<ChildAssociationRef> children = nodeService.getChildAssocs(node.getNodeRef(), ForumModel.ASSOC_DISCUSSION, RegexQNamePattern.MATCH_ALL);
// make sure there is one visible child association for the node
if (children.size() == 1) {
result = true;
}
}
return result;
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class DiscussionCopyEvaluator method evaluate.
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node) {
boolean result = true;
// if the node in question is a forum...
if (node.getType().equals(ForumModel.TYPE_FORUM)) {
// get the association type
FacesContext context = FacesContext.getCurrentInstance();
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(node.getNodeRef());
QName assocType = parentAssoc.getTypeQName();
// only allow the action if the association type is not the discussion assoc
result = (assocType.equals(ForumModel.ASSOC_DISCUSSION) == false);
}
// impossible to copy a translation without content.
if (result && node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) {
result = false;
}
if (!node.hasPermission(PermissionService.READ)) {
result = false;
}
return result;
}
Aggregations