Last active
August 29, 2015 14:04
-
-
Save cmlewis/0a395d31afda276f6f75 to your computer and use it in GitHub Desktop.
Alfresco Share action to view any object in Alfresco repository in the Share node browser. Admins can click this action to automatically bring up the node in the Share node browser instead of having to copy, paste, and search the noderef in the node browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> | |
<beans> | |
<!-- ... --> | |
<!-- Action Evaluators --> | |
<bean id="com.someco.doclib.action.UserIsAdminEvaluator" class="com.someco.web.evaluator.UserIsAdminEvaluator" /> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.someco.web.evaluator; | |
import org.alfresco.web.evaluator.BaseEvaluator; | |
import org.apache.log4j.Logger; | |
import org.json.simple.JSONObject; | |
import org.springframework.extensions.surf.RequestContext; | |
import org.springframework.extensions.surf.support.ThreadLocalRequestContext; | |
import org.springframework.extensions.webscripts.connector.User; | |
/** | |
* Action evaluator to determine if user is an admin. Used to show/hide Share actions | |
* in the doclib and potentially other locations. | |
* | |
* Deploy this file in your Share amp. | |
* | |
* @author Christy Lewis | |
* @version 1.0 | |
* | |
* <h2>Modification History</h2> | |
* <ul> | |
* <li>Jul 21, 2014 (Christy Lewis) Created. | |
* </ul> | |
*/ | |
public class UserIsAdminEvaluator extends BaseEvaluator { | |
private Logger logger = Logger.getLogger(UserIsAdminEvaluator.class); | |
/** | |
* Evaluate the given node to determine if the action should be displayed. | |
* | |
* @param jsonObject The json object representation of the node | |
* @return A flag that specifies if the action should be shown for the node or not | |
*/ | |
@Override | |
public boolean evaluate(JSONObject jsonObject) { | |
logger.debug("Evaluating if the user is an admin to determine if this action should display."); | |
RequestContext rc = ThreadLocalRequestContext.getRequestContext(); | |
User user = rc.getUser(); | |
logger.debug("User " + user.getName() + " is an admin: " + user.isAdmin()); | |
return user.isAdmin(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment