Revision 6221
Added by ben leinfelder over 13 years ago
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java | ||
---|---|---|
131 | 131 |
|
132 | 132 |
// are we allowed to do this? |
133 | 133 |
if (!hasPermission(session, pid, Permission.CHANGE_PERMISSION)) { |
134 |
throw new NotAuthorized("4881", "not allowed by " + subject.getValue() + " on " + guid);
|
|
134 |
throw new NotAuthorized("4881", Permission.CHANGE_PERMISSION + " not allowed by " + subject.getValue() + " on " + guid);
|
|
135 | 135 |
} |
136 | 136 |
|
137 | 137 |
SystemMetadata systemMetadata = null; |
... | ... | |
183 | 183 |
String guid = pid.getValue(); |
184 | 184 |
|
185 | 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);
|
|
186 |
if (!hasPermission(session, pid, Permission.WRITE)) {
|
|
187 |
throw new NotAuthorized("4720", Permission.WRITE + " not allowed by " + subject.getValue() + " on " + guid);
|
|
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
SystemMetadata systemMetadata = null; |
... | ... | |
276 | 276 |
* @throws NotImplemented |
277 | 277 |
*/ |
278 | 278 |
@Override |
279 |
public boolean assertRelation(Session session, Identifier pidofsubject,
|
|
279 |
public boolean assertRelation(Session session, Identifier pidOfSubject,
|
|
280 | 280 |
String relationship, Identifier pidOfObject) |
281 | 281 |
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, |
282 | 282 |
InvalidRequest, NotImplemented { |
283 | 283 |
|
284 |
|
|
285 |
// get the system metadata |
|
286 |
String guid1 = pidOfSubject.getValue(); |
|
287 |
// are we allowed to do this? |
|
288 |
if (!hasPermission(session, pidOfSubject, Permission.READ)) { |
|
289 |
throw new NotAuthorized("4881", Permission.READ + " not allowed on " + guid1); |
|
290 |
} |
|
291 |
|
|
292 |
SystemMetadata systemMetadata = null; |
|
293 |
try { |
|
294 |
systemMetadata = IdentifierManager.getInstance().getSystemMetadata(guid1); |
|
295 |
} catch (McdbDocNotFoundException e) { |
|
296 |
throw new NotFound("4884", "No record found for: " + guid1); |
|
297 |
} |
|
298 |
|
|
299 |
// check relationships |
|
300 |
// TODO: make this more strongly typed? |
|
301 |
if (relationship.equalsIgnoreCase("describes")) { |
|
302 |
return systemMetadata.getDescribeList().contains(pidOfObject); |
|
303 |
} |
|
304 |
if (relationship.equalsIgnoreCase("describedBy")) { |
|
305 |
return systemMetadata.getDescribedByList().contains(pidOfObject); |
|
306 |
} |
|
307 |
if (relationship.equalsIgnoreCase("derivedFrom")) { |
|
308 |
return systemMetadata.getDerivedFromList().contains(pidOfObject); |
|
309 |
} |
|
310 |
if (relationship.equalsIgnoreCase("obsoletes")) { |
|
311 |
return systemMetadata.getObsoleteList().contains(pidOfObject); |
|
312 |
} |
|
313 |
if (relationship.equalsIgnoreCase("obsoletedBy")) { |
|
314 |
return systemMetadata.getObsoletedByList().contains(pidOfObject); |
|
315 |
} |
|
316 |
|
|
284 | 317 |
return false; |
285 | 318 |
} |
286 | 319 |
|
Also available in: Unified diff
implement assertRelation