Changeset 4253


Ignore:
Timestamp:
01/10/14 17:27:49 (10 years ago)
Author:
olhsha
Message:

adding, updating, deleting a user (only for a user with admin rights)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/UserResource.java

    r4252 r4253  
    141141    @Consumes(MediaType.APPLICATION_XML)
    142142    @Produces(MediaType.APPLICATION_XML)
    143     @Path("{remoteId: " + BackendConstants.regExpRemoteId+ "}")
     143    @Path("{remoteId: " + BackendConstants.regExpRemoteId + "}")
    144144    public JAXBElement<User> addUser(@PathParam("remoteId") String remoteId, User user) throws SQLException, IOException {
    145145        final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(httpServletRequest.getRemoteUser());
     
    149149                final Number userID = dbIntegrityService.addUser(user, remoteId);
    150150                if (userID != null) {
    151                 final User addedUser = dbIntegrityService.getUser(userID);
    152                 return new ObjectFactory().createUser(addedUser);
    153                 }
    154                 else {
     151                    final User addedUser = dbIntegrityService.getUser(userID);
     152                    return new ObjectFactory().createUser(addedUser);
     153                } else {
    155154                    httpServletResponse.sendError(HttpServletResponse.SC_CONFLICT, "The user with the given e-mail already exists in the database");
    156155                    return null;
     
    193192    }
    194193
    195    
    196    
    197194    @DELETE
    198195    @Path("{userId: " + BackendConstants.regExpRemoteId + "}")
     
    205202                if (userID != null) {
    206203                    final Integer result = dbIntegrityService.deleteUser(userID);
    207                     return "There is "+ result.toString()+" row deleted";
     204                    return "There is " + result.toString() + " row deleted";
    208205                } else {
    209206                    httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "The user with the given id is not found in the database");
     
    219216        }
    220217    }
    221     }
    222    
    223    
    224    
    225    
     218
    226219    private boolean ifLoggedIn(Number userID) {
    227220        return httpServletRequest.getRemoteUser().equals(dbIntegrityService.getUserRemoteID(userID));
Note: See TracChangeset for help on using the changeset viewer.