src/com/vehiclerental/presentationLayer/headOffice/StaffHeadOfficeController.java
/**
     * Search user accounts matching the given criteria (the staff accounts won't be returned)
     *
     * @param request the request parameters
     * @return the result response
     */
Search user accounts matching the given criteria (the staff accounts won't be returned)
@param request the request parameters
@return the result response
Search user accounts matching the given criteria ( the staff accounts won ' t be returned ) @param request the request parameters @return the result response
public static HeadOfficeResponseMessage HandleSearchUser(HeadOfficeRequestMessage request) {
        SearchUserContract searchUserContract = SerializationUtils.deserialize(request.SerializedObject, SearchUserContract.class);
        if (searchUserContract == null) {
            return generateError(request.OperationCode, 400, "Bad request");
        }
        try {
            doAuthentication(request.getAuthEmail(), request.getAuthPassword(), true);
            /* Service calls */
            UserService userService = ServiceFactory.getUserService();
            List<User> users = userService.searchUser(searchUserContract);
            List<UserContract> userContracts = new ArrayList<UserContract>();
            for (User user : users) {
                userContracts.add(new UserContract(user));
            }
            return generateSuccessfulResponse(request.OperationCode, userContracts);
        } 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 HandleSearchUser ( HeadOfficeRequestMessage request ) { SearchUserContract searchUserContract = SerializationUtils . deserialize ( request . SerializedObject , SearchUserContract . class ) ; if ( searchUserContract == null ) { return generateError ( request . OperationCode , 400 , "Bad request" ) ; } try { doAuthentication ( request . getAuthEmail ( ) , request . getAuthPassword ( ) , true ) ; /* Service calls */ UserService userService = ServiceFactory . getUserService ( ) ; List < User > users = userService . searchUser ( searchUserContract ) ; List < UserContract > userContracts = new ArrayList < UserContract > ( ) ; for ( User user : users ) { userContracts . add ( new UserContract ( user ) ) ; } return generateSuccessfulResponse ( request . OperationCode , userContracts ) ; } 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" ) ; } }
Search user accounts matching the given criteria (the staff accounts won't be returned)
 @param request the request parameters
 @return the result response
Search user accounts matching the given criteria ( the staff accounts won ' t be returned ) @param request the request parameters @return the result response
//Form socket response