atg.userdirectory.droplet
Class HasFunction

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.userdirectory.droplet.HasFunction
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, atg.userdirectory.droplet.Constants, java.util.EventListener, javax.servlet.Servlet

public class HasFunction
extends DynamoServlet
implements atg.userdirectory.droplet.Constants

This droplet is used to query whether or not a user has a particular function associated with them. If the user has the function then then the true oparam will be rendered. If the user does not have the function then the false oparam will be rendered. If any parameters are missing, or a general error is encountered the error oparam will be rendered.

Here are some examples of using this droplet...

This is an example of using the droplet to see if the current user has a relative role, with a function name of admin.
<droplet bean="/atg/userdirectory/HasFunction"> <param name="userid" value="bean:/atg/userprofiling/Profile.id"/> <param name="function" value="admin"/> <oparam name="true"> Have the admin function </oparam> <oparam name="false"> Do not have the admin function </oparam> </droplet>

This example will do the same as the above example except that it will additionally ensure that the the relativeRole is relative to an organization with an id of org3004
<droplet bean="/atg/userdirectory/HasFunction"> <param name="userid" value="bean:/atg/userprofiling/Profile.id"/> <param name="function" value="admin"/> <param name="organizationId" value="org3004"/> <oparam name="true"> Have the admin function </oparam> <oparam name="false"> Do not have the admin function </oparam> </droplet>

See Also:
UserDirectory, RelativeRole, OrganizationalEntity

Field Summary
static java.lang.String CLASS_VERSION
           
static ParameterName FALSE
           
static ParameterName FUNCTION
           
static ParameterName ORGANIZATION_ID
           
static ParameterName TRUE
           
static ParameterName USER_ID
           
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.userdirectory.droplet.Constants
EMPTY, ERROR, INVALID_OPTIONAL_PARAM, MISSING_REQUIRED_PARAM, NO_ORGANIZATION, NO_USER, OUTPUT
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
HasFunction()
           
 
Method Summary
 UserDirectory getUserDirectory()
          Gets the userDirectory property
protected  boolean isMissingParameters(java.lang.String pUserId, java.lang.String pFunctionName, java.lang.String pOrganization)
          This method will determine if there are any missing parameters passed to this droplet.
protected  boolean isUserHasFunction(java.util.Collection pRoles, java.lang.String pFunctionName, Organization pOrganization)
          This method determines if the user has the function specified.
 void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          The service method will perform the work of this droplet.
 void setUserDirectory(UserDirectory pUserDirectory)
          Sets the userDirectory property
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

USER_ID

public static final ParameterName USER_ID

FUNCTION

public static final ParameterName FUNCTION

ORGANIZATION_ID

public static final ParameterName ORGANIZATION_ID

TRUE

public static final ParameterName TRUE

FALSE

public static final ParameterName FALSE
Constructor Detail

HasFunction

public HasFunction()
Method Detail

setUserDirectory

public void setUserDirectory(UserDirectory pUserDirectory)
Sets the userDirectory property

Parameters:
pUserDirectory - the userdirectory to perform on

getUserDirectory

public UserDirectory getUserDirectory()
Gets the userDirectory property

Returns:
the userdirectory to perform on

isUserHasFunction

protected boolean isUserHasFunction(java.util.Collection pRoles,
                                    java.lang.String pFunctionName,
                                    Organization pOrganization)
This method determines if the user has the function specified. The pOrganization parameter is optional. If it is specified, then this method will only return true if the user has the function relative to the supplied organization.

This method works by iterating over the collection of roles passed in via the pRoles parameter. If any of the roles are atg.userdirectory.RelativeRoleRelativeRoles then the function name is extracted from the role. If the function name for the role matches the function name supplied by the pFunctionName parameter, then this will method will return true.

Parameters:
pRoles - collection of roles relative to a particular principal
pFunctionName - function name to search for in the role list
pOrganization - optional parameter. If specified, this method will only return true if there is a relative role whose function equals the specified function name via pFunctionName parameter AND that function is found on a relative role that is relative to pOrganization
Returns:
true if the user has the specified function in a relative role

service

public void service(DynamoHttpServletRequest pRequest,
                    DynamoHttpServletResponse pResponse)
             throws javax.servlet.ServletException,
                    java.io.IOException
The service method will perform the work of this droplet. It will first check to make sure that all necessary parameters that are required by this droplet are actually passed in. This is done by the isMissingParameters() method.

Next, it will extract the user and organization by their primaryKey from the UserDirectory property that is configured. If the user can not be extracted, an error condition is triggered. If the page author supplied an organization id and the organization can not be extracted, then an error condition is triggered.

Finally, the isUserHasFunction method will be called to determine if the user has the specified function associated with them.

Overrides:
service in class DynamoServlet
Parameters:
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs

isMissingParameters

protected boolean isMissingParameters(java.lang.String pUserId,
                                      java.lang.String pFunctionName,
                                      java.lang.String pOrganization)
This method will determine if there are any missing parameters passed to this droplet. If there are then an error is logged and this method will return true. This method will look for the following parameters:

Parameters:
pUserId - a String value
pFunctionName - a String value
pOrganization - a String value
Returns:
a boolean value