LorenzBuehmann commented on issue #1259:
URL: https://github.com/apache/jena/issues/1259#issuecomment-1103846006

   @afs a follow up issue/question (we could also open another issue for better 
reference)
   
   Wikidata people argued to use POST form because it works ...
   
   We tried to set the `SERVICE` request mode via Fuseki assembler config:
   
   ```
   ja:context [ ja:cxtName "arq:httpServiceSendMode" ;  ja:cxtValue 
"asGetWithLimitForm" ] ;
   ```
   
   This indeed fails, as `Context::get` tries to return an object of the 
expected type in `Service::chooseQuerySendMode` method which in that case will 
be `QuerySendMode` and indeed casting a `String` to this type fails.
   
   A quick fix would workaround the limitation and handle at least the two 
different types of the context value, i.e. i) `String` coming from an assembler 
config or ii) a `QuerySendMode` coming from maybe some Java API setup :
   
   ```java
   private static QuerySendMode chooseQuerySendMode(String serviceURL, Context 
context, QuerySendMode dftValue) {
           if ( context == null )
               return dftValue;
           Object querySendMode = context.<Object>get(httpServiceSendMode, 
dftValue);
           if (querySendMode instanceof String) { // handle string type from 
assembler config
               return QuerySendMode.valueOf((String) querySendMode);
           } else if (querySendMode instanceof QuerySendMode) { // handle enum 
type from Java API
               return (QuerySendMode) querySendMode;
           }
           // handle null value and other non-supported types
           return context.get(httpServiceSendMode, dftValue);
       }
   ```
   
   


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

Reply via email to