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

Don't add a language to a mimetype #840

Closed
whikloj opened this issue Jun 4, 2018 · 8 comments
Closed

Don't add a language to a mimetype #840

whikloj opened this issue Jun 4, 2018 · 8 comments

Comments

@whikloj
Copy link
Member

whikloj commented Jun 4, 2018

Coming from #86 (comment)

It has been determined that Fedora 4.7.2 allows us to change the ebucore:hasMimeType triple on a binary to have a language string attached. But this leaves the repository unable to serve the binary anymore.

Regardless, mimetype should probably not have a language string attached.

Steps to reproduce:

  1. Create a binary in Fedora

     > curl -i -H"Content-type: image/jpeg" -d "@louis_riel_tn.jpg" -XPUT http://localhost:8080/fcrepo/rest/jared_test
    
  2. Verify the binary

    > curl -I http://localhost:8080/fcrepo/rest/jared_test
    HTTP/1.1 200 OK
    
  3. Verify the metadata

    > curl -i http://localhost:8080/fcrepo/rest/jared_test/fcr:metadata
    

    Note this triple ebucore:hasMimeType "image/jpeg"^^<http://www.w3.org/2001/XMLSchema#string> ;

  4. Get the metadata to a file

    > curl -H"Prefer: return=representation; omit=\"http://fedora.info/definitions/v4/repository#ServerManaged\"" -o test_metadata http://localhost:8080/fcrepo/rest/jared_test -H"Accept: text/turtle"
    
  5. Edit the metadata file test_metadata to change
    ebucore:hasMimeType "image/jpeg"^^<http://www.w3.org/2001/XMLSchema#string> ;
    to
    ebucore:hasMimeType "image/jpeg"@en ;

  6. Put the metadata back

    > curl -i -XPUT -H"Content-type: text/turtle" -d "@test_metadata" http://localhost:8080/fcrepo/rest/jared_test/fcr:metadata -H"Prefer: handling=lenient; received=\"minimal\""
    
  7. Verify the change metadata

    > curl -i http://localhost:8080/fcrepo/rest/jared_test/fcr:metadata
    
  8. Try to get the binary

    > curl -i http://localhost:8080/fcrepo/rest/jared_test
    HTTP/1.1 500 Internal Server Error
    
@whikloj
Copy link
Member Author

whikloj commented Jun 4, 2018

Currently trying to reproduce with Fedora 4.7.5 to see if this has been resolved.

@whikloj
Copy link
Member Author

whikloj commented Jun 4, 2018

Same problem with 4.7.5

@whikloj
Copy link
Member Author

whikloj commented Jun 4, 2018

Stack trace for reference

> curl -i "http://localhost:8080/fcrepo/rest/9e/62/f5/ea/9e62f5ea-0785-45a1-8049-69273daf6637"
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
ETag: "2a696bcf48383d2f5870cd6ac7a4b43854eeb8f2"
Last-Modified: Mon, 04 Jun 2018 20:30:56 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 5150
Date: Mon, 04 Jun 2018 21:35:01 GMT
Connection: close

java.lang.IllegalArgumentException: Error parsing media type 'image/jpeg^^http://www.w3.org/1999/02/22-rdf-syntax-ns#langString^^en'
	at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:92)
	at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:60)
	at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
	at org.fcrepo.http.api.FedoraLdp.getResource(FedoraLdp.java:254)
	at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.text.ParseException: Next event is not a Separator
	at org.glassfish.jersey.message.internal.HttpHeaderReader.nextSeparator(HttpHeaderReader.java:141)
	at org.glassfish.jersey.message.internal.HttpHeaderReader.readParameters(HttpHeaderReader.java:306)
	at org.glassfish.jersey.message.internal.HttpHeaderReader.readParameters(HttpHeaderReader.java:296)
	at org.glassfish.jersey.message.internal.MediaTypeProvider.valueOf(MediaTypeProvider.java:118)
	at org.glassfish.jersey.message.internal.MediaTypeProvider.fromString(MediaTypeProvider.java:90)
	... 49 more

@whikloj
Copy link
Member Author

whikloj commented Jun 4, 2018

There maybe a fix for this, but it is on the master branch and therefore might not come out till Fedora 5.0.0. I'll test a build of it tomorrow.

@whikloj
Copy link
Member Author

whikloj commented Jun 5, 2018

This is fixed on the master branch of Fedora, but that means this PUT would fail. So we need to stop adding the language tag to the mimetype before we can move to Fedora 5.

> curl -ufedoraAdmin:fedoraAdmin -XPUT -d"@jared_test" -H"Content-type: text/turtle" -H"Prefer: handling=lenient; received=\"minimal\"" http://localhost:8080/rest/test1/fcr:metadata -i
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Date: Tue, 05 Jun 2018 13:19:26 GMT
Set-Cookie: JSESSIONID=17ssf14p45t4v1u7rm4ah1e9vj;Path=/
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Mon, 04-Jun-2018 13:19:26 GMT
Link: <http://localhost:8080/static/constraints/ConstraintViolationException.rdf>; rel="http://www.w3.org/ns/ldp#constrainedBy"
Content-Type: text/plain;charset=utf-8
Content-Length: 115
Server: Jetty(9.3.1.v20150714)

Invalid value for 'http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasMimeType' encountered : "image/jpeg"@en

@dannylamb
Copy link
Contributor

dannylamb commented Jul 12, 2018

^^PR is up for this one.

@whikloj When working through the changes for flysystem, this became a major hassle and led to weird timing issues on generating derviatives etc... If the pres master is in Fedora only, then maybe you'd get a derivative, maybe not. Depends on when the update for the Media with the lang tag rolled through and blocked everything from working.

The fix was really simple. Enable the content_translation module and set up which fields you want to be translated. Non-translatable filelds are explicitly serialized out as xsd:strings.

@whikloj
Copy link
Member Author

whikloj commented Jul 12, 2018

So this will be a requirement for a CLAW site, we should document that somewhere (we probably need a What your Drupal must have page). I thought there was a way in config, but I couldn't find it during iCampEU so I thought maybe I was wrong.

@whikloj
Copy link
Member Author

whikloj commented Jul 12, 2018

I just realized you added it as part of the Islandora Core Features...so
Nevermind

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

No branches or pull requests

3 participants