Project

General

Profile

« Previous | Next » 

Revision 2558

Added by sgarg over 18 years ago

Added new methods to MetaCatUtil: isAdministrator and isModerator.

These methods are used to check if a given username is part of the admin and moderator list specified in metacat.properties

Modified DocumentImpl and MetaCatServlet to use these functions.

View differences:

DocumentImpl.java
2520 2520
            MetaCatUtil.debugMessage("Start deleting doc " + docid + "...", 20);
2521 2521
            // check for 'write' permission for 'user' to delete this document
2522 2522
            if (!hasAllPermission(user, groups, accnum)) {
2523
                boolean adminIsAuthenticated = false;
2524
                String[] administrators = null;
2525
                String adminList = MetaCatUtil.getOption("administrators");
2526
                try {
2527
                    administrators = adminList.split(":");
2528
                } catch (Exception pse) {
2529
                    administrators = null;
2530
                    MetaCatUtil.debugMessage("Error in DocumentImpl.delete: "
2531
                                             + pse.getMessage(), 20);
2532
                }
2533
                for (int i = 0; i < administrators.length; i++) {
2534
                    if (user.equals(administrators[i])) {
2535
                        adminIsAuthenticated = true;
2536
                    }
2537
                }
2538

  
2539
                if(!adminIsAuthenticated){
2523
                if(!MetaCatUtil.isAdministrator(user, groups)){
2540 2524
                    throw new Exception(
2541 2525
                        "User " + user
2542 2526
                        + " does not have permission to delete XML Document #"

Also available in: Unified diff