Project

General

Profile

« Previous | Next » 

Revision 6744

refactor Metacat access handling to be on a per-revision basis so that it more closely aligns with the DataONE approach
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5560

View differences:

DocumentImpl.java
1268 1268
                    // if it is inline data first to get the inline data
1269 1269
                    // internal id
1270 1270
                    String fileName = currentNode.getNodeData();
1271
                    String accessfileName = 
1272
                    	DocumentUtil.getDocIdWithoutRevFromInlineDataID(fileName);
1271
                    // use full docid with revision
1272
                    String accessfileName = fileName; //DocumentUtil.getDocIdWithoutRevFromInlineDataID(fileName);
1273
                    
1273 1274
                    // check if user has read permision for this inline data
1274 1275
                    boolean readInlinedata = false;
1275 1276
                    try {
1276 1277
                        Hashtable<String, String> unReadableInlineDataList =
1277
                            PermissionController
1278
                                .getUnReadableInlineDataIdList(accessfileName,
1279
                                        user, groups, true);
1278
                            PermissionController.getUnReadableInlineDataIdList(accessfileName, user, groups);
1280 1279
                        if (!unReadableInlineDataList.containsValue(fileName)) {
1281 1280
                            readInlinedata = true;
1282 1281
                        }
......
1417 1416
			
1418 1417
			// get a list of inline data sections that are not readable
1419 1418
			// by this user
1419
			String fullDocid = docid + "." + rev;
1420 1420
            Hashtable<String, String> unReadableInlineDataList =
1421
                PermissionController
1422
                    .getUnReadableInlineDataIdList(docid,
1423
                            user, groups, true);
1421
                PermissionController.getUnReadableInlineDataIdList(fullDocid, user, groups);
1424 1422
            
1425 1423
            // If this is for each unreadable section, strip the inline data
1426 1424
			// from the doc
......
2753 2751
        }
2754 2752

  
2755 2753
        if (action.equals("UPDATE")) {
2756
            // check for 'write' permission for 'user' to update this document
2757
            if (!hasWritePermission(user, groups, accnum) 
2754
			// check for 'write' permission for 'user' to update this document
2755
        	// use the previous revision to check the permissions
2756
            String docIdWithoutRev = DocumentUtil.getSmartDocId(accnum);
2757
        	int latestRev = DBUtil.getLatestRevisionInDocumentTable(docIdWithoutRev);
2758
        	String latestDocId = docIdWithoutRev + "." + latestRev;
2759
            if (!hasWritePermission(user, groups, latestDocId) 
2758 2760
            		&& !AuthUtil.isAdministrator(user, groups)) {
2759 2761
                throw new Exception(
2760 2762
                    "User " + user
2761 2763
                    + " does not have permission to update XML Document #"
2762
                    + accnum); }
2764
                    + latestDocId); }
2763 2765
        }
2764 2766
        XMLReader parser = null;
2765 2767
        try {
......
3267 3269
            
3268 3270
            // Now delete it from xml_access table
3269 3271
            /*************** DO NOT DELETE ACCESS - need to archive this ******************/
3270
//            pstmt = conn.prepareStatement(
3271
//                    "DELETE FROM xml_access WHERE accessfileid = ?");
3272
//            pstmt.setString(1, docid);
3273
//            logMetacat.debug("DocumentImpl.delete - executing SQL: " + pstmt.toString());
3274
//            pstmt.execute();
3275
//            pstmt.close();
3276
//            conn.increaseUsageCount(1);
3277
//            double afterDeleteXmlAccess1 = System.currentTimeMillis()/1000;
3278
//            logMetacat.info("DocumentImpl.delete - The deleting xml_access base one accessfileid time is "+(afterDeleteXmlAccess1 - afterDeleteIndex ));
3279
//            pstmt = conn.prepareStatement(
3280
//                    "DELETE FROM xml_access WHERE docid = ?");
3281
//            pstmt.setString(1, docid);
3282
//            logMetacat.debug("DocumentImpl.delete - executing SQL: " + pstmt.toString());
3283
//            pstmt.execute();
3284
//            pstmt.close();
3285
//            conn.increaseUsageCount(1);
3286 3272
            double afterDeleteXmlAccess2 = System.currentTimeMillis()/1000;
3287
//            logMetacat.info("DocumentImpl.delete - The deleting xml_access base on docid time is "+(afterDeleteXmlAccess2 - afterDeleteXmlAccess1 ));
3288
            /******* END DELETE ACCESS *************/
3273
            /******* END DELETE ACCESS *************/            
3274
            // Delete enteries from xml_queryresult
3289 3275

  
3290
            
3291
            // Delete enteries from xml_queryresult
3292
//            pstmt = conn.prepareStatement(
3293
//                    "DELETE FROM xml_queryresult WHERE docid = ?");
3294
//            pstmt.setString(1, docid);
3295
//            logMetacat.debug("DocumentImpl.delete - running sql: " + pstmt.toString());
3296
//            pstmt.execute();
3297
//            pstmt.close();
3298
//            conn.increaseUsageCount(1);
3299 3276
            try {
3300 3277
                XMLQueryresultAccess xmlQueryresultAccess = new XMLQueryresultAccess();
3301 3278
                xmlQueryresultAccess.deleteXMLQueryresulForDoc(docid);

Also available in: Unified diff