Project

General

Profile

« Previous | Next » 

Revision 9177

Added by Jing Tao almost 10 years ago

Created the updateSystemMetadata method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
1976 1976
          }
1977 1977
      }
1978 1978
  }
1979
  
1980
    public void synchronizeObject(Session session, SystemMetadata sysmeta) throws NotAuthorized, InvalidRequest{
1981
        if(session == null) {
1982
            throw new NotAuthorized("4861", "No Session - could not authorize for synchorinzing object." +
1983
                    "  If you are not logged in, please do so and retry the request.");
1984
        } 
1985
        if(sysmeta == null) {
1986
            throw new InvalidRequest("4863", "The system metadata shouldn't be null in synchronizing an object.");
1987
        }
1988
        Identifier pid = sysmeta.getIdentifier();
1989
        //only the authoritative node can call this method
1990
        if( !isAuthoritativeMNodeAdmin(session, pid) ){
1991
            throw new NotAuthorized("4861", "Only the authoritative node "+sysmeta.getAuthoritativeMemberNode().getValue()+
1992
                    " of the object "+pid.getValue()+" can have the synchroinzeObject request.");
1993
        }
1994
        
1995
        
1996
    }
1979 1997

  
1980 1998
	@Override
1981 1999
	public QueryEngineDescription getQueryEngineDescription(Session session,
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
1597 1597
      } catch (SQLException e) {
1598 1598
          logMetacat.warn("Could not log 'updateSystemMetadata' event because the localId couldn't be identified for the pid: " + pid.getValue());
1599 1599
      }
1600
      boolean ifAuthoritativeNode = isAuthoritativeNode(pid);
1601 1600
      return true;
1602 1601
	}
1603 1602
	
1604
	private boolean isAuthoritativeNode(Identifier pid) {
1603
	/*
1604
	 * Determine if the current node is the authoritative node for the given pid.
1605
	 */
1606
	protected boolean isAuthoritativeNode(Identifier pid) {
1605 1607
	    boolean isAuthoritativeNode = false;
1606 1608
	    if(pid != null && pid.getValue() != null) {
1607 1609
	        SystemMetadata sys = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
177 177
 * MNStorage.create()
178 178
 * MNStorage.update()
179 179
 * MNStorage.delete()
180
 * MNStorage.updateSystemMetadata()
180 181
 * MNReplication.replicate()
181 182
 * 
182 183
 */
......
2141 2142
		return bagInputStream;
2142 2143
	}
2143 2144

  
2144
	
2145
	@Override
2146
	public boolean updateSystemMetadata(Session session, Identifier pid,
2147
            SystemMetadata sysmeta) throws NotImplemented, NotAuthorized,
2148
            ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
2149
	 if(sysmeta == null) {
2150
	     throw  new InvalidRequest("4863", "The system metadata object should NOT be null in the updateSystemMetadata request.");
2151
	 }
2152
	 if(!isAuthoritativeNode(pid)) {
2153
	     throw  new InvalidRequest("4863", "Client can only call updateSystemMetadata request on the authoritative memember node.");
2154
	 }
2155
      //update the system metadata locally  
2156
      boolean success = super.updateSystemMetadata(session, pid, sysmeta);
2157
      
2158
      if(success) {
2159
          //notify the cns the synchornize the new system metadata.
2160
      }
2161
      return success;
2162
    }
2145 2163
    
2146 2164
}

Also available in: Unified diff