if (rdfFormat == null) {
throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE, "Unsupported MIME type: "
+ mimeType);
}
ServerConnection connection = getConnection();
ValueFactory vf = connection.getValueFactory();
Form params = getQuery();
Resource[] contexts = ServerUtil.parseContextParam(params, CONTEXT_PARAM_NAME, vf);
URI baseURI = ServerUtil.parseURIParam(params, BASEURI_PARAM_NAME, vf);
if (baseURI == null) {
baseURI = vf.createURI("foo:bar");
logger.info("no base URI specified, using dummy '{}'", baseURI);
}
try {
InputStream in = entity.getStream();
boolean autoCommit = connection.isAutoCommit();
if (autoCommit) {
connection.begin();
}
try {
if (replaceCurrent) {
connection.clear(contexts);
}
connection.add(in, baseURI.toString(), rdfFormat, contexts);
if (autoCommit) {
connection.commit();
}
connection.getCacheInfo().processUpdate();
}
finally {
if (autoCommit && !connection.isAutoCommit()) {
// restore auto-commit by rolling back'
connection.rollback();
}
}
}
catch (UnsupportedRDFormatException e) {
throw new ResourceException(CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE,