atg.userdirectory.droplet
Class HasFunction
java.lang.Object
atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
atg.nucleus.GenericService
atg.nucleus.TimedOperationService
atg.nucleus.servlet.ServletService
atg.nucleus.servlet.HttpServletService
atg.servlet.DynamoServlet
atg.userdirectory.droplet.HasFunction
- All Implemented Interfaces:
- NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, 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
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 |
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, reResolveThis, 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 |
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
HasFunction
public HasFunction()
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 principalpFunctionName
- function name to search for in the role listpOrganization
- 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
valuepResponse
- 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:
- pUserid - this is the primayKey that is used
to look up the user. If it is missing, then the droplet will
consider this an error condition.
- pFunctionName - this is the function name that this droplet
will look for. If it is missing, then the droplet will consider this
an error condition.
- pOrganization - this parameter is optional. If it is missing
the droplet will not error.
- Parameters:
pUserId
- a String
valuepFunctionName
- a String
valuepOrganization
- a String
value
- Returns:
- a
boolean
value