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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]