Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

125605 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125498 slanglois: MNT-16155 Update source headers - remove svn:eol-style property on Java and JSP source files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125783 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Raluca Munteanu
2016-04-26 13:03:25 +00:00
parent d6f9f50c39
commit dead3c3825
265 changed files with 44099 additions and 44099 deletions

View File

@@ -1,38 +1,38 @@
package org.alfresco.web.action;
import java.io.Serializable;
import org.alfresco.web.bean.repository.Node;
/**
* Contract supported by all classes that provide dynamic evaluation for a UI action.
* <p>
* Evaluators are supplied with a Node instance context object.
* <p>
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @author Kevin Roast
*/
public interface ActionEvaluator extends Serializable
{
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @param node Node context for the action
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Node node);
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the state etc. of the given object and return the result.
*
* @param obj The object the action is for
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Object obj);
}
package org.alfresco.web.action;
import java.io.Serializable;
import org.alfresco.web.bean.repository.Node;
/**
* Contract supported by all classes that provide dynamic evaluation for a UI action.
* <p>
* Evaluators are supplied with a Node instance context object.
* <p>
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @author Kevin Roast
*/
public interface ActionEvaluator extends Serializable
{
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the properties etc. of the Node context and return the result.
*
* @param node Node context for the action
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Node node);
/**
* The evaluator should decide if the action precondition is valid based on the appropriate
* logic and the state etc. of the given object and return the result.
*
* @param obj The object the action is for
*
* @return result of whether the action can proceed.
*/
public boolean evaluate(Object obj);
}

View File

@@ -1,34 +1,34 @@
package org.alfresco.web.action.evaluator;
import java.util.Map;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Approve' workflow step for document or space.
*
* @author Kevin Roast
*/
public class ApproveDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 2958297435415449179L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
Map<String,Object> properties = node.getProperties();
Boolean approveMove = (Boolean) properties.get("app:approveMove");
boolean isMove = approveMove == null ? false : approveMove;
boolean canProceed = (properties.get("app:approveStep") != null) && !node.isLocked();
//If this approval is going to result in a move of the node then we check whether the user
//has permission. The delete permission is required in order to move a node (odd, perhaps, but true).
canProceed &= (!isMove || node.hasPermission(PermissionService.DELETE));
return canProceed;
}
}
package org.alfresco.web.action.evaluator;
import java.util.Map;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Approve' workflow step for document or space.
*
* @author Kevin Roast
*/
public class ApproveDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 2958297435415449179L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
Map<String,Object> properties = node.getProperties();
Boolean approveMove = (Boolean) properties.get("app:approveMove");
boolean isMove = approveMove == null ? false : approveMove;
boolean canProceed = (properties.get("app:approveStep") != null) && !node.isLocked();
//If this approval is going to result in a move of the node then we check whether the user
//has permission. The delete permission is required in order to move a node (odd, perhaps, but true).
canProceed &= (!isMove || node.hasPermission(PermissionService.DELETE));
return canProceed;
}
}

View File

@@ -1,25 +1,25 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Cancel checkout document.
*
* @author Kevin Roast
*/
public class CancelCheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -9015403093449070254L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Cancel checkout document.
*
* @author Kevin Roast
*/
public class CancelCheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -9015403093449070254L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CANCEL_CHECK_OUT));
}
}

View File

@@ -1,59 +1,59 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
/**
* UI Action Evaluator for cancel workflow action. The action
* is only allowed if the workflow the task belongs to was
* started by the current user.
*
* @author gavinc
*/
public class CancelWorkflowEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 7663087149225546333L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = false;
FacesContext context = FacesContext.getCurrentInstance();
// get the task from the node
WorkflowTask task = (WorkflowTask)node.getProperties().get("workflowTask");
if (task != null)
{
NodeRef initiator = task.path.instance.initiator;
if (initiator != null)
{
// find the current username
User user = Application.getCurrentUser(context);
String currentUserName = user.getUserName();
// get the username of the initiator
NodeService nodeSvc = Repository.getServiceRegistry(
context).getNodeService();
String userName = (String)nodeSvc.getProperty(initiator, ContentModel.PROP_USERNAME);
// if the current user started the workflow allow the cancel action
if (currentUserName.equals(userName))
{
result = true;
}
}
}
return result;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
/**
* UI Action Evaluator for cancel workflow action. The action
* is only allowed if the workflow the task belongs to was
* started by the current user.
*
* @author gavinc
*/
public class CancelWorkflowEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 7663087149225546333L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = false;
FacesContext context = FacesContext.getCurrentInstance();
// get the task from the node
WorkflowTask task = (WorkflowTask)node.getProperties().get("workflowTask");
if (task != null)
{
NodeRef initiator = task.path.instance.initiator;
if (initiator != null)
{
// find the current username
User user = Application.getCurrentUser(context);
String currentUserName = user.getUserName();
// get the username of the initiator
NodeService nodeSvc = Repository.getServiceRegistry(
context).getNodeService();
String userName = (String)nodeSvc.getProperty(initiator, ContentModel.PROP_USERNAME);
// if the current user started the workflow allow the cancel action
if (currentUserName.equals(userName))
{
result = true;
}
}
}
return result;
}
}

View File

@@ -1,25 +1,25 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Checkin document.
*
* @author Kevin Roast
*/
public class CheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5398249535631219663L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CHECK_IN));
}
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Checkin document.
*
* @author Kevin Roast
*/
public class CheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5398249535631219663L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null &&
node.hasPermission(PermissionService.CHECK_IN));
}
}

View File

@@ -1,34 +1,34 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkout document.
*
* @author Kevin Roast
*/
public class CheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5510366635124591353L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.hasPermission(PermissionService.CHECK_OUT) &&
(node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false) &&
node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) == false));
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkout document.
*
* @author Kevin Roast
*/
public class CheckoutDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5510366635124591353L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.hasPermission(PermissionService.CHECK_OUT) &&
(node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false) &&
node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) == false));
}
}

View File

@@ -1,23 +1,23 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ForumModel;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a forum around a node.
*
* @author Kevin Roast
*/
public class CreateForumNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -5132048668011887505L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == false &&
node.isLocked() == false);
}
}
package org.alfresco.web.action.evaluator;
import org.alfresco.model.ForumModel;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a forum around a node.
*
* @author Kevin Roast
*/
public class CreateForumNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -5132048668011887505L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE) == false &&
node.isLocked() == false);
}
}

View File

@@ -1,59 +1,59 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Delete document.
*
* @author Kevin Roast
*/
public class DeleteDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5742287199692844685L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the node to delete is a ml container, test if the user has enought right on each translation
if(node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
return MultilingualUtils.canDeleteEachTranslation(node, fc);
}
boolean isPivot = false;
// special case for multilingual documents
if (node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
// if the translation is the last translation, user can delete it
if (mlservice.getTranslations(node.getNodeRef()).size() == 1)
{
isPivot = false;
}
// Else if the node is the pivot language, user can't delete it
else if (mlservice.getPivotTranslation(node.getNodeRef()).getId()
.equalsIgnoreCase(node.getNodeRef().getId()))
{
isPivot = true;
}
// finally, the node is not the pivot translation, user can delete it
}
return (node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false &&
isPivot == false);
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.ml.MultilingualContentService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.ml.MultilingualUtils;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Delete document.
*
* @author Kevin Roast
*/
public class DeleteDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 5742287199692844685L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
// the node to delete is a ml container, test if the user has enought right on each translation
if(node.getType().equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER))
{
return MultilingualUtils.canDeleteEachTranslation(node, fc);
}
boolean isPivot = false;
// special case for multilingual documents
if (node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
{
MultilingualContentService mlservice =
(MultilingualContentService) FacesHelper.getManagedBean(fc, "MultilingualContentService");
// if the translation is the last translation, user can delete it
if (mlservice.getTranslations(node.getNodeRef()).size() == 1)
{
isPivot = false;
}
// Else if the node is the pivot language, user can't delete it
else if (mlservice.getPivotTranslation(node.getNodeRef()).getId()
.equalsIgnoreCase(node.getNodeRef().getId()))
{
isPivot = true;
}
// finally, the node is not the pivot translation, user can delete it
}
return (node.isLocked() == false &&
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false &&
isPivot == false);
}
}

View File

@@ -1,47 +1,47 @@
package org.alfresco.web.action.evaluator;
import java.util.List;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Discuss a node.
*
* @author Kevin Roast
*/
public class DiscussNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8754174908349998903L;
/**
* @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;
}
}
package org.alfresco.web.action.evaluator;
import java.util.List;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Discuss a node.
*
* @author Kevin Roast
*/
public class DiscussNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8754174908349998903L;
/**
* @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;
}
}

View File

@@ -1,59 +1,59 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the copy action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCopyEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -4080878553011296677L;
/**
* @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;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the copy action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCopyEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -4080878553011296677L;
/**
* @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;
}
}

View File

@@ -1,46 +1,46 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the cut action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCutEvaluator extends CutNodeEvaluator
{
private static final long serialVersionUID = 7260556874788184200L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = super.evaluate(node);
// if the node in question is a forum...
if (result && 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);
}
return result;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* Evaluates whether the cut action should be visible.
*
* If the node is a discussion don't allow the action.
*
* @author gavinc
*/
public class DiscussionCutEvaluator extends CutNodeEvaluator
{
private static final long serialVersionUID = 7260556874788184200L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean result = super.evaluate(node);
// if the node in question is a forum...
if (result && 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);
}
return result;
}
}

View File

@@ -1,51 +1,51 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via CIFS.
*
* @author Kevin Roast
*/
public class EditDocCIFSEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -8988276140748731926L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// if the node is inline editable, the default http behaviour should always be used
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
"cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via CIFS.
*
* @author Kevin Roast
*/
public class EditDocCIFSEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -8988276140748731926L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// if the node is inline editable, the default http behaviour should always be used
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
"cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}

View File

@@ -1,59 +1,59 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via HTTP or inline edit.
*
* @author Kevin Roast
*/
public class EditDocHttpEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3694679925715830430L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// Since the reader returned of an empty translation is the reader of it's pivot translation, it makes
// no sens to edit it on-line.
if(node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
//result = false
}
// if the node is inline editable, the default http behaviour should
// always be used otherwise the configured approach is used
else if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == true &&
node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null &&
((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true)
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via HTTP or inline edit.
*
* @author Kevin Roast
*/
public class EditDocHttpEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3694679925715830430L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// Since the reader returned of an empty translation is the reader of it's pivot translation, it makes
// no sens to edit it on-line.
if(node.getAspects().contains(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
{
//result = false
}
// if the node is inline editable, the default http behaviour should
// always be used otherwise the configured approach is used
else if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == true &&
node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null &&
((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true)
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}

View File

@@ -1,50 +1,50 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via Webdav.
*
* @author Kevin Roast
*/
public class EditDocWebDavEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 293342561997588700L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// if the node is inline editable, the default http behaviour should always be used
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
"webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.coci.EditOnlineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Edit document via Webdav.
*
* @author Kevin Roast
*/
public class EditDocWebDavEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 293342561997588700L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext fc = FacesContext.getCurrentInstance();
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
boolean result = false;
// if the node is inline editable, the default http behaviour should always be used
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
{
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
"webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
{
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
{
result = true;
}
}
}
return result;
}
}

View File

@@ -1,54 +1,54 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkin a document with potentially a Forum attached.
*
* @author Kevin Roast
*/
public class ForumsCheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -924897450989526336L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean allow = false;
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null)
{
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{
CheckOutCheckInService checkOutCheckInService =
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getCheckOutCheckInService();
// get the original locked node (via the copiedfrom aspect)
NodeRef lockedNodeRef = checkOutCheckInService.getCheckedOut(node.getNodeRef());
if (lockedNodeRef != null)
{
Node lockedNode = new Node(lockedNodeRef);
allow = (node.hasPermission(PermissionService.CHECK_IN) &&
lockedNode.hasPermission(PermissionService.CONTRIBUTOR));
}
}
else
{
// there is no discussion so just check they have checkin permission for the node
allow = node.hasPermission(PermissionService.CHECK_IN);
}
}
return allow;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Checkin a document with potentially a Forum attached.
*
* @author Kevin Roast
*/
public class ForumsCheckinDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -924897450989526336L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
boolean allow = false;
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) &&
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) == null)
{
if (node.hasAspect(ForumModel.ASPECT_DISCUSSABLE))
{
CheckOutCheckInService checkOutCheckInService =
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getCheckOutCheckInService();
// get the original locked node (via the copiedfrom aspect)
NodeRef lockedNodeRef = checkOutCheckInService.getCheckedOut(node.getNodeRef());
if (lockedNodeRef != null)
{
Node lockedNode = new Node(lockedNodeRef);
allow = (node.hasPermission(PermissionService.CHECK_IN) &&
lockedNode.hasPermission(PermissionService.CONTRIBUTOR));
}
}
else
{
// there is no discussion so just check they have checkin permission for the node
allow = node.hasPermission(PermissionService.CHECK_IN);
}
}
return allow;
}
}

View File

@@ -1,22 +1,22 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Reject' workflow step for document or space.
*
* @author Kevin Roast
*/
public class RejectDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7733947744617999298L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.getProperties().get("app:rejectStep") != null &&
node.isLocked() == false);
}
}
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - 'Reject' workflow step for document or space.
*
* @author Kevin Roast
*/
public class RejectDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7733947744617999298L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.getProperties().get("app:rejectStep") != null &&
node.isLocked() == false);
}
}

View File

@@ -1,27 +1,27 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a shortcut to a node.
*
* @author Kevin Roast
*/
public class ShortcutNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8768692540125721144L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
NavigationBean nav =
(NavigationBean)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), NavigationBean.BEAN_NAME);
return (nav.getIsGuest() == false);
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Create a shortcut to a node.
*
* @author Kevin Roast
*/
public class ShortcutNodeEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 8768692540125721144L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
NavigationBean nav =
(NavigationBean)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), NavigationBean.BEAN_NAME);
return (nav.getIsGuest() == false);
}
}

View File

@@ -1,45 +1,45 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.BPMEngineRegistry;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;
/**
* UI Action Evaluator - Start workflow on a node.
*
* @author gavinc
*/
public class StartWorkflowEvaluator extends BaseActionEvaluator
{
private static final String BPM_ENGINE_BEAN_NAME = "bpm_engineRegistry";
private static final long serialVersionUID = 3110333488835027710L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
NavigationBean nav =
(NavigationBean)FacesHelper.getManagedBean(facesContext, NavigationBean.BEAN_NAME);
// determine whether the workflow services are active
boolean workflowPresent = false;
WebApplicationContext springContext = FacesContextUtils.getRequiredWebApplicationContext(facesContext);
BPMEngineRegistry bpmReg = (BPMEngineRegistry)springContext.getBean(BPM_ENGINE_BEAN_NAME);
if (bpmReg != null)
{
String[] components = bpmReg.getWorkflowComponents();
workflowPresent = (components != null && components.length > 0);
}
return (workflowPresent && nav.getIsGuest() == false &&
node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) == false);
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.workflow.BPMEngineRegistry;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.jsf.FacesContextUtils;
/**
* UI Action Evaluator - Start workflow on a node.
*
* @author gavinc
*/
public class StartWorkflowEvaluator extends BaseActionEvaluator
{
private static final String BPM_ENGINE_BEAN_NAME = "bpm_engineRegistry";
private static final long serialVersionUID = 3110333488835027710L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
NavigationBean nav =
(NavigationBean)FacesHelper.getManagedBean(facesContext, NavigationBean.BEAN_NAME);
// determine whether the workflow services are active
boolean workflowPresent = false;
WebApplicationContext springContext = FacesContextUtils.getRequiredWebApplicationContext(facesContext);
BPMEngineRegistry bpmReg = (BPMEngineRegistry)springContext.getBean(BPM_ENGINE_BEAN_NAME);
if (bpmReg != null)
{
String[] components = bpmReg.getWorkflowComponents();
workflowPresent = (components != null && components.length > 0);
}
return (workflowPresent && nav.getIsGuest() == false &&
node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) == false);
}
}

View File

@@ -1,21 +1,21 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Take ownership of a document.
*
* @author Kevin Roast
*/
public class TakeOwnershipDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 3966463533922521230L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.isLocked() == false);
}
}
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Take ownership of a document.
*
* @author Kevin Roast
*/
public class TakeOwnershipDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 3966463533922521230L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.isLocked() == false);
}
}

View File

@@ -1,35 +1,35 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Unlock a locked document.
*
* @author Kevin Roast
*/
public class UnlockDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7056759932698306087L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
if (node.isLocked())
{
FacesContext fc = FacesContext.getCurrentInstance();
CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) FacesHelper.getManagedBean(fc, "CheckoutCheckinService");
if (checkOutCheckInService.getWorkingCopy(node.getNodeRef()) == null)
{
return true;
}
}
return false;
}
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Unlock a locked document.
*
* @author Kevin Roast
*/
public class UnlockDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -7056759932698306087L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
if (node.isLocked())
{
FacesContext fc = FacesContext.getCurrentInstance();
CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) FacesHelper.getManagedBean(fc, "CheckoutCheckinService");
if (checkOutCheckInService.getWorkingCopy(node.getNodeRef()) == null)
{
return true;
}
}
return false;
}
}

View File

@@ -1,21 +1,21 @@
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Proceed if the document is not locked.
*
* @author Kevin Roast
*/
public class UnlockedDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3216759932698306123L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.isLocked() == false);
}
package org.alfresco.web.action.evaluator;
import org.alfresco.web.bean.repository.Node;
/**
* UI Action Evaluator - Proceed if the document is not locked.
*
* @author Kevin Roast
*/
public class UnlockedDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = -3216759932698306123L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
return (node.isLocked() == false);
}
}

View File

@@ -1,35 +1,35 @@
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.web.bean.coci.EditOfflineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Update document content.
*
* @author Kevin Roast
*/
public class UpdateDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 6030963610213633893L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
boolean isOfflineEditing =
(EditOfflineDialog.OFFLINE_EDITING.equals(node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE)));
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.isWorkingCopyOwner() && !isOfflineEditing) ||
(!node.isLocked() && !node.hasAspect(ContentModel.ASPECT_WORKING_COPY)));
}
package org.alfresco.web.action.evaluator;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.web.bean.coci.EditOfflineDialog;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
/**
* UI Action Evaluator - Update document content.
*
* @author Kevin Roast
*/
public class UpdateDocEvaluator extends BaseActionEvaluator
{
private static final long serialVersionUID = 6030963610213633893L;
/**
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
*/
public boolean evaluate(Node node)
{
DictionaryService dd = Repository.getServiceRegistry(
FacesContext.getCurrentInstance()).getDictionaryService();
boolean isOfflineEditing =
(EditOfflineDialog.OFFLINE_EDITING.equals(node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE)));
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
((node.isWorkingCopyOwner() && !isOfflineEditing) ||
(!node.isLocked() && !node.hasAspect(ContentModel.ASPECT_WORKING_COPY)));
}
}