Package org.apache.click.service

Examples of org.apache.click.service.LogService


     */
    public static LogService getLogService() {
        Context context = Context.getThreadLocalContext();
        ServletContext servletContext = context.getServletContext();
        ConfigService configService = getConfigService(servletContext);
        LogService logService = configService.getLogService();
        return logService;
    }
View Full Code Here


                    request.setCharacterEncoding(charset);

                } catch (UnsupportedEncodingException ex) {
                    String msg =
                        "The character encoding " + charset + " is invalid.";
                    LogService logService =
                        clickServlet.getConfigService().getLogService();
                    logService.warn(msg, ex);
                }
            }

            FileUploadService fus =
                clickServlet.getConfigService().getFileUploadService();
View Full Code Here

                String value = context.getRequestParameter(submitTokenName);
                if (value == null || value.length() == 0) {
                    // CLK-289. If a session attribute exists for the
                    // SUBMIT_CHECK, but no request parameter, we assume the
                    // submission is a duplicate and therefore invalid.
                    LogService logService = ClickUtils.getLogService();
                    logService.warn("    'Redirect After Post' token called '"
                        + submitTokenName + "' is registered in the session, "
                        + "but no matching request parameter was found. "
                        + "(form name: '" + getName()
                        + "'). To protect against a 'duplicate post', "
                        + "Form.onSubmitCheck() will return false.");
View Full Code Here

        if (StringUtils.isNotBlank(targetDir)) {
            realTargetDir = realTargetDir + targetDir;
        }


        LogService logger = getConfigService(servletContext).getLogService();

        try {

            // Create files deployment directory
            File directory = new File(realTargetDir);
            if (!directory.exists()) {
                if (!directory.mkdirs()) {
                    String msg =
                        "could not create deployment directory: " + directory;
                    throw new IOException(msg);
                }
            }

            String destination = resource;
            int index = resource.lastIndexOf('/');
            if (index != -1) {
                destination = resource.substring(index + 1);
            }

            destination = realTargetDir + File.separator + destination;

            File destinationFile = new File(destination);

            if (!destinationFile.exists()) {
                InputStream inputStream =
                    getResourceAsStream(resource, ClickUtils.class);

                if (inputStream != null) {
                    FileOutputStream fos = null;
                    try {
                        fos = new FileOutputStream(destinationFile);
                        byte[] buffer = new byte[1024];
                        while (true) {
                            int length = inputStream.read(buffer);
                            if (length <  0) {
                                break;
                            }
                            fos.write(buffer, 0, length);
                        }

                        if (logger.isTraceEnabled()) {
                            int lastIndex =
                                destination.lastIndexOf(File.separatorChar);
                            if (lastIndex != -1) {
                                destination =
                                    destination.substring(lastIndex + 1);
                            }
                            String msg =
                                "deployed " + targetDir + "/" + destination;
                            logger.trace(msg);
                        }

                    } finally {
                        close(fos);
                        close(inputStream);
                    }
                } else {
                    String msg =
                        "could not locate classpath resource: " + resource;
                    throw new IOException(msg);
                }
            }

        } catch (IOException ioe) {
            String msg =
                "error occurred deploying resource " + resource
                + ", error " + ioe;
            logger.warn(msg);

        } catch (SecurityException se) {
            String msg =
                "error occurred deploying resource " + resource
                + ", error " + se;
            logger.warn(msg);
        }
    }
View Full Code Here

        packageName = StringUtils.replaceChars(packageName, '.', '/');
        packageName = "/" + packageName;
        String controlName = ClassUtils.getShortClassName(controlClass);

        ConfigService configService = getConfigService(servletContext);
        LogService logService = configService.getLogService();
        String descriptorFile = packageName + "/" + controlName + ".files";
        logService.debug("Use deployment descriptor file:" + descriptorFile);

        try {
            InputStream is = getResourceAsStream(descriptorFile, ClickUtils.class);
            List fileList = IOUtils.readLines(is);
            if (fileList == null || fileList.isEmpty()) {
                logService.info("there are no files to deploy for control " + controlClass.getName());
                return;
            }

            // a target dir list is required cause the ClickUtils.deployFile() is too inflexible to autodetect
            // required subdirectories.
            List targetDirList = new ArrayList(fileList.size());
            for (int i = 0; i < fileList.size(); i++) {
                String filePath = (String) fileList.get(i);
                String destination = "";
                int index = filePath.lastIndexOf('/');
                if (index != -1) {
                    destination = filePath.substring(0, index + 1);
                }
                targetDirList.add(i, targetDir + "/" + destination);
                fileList.set(i, packageName + "/" + filePath);
            }

            for (int i = 0; i < fileList.size(); i++) {
                String source = (String) fileList.get(i);
                String targetDirName = (String) targetDirList.get(i);
                ClickUtils.deployFile(servletContext, source, targetDirName);
            }

        } catch (IOException e) {
            String msg = "error occurred getting resource " + descriptorFile + ", error " + e;
            logService.warn(msg);
        }
    }
View Full Code Here

     */
    public static LogService getLogService() {
        Context context = Context.getThreadLocalContext();
        ServletContext servletContext = context.getServletContext();
        ConfigService configService = getConfigService(servletContext);
        LogService logService = configService.getLogService();
        return logService;
    }
View Full Code Here

                    request.setCharacterEncoding(charset);

                } catch (UnsupportedEncodingException ex) {
                    String msg =
                        "The character encoding " + charset + " is invalid.";
                    LogService logService =
                        clickServlet.getConfigService().getLogService();
                    logService.warn(msg, ex);
                }
            }

            FileUploadService fus =
                clickServlet.getConfigService().getFileUploadService();
View Full Code Here

        Validate.notNull(servletContext, "Null servletContext parameter");

        configService = ClickUtils.getConfigService(servletContext);

        // Attempt to match Freemarker Logger to configured LogService type
        LogService logService = configService.getLogService();
        if (logService instanceof Log4JLogService) {
            Logger.selectLoggerLibrary(Logger.LIBRARY_LOG4J);

        } else if (logService instanceof JdkLogService) {
            Logger.selectLoggerLibrary(Logger.LIBRARY_JAVA);
View Full Code Here

     * @return a template model as a map
     */
    public static Map<String, Object> createTemplateModel(final Page page, Context context) {

        ConfigService configService = ClickUtils.getConfigService(context.getServletContext());
        LogService logger = configService.getLogService();

        final Map<String, Object> model = new HashMap<String, Object>(page.getModel());

        final HttpServletRequest request = context.getRequest();

        Object pop = model.put("request", request);
        if (pop != null && !page.isStateful()) {
            String msg = page.getClass().getName() + " on " + page.getPath()
                         + " model contains an object keyed with reserved "
                         + "name \"request\". The page model object "
                         + pop + " has been replaced with the request object";
            logger.warn(msg);
        }

        pop = model.put("response", context.getResponse());
        if (pop != null && !page.isStateful()) {
            String msg = page.getClass().getName() + " on " + page.getPath()
                         + " model contains an object keyed with reserved "
                         + "name \"response\". The page model object "
                         + pop + " has been replaced with the response object";
            logger.warn(msg);
        }

        SessionMap sessionMap = new SessionMap(request.getSession(false));
        pop = model.put("session", sessionMap);
        if (pop != null && !page.isStateful()) {
            String msg = page.getClass().getName() + " on " + page.getPath()
                         + " model contains an object keyed with reserved "
                         + "name \"session\". The page model object "
                         + pop + " has been replaced with the request "
                         + " session";
            logger.warn(msg);
        }

        pop = model.put("context", request.getContextPath());
        if (pop != null && !page.isStateful()) {
            String msg = page.getClass().getName() + " on " + page.getPath()
                         + " model contains an object keyed with reserved "
                         + "name \"context\". The page model object "
                         + pop + " has been replaced with the request "
                         + " context path";
            logger.warn(msg);
        }

        Format format = page.getFormat();
        if (format != null) {
            pop = model.put("format", format);
            if (pop != null && !page.isStateful()) {
                String msg = page.getClass().getName() + " on "
                        + page.getPath()
                        + " model contains an object keyed with reserved "
                        + "name \"format\". The page model object " + pop
                        + " has been replaced with the format object";
                logger.warn(msg);
            }
        }

        String path = page.getPath();
        if (path != null) {
           pop = model.put("path", path);
            if (pop != null && !page.isStateful()) {
                String msg = page.getClass().getName() + " on "
                        + page.getPath()
                        + " model contains an object keyed with reserved "
                        + "name \"path\". The page model object " + pop
                        + " has been replaced with the page path";
                logger.warn(msg);
            }
        }

        pop = model.put("messages", page.getMessages());
        if (pop != null && !page.isStateful()) {
            String msg = page.getClass().getName() + " on " + page.getPath()
                         + " model contains an object keyed with reserved "
                         + "name \"messages\". The page model object "
                         + pop + " has been replaced with the request "
                         + " messages";
            logger.warn(msg);
        }

        return model;
    }
View Full Code Here

                String value = context.getRequestParameter(submitTokenName);
                if (value == null || value.length() == 0) {
                    // CLK-289. If a session attribute exists for the
                    // SUBMIT_CHECK, but no request parameter, we assume the
                    // submission is a duplicate and therefore invalid.
                    LogService logService = ClickUtils.getLogService();
                    logService.warn("    'Redirect After Post' token called '"
                        + submitTokenName + "' is registered in the session, "
                        + "but no matching request parameter was found. "
                        + "(form name: '" + getName()
                        + "'). To protect against a 'duplicate post', "
                        + "Form.onSubmitCheck() will return false.");
View Full Code Here

TOP

Related Classes of org.apache.click.service.LogService

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.