Project

General

Profile

« Previous | Next » 

Revision 2429

Added by sgarg over 19 years ago

Added code so that metacat administrator can delete any document.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
2404 2404

  
2405 2405
            MetaCatUtil.debugMessage("Start deleting doc " + docid + "...", 20);
2406 2406
            // check for 'write' permission for 'user' to delete this document
2407
            if (!hasAllPermission(user, groups, accnum)) { throw new Exception(
2408
                    "User " + user
2409
                    + " does not have permission to delete XML Document #"
2410
                    + accnum); }
2407
            if (!hasAllPermission(user, groups, accnum)) {
2408
                boolean adminIsAuthenticated = false;
2409
                String[] administrators = null;
2410
                String adminList = MetaCatUtil.getOption("administrators");
2411
                try {
2412
                    administrators = adminList.split(":");
2413
                } catch (Exception pse) {
2414
                    administrators = null;
2415
                    MetaCatUtil.debugMessage("Error in DocumentImpl.delete: "
2416
                                             + pse.getMessage(), 20);
2417
                }
2418
                for (int i = 0; i < administrators.length; i++) {
2419
                    if (user.equals(administrators[i])) {
2420
                        adminIsAuthenticated = true;
2421
                    }
2422
                }
2411 2423

  
2424
                if(!adminIsAuthenticated){
2425
                    throw new Exception(
2426
                        "User " + user
2427
                        + " does not have permission to delete XML Document #"
2428
                        + accnum);
2429
                }
2430
            }
2431

  
2412 2432
            conn.setAutoCommit(false);
2413 2433
            // Copy the record to the xml_revisions table
2414 2434
            DocumentImpl.archiveDocRevision(conn, docid, user);

Also available in: Unified diff