本文整理汇总了Java中org.apache.jena.riot.WebContent类的典型用法代码示例。如果您正苦于以下问题:Java WebContent类的具体用法?Java WebContent怎么用?Java WebContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebContent类属于org.apache.jena.riot包,在下文中一共展示了WebContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
protected void validate(HttpAction action) {
String method = action.getRequest().getMethod();
switch(method) {
case HttpNames.METHOD_POST:
case HttpNames.METHOD_PATCH:
break;
default:
ServletOps.errorMethodNotAllowed(method+" : Patch must use POST or PATCH");
}
String ctStr = action.request.getContentType();
// Must be UTF-8 or unset. But this is wrong so often,
// it is less trouble to just force UTF-8.
String charset = action.request.getCharacterEncoding();
if ( charset != null && ! WebContent.charsetUTF8.equals(charset) )
ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Charset must be omitted or UTF-8, not "+charset);
// If no header Content-type - assume patch-text.
ContentType contentType = ( ctStr != null ) ? ContentType.create(ctStr) : ctPatchText;
if ( ! ctPatchText.equals(contentType) && ! ctPatchBinary.equals(contentType) )
ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Allowed Content-types are "+ctPatchText+" or "+ctPatchBinary+", not "+ctStr);
if ( ctPatchBinary.equals(contentType) )
ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, contentTypePatchBinary+" not supported yet");
}
开发者ID:afs,项目名称:rdf-delta,代码行数:25,代码来源:PatchApplyService.java
示例2: json
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
public static void json(HttpServletRequest req, HttpServletResponse resp, JsonValue responseContent) {
try {
resp.setHeader(HttpNames.hCacheControl, "no-cache");
resp.setHeader(HttpNames.hContentType, WebContent.contentTypeJSON);
resp.setStatus(HttpSC.OK_200);
try(ServletOutputStream out = resp.getOutputStream(); IndentedWriter b = new IndentedWriter(out); ) {
b.setFlatMode(true);
JSON.write(b, responseContent);
b.ensureStartOfLine();
b.flush();
out.write('\n');
}
} catch (IOException ex) {
LOG.warn("json: IOException", ex);
try {
resp.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, "Internal server error");
} catch (IOException ex2) {}
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:S_JSON.java
示例3: handle
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
if ( request.getMethod().equals(METHOD_POST)) {
response.setContentType(WebContent.contentTypeTextPlain);
response.setCharacterEncoding(WebContent.charsetUTF8) ;
String reason=(response instanceof Response)?((Response)response).getReason():null;
String msg = String.format("%03d %s\n", response.getStatus(), reason) ;
response.getOutputStream().write(msg.getBytes(StandardCharsets.UTF_8)) ;
response.getOutputStream().flush() ;
baseRequest.setHandled(true);
return;
}
super.handle(target, baseRequest, request, response);
}
开发者ID:afs,项目名称:rdf-delta,代码行数:17,代码来源:HttpErrorHandler.java
示例4: createDefaultLoaders
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected Map<String, ContentStreamLoader> createDefaultLoaders(final NamedList parameters) {
final Map<String, ContentStreamLoader> registry = new HashMap<String, ContentStreamLoader>();
final ContentStreamLoader loader = new RdfDataLoader();
for (final Lang language : RDFLanguages.getRegisteredLanguages()) {
registry.put(language.getContentType().toHeaderString(), loader);
}
registry.put(WebContent.contentTypeSPARQLUpdate, new Sparql11UpdateRdfDataLoader());
if (log.isDebugEnabled()) {
prettyPrint(registry);
}
return registry;
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:17,代码来源:RdfBulkUpdateRequestHandler.java
示例5: updateUsingPOSTDirectly
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void updateUsingPOSTDirectly() throws Exception {
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeSPARQLUpdate);
when(httpRequest.getMethod()).thenReturn("POST");
final List<ContentStream> dummyStream = new ArrayList<ContentStream>(1);
dummyStream.add(new ContentStreamBase.ByteArrayStream(new byte[0], "dummy") {
@Override
public String getContentType() {
return WebContent.contentTypeSPARQLUpdate;
}
});
when(request.getContentStreams()).thenReturn(dummyStream);
when(request.getParams()).thenReturn(new ModifiableSolrParams());
cut.handleRequestBody(request, response);
verify(cut).requestHandler(request, Sparql11SearchHandler.DEFAULT_UPDATE_HANDLER_NAME);
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:20,代码来源:Sparql11SearchHandlerTestCase.java
示例6: queryUsingPOSTDirectly
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void queryUsingPOSTDirectly() throws Exception {
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeSPARQLQuery);
when(httpRequest.getMethod()).thenReturn("POST");
final List<ContentStream> dummyStream = new ArrayList<ContentStream>(1);
dummyStream.add(new ContentStreamBase.ByteArrayStream(new byte[0], "dummy") {
@Override
public String getContentType() {
return WebContent.contentTypeSPARQLUpdate;
}
});
when(request.getContentStreams()).thenReturn(dummyStream);
when(request.getParams()).thenReturn(new ModifiableSolrParams());
cut.handleRequestBody(request, response);
verify(cut).requestHandler(request, Sparql11SearchHandler.DEFAULT_SEARCH_HANDLER_NAME);
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:20,代码来源:Sparql11SearchHandlerTestCase.java
示例7: sparql
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
public String sparql(String subject) {
// First query takes the most specific class from a given resource.
String ontology_service = endpoint;
String endpointsSparql = "select ?label where {<" + subject
+ "> <http://www.w3.org/2000/01/rdf-schema#label> ?label FILTER (lang(?label) = 'en')} LIMIT 100";
Query sparqlQuery = QueryFactory.create(endpointsSparql, Syntax.syntaxARQ);
QueryEngineHTTP qexec = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(ontology_service, sparqlQuery);
qexec.setModelContentType(WebContent.contentTypeRDFXML);
ResultSet results = qexec.execSelect();
String property = null;
while (results.hasNext()) {
QuerySolution qs = results.next();
property = qs.getLiteral("?label").getLexicalForm();
}
return property;
}
开发者ID:dice-group,项目名称:AGDISTIS,代码行数:21,代码来源:TripleIndexCreatorContext.java
示例8: createObject
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
/**
* Update an object using SPARQL-UPDATE
*
* @param requestBodyStream SPARQL-update request
* @return
*/
@PATCH
@Consumes({WebContent.contentTypeSPARQLUpdate})
public Response createObject(@ContentLocation final InputStream requestBodyStream) {
// TODO: Parse and persist the changes indicated in the sparql-update
return noContent().build();
}
开发者ID:duraspace,项目名称:lambdora,代码行数:15,代码来源:LambdoraLdp.java
示例9: handle
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
public void handle(Patch patch) {
IndentedLineBuffer x = new IndentedLineBuffer() ;
RDFChanges scData = new RDFChangesWriteUpdate(x) ;
patch.play(scData);
x.flush();
String reqStr = x.asString() ;
updateEndpoints.forEach((ep)->{
try { HttpOp.execHttpPost(ep, WebContent.contentTypeSPARQLUpdate, reqStr) ; }
catch (HttpException ex) { DPS.LOG.warn("Failed to send to "+ep) ; }
}) ;
}
开发者ID:afs,项目名称:rdf-delta,代码行数:13,代码来源:PHandlerGSP.java
示例10: text
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
private void text(HttpServletRequest req, HttpServletResponse resp) {
try {
resp.setHeader(HttpNames.hContentType, WebContent.contentTypeTextPlain);
resp.setStatus(HttpSC.OK_200);
try(ServletOutputStream out = resp.getOutputStream(); ) {
output.actionEx(out);
}
} catch (IOException ex) {
LOG.warn("text out: IOException", ex);
try {
resp.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, "Internal server error");
} catch (IOException ex2) {}
}
}
开发者ID:afs,项目名称:rdf-delta,代码行数:15,代码来源:S_ReplyText.java
示例11: createDefaultLoaders
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
protected Map<String, ContentStreamLoader> createDefaultLoaders(final NamedList parameters) {
final Map<String, ContentStreamLoader> registry = new HashMap<String, ContentStreamLoader>();
registry.put(WebContent.contentTypeHTMLForm, new Sparql11UpdateRdfDataLoader());
registry.put("application/rdf+xml", new Sparql11UpdateRdfDataLoader());
registry.put(WebContent.contentTypeSPARQLUpdate, new Sparql11UpdateRdfDataLoader());
if (log.isDebugEnabled()) {
prettyPrint(registry);
}
return registry;
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:15,代码来源:RdfUpdateRequestHandler.java
示例12: getContentType_AskQueryWithIncomingMediaType
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void getContentType_AskQueryWithIncomingMediaType() {
assertIncomingRequestWithMediaType(
askQuery,
new String[] {
WebContent.contentTypeTextCSV,
WebContent.contentTypeTextPlain,
WebContent.contentTypeTextTSV,
ResultSetLang.SPARQLResultSetJSON.getHeaderString(),
ResultSetLang.SPARQLResultSetXML.getHeaderString() });
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:12,代码来源:ResponseContentTypeChoiceTestCase.java
示例13: getContentType_DescribeQueryWithIncomingMediaType
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void getContentType_DescribeQueryWithIncomingMediaType() {
assertIncomingRequestWithMediaType(
describeQuery,
new String[] {
WebContent.contentTypeRDFXML,
WebContent.contentTypeNTriples,
WebContent.contentTypeTurtle });
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:10,代码来源:ResponseContentTypeChoiceTestCase.java
示例14: getContentType_ConstructQueryWithIncomingMediaType
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void getContentType_ConstructQueryWithIncomingMediaType() {
assertIncomingRequestWithMediaType(
constructQuery,
new String[] {
WebContent.contentTypeRDFXML,
WebContent.contentTypeNTriples,
WebContent.contentTypeTurtle });
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:10,代码来源:ResponseContentTypeChoiceTestCase.java
示例15: updateUsingPOSTWithURLEncodedParameters
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void updateUsingPOSTWithURLEncodedParameters() throws Exception {
final ModifiableSolrParams parameters = new ModifiableSolrParams();
parameters.set(Names.UPDATE_PARAMETER_NAME, randomString());
when(httpRequest.getMethod()).thenReturn("POST");
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeHTMLForm);
when(request.getParams()).thenReturn(parameters);
cut.handleRequestBody(request, response);
verify(cut).requestHandler(request, Sparql11SearchHandler.DEFAULT_UPDATE_HANDLER_NAME);
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:14,代码来源:Sparql11SearchHandlerTestCase.java
示例16: updateUsingPOSTWithURLEncodedParametersWithoutUpdateCommand
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void updateUsingPOSTWithURLEncodedParametersWithoutUpdateCommand() throws Exception {
when(httpRequest.getMethod()).thenReturn("POST");
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeHTMLForm);
when(request.getParams()).thenReturn(new ModifiableSolrParams());
try {
cut.handleRequestBody(request, response);
fail();
} catch (final Exception expected) {
final SolrException exception = (SolrException) expected;
assertEquals(ErrorCode.BAD_REQUEST.code, exception.code());
assertEquals(Sparql11SearchHandler.MISSING_QUERY_OR_UPDATE_IN_POST_MESSAGE, exception.getMessage());
}
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:16,代码来源:Sparql11SearchHandlerTestCase.java
示例17: queryUsingPOSTWithURLEncodedParameters_I
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void queryUsingPOSTWithURLEncodedParameters_I() throws Exception {
final ModifiableSolrParams parameters = new ModifiableSolrParams();
parameters.set(Names.QUERY, randomString());
when(httpRequest.getMethod()).thenReturn("POST");
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeHTMLForm);
when(request.getParams()).thenReturn(parameters);
cut.handleRequestBody(request, response);
verify(cut).requestHandler(request, Sparql11SearchHandler.DEFAULT_SEARCH_HANDLER_NAME);
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:14,代码来源:Sparql11SearchHandlerTestCase.java
示例18: queryUsingPOSTWithURLEncodedParameters_II
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void queryUsingPOSTWithURLEncodedParameters_II() throws Exception {
final ModifiableSolrParams parameters = new ModifiableSolrParams();
parameters.set(Names.QUERY, randomString());
when(httpRequest.getMethod()).thenReturn("POST");
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeHTMLForm + ";charset=UTF-8");
when(request.getParams()).thenReturn(parameters);
cut.handleRequestBody(request, response);
verify(cut).requestHandler(request, Sparql11SearchHandler.DEFAULT_SEARCH_HANDLER_NAME);
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:14,代码来源:Sparql11SearchHandlerTestCase.java
示例19: queryUsingPOSTWithURLEncodedParametersWithoutUpdateCommand
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Test
public void queryUsingPOSTWithURLEncodedParametersWithoutUpdateCommand() throws Exception {
when(httpRequest.getMethod()).thenReturn("POST");
when(httpRequest.getContentType()).thenReturn(WebContent.contentTypeHTMLForm);
when(request.getParams()).thenReturn(new ModifiableSolrParams());
try {
cut.handleRequestBody(request, response);
fail();
} catch (final Exception expected) {
final SolrException exception = (SolrException) expected;
assertEquals(ErrorCode.BAD_REQUEST.code, exception.code());
assertEquals(Sparql11SearchHandler.MISSING_QUERY_OR_UPDATE_IN_POST_MESSAGE, exception.getMessage());
}
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:16,代码来源:Sparql11SearchHandlerTestCase.java
示例20: getContentType
import org.apache.jena.riot.WebContent; //导入依赖的package包/类
@Override
public String getContentType() {
return WebContent.contentTypeHTMLForm;
}
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:5,代码来源:Sparql11SearchHandler.java
注:本文中的org.apache.jena.riot.WebContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论