Project

General

Profile

« Previous | Next » 

Revision 8634

look up guid when done setting access by docid so we can sync and refresh accesspolicy on MN and CN.

View differences:

MetacatHandler.java
3575 3575
                    accessControl.insertPermissions(principal, 
3576 3576
                      Integer.valueOf(AccessControlList.intValue(permission)).longValue(), 
3577 3577
                      permType, permOrder, null, null);
3578
                    
3579
                    // refresh using guid
3580
                    guid = accessionNumber;
3581
                    try {
3582
          	             String tempDocid = DocumentUtil.getDocIdFromAccessionNumber(accessionNumber);
3583
          	             int rev = DocumentUtil.getRevisionFromAccessionNumber(accessionNumber);
3584
          	             guid = IdentifierManager.getInstance().getGUID(tempDocid, rev);
3585
                      	 logMetacat.debug("Found pid: " + guid);
3586
                    } catch (Exception e) {
3587
                       	logMetacat.warn("Error looking up pid for [assumed] docid: " + accessionNumber);
3588
                    }
3589
                    
3590
            		// force hazelcast to refresh system metadata
3591
                    HazelcastService.getInstance().refreshSystemMetadataEntry(guid);
3592
                    
3593
                    logMetacat.debug("Synching CN access policy for pid: " + guid);
3594

  
3595
        			try {
3596
        				ArrayList<String> guids = new ArrayList<String>(Arrays.asList(guid));
3597
        				SyncAccessPolicy syncAP = new SyncAccessPolicy();
3598
        				logMetacat.debug("Trying to syncing access policy for pid: " + guid);
3599
        				syncAP.sync(guids);
3600
        			} catch (Exception e) {
3601
        				logMetacat.error("Error syncing pids: " + guid
3602
        						+ " Exception " + e.getMessage(), e);
3603
        			}
3578 3604
                } catch (Exception ee) {
3579 3605
                    logMetacat.error("MetacatHandler.handleSetAccessAction - " +
3580 3606
                    		         "Error inserting permission: " + 
3581
                    		         ee.getMessage());
3582
                    ee.printStackTrace(System.out);
3607
                    		         ee.getMessage(), ee);
3583 3608
                    error = "Failed to set access control for document "
3584 3609
                            + accessionNumber + " because " + ee.getMessage();
3585 3610
                    errorList.addElement(error);
3586 3611
                    continue;
3587 3612
                }
3588 3613
            }
3589
            // force hazelcast to update system metadata
3590
            HazelcastService.getInstance().refreshSystemMetadataEntry(guid);
3591 3614
            
3592
            logMetacat.debug("Setting CN access policy for pid: " + guid);
3593 3615

  
3594
			try {
3595
				ArrayList<String> guids = new ArrayList<String>(Arrays.asList(guid));
3596
				SyncAccessPolicy syncAP = new SyncAccessPolicy();
3597

  
3598
				logMetacat.debug("Trying to syncing access policy for pids: "
3599
						+ guid);
3600
				syncAP.sync(guids);
3601
			} catch (Exception e) {
3602
				logMetacat.error("Error syncing pids: " + guid
3603
						+ " Exception " + e.getMessage());
3604
                e.printStackTrace(System.out);
3605
			}
3606

  
3607 3616
            //force replication when this action is called
3608 3617
            boolean isXml = true;
3609 3618
            if (publicId.equalsIgnoreCase("BIN")) {

Also available in: Unified diff