Package org.jahia.bin

Examples of org.jahia.bin.ActionResult


        convertedFileNode.setProperty("convertedDocFormat", returnedMimeType);
        convertedFileNode.setProperty("conversionSucceeded", conversionSucceeded);

        session.save();
        }
        return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject());
    }
View Full Code Here


        Map<String,Object> bindings = new HashMap<String,Object>();
        bindings.put("newUser",user);
        if (mailService.isEnabled()) {
            mailService.sendMessageWithTemplate(templatePath,bindings,to,from,cc,bcc,resource.getLocale(),"Jahia User Registration");
        }
        return new ActionResult(HttpServletResponse.SC_ACCEPTED,parameters.get("userredirectpage").get(0), new JSONObject());
    }
View Full Code Here

        String passwd = req.getParameter("password").trim();
        JSONObject json = new JSONObject();

        if (!resource.getNode().hasPermission("jcr:write_default") || !resource.getNode().isNodeType("jnt:user")) {
            return new ActionResult(HttpServletResponse.SC_FORBIDDEN, null, null);
        }

        if ("".equals(passwd)) {
            String userMessage = JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.specifyPassword.label", renderContext.getUILocale());
            json.put("errorMessage", userMessage);
        } else {
            String passwdConfirm = req.getParameter("passwordconfirm").trim();
            if (!passwdConfirm.equals(passwd)) {
                String userMessage = JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.passwdNotMatch.label", renderContext.getUILocale());
                json.put("errorMessage",userMessage);
            } else {
                JahiaPasswordPolicyService pwdPolicyService = ServicesRegistry.getInstance().getJahiaPasswordPolicyService();
                JahiaUser user = ServicesRegistry.getInstance().getJahiaUserManagerService().lookupUser(resource.getNode().getName());

                PolicyEnforcementResult evalResult = pwdPolicyService.enforcePolicyOnPasswordChange(user, passwd, true);
                if (!evalResult.isSuccess()) {
                    EngineMessages policyMsgs = evalResult.getEngineMessages();
                    String res = "";
                    for (EngineMessage message : policyMsgs.getMessages()) {
                        res += (message.isResource() ? MessageFormat.format(JahiaResourceBundle.getJahiaInternalResource(message.getKey(), renderContext.getUILocale()), message.getValues()) : message.getKey())+"\n";
                    }
                    json.put("errorMessage", res);
                } else {
                    // change password
                    user.setPassword(passwd);
                    json.put("errorMessage", JahiaResourceBundle.getJahiaInternalResource("org.jahia.admin.userMessage.passwordChanged.label", renderContext.getUILocale()));

                    httpSession.setAttribute(ProcessingContext.SESSION_USER, user);

                    json.put("result", "success");
                }
            }
        }

        return new ActionResult(HttpServletResponse.SC_OK, null, json);
    }
View Full Code Here

        if (req.getSession().getAttribute("passwordRecoveryAsked") != null) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.alreadysent",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(HttpServletResponse.SC_OK, null, json);
        }

        JahiaUser user = userManagerService.lookupUser(username);
        if (user == null ) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.username.invalid",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(SC_OK, null, json);
        }

        String to = user.getProperty("j:email");
        if (to == null || !MailService.isValidEmailAddress(to, false)) {
            JSONObject json = new JSONObject();
            String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.invalid",
                    resource.getLocale(), "Jahia User Registration");
            json.put("message", message);
            return new ActionResult(SC_OK, null, json);
        }
        String from = SettingsBean.getInstance().getMail_from();

        String authKey = DigestUtils.md5Hex(username + System.currentTimeMillis());
        req.getSession().setAttribute("passwordRecoveryToken", new PasswordToken(authKey, user.getLocalPath()));

        Map<String,Object> bindings = new HashMap<String,Object>();
        bindings.put("link", req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() +
                Jahia.getContextPath() + Render.getRenderServletPath() + "/live/"
                + resource.getLocale().getLanguage() + resource.getNode().getPath() + ".html?key=" + authKey);
        bindings.put("user", user);

        mailService.sendMessageWithTemplate(templatePath, bindings, to, from, null, null, resource.getLocale(), "Jahia User Registration");
        req.getSession().setAttribute("passwordRecoveryAsked", true);

        JSONObject json = new JSONObject();
        String message = JahiaResourceBundle.getString("JahiaUserRegistration", "passwordrecovery.mail.sent",
                resource.getLocale(), "Jahia User Registration");
        json.put("message", message);
        return new ActionResult(HttpServletResponse.SC_ACCEPTED, null, json);
    }
View Full Code Here

                node.setProperty("j:lastVote", values.get(0));
                node.setProperty("j:nbOfVotes",node.getProperty("j:nbOfVotes").getLong()+1);
                node.setProperty("j:sumOfVotes",node.getProperty("j:sumOfVotes").getLong()+ Long.valueOf(values.get(0)));
                session.save();
                try {
                    return new ActionResult(HttpServletResponse.SC_OK, node.getPath(), Render.serializeNodeToJSON(node));
                } catch (IOException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                } catch (JSONException e) {
                    e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
                }
View Full Code Here

            bookmark.setProperty("date", new GregorianCalendar());
            if (req.getParameter("url") != null) { bookmark.setProperty("url", req.getParameter("url")); }
            bookmark.setProperty("jcr:title", req.getParameter("jcr:title"));
            bookmark.saveSession();
        }
        return new ActionResult(HttpServletResponse.SC_OK, null, new JSONObject());
    }
View Full Code Here

            NodeIterator n = action.getNodes();
            while (n.hasNext()) {
                JCRNodeWrapper actionNode = (JCRNodeWrapper) n.next();
                String actionName = actionNode.getProperty("j:action").getString();
                ActionResult r = callAction(request, actionName);
            }
        } catch (RepositoryException e) {

        }
        return "ok";
View Full Code Here

        // Check in
        versionManager.checkin(pollNode.getPath());
        // Check in poll node
        versionManager.checkin(answerNode.getPath());

        return new ActionResult(HttpServletResponse.SC_OK, null, generateJSONObject(pollNode));
    }
View Full Code Here

                actionNode = nodeWrapper;
            }
        }
        if (actionNode != null && actionNode.hasProperty("node")) {
            Node n = actionNode.getProperty("node").getNode();
            return new ActionResult(HttpServletResponse.SC_OK, n.getPath());
        }
        return new ActionResult(HttpServletResponse.SC_OK);
    }
View Full Code Here

*/
public class ResultsAction extends Action {
     private transient static Logger logger = org.slf4j.LoggerFactory.getLogger(VoteAction.class);

    public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource, JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver) throws Exception {
     return new ActionResult(HttpServletResponse.SC_OK, null, VoteAction.generateJSONObject(renderContext.getMainResource().getNode()));
    }
View Full Code Here

TOP

Related Classes of org.jahia.bin.ActionResult

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.