/** * Creates the ResponseContext for a newly created entry. By default, a BaseResponseContext is returned. The * Location, Content-Location, Etag and status are set appropriately. */ protected ResponseContext buildCreateEntryResponse(String link, Entry entry) { BaseResponseContext<Entry> rc = new BaseResponseContext<Entry>(entry); rc.setLocation(link); rc.setContentLocation(rc.getLocation().toString()); rc.setEntityTag(calculateEntityTag(entry)); rc.setStatus(201); return rc; }
public BaseResponseContext(T base, boolean chunked) { this.base = base; setStatus(200); setStatusText("OK"); this.chunked = chunked; try { MimeType type = getContentType(); String charset = type.getParameter("charset"); if (charset == null) charset = getCharsetFromBase(base); if (charset == null) charset = "UTF-8"; type.setParameter("charset", charset); setContentType(type.toString()); } catch (Exception e) { } }
/** * Return a document */ @SuppressWarnings("unchecked") public static ResponseContext returnBase(Base base, int status, Date lastModified) { log.debug(Localizer.get("RETURNING.DOCUMENT")); BaseResponseContext response = new BaseResponseContext(base); response.setStatus(status); if (lastModified != null) response.setLastModified(lastModified); // response.setContentType(MimeTypeHelper.getMimeType(base)); Document doc = base instanceof Document ? (Document)base : ((Element)base).getDocument(); if (doc.getEntityTag() != null) { response.setEntityTag(doc.getEntityTag()); } else if (doc.getLastModified() != null) { response.setLastModified(doc.getLastModified()); } return response; }
/** * {@inheritDoc} */ @Override protected ResponseContext buildGetEntryResponse(RequestContext request, Entry entry) throws ResponseContextException { // The same as in super class but without ETag. Document<Entry> doc = entry.getDocument(); ResponseContext rc = new BaseResponseContext<Document<Entry>>(doc); // rc.setEntityTag(ProviderHelper.calculateEntityTag(entry)); return rc; }
/** * {@inheritDoc} */ @Override protected ResponseContext buildGetFeedResponse(Feed feed) { // The same as in super class but without ETag. Document<Feed> document = feed.getDocument(); AbstractResponseContext rc = new BaseResponseContext<Document<Feed>>(document); // rc.setEntityTag(calculateEntityTag(document.getRoot())); return rc; }
BaseResponseContext<Base> rc = new BaseResponseContext<Base>(entry); IRI baseUri = ProviderHelper.resolveBase(request); IRI editLinkResolvedHref = entry.getEditLinkResolvedHref(); throw new Error("createEntryInternal() must set the edit link href"); rc.setLocation(baseUri.resolve(editLinkResolvedHref).toString()); rc.setContentLocation(rc.getLocation().toString()); rc.setEntityTag(calculateEntityTag(entry)); rc.setStatus(HttpServletResponse.SC_CREATED); return rc; } else {
public ResponseContext process(RequestContext requestContext, WorkspaceManager workspaceManager, CollectionAdapter collectionAdapter) { String method = requestContext.getMethod(); if (method.equalsIgnoreCase("GET")) { OpenSearchDescription description = this.openSearchInfo.asOpenSearchDescriptionElement(requestContext); ResponseContext response = new BaseResponseContext(description); response.setContentType(OpenSearchConstants.OPENSEARCH_DESCRIPTION_CONTENT_TYPE); return response; } else { return null; } }
feed.insertEntry(entry); feed.setUpdated(new Date()); BaseResponseContext rc = new BaseResponseContext(entry); IRI baseUri = ProviderHelper.resolveBase(request); rc.setLocation(baseUri.resolve(entry.getEditLinkResolvedHref()) .toString()); rc.setContentLocation(rc.getLocation().toString()); rc.setEntityTag(calculateEntityTag(entry)); rc.setStatus(201); return rc; } else {
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; }
public ResponseContext search(RequestContext request, Map<String, String> parameters) { List<T> searchResults = this.doSearch(request, parameters); Feed feed = this.createFeed(request, parameters, searchResults); Document<Feed> document = feed.getDocument(); ResponseContext response = new BaseResponseContext<Document<Feed>>(document); return response; }
/** * 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; }
private Response makeRepositoryInfoResponse(HttpServletRequest httpRequest, URI baseUri, String repositoryId) { Service service = AbderaFactory.getInstance().getFactory().newService(); service.declareNS(AtomCMIS.CMIS_NS_URI, AtomCMIS.CMIS_PREFIX); service.declareNS(AtomCMIS.CMISRA_NS_URI, AtomCMIS.CMISRA_PREFIX); addCmisRepository(httpRequest, service, repositoryId, baseUri); Document<Service> serviceDocument = service.getDocument(); serviceDocument.setCharset("utf-8"); ResponseContext abderaResponse = new BaseResponseContext<Document<Service>>(serviceDocument); abderaResponse.setStatus(200); return Response.ok(abderaResponse).header(HttpHeaders.CACHE_CONTROL, "no-cache") .type(MediaType.APPLICATION_ATOM_XML).build(); }
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; }
/** * {@inheritDoc} */ protected ResponseContext buildCreateEntryResponse(String link, Entry entry) { Document<Entry> doc = entry.getDocument(); ResponseContext rc = new BaseResponseContext<Document<Entry>>(doc); rc.setLocation(link); rc.setContentLocation(rc.getLocation().toString()); // rc.setEntityTag(ProviderHelper.calculateEntityTag(entry)); rc.setStatus(201); 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); } }
treat.setTreatment(treatment); return new BaseResponseContext<Entry>(entry);