org.alfresco.bm.user
Class CreateUser

java.lang.Object
  extended by org.alfresco.bm.event.AbstractEventProcessor
      extended by org.alfresco.bm.http.AuthenticatedHttpEventProcessor
          extended by org.alfresco.bm.user.CreateUser
All Implemented Interfaces:
EventProcessor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware

public class CreateUser
extends AuthenticatedHttpEventProcessor

Event processor that creates a test-user in the alfresco-system based on the username present in the event and inserts an entry in mongo.

Input

Username of user to create

Data

Collection containing users. User will be marked as created and alfresco node-id will be stored.

Actions

The user is created in alfresco through REST. An exception is thrown when user creation fails. When user already existed in alfresco when processed and 'ignoreExistingUsers' property is set to true, the event is considered processed successfuly instead of throwing an exception.

Output

No next event will be scheduled.

Since:
1.1
Author:
Frederik Heremans

Field Summary
static String PEOPLE_JSON_EMAIL
           
static String PEOPLE_JSON_FIRSTNAME
           
static String PEOPLE_JSON_LASTNAME
           
static String PEOPLE_JSON_NODEREF
           
static String PEOPLE_JSON_PASSWORD
           
static String PEOPLE_JSON_USERNAME
           
static String PEOPLE_PICKER_URL
          URL for getting a single cm:person object based on a username.
 
Fields inherited from class org.alfresco.bm.event.AbstractEventProcessor
DEFAULT_WARN_DELAY, logger
 
Constructor Summary
CreateUser(org.alfresco.http.HttpClientProvider httpClientProvider, org.alfresco.http.AuthenticationDetailsProvider authenticationDetailsProvider, String baseUrl, UserDataService userDataService)
           
 
Method Summary
 EventResult processEvent(Event event)
          Process an event.
 void setIgnoreExistingUsers(boolean ignoreExistingUsers)
           
 
Methods inherited from class org.alfresco.bm.http.AuthenticatedHttpEventProcessor
executeHttpMethodAsAdmin, executeHttpMethodAsUser, getAuthDetailProvider, getFullUrlForPath, getHttpProvider, releaseResources, setTicketBasedAuthentication
 
Methods inherited from class org.alfresco.bm.event.AbstractEventProcessor
getWarnDelay, register, setBeanName, setEventName, setEventNames, setRegistry, setWarnDelay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PEOPLE_PICKER_URL

public static final String PEOPLE_PICKER_URL
URL for getting a single cm:person object based on a username.

Parameters:
- The username. Be sure this name is unique and isn't part of another username. Eg. 'user1' and 'user12' will both appear when searching 'user1', with 'user12' as first result. This is not desirable so make sure usernames end with a constant, eg: 'user-1-' to have unique name-parts.

See Also:
Constant Field Values

PEOPLE_JSON_USERNAME

public static final String PEOPLE_JSON_USERNAME
See Also:
Constant Field Values

PEOPLE_JSON_FIRSTNAME

public static final String PEOPLE_JSON_FIRSTNAME
See Also:
Constant Field Values

PEOPLE_JSON_LASTNAME

public static final String PEOPLE_JSON_LASTNAME
See Also:
Constant Field Values

PEOPLE_JSON_EMAIL

public static final String PEOPLE_JSON_EMAIL
See Also:
Constant Field Values

PEOPLE_JSON_PASSWORD

public static final String PEOPLE_JSON_PASSWORD
See Also:
Constant Field Values

PEOPLE_JSON_NODEREF

public static final String PEOPLE_JSON_NODEREF
See Also:
Constant Field Values
Constructor Detail

CreateUser

public CreateUser(org.alfresco.http.HttpClientProvider httpClientProvider,
                  org.alfresco.http.AuthenticationDetailsProvider authenticationDetailsProvider,
                  String baseUrl,
                  UserDataService userDataService)
Method Detail

processEvent

public EventResult processEvent(Event event)
                         throws Exception
Description copied from interface: EventProcessor
Process an event.

NOTE: All errors are treated as terminal i.e. there will be no follow-up events published. The event and result services are provided to allow event processing to be aware of previous and future work. If the service is used to modify queues, the results could be unexpected e.g. clearing the queue will not always mean that no more events will be processed.

Parameters:
event - the event (along with associated data)
Returns:
the result of the process (includes errors and next events)
Throws:
Exception

setIgnoreExistingUsers

public void setIgnoreExistingUsers(boolean ignoreExistingUsers)
Parameters:
ignoreExistingUsers - whether or not to ignore existing users when creating. If set to true the event will be successful when executed. If set to false, an exception will be thrown when user already exists.


Copyright © 2012. All Rights Reserved.