You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "afs (via GitHub)" <gi...@apache.org> on 2024/09/09 12:23:15 UTC
[PR] GH-2700: Configurable server content negotiation [jena]
afs opened a new pull request, #2702:
URL: https://github.com/apache/jena/pull/2702
GitHub issue resolved #2700
Pull request Description:
Allow the Fuskei server content negotiation choices to be altered on server start-up.
----
- [x] Key commit messages start with the issue number (GH-xxxx)
By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2702:
URL: https://github.com/apache/jena/pull/2702#discussion_r1750544205
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
+
+ // ---- Default configuration settings or when content negotiation does not provide a media type.
+
+ public static final MediaType acceptRDFXMLDefault() { return MediaType.create(contentTypeRDFXML); }
+ public static final MediaType acceptNQuadsDefault() { return MediaType.create(contentTypeNQuads); }
+ public static final MediaType acceptResultSetXMLDefault() { return MediaType.create(contentTypeResultsXML); }
+ public static final MediaType acceptJSONDefault() { return MediaType.create(contentTypeJSON); }
+ public static final MediaType acceptTurtleDefault() { return MediaType.create(contentTypeTurtle); }
+
+ // ---- Default offers for content negotiation.
+
+ public static final AcceptList jsonOfferDefault() { return AcceptList.create(contentTypeJSON); }
+
+ public static final AcceptList constructOfferDefault() { return AcceptList.create(contentTypeTurtle,
Review Comment:
> Could the defaults be generated based on `RDFLanguages` or other suitable registry rather than hardcoding?
1. The order in `Accept` and `offer` lists matters.
1. Maybe a user wants a server to offer a subset of what Jena can support.
1. `RDFLanguages` is a registry of constants. It does not guarantee a writer exists nor does it cover result sets. So more annotation of the entries woudl be needed but it's in RIOT not Fuseki.
1. Each offer type is context dependent. If it's a SELECT query, then `rsOfferTable` is used. If the result is a CONSTRUCT, `constructOffer`, if it is GSP, then it depends on graph vs dataset. It would be reasonable to want a setup with different formats for different operations e.g. pretty format Turtle as the result of CONSTRUCT but flat (streaming) Turtle for GSP read.
A new registry would be configurable. If it was a map of enum, for the context, to offer with fixed choice of enum key at each use point, it's the same as asking for the right constant at the point of use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2702:
URL: https://github.com/apache/jena/pull/2702#discussion_r1750544205
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
+
+ // ---- Default configuration settings or when content negotiation does not provide a media type.
+
+ public static final MediaType acceptRDFXMLDefault() { return MediaType.create(contentTypeRDFXML); }
+ public static final MediaType acceptNQuadsDefault() { return MediaType.create(contentTypeNQuads); }
+ public static final MediaType acceptResultSetXMLDefault() { return MediaType.create(contentTypeResultsXML); }
+ public static final MediaType acceptJSONDefault() { return MediaType.create(contentTypeJSON); }
+ public static final MediaType acceptTurtleDefault() { return MediaType.create(contentTypeTurtle); }
+
+ // ---- Default offers for content negotiation.
+
+ public static final AcceptList jsonOfferDefault() { return AcceptList.create(contentTypeJSON); }
+
+ public static final AcceptList constructOfferDefault() { return AcceptList.create(contentTypeTurtle,
Review Comment:
> Could the defaults be generated based on `RDFLanguages` or other suitable registry rather than hardcoding?
1. The order in `Accept` and `offer` lists matters.
1. Maybe a user wants a server to offer a subset of what Jena can support.
1. `RDFLanguages` is a registry of constants. It does not guarantee a writer exists nor does it cover result sets. So more annotation of the entries would be needed but it's in RIOT not Fuseki.
1. Each offer type is context dependent. If it's a SELECT query, then `rsOfferTable` is used. If the result is a CONSTRUCT, `constructOffer`, if it is GSP, then it depends on graph vs dataset. It would be reasonable to want a setup with different formats for different operations e.g. pretty format Turtle as the result of CONSTRUCT but flat (streaming) Turtle for GSP read.
A new registry would be configurable. If it was a map of enum, for the context, to offer, with a fixed choice of enum key at each use point, it's the same as asking for the right constant at the point of use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2702:
URL: https://github.com/apache/jena/pull/2702#discussion_r1750544205
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
+
+ // ---- Default configuration settings or when content negotiation does not provide a media type.
+
+ public static final MediaType acceptRDFXMLDefault() { return MediaType.create(contentTypeRDFXML); }
+ public static final MediaType acceptNQuadsDefault() { return MediaType.create(contentTypeNQuads); }
+ public static final MediaType acceptResultSetXMLDefault() { return MediaType.create(contentTypeResultsXML); }
+ public static final MediaType acceptJSONDefault() { return MediaType.create(contentTypeJSON); }
+ public static final MediaType acceptTurtleDefault() { return MediaType.create(contentTypeTurtle); }
+
+ // ---- Default offers for content negotiation.
+
+ public static final AcceptList jsonOfferDefault() { return AcceptList.create(contentTypeJSON); }
+
+ public static final AcceptList constructOfferDefault() { return AcceptList.create(contentTypeTurtle,
Review Comment:
> Could the defaults be generated based on `RDFLanguages` or other suitable registry rather than hardcoding?
1. The order in `Accept` and `offer` lists matters.
1. Maybe a user wants a server to offer a subset of what Jena can support.
1. `RDFLanguages` is a registry of constants. It does not guarantee a writer exists nor does it cover result sets.
1. Each offer type is context dependent. If it's a SELECT query, then `rsOfferTable` is used. If the result is a CONSTRUCT, `constructOffer`, if it is GSP, then it depends on graph vs dataset. It's not a choice. A registry would be an enum to offer with fixed choice of enum key. That's the same as asking for the right constant.
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
Review Comment:
Yes. Jena has init mechanisms for external code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "Ostrzyciel (via GitHub)" <gi...@apache.org>.
Ostrzyciel commented on PR #2702:
URL: https://github.com/apache/jena/pull/2702#issuecomment-2341333961
This looks good to me, solves my issue entirely.
The only (probably insignificant) downside I see is that if hypothetically had two Jena extensions that both wanted to modify these fields, they could override each other... but this is a rare case I guess. You can always get around this by appending to the current list instead of overriding it.
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs merged PR #2702:
URL: https://github.com/apache/jena/pull/2702
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "rvesse (via GitHub)" <gi...@apache.org>.
rvesse commented on code in PR #2702:
URL: https://github.com/apache/jena/pull/2702#discussion_r1750368514
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
+
+ // ---- Default configuration settings or when content negotiation does not provide a media type.
+
+ public static final MediaType acceptRDFXMLDefault() { return MediaType.create(contentTypeRDFXML); }
+ public static final MediaType acceptNQuadsDefault() { return MediaType.create(contentTypeNQuads); }
+ public static final MediaType acceptResultSetXMLDefault() { return MediaType.create(contentTypeResultsXML); }
+ public static final MediaType acceptJSONDefault() { return MediaType.create(contentTypeJSON); }
+ public static final MediaType acceptTurtleDefault() { return MediaType.create(contentTypeTurtle); }
+
+ // ---- Default offers for content negotiation.
+
+ public static final AcceptList jsonOfferDefault() { return AcceptList.create(contentTypeJSON); }
+
+ public static final AcceptList constructOfferDefault() { return AcceptList.create(contentTypeTurtle,
Review Comment:
Could the defaults be generated based on `RDFLanguages` or other suitable registry rather than hardcoding?
Then the OPs scenario in #2700 may just work without them needing any further code to modify the static fields
Obviously initialisation and registration order is going to be a thing so may need both approaches regardless, WDYT?
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
Review Comment:
So this basically makes all these fields mutable so they can be modified within to the server operators preferred configuration?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "Ostrzyciel (via GitHub)" <gi...@apache.org>.
Ostrzyciel commented on PR #2702:
URL: https://github.com/apache/jena/pull/2702#issuecomment-2341465018
@afs yup, it all sounds perfectly reasonable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on code in PR #2702:
URL: https://github.com/apache/jena/pull/2702#discussion_r1750544205
##########
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/DEF.java:
##########
@@ -22,74 +22,110 @@
import org.apache.jena.atlas.web.MediaType;
import static org.apache.jena.riot.WebContent.*;
+/**
+ * Content negotiation setup.
+ */
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(contentTypeRDFXML);
- public static final MediaType acceptNQuads = MediaType.create(contentTypeNQuads);
- public static final MediaType acceptRSXML = MediaType.create(contentTypeResultsXML);
- public static final MediaType acceptJSON = MediaType.create(contentTypeJSON);
- public static final MediaType acceptTurtle = MediaType.create(contentTypeTurtle);
-
- public static final AcceptList jsonOffer = AcceptList.create(contentTypeJSON);
-
- public static final AcceptList constructOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift,
-
- contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeNQuads,
- contentTypeNQuadsAlt1
- );
-
- public static final AcceptList rdfOffer = AcceptList.create(contentTypeTurtle,
- contentTypeTurtleAlt1,
- contentTypeNTriples,
- contentTypeNTriplesAlt,
- contentTypeRDFXML,
- contentTypeTriX,
- contentTypeTriXxml,
- contentTypeJSONLD,
- contentTypeRDFJSON,
- contentTypeRDFThrift
- );
-
- public static final AcceptList quadsOffer = AcceptList.create(contentTypeTriG,
- contentTypeTriGAlt1,
- contentTypeJSONLD,
- contentTypeNQuads,
- contentTypeNQuadsAlt1,
- contentTypeTriX,
- contentTypeTriXxml
- );
+ // @formatter:off
+
+ // ---- Server configuration default media type
+
+ public static MediaType acceptRDFXML = acceptRDFXMLDefault();
+ public static MediaType acceptNQuads = acceptNQuadsDefault();
+ public static MediaType acceptResultSetXML = acceptResultSetXMLDefault();
+ public static MediaType acceptJSON = acceptJSONDefault();
+ public static MediaType acceptTurtle = acceptTurtleDefault();
+
+ // ---- Server configuration offers for content negotiation
+
+ public static AcceptList jsonOffer = jsonOfferDefault();
+
+ public static AcceptList constructOffer = constructOfferDefault();
+
+ public static AcceptList rdfOffer = rdfOfferDefault();
+
+ public static AcceptList quadsOffer = quadsOfferDefault();
+
+ // Offer for SELECT
+ public static AcceptList rsOfferTable = rsOfferTableDefault();
+
+ // Offer for ASK
+ public static AcceptList rsOfferBoolean = rsOfferBooleanDefault();
+
+
+ // ---- Default configuration settings or when content negotiation does not provide a media type.
+
+ public static final MediaType acceptRDFXMLDefault() { return MediaType.create(contentTypeRDFXML); }
+ public static final MediaType acceptNQuadsDefault() { return MediaType.create(contentTypeNQuads); }
+ public static final MediaType acceptResultSetXMLDefault() { return MediaType.create(contentTypeResultsXML); }
+ public static final MediaType acceptJSONDefault() { return MediaType.create(contentTypeJSON); }
+ public static final MediaType acceptTurtleDefault() { return MediaType.create(contentTypeTurtle); }
+
+ // ---- Default offers for content negotiation.
+
+ public static final AcceptList jsonOfferDefault() { return AcceptList.create(contentTypeJSON); }
+
+ public static final AcceptList constructOfferDefault() { return AcceptList.create(contentTypeTurtle,
Review Comment:
> Could the defaults be generated based on `RDFLanguages` or other suitable registry rather than hardcoding?
1. The order in `Accept` and `offer` lists matters.
1. Maybe a user wants a server to offer a subset of what Jena can support.
1. `RDFLanguages` is a registry of constants. It does not guarantee a writer exists nor does it cover result sets. So more annotation of the entries woudl be needed but it's in RIOT not Fuseki.
1. Each offer type is context dependent. If it's a SELECT query, then `rsOfferTable` is used. If the result is a CONSTRUCT, `constructOffer`, if it is GSP, then it depends on graph vs dataset. It would be reasonable to want a setup with different formats for different operations e.g. pretty format Turtle as the result of CONSTRUCT but flat (streaming) Turtle for GSP read.
A new registry would be configurable. If it was a map of enum, for the context, to offer, with a fixed choice of enum key at each use point, it's the same as asking for the right constant at the point of use.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org
Re: [PR] GH-2700: Configurable server content negotiation [jena]
Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #2702:
URL: https://github.com/apache/jena/pull/2702#issuecomment-2341461351
> if hypothetically we had two Jena extensions that both wanted to modify these fields
:smile:
Best I can think of is to check the current value of a slot against the initial system setting. That detects possible conflict.
Testing object identity is good enough.
Automatically resolving is problematic in the general case with adds and removes of the offer lists because the two subsystems may be have conflicting requirements. Additions could be merged reasonably safely.
The Jena initialization mechanisms (Jena System init, Fuseki modules) are both sequential so no concurrent overwrite problems.
They can be ordered by level if needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org