Changeset 448 for tapas/web


Ignore:
Timestamp:
04/02/12 18:07:58 (12 years ago)
Author:
vmipsl
Message:

WebException? Backoffice

Location:
tapas/web/src/com/ether
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tapas/web/src/com/ether/ControllerBackoffice.java

    r418 r448  
    3030    /** *********************************************************** **/ 
    3131    /** *********************** VIEWS ***************************** **/ 
    32     /** *********************************************************** **/ 
     32    /** 
     33     * ********************************************************** * 
     34     */ 
    3335    @ControllerMethod(view = VIEW_BO_INDEX, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 
    3436    public Map<String, Object> home() 
    35             throws ServiceException 
     37            throws WebException 
    3638    { 
    3739        return new HashMap<String, Object>(); 
     
    4042    @ControllerMethod(view = VIEW_BO_USER, backofficeMethod = true, defaultView = VIEW_BO_INDEX, jsonResult = true) 
    4143    public JSONObject viewUser() 
    42             throws ServiceException, WebException 
     44            throws WebException 
    4345    { 
    4446        final JSONObject jsonObject = sortUser( "lastName", null, "ALL", true, true, 5, 1 ); 
     
    4951    /** *********************************************************** **/ 
    5052    /** *********************** CALLS ***************************** **/ 
    51     /** *********************************************************** **/ 
     53    /** 
     54     * ********************************************************** * 
     55     */ 
    5256    @ControllerMethod(jsonResult = true, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 
    5357    public JSONObject addUser( @NotNull @ParamName(ParameterConstants.PARAMETER_NAME) final String lastName, 
     
    5963                               @Nullable @ParamName(ParameterConstants.PARAMETER_COUNTRY) final String country, 
    6064                               @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO ) 
    61             throws WebException, ServiceException 
     65            throws WebException 
    6266    { 
    6367        try 
     
    8488            throw new WebException( WebException.WebCode.ERROR_ENCRYPT_PASSWORD, "This password cannot be encrypted" ); 
    8589        } 
     90        catch( ServiceException e ) 
     91        { 
     92            throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 
     93        } 
    8694 
    8795        return getAllUsers(); 
     
    9098    @ControllerMethod(jsonResult = true, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 
    9199    public JSONObject removeUser( @NotNull @ParamName(ParameterConstants.PARAMETER_ID) final Integer userId ) 
    92             throws WebException, ServiceException 
    93     { 
    94         _backofficeService.removeUserById( userId ); 
    95  
    96         return getAllUsers(); 
     100            throws WebException 
     101    { 
     102        try 
     103        { 
     104            _backofficeService.removeUserById( userId ); 
     105            return getAllUsers(); 
     106        } 
     107        catch( ServiceException e ) 
     108        { 
     109            throw new WebException( WebException.WebCode.ERROR_TO_REMOVE_USER, e ); 
     110        } 
    97111    } 
    98112 
     
    108122                                  @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO, 
    109123                                  @NotNull @ParamName(ParameterConstants.PARAMETER_KEEP_SAME_PASSWORD) final Boolean keepSamePassword ) 
    110             throws WebException, ServiceException 
     124            throws WebException 
    111125    { 
    112126        try 
     
    142156            throw new WebException( WebException.WebCode.ERROR_ENCRYPT_PASSWORD, "This password cannot be encrypted" ); 
    143157        } 
     158        catch( ServiceException e ) 
     159        { 
     160            throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 
     161        } 
    144162 
    145163        return getAllUsers(); 
     
    154172                                @ParamName(ParameterConstants.PARAMETER_MAX_RESULTS) final Integer maxResults, 
    155173                                @ParamName(ParameterConstants.PARAMETER_PAGE) final Integer page ) 
    156             throws WebException, ServiceException 
    157     { 
    158         final UserFilter filter = new UserFilter( sort, searchText, sortAccessBoFalse, sortAccessBoTrue, maxResults, page ); 
    159         if( !"ALL".equals( sortRole ) ) 
    160             filter.setSortRole( UserRole.valueOf( sortRole ) ); 
    161  
    162         final PaginatedResult<User> users = _backofficeService.searchUsers( filter ); 
    163  
    164         final JSONObject result = new JSONObject(); 
    165         result.put( "jSonUsers", getJsonHelper().toJSON( users.getPaginatedResults() ) ); 
    166         result.put( "usersNumber", users.getTotalCount() ); 
    167         return result; 
     174            throws WebException 
     175    { 
     176        try 
     177        { 
     178            final UserFilter filter = new UserFilter( sort, searchText, sortAccessBoFalse, sortAccessBoTrue, maxResults, page ); 
     179            if( !"ALL".equals( sortRole ) ) 
     180                filter.setSortRole( UserRole.valueOf( sortRole ) ); 
     181 
     182            final PaginatedResult<User> users = _backofficeService.searchUsers( filter ); 
     183 
     184            final JSONObject result = new JSONObject(); 
     185            result.put( "jSonUsers", getJsonHelper().toJSON( users.getPaginatedResults() ) ); 
     186            result.put( "usersNumber", users.getTotalCount() ); 
     187            return result; 
     188        } 
     189        catch( ServiceException e ) 
     190        { 
     191            throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 
     192        } 
    168193    } 
    169194 
    170195    private JSONObject getAllUsers() 
    171             throws ServiceException 
    172     { 
    173         final List<User> users = _backofficeService.getAllUsersByNameOrder(); 
    174  
    175         final JSONObject result = new JSONObject(); 
    176         result.put( "jSonUsers", getJsonHelper().toJSON( users ) ); 
    177         return result; 
     196            throws WebException 
     197    { 
     198        try 
     199        { 
     200            final List<User> users = _backofficeService.getAllUsersByNameOrder(); 
     201 
     202            final JSONObject result = new JSONObject(); 
     203            result.put( "jSonUsers", getJsonHelper().toJSON( users ) ); 
     204            return result; 
     205        } 
     206        catch( ServiceException e ) 
     207        { 
     208            throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 
     209        } 
     210 
    178211    } 
    179212 
  • tapas/web/src/com/ether/WebException.java

    r447 r448  
    4545        ERROR_ENCRYPT_PASSWORD, 
    4646        ERROR_EMAIL_CANNOT_BE_SEND, 
    47               ERROR_NO_OBSERVATORY_FOUND, 
    4847        ERROR_XML_CREATION, 
    49         ERROR_TO_READ_FILE_PROPERTIES 
     48        ERROR_NO_OBSERVATORY_FOUND, 
     49        ERROR_NO_USER_FOUND, 
     50        ERROR_TO_READ_FILE_PROPERTIES, 
     51        ERROR_TO_REMOVE_USER 
    5052    } 
    5153 
Note: See TracChangeset for help on using the changeset viewer.