atg.userdirectory.droplet
Class CreateOrganizationFormHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.droplet.TransactionalFormHandler
                      extended by atg.userdirectory.droplet.CreateOrganizationFormHandler
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class CreateOrganizationFormHandler
extends TransactionalFormHandler

This formhandler is used to create a new organization in the user directory. Since the UserDirectory interface does not provide factory methods to create new organizations, we rely on a concrete implementation to create the Organizations. This is the getRepositoryUserDirectory method.

In addition to creating a new organization the following properties can be set on the organization


Finally, this formhandler provides additonal functionality to create relative roles for the newly created organization as well as assign those roles to a particular principal.

The following properties will typically be set in a properties file

assignableFunctionNames
The list of "functions" that should get assigned to a user. These functions are used to extract a relativeRole from an organization and then assign that relativeRole to the user.
functionNames
This is a list of "functions" that will be used to create relativeRoles on a particular organization.
repositoryUserDirectory
Specifies a repositoryUserDirectory component that is used to interact with the userdirectory API. It has to be a concrete implementation of the userdirectory API because we need to be able to create objects from it.

The formhandler supports the following submit methods

createOrganization
This function actually creates a new organization using the the repositoryUserDirectory as the means to create the new organization.

The following properties might be set in the jhtml page

organizationName
The name of the organization that is going to be created. This will typically be set in form input fields.
organizationDescription
The description of the organization that is going to be created. This will typcially be set in form input fields.
parentOrganizationId
The id of the parentOrganization for the newly created organization.
createRelativeRoles
If this property is set to true, then relativeRoles will be created. a relative role is created using the list of functions specified in the functionNames string array.
assignRelativeRoles
If this property is set to true, then the list of relativeRoles specified in the assignableFunctionNames will be assigned to a user.
userId
The user whom the relativeRoles listed in assignableFunctionNames will be assigned to.

See Also:
RepositoryUserDirectory

Field Summary
static java.lang.String CLASS_VERSION
           
static java.lang.String ERR_NO_ORG_DESC
           
static java.lang.String ERR_NO_ORG_NAME
           
static java.lang.String ERR_NO_PARENT_ORG_ID
           
static java.lang.String ERR_NO_USER_PKEY
           
static java.lang.String ERR_ORG_ALREADY_EXISTS
           
static java.lang.String ERR_UNABLE_ASSIGN_REL_ROLE
           
static java.lang.String ERR_UNABLE_TO_ADD_ORG
           
static java.lang.String ERR_UNABLE_TO_ASSIGN_ROLES
           
static java.lang.String ERR_UNABLE_TO_CREATE_ROLES
           
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
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
CreateOrganizationFormHandler()
           
 
Method Summary
protected  void addFormException(java.lang.String pErrorKey, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Adds a form exception to the formhandler.
protected  void assignRelativeRoles(Organization pOrganization, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method will assign relativeRoles to the user whose primary key is returned by the #getUserIdgetUserId method.
protected  void createOrganization(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is responsible for creating a new organization.
protected  void createRelativeRoles(Organization pOrganization, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method creates relative roles for a particular organization.
 java.lang.String[] getAssignableFunctionNames()
          Lists the relativeRoles that should be assigned to a particular user.
 java.lang.String getCreateOrganizationErrorURL()
          URL to redirect to on error.
 java.lang.String getCreateOrganizationSuccessURL()
          URL to redirect to on success.
 java.lang.String[] getFunctionNames()
          The list of fucntion names.
protected  java.util.Locale getLocale(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Returns either the Locale from the Request object (if it isn't NULL), or the Locale from the JVM.
 Organization getOrganization()
          Return the organization property.
 java.lang.String getOrganizationDescription()
          The description of the organization that is going to be created
 java.lang.String getOrganizationName()
          The name of the organization that is going to be created
 java.lang.String getParentOrganizationId()
          The id of the organization that will act as the parent for the newly created organization.
 RepositoryUserDirectory getRepositoryUserDirectory()
          References the userDirectory that will be used to create and manipulate organizations.
 java.lang.String getStringResource(java.lang.String pResourceName, java.util.Locale pLocale)
          This method acts as a utility method to obtain a given resource for a particular key.
 java.lang.String getUserId()
          The user who will get assigned relativeRoles if the assignRelativeRoles property is set to true.
 java.lang.String getUserLocale()
          Return the userLocale property.
 boolean handleCreateOrganization(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This method is responsible for creating a new organization.
 boolean isAssignRelativeRoles()
          Indicates whether or not relativeRoles should be assigned to the user specified by the userId property.
 boolean isCreateRelativeRoles()
          Indicates whether or not relativeRoles should be created for a particular organization/function combination.
 boolean isOrgDescriptionRequired()
          Indicates whether or not an organization description is required or not.
 boolean isOrgNameRequired()
          Indicates whether or not an organization name is required.
 boolean isParentOrgRequired()
          Indicats whether or not a parentOrg is required in order to create a new organization.
 void postCreateOrganization(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          This is called after all work is done by the handleCreateOrganization method.
 void preCreateOrganization(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Called before any work is done by the handleCreateOrganization method.
 void setAssignableFunctionNames(java.lang.String[] pAssignableFunctionNames)
          Set the assignableFunctionNames property.
 void setAssignRelativeRoles(boolean pAssignRelativeRoles)
          Set the assignRelativeRoles property.
 void setCreateOrganizationErrorURL(java.lang.String pCreateOrganizationErrorURL)
          Set the createOrganizationErrorURL property.
 void setCreateOrganizationSuccessURL(java.lang.String pCreateOrganizationSuccessURL)
          Set the createOrganizationSuccessURL property.
 void setCreateRelativeRoles(boolean pCreateRelativeRoles)
          Set the createRelativeRoles property.
 void setFunctionNames(java.lang.String[] pFunctionNames)
          Set the FunctionNames property.
 void setOrganization(Organization pOrganization)
          Set the organization property.
 void setOrganizationDescription(java.lang.String pOrganizationDescription)
          Set the OrganizationDescription property.
 void setOrganizationName(java.lang.String pOrganizationName)
          Set the OrganizationName property.
 void setOrgDescriptionRequired(boolean pOrgDescriptionRequired)
          Set the orgDescriptionRequired property.
 void setOrgNameRequired(boolean pOrgNameRequired)
          Set the orgNameRequired property.
 void setParentOrganizationId(java.lang.String pParentOrganizationId)
          Set the ParentOrganizationId property.
 void setParentOrgRequired(boolean pParentOrgRequired)
          Set the parentOrgRequired property.
 void setRepositoryUserDirectory(RepositoryUserDirectory pRepositoryUserDirectory)
          Set the RepositoryUserDirectory property.
protected  void setRollbackOnly()
          This method will call the setRollbackTransaction method on the superclass.
 void setUserId(java.lang.String pUserId)
          Set the userId property.
 void setUserLocale(java.lang.String pUserLocale)
          Set the userLocale property.
 
Methods inherited from class atg.droplet.TransactionalFormHandler
afterSet, beforeSet, checkFormRedirect, commitTransaction, getTransactionDemarcation, isEnsureTransaction, isRollbackTransaction, isRollbackTransactionOnUnhandledException, isTransactionMarkedAsRollback, setEnsureTransaction, setRollbackTransaction, setRollbackTransactionOnUnhandledException, setTransactionDemarcation
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet, beforeGet
 
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

ERR_ORG_ALREADY_EXISTS

public static final java.lang.String ERR_ORG_ALREADY_EXISTS
See Also:
Constant Field Values

ERR_NO_ORG_NAME

public static final java.lang.String ERR_NO_ORG_NAME
See Also:
Constant Field Values

ERR_NO_ORG_DESC

public static final java.lang.String ERR_NO_ORG_DESC
See Also:
Constant Field Values

ERR_NO_PARENT_ORG_ID

public static final java.lang.String ERR_NO_PARENT_ORG_ID
See Also:
Constant Field Values

ERR_UNABLE_TO_ADD_ORG

public static final java.lang.String ERR_UNABLE_TO_ADD_ORG
See Also:
Constant Field Values

ERR_NO_USER_PKEY

public static final java.lang.String ERR_NO_USER_PKEY
See Also:
Constant Field Values

ERR_UNABLE_TO_ASSIGN_ROLES

public static final java.lang.String ERR_UNABLE_TO_ASSIGN_ROLES
See Also:
Constant Field Values

ERR_UNABLE_TO_CREATE_ROLES

public static final java.lang.String ERR_UNABLE_TO_CREATE_ROLES
See Also:
Constant Field Values

ERR_UNABLE_ASSIGN_REL_ROLE

public static final java.lang.String ERR_UNABLE_ASSIGN_REL_ROLE
See Also:
Constant Field Values
Constructor Detail

CreateOrganizationFormHandler

public CreateOrganizationFormHandler()
Method Detail

getOrganization

public Organization getOrganization()
Return the organization property. This property gets set by the createOrganization() method. This allows later functions such as postCreateOrganization to access the newly created organization. This method should not be set via jhtml or properties file

Returns:
the newly created organization

setOrganization

public void setOrganization(Organization pOrganization)
Set the organization property.

Parameters:
pOrganization -

getUserId

public java.lang.String getUserId()
The user who will get assigned relativeRoles if the assignRelativeRoles property is set to true. The id value of this property is used to lookup the user in the userdirectory by their primaryKey.

Returns:
the id of the user whom will be assigned relativeRoles

setUserId

public void setUserId(java.lang.String pUserId)
Set the userId property.

Parameters:
pUserId -

isCreateRelativeRoles

public boolean isCreateRelativeRoles()
Indicates whether or not relativeRoles should be created for a particular organization/function combination. This defaults to true.

Returns:
true if relativeRoles should be created

setCreateRelativeRoles

public void setCreateRelativeRoles(boolean pCreateRelativeRoles)
Set the createRelativeRoles property.

Parameters:
pCreateRelativeRoles -

isAssignRelativeRoles

public boolean isAssignRelativeRoles()
Indicates whether or not relativeRoles should be assigned to the user specified by the userId property. This defaults to true.

Returns:
true if relative roles should be assigned

setAssignRelativeRoles

public void setAssignRelativeRoles(boolean pAssignRelativeRoles)
Set the assignRelativeRoles property.

Parameters:
pAssignRelativeRoles -

getAssignableFunctionNames

public java.lang.String[] getAssignableFunctionNames()
Lists the relativeRoles that should be assigned to a particular user.

Returns:
the list of relativeRoles that should be assigned

setAssignableFunctionNames

public void setAssignableFunctionNames(java.lang.String[] pAssignableFunctionNames)
Set the assignableFunctionNames property.

Parameters:
pAssignableFunctionNames -

getFunctionNames

public java.lang.String[] getFunctionNames()
The list of fucntion names. This list will be used to create relativeRoles specific to the newly created organization.

Returns:
the list of functions

setFunctionNames

public void setFunctionNames(java.lang.String[] pFunctionNames)
Set the FunctionNames property.

Parameters:
pFunctionNames -

isOrgNameRequired

public boolean isOrgNameRequired()
Indicates whether or not an organization name is required. Defaults to true.

Returns:
true if the org name is required

setOrgNameRequired

public void setOrgNameRequired(boolean pOrgNameRequired)
Set the orgNameRequired property.

Parameters:
pOrgNameRequired -

isOrgDescriptionRequired

public boolean isOrgDescriptionRequired()
Indicates whether or not an organization description is required or not. False by default.

Returns:
true if the description is required

setOrgDescriptionRequired

public void setOrgDescriptionRequired(boolean pOrgDescriptionRequired)
Set the orgDescriptionRequired property.

Parameters:
pOrgDescriptionRequired -

isParentOrgRequired

public boolean isParentOrgRequired()
Indicats whether or not a parentOrg is required in order to create a new organization.

Returns:
true if a parentOrg is required in order to create a new organization

setParentOrgRequired

public void setParentOrgRequired(boolean pParentOrgRequired)
Set the parentOrgRequired property.

Parameters:
pParentOrgRequired -

getUserLocale

public java.lang.String getUserLocale()
Return the userLocale property.

Returns:
users locale.

setUserLocale

public void setUserLocale(java.lang.String pUserLocale)
Set the userLocale property.

Parameters:
pUserLocale -

getCreateOrganizationSuccessURL

public java.lang.String getCreateOrganizationSuccessURL()
URL to redirect to on success.

Returns:
location to redirect to on success

setCreateOrganizationSuccessURL

public void setCreateOrganizationSuccessURL(java.lang.String pCreateOrganizationSuccessURL)
Set the createOrganizationSuccessURL property.

Parameters:
pCreateOrganizationSuccessURL -

getCreateOrganizationErrorURL

public java.lang.String getCreateOrganizationErrorURL()
URL to redirect to on error.

Returns:
location to redirect to on error

setCreateOrganizationErrorURL

public void setCreateOrganizationErrorURL(java.lang.String pCreateOrganizationErrorURL)
Set the createOrganizationErrorURL property.

Parameters:
pCreateOrganizationErrorUR -

getOrganizationName

public java.lang.String getOrganizationName()
The name of the organization that is going to be created

Returns:
organization name

setOrganizationName

public void setOrganizationName(java.lang.String pOrganizationName)
Set the OrganizationName property.

Parameters:
pOrganizationName -

getOrganizationDescription

public java.lang.String getOrganizationDescription()
The description of the organization that is going to be created

Returns:
the description of the organization that is about to be created

setOrganizationDescription

public void setOrganizationDescription(java.lang.String pOrganizationDescription)
Set the OrganizationDescription property.

Parameters:
pOrganizationDescription -

getParentOrganizationId

public java.lang.String getParentOrganizationId()
The id of the organization that will act as the parent for the newly created organization.

Returns:
id of the parent organization

setParentOrganizationId

public void setParentOrganizationId(java.lang.String pParentOrganizationId)
Set the ParentOrganizationId property.

Parameters:
pParentOrganizationId -

getRepositoryUserDirectory

public RepositoryUserDirectory getRepositoryUserDirectory()
References the userDirectory that will be used to create and manipulate organizations.

Returns:
the RepositoryUserDirectory

setRepositoryUserDirectory

public void setRepositoryUserDirectory(RepositoryUserDirectory pRepositoryUserDirectory)
Set the RepositoryUserDirectory property.

Parameters:
pRepositoryUserDirectory -

preCreateOrganization

public void preCreateOrganization(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
Called before any work is done by the handleCreateOrganization method. This currently does nothing.

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

postCreateOrganization

public void postCreateOrganization(DynamoHttpServletRequest pRequest,
                                   DynamoHttpServletResponse pResponse)
                            throws javax.servlet.ServletException,
                                   java.io.IOException
This is called after all work is done by the handleCreateOrganization method. This will first check to see if the createRelativeRoles method should be invoked by checking the createRelativeRoles property.

After creatRelativeRoles is optionally called, the method will see if the transaction is rolled back. If it is not then it will see if it should invoke the assignRelativeRoles by checking the assignRelativeRoles property.

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

createRelativeRoles

protected void createRelativeRoles(Organization pOrganization,
                                   DynamoHttpServletRequest pRequest,
                                   DynamoHttpServletResponse pResponse)
This method creates relative roles for a particular organization. An example of this is an organization might have a relativeRole such as Approver For Acme. That is, the user has the Approver funtion, but it is relative to the Acme organization.

This method creates relative roles by iterating through the list of functions listed in the functionNames property. This roles are created relative to the pOrganization parameter.

If an error is encountered, the transaction will be marked for rollback and a droplet exception will be generated.

Parameters:
pOrganization - organization for w2hich relative roles will be created
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value

assignRelativeRoles

protected void assignRelativeRoles(Organization pOrganization,
                                   DynamoHttpServletRequest pRequest,
                                   DynamoHttpServletResponse pResponse)
This method will assign relativeRoles to the user whose primary key is returned by the #getUserIdgetUserId method.

After the user is extracted from the userDirectory via the primaryKey, the values returned by the assignableFunctionNames method will be used to get relativeRoles from the organization and then assign them to the user.

Parameters:
pOrganization - the organization that the roles should be relative to
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value

handleCreateOrganization

public boolean handleCreateOrganization(DynamoHttpServletRequest pRequest,
                                        DynamoHttpServletResponse pResponse)
                                 throws javax.servlet.ServletException,
                                        java.io.IOException
This method is responsible for creating a new organization. This method acts as a controller method for invoking other methods in the correct order. It will invoke the preCreateOrganization, createOrganization, and postCreateOrganization methods.

If a form error is ever generated, the method will redirect to the createOrganizationErrorURL. After all processing is done by the form the form will redirect to either the createOrganizationErrorURL or the createOrganizationSuccessURL.

Parameters:
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value
Returns:
a boolean value
Throws:
javax.servlet.ServletException - if an error occurs
java.io.IOException - if an error occurs

createOrganization

protected void createOrganization(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
This method is responsible for creating a new organization. It will first check to make sure that the necessary information to create an organization is supplied. It will check the following properties:
  • orgNameRequired
  • orgDescriptionRequired
  • parentOrgRequired

If any of the above checks fail, a droplet exception will be generated specifying what piece of information was missing and will return from the method.

Next the organization will be created using the repositoryUserDirectory property. If an organization is successfully created, the setOrganization method will be called. Setting the organization for the remainder of the formhandlers lifetime allows later methods, such as the postCreateOrganization method to access the organization.

Parameters:
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value

addFormException

protected void addFormException(java.lang.String pErrorKey,
                                DynamoHttpServletRequest pRequest,
                                DynamoHttpServletResponse pResponse)
Adds a form exception to the formhandler. The exception that is generated is created using the pErrorKey to obtain a resource using the getStringResource method.

Parameters:
pErrorKey - the resource key
pRequest - a DynamoHttpServletRequest value
pResponse - a DynamoHttpServletResponse value

getLocale

protected java.util.Locale getLocale(DynamoHttpServletRequest pRequest,
                                     DynamoHttpServletResponse pResponse)
Returns either the Locale from the Request object (if it isn't NULL), or the Locale from the JVM.

Parameters:
pRequest - the servlet's request
Returns:
Either the Locale from the Request object, or the Locale from the JVM.

getStringResource

public java.lang.String getStringResource(java.lang.String pResourceName,
                                          java.util.Locale pLocale)
This method acts as a utility method to obtain a given resource for a particular key. This is used to lookup error messages for the users locale.

Parameters:
pResourceName - the resource key used to obtain the resource
pLocale - the users locale for which the resource bundle will be obtained.
Returns:
The String resource

setRollbackOnly

protected void setRollbackOnly()
This method will call the setRollbackTransaction method on the superclass. Indicating that the transaction should be rolled back.