Project

General

Profile

« Previous | Next » 

Revision 8561

Fixed bug where sync'ing not working when CN had more access rules than MN

View differences:

src/edu/ucsb/nceas/metacat/dataone/SyncAccessPolicy.java
61 61
import edu.ucsb.nceas.metacat.AccessionNumberException;
62 62
import edu.ucsb.nceas.metacat.IdentifierManager;
63 63
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
64
import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException;
64 65
import edu.ucsb.nceas.metacat.dataone.D1NodeService;
65 66
import edu.ucsb.nceas.metacat.properties.PropertyService;
66 67
import edu.ucsb.nceas.metacat.shared.ServiceException;
......
116 117
		SystemMetadata cnSysMeta = null;
117 118
		SystemMetadata mnSysMeta = null;
118 119

  
119
		CNode cn = D1Client.getCN();
120
		CNode cn = null;
121
		
122
		try {
123
			cn = D1Client.getCN();
124
		} catch (ServiceFailure sf) {
125
			logMetacat.error("Unable to get Coordinating node name for this MN");
126
			throw new AccessControlException ("Unable to get Coordinating node name for this MN");
127
		}
120 128

  
121
		logMetacat.debug("start: " + objList.getStart() + "count: "
122
				+ objList.getCount());
123 129
		for (int i = objList.getStart(); i < objList.getCount(); i++) {
124 130

  
125 131
			objInfo = objList.getObjectInfo(i);
......
162 168
			if (!isEqual(mnAccessPolicy, cnAccessPolicy)) {
163 169
				try {
164 170
					BigInteger serialVersion = cnSysMeta.getSerialVersion();
165
					logMetacat.debug("Setting access policy from CN for pid: "
166
							+ pid.getValue() + "serial version: "
171
					logMetacat.debug("Requesting CN to set access policy for pid: "
172
							+ pid.getValue() + ", serial version: "
167 173
							+ serialVersion.toString());
168 174
					cn.setAccessPolicy(session, pid, mnAccessPolicy,
169 175
							serialVersion.longValue());
......
192 198
					throw e;
193 199
				}
194 200
			}
195
			logMetacat.debug("Done with pid: " + pid.getValue());
201
			logMetacat.debug("Done syncing access policy for pid: " + pid.getValue());
196 202
		}
197 203

  
198 204
		return syncedIds;
......
348 354
			}
349 355
		}
350 356

  
351
		// Now perform the comparison. This test assumes that the mn perms are
352
		// more
353
		// complete than the cn perms.
357
		// Check if the number of access rules is the same for mn and cn. If not
358
		// then consider them not equal, without performing diff of each access rule.
359
		if (userPerms1.entrySet().size() != userPerms2.entrySet().size())
360
			return false;
361
		
362
		// Now perform the comparison of each access rule of access policy 1 to ap 2.
363
		// This test assumes that the mn perms are more complete than the cn perms.
354 364
		logMetacat.debug("Performing comparison of access policies");
355 365
		for (Map.Entry<Subject, Set<Permission>> entry : userPerms1.entrySet()) {
356 366
			// User name

Also available in: Unified diff