Example usage for org.springframework.web.servlet.support RequestContextUtils getLocale

List of usage examples for org.springframework.web.servlet.support RequestContextUtils getLocale

Introduction

In this page you can find the example usage for org.springframework.web.servlet.support RequestContextUtils getLocale.

Prototype

public static Locale getLocale(HttpServletRequest request) 

Source Link

Document

Retrieve the current locale from the given request, using the LocaleResolver bound to the request by the DispatcherServlet (if available), falling back to the request's accept-header Locale.

Usage

From source file:com.krawler.spring.organizationChart.organizationChartController.java

public ModelAndView getGridMappedUsers(HttpServletRequest request, HttpServletResponse response) {
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();

    try {/*from   w w w.ja  v  a  2 s.c  o  m*/
        String childid = request.getParameter("nodeid");
        String parentid = request.getParameter("parentid");
        String userid = sessionHandlerImplObj.getUserid(request);
        String companyid = sessionHandlerImplObj.getCompanyid(request);
        Locale locale = RequestContextUtils.getLocale(request);
        jobj = organizationService.getGridMappedUsers(parentid, childid, userid, companyid, locale);

        jobj1.put("valid", true);
        jobj1.put("data", jobj);
        jobj1.put("success", true);
    } catch (Exception e) {
        logger.warn("General exception in getGridMappedUsers()", e);
    }
    return new ModelAndView("jsonView", "model", jobj1.toString());
}

From source file:cz.zcu.kiv.eegdatabase.logic.controller.experiment.WizardAjaxMultiController.java

/**
 * Adds new person to database/*from  w  w  w  .  j  a  va 2 s. co  m*/
 *
 * @param request
 * @param response
 * @return
 * @throws IOException
 */
public ModelAndView addNewPerson(HttpServletRequest request, HttpServletResponse response) throws IOException {
    ModelAndView mav = new ModelAndView("experiments/JSonView");
    log.debug("WizardAjaxMultiController - Add new person.");

    Person person = null;
    try {
        person = personService.createPerson(request.getParameter("givenname"), request.getParameter("surname"),
                request.getParameter("dateOfBirth"), request.getParameter("email"),
                request.getParameter("gender"), request.getParameter("phoneNumber"),
                request.getParameter("note"), null);
        mailService.sendRegistrationConfirmMail(person, RequestContextUtils.getLocale(request));
    } catch (MailException e) {
        log.error("E-mail was NOT sent");
        log.error(e);
        e.printStackTrace();
    } catch (ParseException e) {//throw futher? (code will fail anyway)
        log.error(e);
    }

    JSONObject jo = new JSONObject();

    log.debug("Saving attribute - success: true");
    jo.put("success", true);
    log.debug("Saving attribute - personId: " + person.getPersonId());
    jo.put("personId", person.getPersonId());

    //log.debug("Generating username");
    //String username = apc.getGivenname().toLowerCase() + "-" + apc.getSurname().toLowerCase();
    log.debug("Saving  JSONObject: " + jo);
    mav.addObject("result", jo);
    return mav;
}

From source file:cz.zcu.kiv.eegdatabase.logic.controller.article.AddArticleCommentController.java

private void sendNotification(String email, ArticleComment comment, HttpServletRequest request)
        throws MessagingException {
    String articleURL = "http://" + domain + "/articles/detail.html?articleId="
            + comment.getArticle().getArticleId();
    //System.out.println(articleURL);
    String subject = messageSource.getMessage("articles.group.email.subscribtion.subject",
            new String[] { comment.getArticle().getTitle(), comment.getPerson().getUsername() },
            RequestContextUtils.getLocale(request));
    //System.out.println(subject);
    String emailBody = "<html><body>";

    emailBody += "<p>"
            + messageSource.getMessage("articles.group.email.subscribtion.body.text.part1",
                    new String[] { comment.getArticle().getTitle() }, RequestContextUtils.getLocale(request))
            + "";
    emailBody += "&nbsp;(<a href=\"" + articleURL + "\" target=\"_blank\">" + articleURL + "</a>)</p><br />";
    emailBody += "<h3>Text:</h3> <p>" + comment.getText() + "</p><br />";
    emailBody += "<p>" + messageSource.getMessage("articles.comments.email.subscribtion.body.text.part2", null,
            RequestContextUtils.getLocale(request)) + "</p>";
    emailBody += "</body></html>";

    //System.out.println(emailBody);
    log.debug("email body: " + emailBody);

    log.debug("Composing e-mail message");
    MimeMessage mimeMessage = mailSender.createMimeMessage();

    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
    message.setFrom(mailMessage.getFrom());

    //  message.setContent("text/html");
    message.setTo(email);/*  w ww . j a va  2  s .  c  om*/
    //helper.setFrom(messageSource.getMessage("registration.email.from", null, RequestContextUtils.getLocale(request)));
    message.setSubject(subject);
    message.setText(emailBody, true);

    try {
        log.debug("Sending e-mail" + message);
        log.debug("mailSender" + mailSender);
        log.debug("smtp " + mailSender.getHost());
        mailSender.send(mimeMessage);
        log.debug("E-mail was sent");
    } catch (MailException e) {
        log.error("E-mail was NOT sent");
        log.error(e);
    }
}

From source file:de.iteratec.iteraplan.presentation.UserContextInitializationServiceImpl.java

/**
 * Stores the user's login name and the user's roles to the session. The stored information is
 * used in {@link de.iteratec.iteraplan.presentation.dialogs.Start.InitCommand} to create the
 * {@link UserContext} object./*w  ww  .  j a v a  2 s .co  m*/
 * 
 * Retrieves all information about the logged-in user from the iteraplan database, creates the
 * {@link UserContext} filled with the respective values of the logged-in user and stores the
 * context in the global memory. Also checks, if the user's password has expired. If the user
 * context already exists, nothing is done.
 * 
 * @return An error message key or null if everything was successful.
 */
private String createAndStoreUserContext(HttpServletRequest req, Authentication authentication) {
    HttpSession session = req.getSession();

    String userLogin = StringUtils.trim(authentication.getName());
    session.setAttribute(LOGGED_IN_USER_LOGIN, userLogin);

    // Make sure that the MASTER data source is used upon login. The user's context stored in the
    // thread local of the UserContext is not null, if the user has already logged into iteraplan
    // previously and the server has not been restarted since. Note that though the session has
    // been invalidated on logout (see Spring Security configuration), but the UserContext is still
    // there.
    // Thus the reference to the data source that the user connects to must be explicitly set to
    // the MASTER data source. Otherwise the data source stored in the context is used, but the
    // according database does usually not contain all the data necessary for a successful login
    // (e.g. the role for the demo access to iteraplan).
    if (UserContext.getCurrentUserContext() != null) {
        LOGGER.info("Point the user to the MASTER data source.");
        UserContext.getCurrentUserContext().setDataSource(Constants.MASTER_DATA_SOURCE);
    }

    final Set<String> userRoles = getUserRoles(authentication);
    session.setAttribute(LOGGED_IN_USER_ROLES, userRoles);

    User user = userService.getUserByLoginIfExists(userLogin);
    final Set<Role> roles = loadRoles(userRoles);
    Locale locale = RequestContextUtils.getLocale(req);

    // Create and store user context.
    UserContext userContext = new UserContext(userLogin, roles, locale, user);
    UserContext.setCurrentUserContext(userContext);
    session.setAttribute(SessionConstants.USER_CONTEXT, userContext);
    LOGGER.debug("User context created and stored in user's session.");

    LOGIN_LOGGER.info(userContext.toCSVString());

    if (user == null) {
        user = userService.createUser(userLogin);

        // Create and store user context.
        // the new user can only be created after the user context is set (above)
        // as the update of an entity triggers the LastModificationInterceptor, which
        // expects an already set user context
        userContext = new UserContext(userLogin, roles, locale, user);
        UserContext.detachCurrentUserContext();
        UserContext.setCurrentUserContext(userContext);
        session.setAttribute(SessionConstants.USER_CONTEXT, userContext);
    }

    readLdapData(authentication.getPrincipal(), user);

    if (roles != null && !roles.isEmpty()
            && !(roles.containsAll(user.getRoles()) && user.getRoles().containsAll(roles))) {
        user.clearRoles();
        for (Role role : roles) {
            user.addRoleTwoWay(role);
        }
        userService.saveOrUpdate(user);
    }

    final String errorMessageKey = createDataSource(userContext);
    if (errorMessageKey != null) {
        return errorMessageKey;
    }

    LOGGER.info("User has logged in.");

    // notify ElasticeamService (bean), that the metamodel and model for the 'new' datasource needs to be loaded
    elasticService.initOrReload();

    //Create elasticMiContext
    ElasticMiContext elasticMiContext = elasticMiContextAndStakeholderManagerInitializationService
            .initializeMiContextAndStakeholderManager(userLogin, userContext.getDataSource());
    session.setAttribute(SessionConstants.ELASTIC_MI_CONTEXT, elasticMiContext);

    return null;
}

From source file:cz.zcu.kiv.eegdatabase.logic.controller.article.AddArticleController.java

private void sendNotification(String email, Article article, HttpServletRequest request)
        throws MessagingException {
    String articleURL = "http://" + domain + "/articles/detail.html?articleId=" + article.getArticleId();
    //System.out.println(articleURL);
    String subject = messageSource.getMessage("articles.group.email.subscribtion.subject",
            new String[] { article.getTitle(), article.getPerson().getUsername() },
            RequestContextUtils.getLocale(request));
    //System.out.println(subject);
    String emailBody = "<html><body>";

    emailBody += "<p>" + messageSource.getMessage("articles.comments.email.subscribtion.body.text.part1",
            new String[] { article.getTitle() }, RequestContextUtils.getLocale(request)) + "";
    emailBody += "&nbsp;(<a href=\"" + articleURL + "\" target=\"_blank\">" + articleURL + "</a>)</p><br />";
    emailBody += "<h3>" + article.getTitle() + "</h3> <p>" + article.getText() + "</p><br />";
    emailBody += "<p>" + messageSource.getMessage("articles.comments.email.subscribtion.body.text.part2", null,
            RequestContextUtils.getLocale(request)) + "</p>";
    emailBody += "</body></html>";

    //System.out.println(emailBody);
    log.debug("email body: " + emailBody);

    log.debug("Composing e-mail message");
    MimeMessage mimeMessage = mailSender.createMimeMessage();

    MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
    message.setFrom(mailMessage.getFrom());

    //  message.setContent("text/html");
    message.setTo(email);/*from www. ja  v a 2  s.co m*/
    //helper.setFrom(messageSource.getMessage("registration.email.from", null, RequestContextUtils.getLocale(request)));
    message.setSubject(subject);
    message.setText(emailBody, true);

    try {
        log.debug("Sending e-mail" + message);
        log.debug("mailSender" + mailSender);
        log.debug("smtp " + mailSender.getHost());
        mailSender.send(mimeMessage);
        log.debug("E-mail was sent");
    } catch (MailException e) {
        log.error("E-mail was NOT sent");
        log.error(e);
    }
}

From source file:com.krawler.spring.profileHandler.profileHandlerController.java

public JSONObject getUserToEmailJson(List ll, HttpServletRequest request, int totalSize) {
    JSONArray jarr = new JSONArray();
    JSONObject jobj = new JSONObject();
    JSONObject jobjTemp = new JSONObject();
    JSONArray jarrColumns = new JSONArray();
    JSONArray jarrRecords = new JSONArray();
    JSONObject jMeta = new JSONObject();
    try {//from w w w . j a v a2 s .  com
        Iterator ite = ll.iterator();
        while (ite.hasNext()) {
            User obj = (User) ite.next();
            JSONObject tmpObj = new JSONObject();
            tmpObj.put("relatedto", 3);
            tmpObj.put("relatedid", obj.getUserID());
            tmpObj.put("fname", obj.getFirstName());
            tmpObj.put("name", obj.getLastName());
            tmpObj.put("emailid", obj.getEmailID());
            jarr.put(tmpObj);
        }

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.campaigndetails.bouncereport.header.fname", null,
                RequestContextUtils.getLocale(request)));//"First Name");
        jobjTemp.put("tip", messageSource.getMessage("crm.campaigndetails.bouncereport.header.fname", null,
                RequestContextUtils.getLocale(request)));//"First Name");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "fname");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header", messageSource.getMessage("crm.campaigndetails.bouncereport.header.lname", null,
                RequestContextUtils.getLocale(request)));//"Last Name");
        jobjTemp.put("tip", messageSource.getMessage("crm.campaigndetails.bouncereport.header.lname", null,
                RequestContextUtils.getLocale(request)));//"Last Name");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "name");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("header",
                messageSource.getMessage("crm.EMAIL", null, RequestContextUtils.getLocale(request)));// "Email");
        jobjTemp.put("tip",
                messageSource.getMessage("crm.EMAIL", null, RequestContextUtils.getLocale(request)));//"Email");
        jobjTemp.put("pdfwidth", 60);
        jobjTemp.put("dataIndex", "emailid");
        jarrColumns.put(jobjTemp);

        jobjTemp = new JSONObject();
        jobjTemp.put("name", "targetscount");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "name");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "fname");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "emailid");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "relatedto");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "company");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "targetlistDescription");
        jarrRecords.put(jobjTemp);
        jobjTemp = new JSONObject();
        jobjTemp.put("name", "relatedid");
        jarrRecords.put(jobjTemp);

        jobj.put("columns", jarrColumns);
        jMeta.put("totalProperty", "totalCount");
        jMeta.put("root", "data");
        jMeta.put("fields", jarrRecords);
        jobj.put("metaData", jMeta);

        jobj.put("success", true);
        jobj.put("data", jarr);
        jobj.put("totalCount", totalSize);
    } catch (Exception e) {
        logger.warn("General exception in getUserToEmailJson()", e);
    }
    return jobj;
}

From source file:com.krawler.spring.common.CommonFnController.java

public ModelAndView getCompanyTypes(HttpServletRequest request, HttpServletResponse response) {
    JSONObject jobj = new JSONObject();
    boolean issuccess = true;
    String msg = "";
    try {/*from ww  w. j  a  v a  2 s .c  o  m*/
        KwlReturnObject result = accCommonTablesDAO.getCompanyTypes();
        List ll = result.getEntityList();
        Iterator itr = ll.iterator();

        JSONArray jArr = new JSONArray();
        while (itr.hasNext()) {
            CompanyType cType = (CompanyType) itr.next();
            JSONObject obj = new JSONObject();
            obj.put("id", cType.getID());
            obj.put("name", messageSource.getMessage("acc.ct." + cType.getID(), null,
                    RequestContextUtils.getLocale(request)));
            obj.put("details", cType.getDetails());
            jArr.put(obj);
        }
        jobj.put("data", jArr);
        jobj.put("totalCount", result.getRecordTotalCount());
    } catch (Exception ex) {
        Logger.getLogger(CommonFnController.class.getName()).log(Level.SEVERE, null, ex);
        issuccess = false;
        msg = "CommonFnController.getCompanyType : " + ex.getMessage();
    } finally {
        try {
            jobj.put("success", issuccess);
            jobj.put("msg", msg);
        } catch (JSONException ex) {
            Logger.getLogger(CommonFnController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return new ModelAndView("jsonView", "model", jobj.toString());
}

From source file:org.springmodules.validation.commons.taglib.JavascriptValidatorTag.java

/**
 * Render the JavaScript for to perform validations based on the form name.
 *
 * @throws javax.servlet.jsp.JspException if a JSP exception has occurred
 *//*from   ww  w  .  ja va  2s.com*/
public int doStartTag() throws JspException {
    StringBuffer results = new StringBuffer();

    Locale locale = RequestContextUtils.getLocale((HttpServletRequest) pageContext.getRequest());

    ValidatorResources resources = getValidatorResources();

    Form form = resources.getForm(locale, formName);
    if (form != null) {
        if ("true".equalsIgnoreCase(dynamicJavascript)) {
            MessageSource messages = getMessageSource();

            List lActions = new ArrayList();
            List lActionMethods = new ArrayList();

            // Get List of actions for this Form
            for (Iterator i = form.getFields().iterator(); i.hasNext();) {
                Field field = (Field) i.next();

                for (Iterator x = field.getDependencyList().iterator(); x.hasNext();) {
                    Object o = x.next();

                    if (o != null && !lActionMethods.contains(o)) {
                        lActionMethods.add(o);
                    }
                }
            }

            // Create list of ValidatorActions based on lActionMethods
            for (Iterator i = lActionMethods.iterator(); i.hasNext();) {
                String depends = (String) i.next();
                ValidatorAction va = resources.getValidatorAction(depends);

                // throw nicer NPE for easier debugging
                if (va == null) {
                    throw new NullPointerException(
                            "Depends string \"" + depends + "\" was not found in validator-rules.xml.");
                }

                String javascript = va.getJavascript();
                if (javascript != null && javascript.length() > 0) {
                    lActions.add(va);
                } else {
                    i.remove();
                }
            }

            Collections.sort(lActions, new Comparator() {
                public int compare(Object o1, Object o2) {
                    ValidatorAction va1 = (ValidatorAction) o1;
                    ValidatorAction va2 = (ValidatorAction) o2;

                    if ((va1.getDepends() == null || va1.getDepends().length() == 0)
                            && (va2.getDepends() == null || va2.getDepends().length() == 0)) {
                        return 0;
                    } else if ((va1.getDepends() != null && va1.getDepends().length() > 0)
                            && (va2.getDepends() == null || va2.getDepends().length() == 0)) {
                        return 1;
                    } else if ((va1.getDepends() == null || va1.getDepends().length() == 0)
                            && (va2.getDepends() != null && va2.getDepends().length() > 0)) {
                        return -1;
                    } else {
                        return va1.getDependencyList().size() - va2.getDependencyList().size();
                    }
                }
            });

            String methods = null;
            for (Iterator i = lActions.iterator(); i.hasNext();) {
                ValidatorAction va = (ValidatorAction) i.next();

                if (methods == null) {
                    methods = va.getMethod() + "(form)";
                } else {
                    methods += " && " + va.getMethod() + "(form)";
                }
            }

            results.append(getJavascriptBegin(methods));

            for (Iterator i = lActions.iterator(); i.hasNext();) {
                ValidatorAction va = (ValidatorAction) i.next();
                String jscriptVar = null;
                String functionName = null;

                if (va.getJsFunctionName() != null && va.getJsFunctionName().length() > 0) {
                    functionName = va.getJsFunctionName();
                } else {
                    functionName = va.getName();
                }

                results.append("    function " + functionName + " () { \n");
                for (Iterator x = form.getFields().iterator(); x.hasNext();) {
                    Field field = (Field) x.next();

                    // Skip indexed fields for now until there is a good way to handle
                    // error messages (and the length of the list (could retrieve from scope?))
                    if (field.isIndexed() || field.getPage() != page || !field.isDependency(va.getName())) {

                        continue;
                    }

                    String message = MessageUtils.getMessage(messages, locale, va, field);

                    message = (message != null) ? message : "";

                    jscriptVar = this.getNextVar(jscriptVar);

                    results.append("     this." + jscriptVar + " = new Array(\"" + field.getKey() + "\", \""
                            + message + "\", ");

                    results.append("new Function (\"varName\", \"");

                    Map vars = field.getVars();
                    // Loop through the field's variables.
                    Iterator varsIterator = vars.keySet().iterator();
                    while (varsIterator.hasNext()) {
                        String varName = (String) varsIterator.next();
                        Var var = (Var) vars.get(varName);
                        String varValue = var.getValue();
                        String jsType = var.getJsType();

                        // skip requiredif variables field, fieldIndexed, fieldTest, fieldValue
                        if (varName.startsWith("field")) {
                            continue;
                        }

                        if (Var.JSTYPE_INT.equalsIgnoreCase(jsType)) {
                            results.append("this." + varName + "="
                                    + ValidatorUtils.replace(varValue, "\\", "\\\\") + "; ");
                        } else if (Var.JSTYPE_REGEXP.equalsIgnoreCase(jsType)) {
                            results.append("this." + varName + "=/"
                                    + ValidatorUtils.replace(varValue, "\\", "\\\\") + "/; ");
                        } else if (Var.JSTYPE_STRING.equalsIgnoreCase(jsType)) {
                            results.append("this." + varName + "='"
                                    + ValidatorUtils.replace(varValue, "\\", "\\\\") + "'; ");
                            // So everyone using the latest format doesn't need to change their xml files immediately.
                        } else if ("mask".equalsIgnoreCase(varName)) {
                            results.append("this." + varName + "=/"
                                    + ValidatorUtils.replace(varValue, "\\", "\\\\") + "/; ");
                        } else {
                            results.append("this." + varName + "='"
                                    + ValidatorUtils.replace(varValue, "\\", "\\\\") + "'; ");
                        }
                    }

                    results.append(" return this[varName];\"));\n");
                }
                results.append("    } \n\n");
            }
        } else if ("true".equalsIgnoreCase(staticJavascript)) {
            results.append(this.getStartElement());
            if ("true".equalsIgnoreCase(htmlComment)) {
                results.append(htmlBeginComment);
            }
        }
    }

    if ("true".equalsIgnoreCase(staticJavascript)) {
        results.append(getJavascriptStaticMethods(resources));
    }

    if (form != null
            && ("true".equalsIgnoreCase(dynamicJavascript) || "true".equalsIgnoreCase(staticJavascript))) {

        results.append(getJavascriptEnd());
    }

    JspWriter writer = pageContext.getOut();
    try {
        writer.print(results.toString());
    } catch (IOException e) {
        throw new JspException(e.getMessage());
    }

    return (SKIP_BODY);

}

From source file:alfio.controller.api.support.TicketHelper.java

public Optional<Triple<ValidationResult, Event, Ticket>> assignTicket(String eventName, String reservationId,
        String ticketIdentifier, UpdateTicketOwnerForm updateTicketOwner, Optional<Errors> bindingResult,
        HttpServletRequest request, Model model) {
    return assignTicket(eventName, ticketIdentifier, updateTicketOwner, bindingResult, request, t -> {
        model.addAttribute("value", t.getRight());
        model.addAttribute("validationResult", t.getLeft());
        model.addAttribute("countries", getLocalizedCountries(RequestContextUtils.getLocale(request)));
        model.addAttribute("event", t.getMiddle());
    }, Optional.empty());//w  ww.  jav a 2s.  co m
}

From source file:com.krawler.spring.organizationChart.organizationChartController.java

public ModelAndView updateNode(HttpServletRequest request, HttpServletResponse response) {
    JSONObject jobj = new JSONObject();
    JSONObject jobj1 = new JSONObject();
    String retMsg = "";
    //Create transaction
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("JE_Tx");
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
    TransactionStatus status = txnManager.getTransaction(def);
    try {/*  w w w.j a v a  2s . c  o  m*/

        String childid = request.getParameter("nodeid");
        String parentid = request.getParameter("fromId");

        HashMap<String, Object> hm = organizationService.updateNode(parentid, childid);

        boolean success = Boolean.parseBoolean(hm.get("success").toString());
        User parent = (User) hm.get("parent");
        User child = (User) hm.get("child");

        if (parent != null && child != null) {
            auditTrailDAOObj.insertAuditLog(AuditAction.ORGANIZATION_CHART_NODE_ASSIGNED,
                    child.getFirstName() + " " + child.getLastName() + " re-assigned to "
                            + parent.getFirstName() + " " + parent.getLastName(),
                    request, "0");
        }

        if (success) {
            retMsg = "{success:true}";
        } else {
            retMsg = "{success:false,msg:\""
                    + messageSource.getMessage("hrms.common.not.assign.parent.node.employee.role", null,
                            "Could not assign because, parent node has Employee role.",
                            RequestContextUtils.getLocale(request))
                    + "\"}";
        }
        jobj.put("data", retMsg);

        jobj1.put("valid", true);
        jobj1.put("data", jobj);
        jobj1.put("success", true);
        txnManager.commit(status);
    } catch (Exception e) {
        logger.warn("General exception in updateNode()", e);
        txnManager.rollback(status);
    }
    return new ModelAndView("jsonView", "model", jobj1.toString());
}