Project

General

Profile

« Previous | Next » 

Revision 9249

Added by Jing Tao almost 9 years ago

Use the NodeReference object to replace the replicaStatus to restrict the listObjects method.

View differences:

src/edu/ucsb/nceas/metacat/IdentifierManager.java
1682 1682
     * @param startTime
1683 1683
     * @param endTime
1684 1684
     * @param objectFormat
1685
     * @param replicaStatus
1685
     * @param nodeId
1686 1686
     * @param start
1687 1687
     * @param count
1688 1688
     * @return ObjectList
......
1691 1691
     * @throws PropertyNotFoundException 
1692 1692
     */
1693 1693
    public ObjectList querySystemMetadata(Date startTime, Date endTime,
1694
        ObjectFormatIdentifier objectFormatId, boolean replicaStatus,
1694
        ObjectFormatIdentifier objectFormatId, NodeReference nodeId,
1695 1695
        int start, int count, Identifier identifier, boolean isSID) 
1696 1696
        throws SQLException, PropertyNotFoundException, ServiceException {
1697 1697
        ObjectList ol = new ObjectList();
......
1756 1756
                f4 = true;
1757 1757
            }
1758 1758

  
1759
            if (!replicaStatus) {
1759
            /*if (!replicaStatus) {
1760 1760
                String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId");
1761 1761
                if (!f1 && !f2 && !f3 && !f4) {
1762 1762
                    whereClauseSql += " where authoritive_member_node = '" +
......
1765 1765
                    whereClauseSql += " and authoritive_member_node = '" +
1766 1766
                        currentNodeId.trim() + "'";
1767 1767
                }
1768
            }*/
1769
            
1770
            if (nodeId != null && nodeId.getValue() != null && !nodeId.getValue().trim().equals("")) {
1771
                if (!f1 && !f2 && !f3 && !f4) {
1772
                    whereClauseSql += " where authoritive_member_node = '" +
1773
                        nodeId.getValue().trim() + "'";
1774
                } else {
1775
                    whereClauseSql += " and authoritive_member_node = '" +
1776
                        nodeId.getValue().trim() + "'";
1777
                }
1768 1778
            }
1769
            
1770 1779
           
1771 1780
            
1772 1781
            // connection
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
2035 2035
      Integer start, Integer count)
2036 2036
      throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented,
2037 2037
      ServiceFailure {
2038
      boolean replicaStatus= true;
2039
      return super.listObjects(session, startTime, endTime, formatid, identifier, replicaStatus, start, count);
2038

  
2039
      return super.listObjects(session, startTime, endTime, formatid, identifier, nodeId, start, count);
2040 2040
  }
2041 2041

  
2042 2042
  
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1539 1539
   * @throws InvalidRequest
1540 1540
   * @throws NotImplemented
1541 1541
   */
1542
  public ObjectList listObjects(Session session, Date startTime, Date endTime, ObjectFormatIdentifier objectFormatId, Identifier identifier, Boolean replicaStatus, Integer start,
1542
  public ObjectList listObjects(Session session, Date startTime, Date endTime, ObjectFormatIdentifier objectFormatId, Identifier identifier, NodeReference nodeId, Integer start,
1543 1543
          Integer count) throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken {
1544 1544

  
1545 1545
      ObjectList objectList = null;
......
1553 1553
          if(identifier != null) {
1554 1554
              isSid = IdentifierManager.getInstance().systemMetadataSIDExists(identifier);
1555 1555
          }
1556
          objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime, objectFormatId, replicaStatus, start, count, identifier, isSid);
1556
          objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime, objectFormatId, nodeId, start, count, identifier, isSid);
1557 1557
      } catch (Exception e) {
1558 1558
          throw new ServiceFailure("1580", "Error querying system metadata: " + e.getMessage());
1559 1559
      }
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
928 928
    @Override
929 929
    public ObjectList listObjects(Session session, Date startTime, Date endTime, ObjectFormatIdentifier objectFormatId, Identifier identifier, Boolean replicaStatus, Integer start,
930 930
            Integer count) throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken {
931

  
932
        return super.listObjects(session, startTime, endTime, objectFormatId, identifier, replicaStatus, start, count);
931
        NodeReference nodeId = null;
932
        if(!replicaStatus) {
933
            //not include those objects whose authoritative node is not this mn
934
            nodeId = new NodeReference();
935
            try {
936
                String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId"); // return only pids for which this mn
937
                nodeId.setValue(currentNodeId);
938
            } catch(Exception e) {
939
                throw new ServiceFailure("1580", e.getMessage());
940
            }
941
        }
942
        return super.listObjects(session, startTime, endTime, objectFormatId, identifier, nodeId, start, count);
933 943
    }
934 944

  
935 945
    /**
src/edu/ucsb/nceas/metacat/dataone/SyncAccessPolicy.java
52 52
import org.dataone.service.types.v1.AccessPolicy;
53 53
import org.dataone.service.types.v1.AccessRule;
54 54
import org.dataone.service.types.v1.Identifier;
55
import org.dataone.service.types.v1.NodeReference;
55 56
import org.dataone.service.types.v1.ObjectFormatIdentifier;
56 57
import org.dataone.service.types.v1.ObjectInfo;
57 58
import org.dataone.service.types.v1.ObjectList;
......
316 317
			Date startTime = null;
317 318
			Date endTime = null;
318 319
			ObjectFormatIdentifier objectFormatId = null;
319
			Boolean replicaStatus = false; // return only pids for which this mn
320
											// is
320
			//Boolean replicaStatus = false; // return only pids for which this mn
321
			NodeReference thisMN = new NodeReference();
322
			try {
323
			    String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId"); // return only pids for which this mn
324
			    thisMN.setValue(currentNodeId);
325
			} catch (Exception e) {
326
			    logMetacat.error("SyncAccessPolicy.run - can't get the node id of this member node from the metacat property file since :"+e.getMessage());
327
			    return;
328
			}
329
							// is
321 330
			ObjectList objsToSync = null;
322 331
			Integer count = 0;
323 332
			Integer start = 0;
......
350 359
			    
351 360
				objsToSync = IdentifierManager.getInstance()
352 361
						.querySystemMetadata(startTime, endTime,
353
								objectFormatId, replicaStatus, start, count, id, isSid);
362
								objectFormatId, thisMN, start, count, id, isSid);
354 363

  
355 364
				logMetacat.debug("syncTask total # of guids: "
356 365
						+ objsToSync.getTotal() + ", count for this page: "
......
383 392
					objsToSync = IdentifierManager
384 393
							.getInstance()
385 394
							.querySystemMetadata(startTime, endTime,
386
									objectFormatId, replicaStatus, start, count, id, isSid);
395
									objectFormatId, thisMN, start, count, id, isSid);
387 396
				} catch (Exception e) {
388 397
					logMetacat.error("Error syncing ids");
389 398
					syncError = true;
src/edu/ucsb/nceas/metacat/dataone/v1/CNodeService.java
74 74

  
75 75
import edu.ucsb.nceas.metacat.IdentifierManager;
76 76
import edu.ucsb.nceas.metacat.dataone.convert.LogV2toV1Converter;
77
import edu.ucsb.nceas.metacat.properties.PropertyService;
77 78

  
78 79
/**
79 80
 * Represents Metacat's implementation of the DataONE Coordinating Node service
......
321 322
			ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
322 323
			Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
323 324
			NotImplemented, ServiceFailure {
324
		return impl.listObjects(null, startTime, endTime, formatid, null, replicaStatus, start, count);
325
	    NodeReference nodeId = null;
326
        if(!replicaStatus) {
327
            //not include those objects whose authoritative node is not this mn
328
            nodeId = new NodeReference();
329
            try {
330
                String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId"); // return only pids for which this mn
331
                nodeId.setValue(currentNodeId);
332
            } catch(Exception e) {
333
                throw new ServiceFailure("1580", e.getMessage());
334
            }
335
        }
336
		return impl.listObjects(null, startTime, endTime, formatid, null, nodeId, start, count);
325 337
	}
326 338

  
327 339
	@Override
......
330 342
			ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
331 343
			Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
332 344
			NotImplemented, ServiceFailure {
333
		return impl.listObjects(session, startTime, endTime, formatid, null, replicaStatus, start, count);
345
	    NodeReference nodeId = null;
346
        if(!replicaStatus) {
347
            //not include those objects whose authoritative node is not this mn
348
            nodeId = new NodeReference();
349
            try {
350
                String currentNodeId = PropertyService.getInstance().getProperty("dataone.nodeId"); // return only pids for which this mn
351
                nodeId.setValue(currentNodeId);
352
            } catch(Exception e) {
353
                throw new ServiceFailure("1580", e.getMessage());
354
            }
355
        }
356
		return impl.listObjects(session, startTime, endTime, formatid, null, nodeId, start, count);
334 357
	}
335 358

  
336 359
	@Override
src/edu/ucsb/nceas/metacat/restservice/v2/CNResourceHandler.java
1279 1279
        Date endTime = null;
1280 1280
        ObjectFormatIdentifier formatId = null;
1281 1281
        Identifier identifier = null;
1282
        boolean replicaStatus = true;
1282
        //boolean replicaStatus = true;
1283
        NodeReference nodeId = null;
1283 1284
        int start = 0;
1284 1285
        int count = 1000;
1285 1286
        Enumeration<String> paramlist = request.getParameterNames();
......
1315 1316
            } else if (name.equals("identifier") && value != null) {
1316 1317
            	identifier = new Identifier();
1317 1318
            	identifier.setValue(value);
1318
            } else if (name.equals("replicaStatus") && value != null) {
1319
                replicaStatus = Boolean.parseBoolean(value);
1319
            /*} else if (name.equals("replicaStatus") && value != null) {
1320
                replicaStatus = Boolean.parseBoolean(value);*/
1321
            } else if (name.equals("nodeId") && value != null) {
1322
                nodeId = new NodeReference();
1323
                nodeId.setValue(value);
1324
                logMetacat.debug("the nodeId value is "+nodeId.getValue());
1320 1325
            } else if (name.equals("start") && value != null) {
1321 1326
                start = Integer.valueOf(value);
1322 1327
            } else if (name.equals("count") && value != null) {
......
1326 1331
        // make the call
1327 1332
        logMetacat.debug("session: " + session + " fromDate: " + startTime
1328 1333
                + " toDate: " + endTime + " formatId: " + formatId
1329
                + " replicaStatus: " + replicaStatus + " start: " + start
1334
                + " start: " + start
1330 1335
                + " count: " + count);        
1331 1336

  
1332 1337
        // get the list
1333 1338
        ObjectList ol = CNodeService.getInstance(request).listObjects(session,
1334
                startTime, endTime, formatId, identifier, replicaStatus, start, count);
1339
                startTime, endTime, formatId, identifier, nodeId, start, count);
1335 1340

  
1336 1341
        // send it
1337 1342
        OutputStream out = response.getOutputStream();

Also available in: Unified diff