//for remote Entiteis as suggested by
// http://incubator.apache.org/stanbol/docs/trunk/entityhub/entityhubandlinkeddata.html
Map<String,Entity> updated = new HashMap<String,Entity>();
for(Representation representation : parsed.values()){
try {
Entity entity = entityhub.store(representation);
updated.put(entity.getId(), entity);
}catch (EntityhubException e) {
log.error(String.format("Exception while storing Entity %s" +
"in the Entityhub.",representation),e);
}
}
//create the response for the Entity
// for now directly return the added entity. one could also
// consider returning a seeOther (303) with the get URI for the
// created/updated entity
if(updated.isEmpty()){
// No (valid) data parsed
ResponseBuilder rb = Response.status(Status.NOT_MODIFIED);
addCORSOrigin(servletContext, rb, headers);
return rb.build();
} else {
Entity entity = updated.values().iterator().next();
if(method.equals(HttpMethod.POST)){
ResponseBuilder rb = Response.created(uriInfo.getAbsolutePathBuilder()
.queryParam("id", "{entityId}")
.build(entity.getId()));
addCORSOrigin(servletContext, rb, headers);
return rb.build();
} else {
//return Response.noContent().build();
//As alternative return the modified entity