- Timestamp:
- 04/02/12 18:07:58 (12 years ago)
- Location:
- tapas/web/src/com/ether
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/src/com/ether/ControllerBackoffice.java
r418 r448 30 30 /** *********************************************************** **/ 31 31 /** *********************** VIEWS ***************************** **/ 32 /** *********************************************************** **/ 32 /** 33 * ********************************************************** * 34 */ 33 35 @ControllerMethod(view = VIEW_BO_INDEX, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 34 36 public Map<String, Object> home() 35 throws ServiceException37 throws WebException 36 38 { 37 39 return new HashMap<String, Object>(); … … 40 42 @ControllerMethod(view = VIEW_BO_USER, backofficeMethod = true, defaultView = VIEW_BO_INDEX, jsonResult = true) 41 43 public JSONObject viewUser() 42 throws ServiceException,WebException44 throws WebException 43 45 { 44 46 final JSONObject jsonObject = sortUser( "lastName", null, "ALL", true, true, 5, 1 ); … … 49 51 /** *********************************************************** **/ 50 52 /** *********************** CALLS ***************************** **/ 51 /** *********************************************************** **/ 53 /** 54 * ********************************************************** * 55 */ 52 56 @ControllerMethod(jsonResult = true, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 53 57 public JSONObject addUser( @NotNull @ParamName(ParameterConstants.PARAMETER_NAME) final String lastName, … … 59 63 @Nullable @ParamName(ParameterConstants.PARAMETER_COUNTRY) final String country, 60 64 @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO ) 61 throws WebException , ServiceException65 throws WebException 62 66 { 63 67 try … … 84 88 throw new WebException( WebException.WebCode.ERROR_ENCRYPT_PASSWORD, "This password cannot be encrypted" ); 85 89 } 90 catch( ServiceException e ) 91 { 92 throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 93 } 86 94 87 95 return getAllUsers(); … … 90 98 @ControllerMethod(jsonResult = true, backofficeMethod = true, defaultView = VIEW_BO_INDEX) 91 99 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 } 97 111 } 98 112 … … 108 122 @NotNull @ParamName(ParameterConstants.PARAMETER_HAS_ACCESS) final Boolean hasAccessToBO, 109 123 @NotNull @ParamName(ParameterConstants.PARAMETER_KEEP_SAME_PASSWORD) final Boolean keepSamePassword ) 110 throws WebException , ServiceException124 throws WebException 111 125 { 112 126 try … … 142 156 throw new WebException( WebException.WebCode.ERROR_ENCRYPT_PASSWORD, "This password cannot be encrypted" ); 143 157 } 158 catch( ServiceException e ) 159 { 160 throw new WebException( WebException.WebCode.ERROR_NO_USER_FOUND, e ); 161 } 144 162 145 163 return getAllUsers(); … … 154 172 @ParamName(ParameterConstants.PARAMETER_MAX_RESULTS) final Integer maxResults, 155 173 @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 } 168 193 } 169 194 170 195 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 178 211 } 179 212 -
tapas/web/src/com/ether/WebException.java
r447 r448 45 45 ERROR_ENCRYPT_PASSWORD, 46 46 ERROR_EMAIL_CANNOT_BE_SEND, 47 ERROR_NO_OBSERVATORY_FOUND,48 47 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 50 52 } 51 53
Note: See TracChangeset
for help on using the changeset viewer.