}
if (type == null || !importService.getAcceptTypes().contains(type)) return Response.status(412).entity("define a valid content-type (types: "+importService.getAcceptTypes()+")").build();
final String finalType = type;
final InputStream in = request.getInputStream();
Task t = taskManagerService.createTask(String.format("Upload-Import from %s (%s)", request.getRemoteHost(), finalType), TASK_GROUP_NAME);
t.updateMessage("preparing import...");
t.updateDetailMessage("type", finalType);
try {
//create context
URI context = getContext(context_string);
if (context != null) {
t.updateDetailMessage("context", context.toString());
}
t.updateMessage("importing data...");
importService.importData(in,finalType, userService.getCurrentUser(), context);
t.updateMessage("import complete");
return Response.ok().entity("import of content successful\n").build();
} catch(Exception ex) {
log.error("error while importing", ex);
return Response.status(500).entity("error while importing: " + ex.getMessage()).build();