Package org.olat.commons.servlets.pathhandlers

Examples of org.olat.commons.servlets.pathhandlers.PathHandler


        // just another internal forward or even a direct call
        String path = getRelativePath(request);
        if (path.indexOf("/secstatic/") == 0) {
          path = path.substring(10, path.length());
        }
        PathHandler handler = null;
        String relPath = null;
        String handlerName = null;
        long start = 0;
       
        boolean logDebug = Tracing.isDebugEnabled(StaticsLegacyDispatcher.class);
        if (logDebug) start = System.currentTimeMillis();
        try {
            relPath = path.substring(1);
            int index = relPath.indexOf('/');
            if (index != -1) {
                handlerName = relPath.substring(0, index);
                relPath = relPath.substring(index);
            }

            if (handlerName != null)
                    handler = StaticsModule.getInstance(handlerName);
            /*if (handler == null) {
                handler = StaticsModule.getDefaultHandler();
                relPath = path;
            }*/

        } catch (IndexOutOfBoundsException e) {
            // if some problem with the url, we assign no handler
        }

        if (handler == null || relPath == null) {
            // no handler found or relPath incomplete
            response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                    .getRequestURI());
            return false;
        }

        ResourceDescriptor rd = handler.getResourceDescriptor(request, relPath);
        if (rd == null) {
            // no handler found or relPath incomplete
            response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                    .getRequestURI());
            return false;
        }

        setHeaders(response, rd);
        // check if modified since
        long ifModifiedSince = request.getDateHeader("If-Modified-Since");
        long lastMod = rd.getLastModified();
        if (lastMod != -1L && ifModifiedSince >= lastMod) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return false;
        }

        // server the resource
        if (copyContent) {
            InputStream is = handler.getInputStream(request, rd);
            if (is == null) {
                // resource not found or access denied
                response.sendError(HttpServletResponse.SC_NOT_FOUND, request
                        .getRequestURI());
                return false;
View Full Code Here


      String name = path.getAttribute("name");
      String classname = path.getAttribute("classname");
      if (name != null && classname != null) {
        try {
          Class pathHandler = Class.forName(classname);
          PathHandler o = (PathHandler)pathHandler.newInstance();
          o.init(path);
          handlers.put(name, o);
        } catch (Exception e) {
          Tracing.logDebug("*** Failed to instantiate: " + classname, StaticsModule.class);
        }
      }
View Full Code Here

TOP

Related Classes of org.olat.commons.servlets.pathhandlers.PathHandler

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.