try {
String id = getResourceName(request);
T entryObj = getEntry(id, request);
if (entryObj == null) {
return new EmptyResponseContext(404);
}
Entry orig_entry = getEntryFromCollectionProvider(entryObj, new IRI(getFeedIriForEntry(entryObj, request)), request);
if (orig_entry != null) {
MimeType contentType = request.getContentType();
if (contentType != null && !MimeTypeHelper.isAtom(contentType.toString()))
return new EmptyResponseContext(415);
Entry entry = getEntryFromRequest(request);
if (entry != null) {
if (!entry.getId().equals(orig_entry.getId()))
return new EmptyResponseContext(409);
if (!ProviderHelper.isValidEntry(entry))
return new EmptyResponseContext(400);
putEntry(entryObj, entry.getTitle(), new Date(), entry.getAuthors(),
entry.getSummary(), entry.getContentElement(), request);
return new EmptyResponseContext(204);
} else {
return new EmptyResponseContext(400);
}
} else {
return new EmptyResponseContext(404);
}
} catch (ResponseContextException e) {
return createErrorResponse(e);
} catch (ParseException pe) {
return new EmptyResponseContext(415);
} catch (ClassCastException cce) {
return new EmptyResponseContext(415);
} catch (Exception e) {
log.warn(e.getMessage(), e);
return new EmptyResponseContext(400);
}
}