Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1411 #768

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
2 participants
@osmandin
Copy link
Member

commented Apr 14, 2015

DO NOT MERGE. Just for testing. Please ignore style issues.

ajs6f and others added some commits Apr 9, 2015

Prevent non-target resource
fcrepo-1411
while (stmtIterator.hasNext()) {
final Statement s = stmtIterator.next();
final Resource subject = s.getSubject();
if (!subject.toString().contains(getPath())) {

This comment has been minimized.

Copy link
@ajs6f

ajs6f Apr 14, 2015

Contributor

This test is badly wrong.

  • It is comparing a JCR value (the result of getPath()) with an RDF value (subject.toString()). That kind of comparison must be mediated by an IdentifierConverter. Use something more like equals(idTranslator.convert(subject)), catching exceptions, or pass in the request URI and do a comparison to that.
  • It does not account for blank nodes.
  • It does not account for hash-URIs

@osmandin osmandin closed this Apr 14, 2015

@@ -465,10 +467,23 @@ public Boolean isNew() {
public void replaceProperties(final IdentifierConverter<Resource, FedoraResource> idTranslator,
final Model inputModel, final RdfStream originalTriples) throws MalformedRdfException {

LOGGER.info("Resource path: {}", getPath());

final StmtIterator stmtIterator = inputModel.listStatements();

This comment has been minimized.

Copy link
@ajs6f

ajs6f Apr 14, 2015

Contributor

if you are going to use a loop here at all, use listSubjects() instead. It might be better to use Model.query(Selector s).

final Resource subject = s.getSubject();
if (!subject.toString().contains(getPath())) {
LOGGER.info("Input model subject not target of resource: {}", subject.toString());
throw new UnsupportedOperationException("Non targetted resource " + subject.toString());

This comment has been minimized.

Copy link
@ajs6f

ajs6f Apr 14, 2015

Contributor

Let's subclass this to something more specific, a la NonLocalTriplesException or the like. In fact, we might want to let that exception take some fields to record the particular triples that failed-- that might help us create nice and useful error messages in the HTTP layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.