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

POST/PATCH must advertise constraints if triples not persisted #808

Closed
wants to merge 15 commits into from

Conversation

whikloj
Copy link
Collaborator

@whikloj whikloj commented Jun 2, 2015

Addresses FCREPO-1418

@@ -493,6 +494,8 @@ public void replaceProperties(final IdentifierConverter<Resource, FedoraResource
try {
new RdfRemover(idTranslator, getSession(), replacementStream
.withThisContext(differencer)).consume();
} catch (final ConstraintViolationException e) {
Copy link
Contributor

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?

Copy link
Collaborator Author

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...

Copy link
Contributor

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.

@ajs6f
Copy link
Contributor

ajs6f commented Jun 2, 2015

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) {
Copy link
Contributor

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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) {
Copy link

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.

Copy link
Collaborator Author

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awoods
Copy link

awoods commented Jun 22, 2015

Please add a new integration test method to FedoraLdpIT that creates an error case and verifies the created link header.

@awoods
Copy link

awoods commented Jun 22, 2015

It would be helpful to have an integration test that verifies:
** the existence of the static RDF pages are available in fcrepo-webapp (see: https://github.com/fcrepo4/fcrepo4/blob/master/fcrepo-webapp/src/test/java/org/fcrepo/integration/SanityCheckIT.java)
** the existence of the static RDF pages in the codebase, with the proper name, that correlates to the respective Exception classes.

Update ExceptionMappers to use new superclass.
Add unit test.
Add integration test.
@whikloj
Copy link
Collaborator Author

whikloj commented Jun 24, 2015

Regarding this SanityCheck, I think that it:

  1. Would need the issue about Grizzly not serving static pages to be resolved first.
  2. Because there are RDF files for a subset of Exceptions (subclasses of ConstraintViolationException), I'm not sure how you would locate those Exceptions.

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);
Copy link
Contributor

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.

@awoods
Copy link

awoods commented Jun 25, 2015

See: whikloj#2
...will look at the SanityIT.java later.

whikloj and others added 3 commits June 25, 2015 12:57
Move string format into OutOfDomainException constructor, update calls
to Exception.
Add test to ensure Constraints RDF exists
@awoods
Copy link

awoods commented Jun 25, 2015

See: whikloj#3 for the SanityIT.

Add test to verify Constraint Link header
*/
package org.fcrepo.kernel.exception;

import javax.ws.rs.core.UriInfo;
Copy link

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?

@awoods
Copy link

awoods commented Jun 29, 2015

Resolved with: 447e56a

@awoods awoods closed this Jun 29, 2015
@awoods awoods deleted the FCREPO-1418 branch June 29, 2015 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants