Project

General

Profile

« Previous | Next » 

Revision 6219

implement CNReplication.setReplicationPolicy

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
120 120
	@Override
121 121
	public boolean setReplicationPolicy(Session session, Identifier pid,
122 122
	  ReplicationPolicy policy) 
123
	  throws NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest {
123
	  throws NotImplemented, NotFound, NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken {
124 124

  
125
		return false;
125
		// get the subject
126
		Subject subject = session.getSubject();
127
		// get the system metadata
128
		String guid = pid.getValue();
129
		
130
		// are we allowed to do this?
131
		if (!hasPermission(session, pid, Permission.CHANGE_PERMISSION)) {
132
			throw new NotAuthorized("4881", "not allowed by " + subject.getValue() + " on " + guid);	
133
		}
134
		
135
		SystemMetadata systemMetadata = null;
136
		try {
137
			systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid);
138
		} catch (McdbDocNotFoundException e) {
139
			throw new NotFound("4884", "No record found for: " + guid);
140
		}
141
				
142
		// set the new policy
143
		systemMetadata.setReplicationPolicy(policy);
144
		
145
		// update the metadata
146
		try {
147
			IdentifierManager.getInstance().updateSystemMetadata(systemMetadata);
148
		} catch (McdbDocNotFoundException e) {
149
			throw new ServiceFailure("4882", e.getMessage());
150
		}
151

  
152
		return true;
126 153
	}
127 154

  
128 155
	/**

Also available in: Unified diff