Package info.openurl.oom

Examples of info.openurl.oom.OpenURLResponse


      status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }
    HashMap<String, String> header_map = new HashMap<String, String>();
    header_map.put("Content-Length", sb.toString().getBytes() + "");
    header_map.put("Date", HttpDate.getHttpDate());
    return new OpenURLResponse(status, responseFormat, sb.toString().getBytes(), header_map);
  }
View Full Code Here


        }
       
        HashMap<String, String> header_map = new HashMap<String, String>();
        header_map.put("Content-Length", bytes.length + "");
        header_map.put("Date", HttpDate.getHttpDate());
        return new OpenURLResponse(status, responseFormat, bytes, header_map);
    }
View Full Code Here

            status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        }
        HashMap<String, String> header_map = new HashMap<String, String>();
        header_map.put("Content-Length", baos.size() + "");
        header_map.put("Date", HttpDate.getHttpDate());
        return new OpenURLResponse(status, responseFormat, baos.toByteArray(), header_map);
    }
View Full Code Here

      status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }
    HashMap<String, String> header_map = new HashMap<String, String>();
    header_map.put("Content-Length", baos.size() + "");
    header_map.put("Date", HttpDate.getHttpDate());
    return new OpenURLResponse(status, responseFormat, baos.toByteArray(), header_map);
  }
View Full Code Here

      status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }
    HashMap<String, String> header_map = new HashMap<String, String>();
    header_map.put("Content-Length", Integer.toString(b.length));
    header_map.put("Date", HttpDate.getHttpDate());
    return new OpenURLResponse(status, responseFormat, b, header_map);
  }
View Full Code Here

            if (req.getHeader("referer") != null)
                openURLRequest.getContextObjects()[0].getReferringEntities()[0].addDescriptor(req.getHeader("referer"));
            // rchute: Add requester for possible extension processing
            openURLRequest.getContextObjects()[0].getRequesters()[0].addDescriptor(req.getRemoteAddr());
            // Process the ContextObjects
            OpenURLResponse result = processor.resolve(openURLRequest);
           
            // See if anyone handled the request
            int status;
            if (result == null) {
                status = HttpServletResponse.SC_NOT_FOUND;
            } else {
                status = result.getStatus();
                Cookie[] cookies = result.getCookies();
                if (cookies != null) {
                    for (int i=0; i< cookies.length; ++i) {
                        resp.addCookie(cookies[i]);
                    }
                }
               
                Map sessionMap = result.getSessionMap();
                if (sessionMap != null) {
                    HttpSession session = req.getSession(true);
                    Iterator iter = sessionMap.entrySet().iterator();
                    while (iter.hasNext()) {
                        Map.Entry entry = (Entry) iter.next();
                        session.setAttribute((String) entry.getKey(), entry.getValue());
                    }
                }
               
                Map headerMap = result.getHeaderMap();
                if (headerMap != null) {
                    Iterator iter = headerMap.entrySet().iterator();
                    while (iter.hasNext()) {
                        Map.Entry entry = (Entry) iter.next();
                        resp.setHeader((String) entry.getKey(),
                                (String) entry.getValue());
                    }
                }
            }
           
            // Allow the processor to generate a variety of response types
            switch (status) {
            case HttpServletResponse.SC_MOVED_TEMPORARILY:
                resp.sendRedirect(
                    resp.encodeRedirectURL(
                        result.getRedirectURL()));
                break;
            case HttpServletResponse.SC_SEE_OTHER:
            case HttpServletResponse.SC_MOVED_PERMANENTLY:
                resp.setStatus(status);
                resp.setHeader("Location", result.getRedirectURL());
                break;
            case HttpServletResponse.SC_NOT_FOUND:
                resp.sendError(status);
                break;
            default:
                OutputStream out = resp.getOutputStream();
                resp.setStatus(status);
                resp.setContentType(result.getContentType());
                InputStream is = result.getInputStream();
                byte[] bytes = new byte[1024];
                int len;
                while ((len = is.read(bytes)) != -1) {
                    out.write(bytes, 0, len);
                }
View Full Code Here

        }

        final HashMap<String, String> header_map = new HashMap<String, String>();
        header_map.put("Content-Length", Integer.toString(bytes.length));
        header_map.put("Date", HttpDate.getHttpDate());
        return new OpenURLResponse(status, responseFormat, bytes, header_map);
    }
View Full Code Here

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Getting OpenURLResponse...");
        }

        final OpenURLResponse response = new OpenURLResponse(status, responseFormat, bytes, header_map);

        // Record where our cache file was (if we had/created one)
        if (djatokaCacheFile != null) {
            final StringBuilder dimBuilder = new StringBuilder();
            final int[] dims = params.getScalingDimensions();
            final String level = Integer.toString(params.getLevel());
            final String region = params.getRegion();
            final int rotation = params.getRotationDegree();
            final String ext = getExtension(format);
            String scale;
            String hash;

            if (dims != null) {
                if (dims.length == 2) {
                    dimBuilder.append(dims[0]).append(',').append(dims[1]);
                } else {
                    dimBuilder.append(dims[0]);
                }
            }

            scale = dimBuilder.toString();

            try {
                hash = getTileHash(id, params);
            } catch (final Exception details) {
                if (LOGGER.isErrorEnabled()) {
                    LOGGER.error(details.getMessage(), details);
                }

                hash = null;
            }

            final String f = CacheUtils.getFileName(level, scale, region, rotation);
            id = id + "_" + f;

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("OpenURL service: [ {} | {} | {} | {} ] = {}", new Object[] { level, scale, region,
                    rotation, id });
            }

            if (hash != null) {
                final Map sessionMap = response.getSessionMap();
                final String cacheName = hash + ext;

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Setting cache session data [ {} | {} ]", new Object[] { id, djatokaCacheFile });
                }
View Full Code Here

     */
    public OpenURLResponse resolve(ServiceType serviceType, ContextObject contextObject,
            OpenURLRequest openURLRequest, OpenURLRequestProcessor processor) throws UnsupportedEncodingException {
        String[] privateData = (String[]) contextObject.getReferent().getDescriptors(String.class);
        String name = privateData[0];
        return new OpenURLResponse(HttpServletResponse.SC_OK, "text/plain; charset=utf-8", sayHello(name).getBytes(
                "UTF-8"));
    }
View Full Code Here

        }

        final HashMap<String, String> header_map = new HashMap<String, String>();
        header_map.put("Content-Length", baos.size() + "");
        header_map.put("Date", HttpDate.getHttpDate());
        return new OpenURLResponse(status, responseFormat, baos.toByteArray(), header_map);
    }
View Full Code Here

TOP

Related Classes of info.openurl.oom.OpenURLResponse

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.