src/com/vehiclerental/presentationLayer/headOffice/StaffHeadOfficeController.java
/**
     * Create an user with the given properties
     *
     * @param request the request parameters
     * @return the result response
     */
Create an user with the given properties
@param request the request parameters
@return the result response
Create an user with the given properties @param request the request parameters @return the result response
public static HeadOfficeResponseMessage HandleCreateUser(HeadOfficeRequestMessage request) {
        CreateAccountRequestContract createAccountRequestContract = SerializationUtils.deserialize(request.SerializedObject, CreateAccountRequestContract.class);
        if (createAccountRequestContract == null) {
            return generateError(request.OperationCode, 400, "Bad request");
        }
        try {
            doAuthentication(request.getAuthEmail(), request.getAuthPassword(), true);
            /* Service calls */
            UserService userService = ServiceFactory.getUserService();
            User user = userService.createUser(createAccountRequestContract);
            return generateSuccessfulResponse(request.OperationCode, new UserContract(user));
        } catch (EmailAlreadyInUseException e) {
            return generateError(request.OperationCode, 400, "Email already in use");
        } catch (InvalidPropertyException e) {
            return generateError(request.OperationCode, 400, e.getMessage());
        } catch (DatabaseAccessFailedException e) {
            return generateError(request.OperationCode, 500, "Server error");
        } catch (NotAuthorizedException e) {
            return generateError(request.OperationCode, 401, "Unauthorized");
        }
    }
public static HeadOfficeResponseMessage HandleCreateUser ( HeadOfficeRequestMessage request ) { CreateAccountRequestContract createAccountRequestContract = SerializationUtils . deserialize ( request . SerializedObject , CreateAccountRequestContract . class ) ; if ( createAccountRequestContract == null ) { return generateError ( request . OperationCode , 400 , "Bad request" ) ; } try { doAuthentication ( request . getAuthEmail ( ) , request . getAuthPassword ( ) , true ) ; /* Service calls */ UserService userService = ServiceFactory . getUserService ( ) ; User user = userService . createUser ( createAccountRequestContract ) ; return generateSuccessfulResponse ( request . OperationCode , new UserContract ( user ) ) ; } catch ( EmailAlreadyInUseException e ) { return generateError ( request . OperationCode , 400 , "Email already in use" ) ; } catch ( InvalidPropertyException e ) { return generateError ( request . OperationCode , 400 , e . getMessage ( ) ) ; } catch ( DatabaseAccessFailedException e ) { return generateError ( request . OperationCode , 500 , "Server error" ) ; } catch ( NotAuthorizedException e ) { return generateError ( request . OperationCode , 401 , "Unauthorized" ) ; } }
Create an user with the given properties
 @param request the request parameters
 @return the result response
Create an user with the given properties @param request the request parameters @return the result response
//Form socket response