Project

General

Profile

« Previous | Next » 

Revision 48572

use the email from the userinfo

View differences:

HelloWorldService.java
583 583
        }
584 584

  
585 585
        logger.debug("Trying to delete claims with ids: " + claimIds.toString() + ".");
586

  
586
        UserInfo userInfo = authorization.getUserHandler().getUserInfo(token);
587 587
        for (String claimId : claimIds) {
588 588
            try {
589 589

  
590
                if (authorization.isRegistered(token)) {
591
                    if (authorization.isAdmin(token) || authorization.getUserHandler().getMail(token).equals(fetchClaimHandler.fetchClaimById(claimId,false).getUserMail())) {
590
                if (authorization.isRegistered(userInfo)) {
591
                    if (authorization.isAdmin(userInfo) || userInfo.getEmail().equals(fetchClaimHandler.fetchClaimById(claimId,false).getUserMail())) {
592 592
                        if (claimHandler.deleteClaim(claimId)) {
593 593
                            deletedIds.add(claimId);
594 594
                        } else {
......
815 815
                    .type(MediaType.APPLICATION_JSON)
816 816
                    .build();
817 817
        }
818

  
819
        if (authorization.isRegistered(token)) {
818
        UserInfo userInfo = authorization.getUserHandler().getUserInfo(token);
819
        if (authorization.isRegistered(userInfo)) {
820 820
            ArrayList<String> insertedIds = new ArrayList<String>();
821 821
            JsonArray errorInClaims = new JsonArray();
822 822
            int code200 = 0;
823 823
            int code400 = 0;
824 824
            int code500 = 0;
825 825
            JsonArray jsonArray = new JsonParser().parse(input).getAsJsonArray();
826
            String curatedBy = authorization.getUserHandler().getMail(token);
826
            String curatedBy =userInfo.getEmail();
827 827

  
828 828
            for (JsonElement je : jsonArray) {
829 829
                JsonObject jsonObject = je.getAsJsonObject();
......
1038 1038
    }
1039 1039

  
1040 1040
    private String compose404BulkDeleteMessage(String message, List<String> deletedIds, List<String> notFoundIds) {
1041
        return  "{ \"status\" : \"error\", \"code\" : \"404\", \"message\" : \"  " + message +" \""+  "\"deletedIds\" : " + new Gson().toJson(deletedIds) +","+  "\"notFoundIds\" : " + new Gson().toJson(notFoundIds) + " }";
1041
        return  "{ \"status\" : \"error\", \"code\" : \"404\", \"message\" : \"  " + message +" \","+  "\"deletedIds\" : " + new Gson().toJson(deletedIds) +","+  "\"notFoundIds\" : " + new Gson().toJson(notFoundIds) + " }";
1042 1042
    }
1043 1043
    private String compose404Message(String message) {
1044 1044
        return  "{ \"status\" : \"error\", \"code\" : \"404\", \"message\" : \"  " + message +" \" }";

Also available in: Unified diff