Package org.jahia.params

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


     * @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

    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

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

    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


    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

    }

    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

//            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

    @SuppressWarnings("unchecked")
    protected void handleGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {

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

    @Test
    public void testSimpleFulltextSearchOnSingleSite() throws Exception {
        SearchService searchService = ServicesRegistry.getInstance()
                .getSearchService();
        try {
            ProcessingContext ctx = Jahia.getThreadParamBean();
            RenderContext context = new RenderContext(((ParamBean) ctx)
                    .getRequest(), ((ParamBean) ctx).getResponse(), ctx
                    .getUser());
            JCRSessionWrapper session = JCRSessionFactory.getInstance()
                    .getCurrentUserSession(null, Locale.ENGLISH);
            JCRNodeWrapper homeNode = session
                    .getNode(FIRST_SITECONTENT_ROOT_NODE + "/home");
View Full Code Here

    @Test
    public void testSimpleFulltextSearchOnSingleSiteInFrench() throws Exception {
        SearchService searchService = ServicesRegistry.getInstance()
                .getSearchService();
        try {
            ProcessingContext ctx = Jahia.getThreadParamBean();
            RenderContext context = new RenderContext(((ParamBean) ctx)
                    .getRequest(), ((ParamBean) ctx).getResponse(), ctx
                    .getUser());
            JCRSessionWrapper session = JCRSessionFactory.getInstance()
                    .getCurrentUserSession(null, Locale.FRENCH);
            JCRNodeWrapper homeNode = session
                    .getNode(FIRST_SITECONTENT_ROOT_NODE + "/home");
View Full Code Here

TOP

Related Classes of org.jahia.params.ProcessingContext

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.