Revision 6220
Added by ben leinfelder over 13 years ago
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.io.InputStream; |
27 | 27 |
import java.util.Date; |
28 |
import java.util.List; |
|
28 | 29 |
|
29 | 30 |
import org.apache.log4j.Logger; |
30 | 31 |
import org.dataone.service.cn.CNAuthorization; |
... | ... | |
54 | 55 |
import org.dataone.service.types.ObjectLocationList; |
55 | 56 |
import org.dataone.service.types.Permission; |
56 | 57 |
import org.dataone.service.types.QueryType; |
58 |
import org.dataone.service.types.Replica; |
|
57 | 59 |
import org.dataone.service.types.ReplicationPolicy; |
58 | 60 |
import org.dataone.service.types.ReplicationStatus; |
59 | 61 |
import org.dataone.service.types.Session; |
... | ... | |
175 | 177 |
throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, |
176 | 178 |
InvalidRequest, NotFound { |
177 | 179 |
|
178 |
return false; |
|
180 |
// get the subject |
|
181 |
Subject subject = session.getSubject(); |
|
182 |
// get the system metadata |
|
183 |
String guid = pid.getValue(); |
|
184 |
|
|
185 |
// are we allowed to do this? |
|
186 |
if (!hasPermission(session, pid, Permission.CHANGE_PERMISSION)) { |
|
187 |
throw new NotAuthorized("4720", "not allowed by " + subject.getValue() + " on " + guid); |
|
188 |
} |
|
189 |
|
|
190 |
SystemMetadata systemMetadata = null; |
|
191 |
try { |
|
192 |
systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid); |
|
193 |
} catch (McdbDocNotFoundException e) { |
|
194 |
throw new NotFound("4740", "No record found for: " + guid); |
|
195 |
} |
|
196 |
|
|
197 |
// set the status for each replica |
|
198 |
// TODO: should this method select a certain replica? |
|
199 |
List<Replica> replicas = systemMetadata.getReplicaList(); |
|
200 |
for (Replica replica: replicas) { |
|
201 |
replica.setReplicationStatus(status); |
|
202 |
} |
|
203 |
|
|
204 |
// [re]set the list -- redundant? |
|
205 |
systemMetadata.setReplicaList(replicas); |
|
206 |
|
|
207 |
// update the metadata |
|
208 |
try { |
|
209 |
IdentifierManager.getInstance().updateSystemMetadata(systemMetadata); |
|
210 |
} catch (McdbDocNotFoundException e) { |
|
211 |
throw new ServiceFailure("4700", e.getMessage()); |
|
212 |
} |
|
213 |
|
|
214 |
return true; |
|
179 | 215 |
} |
180 | 216 |
|
181 | 217 |
/** |
Also available in: Unified diff
implement CNReplication.setReplicationStatus() but with a note about selecting which replica's status should be set (right now it is all)