Examples of ProcessingContext


Examples of org.apache.sling.rewriter.ProcessingContext

            assertFalse(configuration.match(context));
        }
    }

    private ProcessingContext createProcessingContext(SlingHttpServletRequest request) {
        final ProcessingContext context = mock(ProcessingContext.class);
        when(context.getContentType()).thenReturn("text/xml");
        when(context.getRequest()).thenReturn(request);

        return context;
    }
View Full Code Here

Examples of org.apache.sling.rewriter.ProcessingContext

    /**
     * Search the first matching processor
     */
    private Processor getProcessor() {
        final ProcessingContext processorContext = new ServletProcessingContext(this.request, this, this.getSlingResponse(), this.contentType);
        Processor found = null;
        final List<ProcessorConfiguration> processorConfigs = this.processorManager.getProcessorConfigurations();
        final Iterator<ProcessorConfiguration> i = processorConfigs.iterator();
        while ( found == null && i.hasNext() ) {
            final ProcessorConfiguration config = i.next();
            if ( config.match(processorContext) ) {
                try {
                    found = this.processorManager.getProcessor(config, processorContext);
                    this.request.getRequestProgressTracker().log("Found processor for post processing {0}", config);
                } catch (final SlingException se) {
                    // if an exception occurs during setup of the pipeline and we are currently
                    // already processing an error, we ignore this!
                    if ( processorContext.getRequest().getAttribute("javax.servlet.error.status_code") != null ) {
                        this.request.getRequestProgressTracker().log("Ignoring found processor for post processing {0}" +
                                " as an error occured ({1}) during setup while processing another error.", config, se);
                    } else {
                        throw se;
                    }
View Full Code Here

Examples of org.glassfish.apf.ProcessingContext

        }

        // process resource related annotations
        EjbInterceptorContext ejbInterceptorContext =
            new EjbInterceptorContext(interceptor);
        ProcessingContext procContext = ainfo.getProcessingContext();
        procContext.pushHandler(ejbInterceptorContext);
        procContext.getProcessor().process(
            procContext, new Class[] { interceptorClass });
        return;
    }
View Full Code Here

Examples of org.jahia.params.ProcessingContext

        } catch (Exception e) {
            throw new ServletException("BeanUtils.populate", e);
        }
        session.setAttribute(CLASS_NAME + "jahiaMailSettings", cfg);
        JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData");
        ProcessingContext jParams = null;
        if (jData != null) {
            jParams = jData.getProcessingContext();
        }

        MailSettingsValidationResult result = MailServiceImpl.validateSettings(cfg, true);
View Full Code Here

Examples of org.jahia.params.ProcessingContext

     * @author Alexandre Kraft
     */
    public void service(HttpServletRequest request, HttpServletResponse response) throws Exception {

        JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData");
        ProcessingContext jParams = null;
        if (jData != null) {
            jParams = jData.getProcessingContext();
        }

        userRequestDispatcher(request, response, request.getSession());
View Full Code Here

Examples of org.jahia.params.ProcessingContext

    private void commitChanges(HttpServletRequest request, HttpServletResponse response, HttpSession session)

            throws IOException, ServletException {
        JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData");
        ProcessingContext jParams = null;
        if (jData != null) {
            jParams = jData.getProcessingContext();
        }

        request.setAttribute("warningMsg", "");
View Full Code Here

Examples of org.jahia.params.ProcessingContext

    //-------------------------------------------------------------------------

    private void reallyDelete(HttpServletRequest request, HttpServletResponse response, HttpSession session)
            throws ServletException, IOException {
        JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData");
        ProcessingContext jParams = null;
        if (jData != null) {
            jParams = jData.getProcessingContext();
        }

        request.setAttribute("warningMsg", "");
View Full Code Here

Examples of org.jahia.params.ProcessingContext


    private void prepareDeployPortlet(HttpServletRequest request, HttpServletResponse response, HttpSession session)
            throws IOException, ServletException {
        JahiaData jData = (JahiaData) request.getAttribute("org.jahia.data.JahiaData");
        ProcessingContext jParams = null;
        if (jData != null) {
            jParams = jData.getProcessingContext();
        }
        String deploy = jParams.getParameter("doDeploy");
        boolean doDeploy = false;
        if (deploy != null && Boolean.parseBoolean(deploy)) {
            doDeploy = true;
        }

        String prepare = jParams.getParameter("doPrepare");
        boolean doPrepare = false;
        if (prepare != null && Boolean.parseBoolean(prepare)) {
            doPrepare = true;
        }
View Full Code Here

Examples of org.jahia.params.ProcessingContext

    }

    public static JahiaSite createSite(String name, String serverName, String templateSet,
                                       String prepackedZIPFile, String siteZIPName) throws Exception {

        ProcessingContext ctx = Jahia.getThreadParamBean();
        JahiaUser admin = JahiaAdminUser.getAdminUser(0);

        JahiaSitesService service = ServicesRegistry.getInstance().getJahiaSitesService();
        JahiaSite site = service.getSiteByKey(name);

        if (site != null) {
            service.removeSite(site);
        }
        File siteZIPFile = null;
        File sharedZIPFile = null;
        try {
            if (!StringUtils.isEmpty(prepackedZIPFile)) {
                ZipInputStream zis = null;
                OutputStream os = null;
                try {
                    zis = new ZipInputStream(new FileInputStream(new File(prepackedZIPFile)));
                    ZipEntry z = null;
                    while ((z = zis.getNextEntry()) != null) {
                        if (siteZIPName.equalsIgnoreCase(z.getName())
                                || "shared.zip".equals(z.getName())) {
                            File zipFile = File.createTempFile("import", ".zip");
                            os = new FileOutputStream(zipFile);
                            byte[] buf = new byte[4096];
                            int r;
                            while ((r = zis.read(buf)) > 0) {
                                os.write(buf, 0, r);
                            }
                            os.close();
                            if ("shared.zip".equals(z.getName())) {
                                sharedZIPFile = zipFile;
                            } else {
                                siteZIPFile = zipFile;
                            }
                        }
                    }
                } catch (IOException e) {
                    logger.error(e.getMessage(), e);
                } finally {
                    if (os != null) {
                        try {
                            os.close();
                        } catch (IOException e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                    if (zis != null) {
                        try {
                            zis.close();
                        } catch (IOException e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                }
            }
            if (sharedZIPFile != null) {
                try {
                    ImportExportBaseService.getInstance().importSiteZip(sharedZIPFile, null, null);
                } catch (RepositoryException e) {
                    logger.warn("shared.zip could not be imported", e);
                }
            }
            site = service.addSite(admin, name, serverName, name, name, ctx.getLocale(),
                    templateSet, siteZIPFile == null ? "noImport" : "fileImport", siteZIPFile,
                    null, false, false, null);
            ctx.setSite(site);
        } finally {
            if (sharedZIPFile != null) {
                sharedZIPFile.delete();
            }
            if (siteZIPFile != null) {
View Full Code Here

Examples of org.jahia.params.ProcessingContext

//            return;
//        }

        final ProcessingContextFactory pcf = (ProcessingContextFactory) SpringContextSingleton.
                getInstance().getContext().getBean(ProcessingContextFactory.class.getName());
        ProcessingContext ctx = null;

        try {
            // should send response wrapper !
            ctx = pcf.getContext(httpServletRequest, httpServletResponse, servletContext);
        } catch (JahiaException e) {
            logger.error("Error while trying to build ProcessingContext", e);
            return;
        }

        try {
            ctx.setOperationMode(ParamBean.EDIT);           
//            ctx.setEntryLoadRequest(new EntryLoadRequest(EntryLoadRequest.STAGING_WORKFLOW_STATE, 0, ctx.getLocales()));

            JahiaUser admin = JahiaAdminUser.getAdminUser(0);
            JCRSessionFactory.getInstance().setCurrentUser(admin);
            ctx.setTheUser(admin);
        } catch (JahiaException e) {
            logger.error("Error getting user", e);
        }

        try {
            String pathInfo = StringUtils.substringAfter(httpServletRequest.getPathInfo(), "/test");
            if (StringUtils.isNotEmpty(pathInfo)) {
                final Set<String> ignoreTests = getIgnoreTests();
                // Execute one test
                String className = pathInfo.substring(pathInfo.lastIndexOf('/')+1);
                try {
                    JUnitCore junitcore = new JUnitCore();
                    SurefireJUnitXMLResultFormatter xmlResultFormatter = new SurefireJUnitXMLResultFormatter(httpServletResponse.getOutputStream());
                    junitcore.addListener(xmlResultFormatter);
                    Class testClass = Class.forName(className);
                    List<Class> classes = getTestClasses(testClass, new ArrayList<Class>());
                    if (classes.isEmpty()) {
                        Description description = Description.createSuiteDescription(testClass);
                        xmlResultFormatter.testRunStarted(description);
                        xmlResultFormatter.testRunFinished(new Result());
                    } else {
                        junitcore.run(new FilterRequest(Request.classes(classes
                                .toArray(new Class[classes.size()])), new Filter() {

                            @Override
                            public boolean shouldRun(Description description) {
                                return !ignoreTests.contains(description.getDisplayName());
                            }

                            @Override
                            public String describe() {
                                return "Filter out Jahia configured methods";
                            }
                        }));
                    }
                } catch (Exception e) {
                    logger.error("Error executing test", e);
                }
            } else {
                WebApplicationContext webApplicationContext = (WebApplicationContext) servletContext.getAttribute(WebApplicationContext.class.getName() + ".jahiaModules");
                Map<String,TestBean> testBeans = webApplicationContext.getBeansOfType(TestBean.class);

                PrintWriter pw = httpServletResponse.getWriter();
                // Return the lists of available tests
                List<String> tests = new LinkedList<String>();
                SortedSet<TestBean> s = new TreeSet<TestBean>(testBeans.values());
                for (TestBean testBean : s) {
                    for (String o : testBean.getTestCases()) {
                        tests.add(o);
                    }
                }

                for (String c : tests) {
          pw.println(c);
        }
            }
        } finally {
            try {
                ctx.setUserGuest();
            } catch (JahiaException e) {
                logger.error(e.getMessage(), e);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.