// much about the order ...
List<ContentType> acceptable = LMFHttpUtils.parseStringList(kiWiIOService.getProducedTypes());
for(ContentType a : acceptable) {
a.setParameter("rel", "meta");
}
ContentType allContent = new ContentType("*","*");
allContent.setParameter("rel", "content");
acceptable.add(0,allContent);
// determine the best match between the offered types and the acceptable types
ContentType bestType = LMFHttpUtils.bestContentType(types,acceptable);
if (bestType != null) {
if (configurationService.getBooleanConfiguration("linkeddata.redirect.put", true)) {
final RepositoryConnection con = sesameService.getConnection();
try {
con.begin();
URI resource = ResourceUtils.getUriResource(con, uri);
con.commit();
return Response
.status(configurationService.getIntConfiguration("linkeddata.redirect.status", 303))
// .location(new URI(configurationService.getBaseUri() +
// bestType.getParameter("rel") + "/" + bestType.getMime() + appendix))
.location(new java.net.URI(ResourceWebServiceHelper.buildResourceLink(resource, bestType, configurationService)))
.build();
} finally {
con.close();
}
} else {
if("content".equalsIgnoreCase(bestType.getParameter("rel")))
return contentWebService.putContent(uri, bestType.getMime(), request);
else if ("meta".equalsIgnoreCase(bestType.getParameter("rel")))
return metaWebService.putMeta(uri, bestType.getMime(), request);
else
return Response.serverError().entity("request did not specify whether it uploads content or metadata; use rel=content|meta attribute in Content-Type header").build();
}
} else {
Response response = Response.status(415).entity("type " + mimetype + " not supported").build();