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
POST/PATCH must advertise constraints if triples not persisted #808
Conversation
@@ -493,6 +494,8 @@ public void replaceProperties(final IdentifierConverter<Resource, FedoraResource | |||
try { | |||
new RdfRemover(idTranslator, getSession(), replacementStream | |||
.withThisContext(differencer)).consume(); | |||
} catch (final ConstraintViolationException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to immediately rethrow a ConstraintViolationException
or do we want to accumulate them to give a more full report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like we are doing directly below this with the MalformedRdfException?
I was a little concerned about how we are reporting if we violate multiple constraints. In which case maybe our constraints should be a single file and the exception message would have to identify which constraint? Not sure...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a very good point. I think you've got it right now. Most folks are not going to throw in RDF with many many violations, anyway.
On the whole this looks really nice. @whikloj ++ Just a few comments in-line, and I do want to make sure I understand how we are publishing the RDF/HTML and if we are doing it efficiently. |
* Generates a link header for a constraint based on UriInfo and the name of the Exception class. | ||
* @return Link | ||
*/ | ||
public static Link buildConstraintLink(final ConstraintViolationException e, final UriInfo uriInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the expected clients of this method are actually subclasses of this class, you could just make it an instance method, which would shorten the code a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I seem to have to pass the uriInfo into this method regardless. If I don't, then it becomes null. Is this an aspect of @context or am I doing something wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a moron, I had @context in all the ExceptionMappers and not in the Exceptions. I think I got this.
Creating OutOfDomainSubjectException subclass of ConstraintViolationException Moving ServerManagedPropertyException to subclass of ConstraintViolationException Added OutOfDomainSubjectExceptionMapper, ConstraintViolationExceptionMapper Changed some Exceptions thrown at JcrPropertyStatementListener
Propagate out of PersistingRdfStreamConsumer and FedoraResourceImpl
Tried to limit @context from bleeding over sub-classes, ended up passing it into the method.
* Generates a link header for a constraint based on UriInfo and the name of the Exception class. | ||
* @return Link | ||
*/ | ||
public Link buildConstraintLink(final UriInfo uriInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test for this class/method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you mock up a URI? I keep getting a target invocation error. Everything is working great then it executes the buildConstraintLink twice and tosses some exception to the JUnit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a new integration test method to FedoraLdpIT that creates an error case and verifies the created link header. |
It would be helpful to have an integration test that verifies: |
Update ExceptionMappers to use new superclass. Add unit test. Add integration test.
Regarding this SanityCheck, I think that it:
As always, if you want to give me some Java education on a way to do this, I can add it to the PR. 😉 |
|
||
@Before | ||
public void setUp() throws RepositoryException, URISyntaxException { | ||
initMocks(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use @RunWith(MockitoJUnitRunner.class), it's a bit crisper to my eye.
See: whikloj#2 |
Move string format into OutOfDomainException constructor, update calls to Exception.
Add test to ensure Constraints RDF exists
See: whikloj#3 for the SanityIT. |
Add test to verify Constraint Link header
*/ | ||
package org.fcrepo.kernel.exception; | ||
|
||
import javax.ws.rs.core.UriInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not want a javax.ws.rs
dependency in fcrepo-kernel
. You should be able to remove the following method:
https://github.com/fcrepo4/fcrepo4/pull/808/files#diff-c14ecfb343036db02d3070d59bd47b0eR64
...and perform all of the buildConstraintLink
logic in ConstraintExceptionMapper
, no?
Removed unused constructor in ConstraintViolationException and sub-classes.
Resolved with: 447e56a |
Addresses FCREPO-1418