Package org.apache.abdera.protocol.server

Examples of org.apache.abdera.protocol.server.ResponseContext


        }

        WorkspaceManager wm = getWorkspaceManager(request);
        CollectionAdapter adapter = wm.getCollectionAdapter(request);
        Transactional transaction = adapter instanceof Transactional ? (Transactional) adapter : null;
        ResponseContext response = null;
        try {
            transactionStart(transaction, request);
            response = processor.process(request, wm, adapter);
            response = response != null ? response : processExtensionRequest(request, adapter);           
        } catch (Throwable e) {
View Full Code Here


                String ifNonMatchValue = context.getHeader("if-none-match");
                if (ifNonMatchValue != null) {
                    String currentETag = Utils.calculateEntityTag(resource);
                    if (ifNonMatchValue.equals(currentETag)) {
                        /* the version is not modified */
                        ResponseContext response = new StringResponseContext("Not Modified", 304);
                        return new ResponseTarget(context, response);
                    }
                }

                // date based conditional get
                long ifModifiedSinceValue = 0;
                Date ifModifiedSince = context.getDateHeader("If-Modified-Since");
                if (ifModifiedSince != null) {
                    ifModifiedSinceValue = ifModifiedSince.getTime();
                }

                if (ifModifiedSinceValue > 0) {
                    long lastModifiedValue = resource.getLastModified().getTime();
                    // convert the time values from milliseconds to seconds
                    ifModifiedSinceValue /= 1000;
                    lastModifiedValue /= 1000;

                    /* condition to check we have latest updates in terms of dates */
                    if (ifModifiedSinceValue >= lastModifiedValue) {
                        /* no need to response with data */
                        ResponseContext response = new StringResponseContext("Not Modified", 304);
                        return new ResponseTarget(context, response);
                    }
                }
            }
        }
View Full Code Here

                    importURL,
                    resource);
        } catch (Exception e) {
            return new StringResponseContext(e, 500);
        }
        ResponseContext rc = new EmptyResponseContext(200);
        try {
            rc.setLocation(
                    URLDecoder.decode(getAtomURI(location, request), "UTF-8").replaceAll(" ", "+"));
        } catch (UnsupportedEncodingException e) {
            // no action
        }
View Full Code Here

        return rc;
    }

    private ResponseContext processRenameRequest(RequestContext request, String path) {
        if (!request.getMethod().equals("POST")) {
            ResponseContext rc = new EmptyResponseContext(405, "Method not allowed");
            rc.setAllow("POST");
            return rc;
        }

        try {
            InputStream is = request.getInputStream();
View Full Code Here

        return new StringResponseContext("Rename successful.", 200);
    }

    private ResponseContext processCopyRequest(RequestContext request, String path) {
        if (!request.getMethod().equals("POST")) {
            ResponseContext rc = new EmptyResponseContext(405, "Method not allowed");
            rc.setAllow("POST");
            return rc;
        }

        try {
            InputStream is = request.getInputStream();
View Full Code Here

        return new StringResponseContext("Copy successful.", 200);
    }

    private ResponseContext processMoveRequest(RequestContext request, String path) {
        if (!request.getMethod().equals("POST")) {
            ResponseContext rc = new EmptyResponseContext(405, "Method not allowed");
            rc.setAllow("POST");
            return rc;
        }

        try {
            InputStream is = request.getInputStream();
View Full Code Here

        return new StringResponseContext("Version successfully created", 200);
    }

    private ResponseContext buildResponseContextFromFeed(Feed feed) {
        Document<Feed> docFeed = feed.getDocument();
        ResponseContext rc = new BaseResponseContext<Document<Feed>>(docFeed);
        rc.setEntityTag(calculateEntityTag(docFeed.getRoot()));
        Date updated = feed.getUpdated();
        if (updated != null) {
            rc.setLastModified(updated);
        }
        return rc;
    }
View Full Code Here

  implements Filter {
 
  public ResponseContext filter(
    RequestContext request,
    FilterChain chain) {
      ResponseContext resp = chain.next(request);
      String format = request.getParameter("format");
      return (resp.getContentType() != null &&
        jsonPreferred(request,resp.getContentType().toString())) ||
        (format != null && format.equalsIgnoreCase("json")) ?
        new JsonResponseContext(resp,request.getAbdera()) :
        resp;
  }
View Full Code Here

    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;
    }
View Full Code Here

    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;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.server.ResponseContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.