public ResponseContext setEntityTag(String etag) { return etag != null ? setEntityTag(new EntityTag(etag)) : removeHeader("ETag"); }
public ResponseContext getService(RequestContext request) { Abdera abdera = request.getAbdera(); Document<Service> service = get_service_doc(abdera); AbstractResponseContext rc; rc = new BaseResponseContext<Document<Service>>(service); rc.setEntityTag(service_etag); return rc; }
/** * Creates the ResponseContext for a GET feed request. By default, a BaseResponseContext is returned. The Etag * header will be set. */ protected ResponseContext buildGetFeedResponse(Feed feed) { Document<Feed> document = feed.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Feed>>(document); rc.setEntityTag(calculateEntityTag(document.getRoot())); return rc; }
public ResponseContext getFeed(RequestContext request) { Abdera abdera = request.getAbdera(); Document<Feed> feed = get_feed_doc(abdera); AbstractResponseContext rc; rc = new BaseResponseContext<Document<Feed>>(feed); rc.setEntityTag(calculateEntityTag(feed.getRoot())); return rc; }
/** * Creates the ResponseContext for a GET entry request. By default, a BaseResponseContext is returned. The Entry * will contain an appropriate atom:source element and the Etag header will be set. */ protected ResponseContext buildGetEntryResponse(RequestContext request, Entry entry) throws ResponseContextException { Feed feed = createFeedBase(request); entry.setSource(feed.getAsSource()); Document<Entry> entry_doc = entry.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Entry>>(entry_doc); rc.setEntityTag(calculateEntityTag(entry)); return rc; }
/** * Implements GET on a COLLECTION */ public ResponseContext getFeed(RequestContext request) { /* Factory factory = */getAndInitFactory(request); Feed feed; try { int length = ProviderHelper.getPageSize(request, "count", 25); int offset = ProviderHelper.getOffset(request, "page", length); String _page = request.getParameter("page"); int page =(_page != null) ? Integer.parseInt(_page) : 0; feed = getFeedInternal(request, offset, length); } catch (BadRequestException e) { return makeExceptionResponse(HttpServletResponse.SC_BAD_REQUEST, e); } Document<Feed> doc = feed.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Feed>>(doc); rc.setEntityTag(calculateEntityTag(feed)); return rc; }
/** * Implements GET on an ENTRY */ public ResponseContext getEntry(RequestContext request) { Entry entry; String entryId = getEntryID(request); try { entry = getEntryInternal(request, entryId); Document<Entry> entryDoc = entry.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Entry>>(entryDoc); rc.setEntityTag(calculateEntityTag(entry)); return rc; } catch (NotFoundException e) { return makeExceptionResponse(HttpServletResponse.SC_NOT_FOUND, "No entry for id " + entryId); } catch (BadRequestException e) { return makeExceptionResponse(HttpServletResponse.SC_BAD_REQUEST, e); } }
public ResponseContext getEntry(RequestContext request) { Entry entry = getAbderaEntry(request); if (entry != null) { Feed feed = entry.getParentElement(); entry = (Entry) entry.clone(); entry.setSource(feed.getAsSource()); Document<Entry> entry_doc = entry.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Entry>>( entry_doc); rc.setEntityTag(calculateEntityTag(entry)); return rc; } else { return new EmptyResponseContext(404); } }