Example usage for javax.servlet.http HttpSession removeAttribute

List of usage examples for javax.servlet.http HttpSession removeAttribute

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession removeAttribute.

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes the object bound with the specified name from this session.

Usage

From source file:ec.sirec.web.base.CatastroControlador.java

public String generarReporteFichaCatastral() throws Exception {
    //Conexion con local datasource
    UtilitariosCod util = new UtilitariosCod();
    Connection conexion = util.getConexion();
    byte[] fichero = null;
    JasperReport jasperReport = null;//from   w  ww.  ja va 2 s.  c  o  m
    Map parameters = new HashMap();
    try {
        copiarImagenDePredio();
        FacesContext context = FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
        ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
        session.removeAttribute("reporteInforme");
        parameters.put("catpre_codigo", catastroPredialActual.getCatpreCodigo());
        parameters.put("logo_gad", servletContext.getRealPath("/imagenes/icons/gadPedroMoncayo.jpg"));
        parameters.put("imagen_predio",
                servletContext.getRealPath("/imagenes/" + catastroPredialActual.getClaveCatastral() + ".jpg"));
        //-----------Sub reportes----------------
        String subrep1 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR1", subrep1);
        String subrep2 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2", subrep2);
        String subrep3 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR3", subrep3);
        //---------Sub sub reportes pagina 1 

        String subrep1_1 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR1_1", subrep1_1);
        String subrep1_2 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR1_2", subrep1_2);
        String subrep1_3 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR1_3", subrep1_3);
        // ------------------
        //---------Sub sub reportes pagina 2 
        String subrep2_1 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1", subrep2_1);
        String subrep2_2 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_2", subrep2_2);

        // ------------------
        //---------Sub sub reporte detalles pagina 2
        String subrep2_1_a = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_a", subrep2_1_a);
        String subrep2_1_b = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_b", subrep2_1_b);
        String subrep2_1_c = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_c", subrep2_1_c);
        String subrep2_1_d = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_d", subrep2_1_d);
        String subrep2_1_e = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_e", subrep2_1_e);
        String subrep2_1_f = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_f", subrep2_1_f);
        String subrep2_1_g = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_g", subrep2_1_g);
        String subrep2_1_h = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_h", subrep2_1_h);
        String subrep2_1_i = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR2_1_i", subrep2_1_i);

        //---------Sub sub reportes pagina 3
        String subrep3_1 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR3_1", subrep3_1);
        String subrep3_2 = servletContext.getRealPath("/reportes/fichaCatastral");
        parameters.put("SUBREPORT_DIR3_2", subrep3_2);
        jasperReport = (JasperReport) JRLoader
                .loadObject(servletContext.getRealPath("/reportes/fichaCatastral/repFichaCatastral.jasper"));
        fichero = JasperRunManager.runReportToPdf(jasperReport, parameters, conexion);
        session.setAttribute("reporteInforme", fichero);

    } catch (JRException ex) {
        LOGGER.log(Level.SEVERE, null, ex);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, null, e);
    } finally {
        if (conexion != null) {
            conexion.close();
        }
    }
    return null;
}

From source file:com.tremolosecurity.idp.providers.Saml2Idp.java

private void doFederation(HttpServletRequest request, HttpServletResponse response, String issuer,
        String nameID, String authnCtx, String url, String relayState, Saml2Trust trust)
        throws Exception, ServletException, IOException {

    if (authnCtx == null) {
        authnCtx = trust.params.get("defaultAuthCtx").getValues().get(0);
    }/*from   w w  w . j  a  v  a2 s  .com*/

    if (nameID == null) {
        nameID = trust.params.get("defaultNameId").getValues().get(0);
    }

    String authChain = trust.authChainMap.get(authnCtx);

    if (authChain == null) {
        StringBuffer b = new StringBuffer();
        b.append("IdP does not have an authenticaiton chain configured with '").append(authnCtx).append("'");
        throw new Exception(b.toString());
    }

    String nameIDAttr = trust.nameIDMap.get(nameID);

    if (logger.isDebugEnabled()) {
        logger.debug("Auth Chain : '" + authChain + "'");
        logger.debug("NameID Attr : '" + nameIDAttr + "'");
    }

    HttpSession session = request.getSession();

    AuthInfo authData = ((AuthController) session.getAttribute(ProxyConstants.AUTH_CTL)).getAuthInfo();
    UrlHolder holder = (UrlHolder) request.getAttribute(ProxyConstants.AUTOIDM_CFG);

    AuthChainType act = holder.getConfig().getAuthChains().get(authChain);

    if (url == null) {
        url = trust.params.get("httpPostRespURL").getValues().get(0);
    }

    SamlTransaction transaction = new SamlTransaction();
    transaction.issuer = issuer;
    transaction.nameIDAttr = nameIDAttr;
    transaction.nameIDFormat = nameID;
    transaction.postToURL = url;
    transaction.authnCtxName = authnCtx;
    transaction.relayState = relayState;

    session.setAttribute(Saml2Idp.TRANSACTION_DATA, transaction);

    if (authData == null || !authData.isAuthComplete() && !(authData.getAuthLevel() < act.getLevel())) {
        nextAuth(request, response, session, false, act);
    } else {
        if (authData.getAuthLevel() < act.getLevel()) {
            //step up authentication, clear existing auth data
            /*AuthController controller = ((AuthController) session.getAttribute(AuthSys.AUTH_CTL));
            controller.setHolder(null);
            for (AuthStep as : controller.getAuthSteps()) {
               as.setExecuted(false);
               as.setSuccess(false);
            }*/

            session.removeAttribute(ProxyConstants.AUTH_CTL);
            holder.getConfig().createAnonUser(session);

            nextAuth(request, response, session, false, act);
        } else {
            //chain.doFilter(req, resp);
            //next.nextSys((HttpServletRequest) req, (HttpServletResponse) resp);
            StringBuffer b = genFinalURL(request);
            response.sendRedirect(b.toString());

        }
    }
}

From source file:org.opentravel.pubs.controllers.PublicationController.java

/**
 * Hanldes the processing for all of the view-specification page targets.
 * /*  ww  w  . j  a v  a 2  s.  c o m*/
 * @param model  the UI model for the current request
 * @param session  the HTTP session
 * @param spec  indicates the name of the specification to view
 * @param newSession  flag indicating that the user has requested to re-register in their session
 * @param specificationForm  the form used to supply content when a new user registers
 * @param pubType  the type of the publication to view (1.0/2.0)
 * @param isMembersOnlyPage  flag indicating whether the page being viewed is a members-only page
 * @param targetPage  the MVC name of the target page
 * @param altPageLocation  the name of the alternate page location in case of registration or redirect
 * @return String
 */
private String doSpecificationPage(Model model, HttpSession session, String spec, boolean newSession,
        ViewSpecificationForm specificationForm, PublicationType pubType, boolean isMembersOnlyPage,
        String targetPage, String altPageLocation) {
    try {
        RegistrantForm registrantForm = specificationForm.getRegistrantForm();
        PublicationDAO pDao = DAOFactoryManager.getFactory().newPublicationDAO();
        Publication publication = null;

        if (spec != null) {
            publication = pDao.getPublication(spec, pubType);
        }
        if (publication == null) {
            publication = pDao.getLatestPublication(pubType, getAllowedStates(isMembersOnlyPage));
        }

        model.addAttribute("publication", publication);
        model.addAttribute("registrationPage", altPageLocation);
        model.addAttribute("releaseNotesUrl", isMembersOnlyPage ? "/specifications/members/ReleaseNotes.html"
                : "/specifications/ReleaseNotes.html");
        setupPublicationCheck(model, isMembersOnlyPage, pubType);

        if (newSession)
            session.removeAttribute("registrantId");
        handleRegistrantInfo(registrantForm, model, session);

        // If we processed the form successfully, clear our model so that its
        // attributes will not show up as URL parameters on redirect
        if (registrantForm.isProcessForm() && (model.asMap().get("registrant") != null)) {
            targetPage = "redirect:/specifications/" + altPageLocation;
            model.asMap().clear();
        }
        specificationForm.setProcessForm(true);

    } catch (Throwable t) {
        log.error("Error during publication controller processing.", t);
        setErrorMessage(DEFAULT_ERROR_MESSAGE, model);
    }
    return applyCommonValues(model, targetPage);
}

From source file:com.adito.security.DefaultLogonController.java

public synchronized void removeSessionTimeoutBlock(HttpSession session, int sessionTimeoutBlockId) {
    try {/*from   ww  w . j  a va 2  s  .  c om*/
        Map sessionTimeoutBlocks = (Map) session.getAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
        if (sessionTimeoutBlocks != null) {
            String reason = (String) sessionTimeoutBlocks.get(String.valueOf(sessionTimeoutBlockId));
            if (reason == null) {
                log.warn("No session timeout block with id of " + sessionTimeoutBlockId);
            } else {
                sessionTimeoutBlocks.remove(String.valueOf(sessionTimeoutBlockId));
                if (log.isDebugEnabled())
                    log.debug("Removing session timeout block " + sessionTimeoutBlockId + " for session "
                            + session.getId() + " ('" + reason + "'). There are now "
                            + sessionTimeoutBlocks.size() + " reasons not to timeout the session.");
            }
            if (sessionTimeoutBlocks.size() == 0) {
                session.removeAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
                User user = (User) session.getAttribute(Constants.USER);
                int minutes = CoreUtil.getUsersProfilePropertyIntOrDefault(session,
                        "webServer.sessionInactivityTimeout", user);
                if (log.isDebugEnabled())
                    log.debug("Initialising timeout for session " + session.getId() + " to " + minutes
                            + " minutes");
                session.setMaxInactiveInterval(minutes == 0 ? -1 : minutes * 60);
            }
        }
    } catch (IllegalStateException ise) {
        log.warn("Couldnt remove session timeout block.", ise);
    }
}

From source file:com.rr.missouri.ui.surveys.surveyController.java

/**
 * The '/startSurvey' GET request will build out the survey and display the first page of the survey.
 *
 * @param i The encrypted client id/* w w  w.  java2  s.  c om*/
 * @param v The encrypted decryption key
 * @param s The id of the selected survey
 *
 * @param session
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/startSurvey", method = RequestMethod.POST)
public ModelAndView startSurvey(@RequestParam(value = "s", required = false) String s,
        @RequestParam(value = "i", required = false) String i,
        @RequestParam(value = "v", required = false) String v,
        @RequestParam(value = "selectedEntities", required = false) List<Integer> selectedEntities,
        HttpSession session) throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/takeSurvey");
    mav.addObject("surveys", surveys);

    //Set the survey answer array to get ready to hold data
    if (session.getAttribute("questionAnswers") != null) {
        session.removeAttribute("questionAnswers");
    }
    session.setAttribute("questionAnswers", new ArrayList<surveyQuestionAnswers>());

    if (session.getAttribute("selectedContentCriterias") != null) {
        session.removeAttribute("selectedContentCriterias");
    }
    session.setAttribute("selectedContentCriterias", new ArrayList<surveyContentCriteria>());

    if (session.getAttribute("districtList") != null) {
        session.removeAttribute("districtList");
    }
    session.setAttribute("districtList", new ArrayList<district>());

    if (session.getAttribute("seenPages") != null) {
        session.removeAttribute("seenPages");
    }
    session.setAttribute("seenPages", new ArrayList<Integer>());

    int clientId = 0;
    int surveyId = 0;

    /* Get the submitted surveys for the selected survey type */
    if (!"".equals(i) && i != null && !"".equals(v) && v != null) {
        /* Decrypt the url */
        decryptObject decrypt = new decryptObject();

        Object obj = decrypt.decryptObject(i, v);

        String[] result = obj.toString().split((","));

        surveyId = Integer.parseInt(result[0].substring(4));

    } else {
        surveyId = Integer.parseInt(s);
    }

    if (surveyId > 0) {

        surveys surveyDetails = surveyManager.getSurveyDetails(surveyId);

        /* Make sure the survey is part of this program and active */
        if (surveyDetails.getProgramId() != programId || surveyDetails.getStatus() == false) {

            /* Redirect back to the survey list page */
        } /* Set up the survey */ else {
            survey survey = new survey();
            survey.setClientId(clientId);
            survey.setSurveyId(surveyId);
            survey.setSurveyTitle(surveyDetails.getTitle());
            survey.setPrevButton(surveyDetails.getPrevButtonText());
            survey.setNextButton(surveyDetails.getNextButtonText());
            survey.setSaveButton(surveyDetails.getDoneButtonText());
            survey.setSubmittedSurveyId(0);

            encryptObject encrypt = new encryptObject();
            Map<String, String> map;

            map = new HashMap<String, String>();
            map.put("id", Integer.toString(surveyId));
            map.put("topSecret", topSecret);

            String[] encrypted = encrypt.encryptObject(map);

            survey.setEncryptedId(encrypted[0]);
            survey.setEncryptedSecret(encrypted[1]);

            /* Get the pages */
            List<SurveyPages> surveyPages = surveyManager.getSurveyPages(surveyId, false, 0, 0, 0);
            SurveyPages currentPage = surveyManager.getSurveyPage(surveyId, true, 1, clientId, 0, 0, 0, 0);
            survey.setPageTitle(currentPage.getPageTitle());
            survey.setPageDesc(currentPage.getPageDesc());
            survey.setSurveyPageQuestions(currentPage.getSurveyQuestions());
            survey.setTotalPages(surveyPages.size());
            survey.setPageId(currentPage.getId());
            survey.setLastPageId(surveyPages.get(surveyPages.size() - 1).getId());

            mav.addObject("survey", survey);
            mav.addObject("surveyPages", surveyPages);
        }
    } else {
        /* Redirect back to the survey list page */

    }

    User userDetails = (User) session.getAttribute("userDetails");

    /* Get a list of available schools for the selected districts */
    if (selectedEntities != null && !selectedEntities.isEmpty() && !"".equals(selectedEntities)) {

        encryptObject encrypt = new encryptObject();
        Map<String, String> map;

        List<district> districtList = (List<district>) session.getAttribute("districtList");

        for (Integer entity : selectedEntities) {

            List<school> schoolList = new ArrayList<school>();

            district district = new district();
            district.setDistrictId(entity);

            programHierarchyDetails districtDetails = hierarchymanager.getProgramHierarchyItemDetails(entity);
            district.setDistrictName(districtDetails.getName());

            Integer userId = 0;
            if (userDetails.getRoleId() == 3) {
                userId = userDetails.getId();
            }

            List schools = hierarchymanager.getProgramOrgHierarchyItems(programId, 3, entity, userId);

            if (!schools.isEmpty() && schools.size() > 0) {

                for (ListIterator iter = schools.listIterator(); iter.hasNext();) {

                    Object[] row = (Object[]) iter.next();

                    school school = new school();
                    school.setSchoolId(Integer.parseInt(row[0].toString()));
                    school.setSchoolName(row[1].toString());

                    //Encrypt the use id to pass in the url
                    map = new HashMap<String, String>();
                    map.put("id", Integer.toString(Integer.parseInt(row[0].toString())));
                    map.put("topSecret", topSecret);

                    String[] encrypted = encrypt.encryptObject(map);

                    school.setEncryptedId(encrypted[0]);
                    school.setEncryptedSecret(encrypted[1]);

                    schoolList.add(school);

                }

                district.setSchoolList(schoolList);

            }

            districtList.add(district);

        }

        mav.addObject("selDistricts", districtList);

    }

    mav.addObject("selSurvey", surveyId);

    mav.addObject("selectedEntities", selectedEntities.toString().replace("[", "").replace("]", ""));
    mav.addObject("currentPage", 1);
    mav.addObject("currPageNum", 1);

    mav.addObject("qNum", 0);
    mav.addObject("disabled", false);

    return mav;
}

From source file:com.rr.moheals.ui.surveys.surveyController.java

/**
 * The '/startSurvey' GET request will build out the survey and display the first page of the survey.
 *
 * @param i The encrypted client id//from   ww  w. ja v  a  2  s . com
 * @param v The encrypted decryption key
 * @param s The id of the selected survey
 *
 * @param session
 * @return
 * @throws Exception
 */
@RequestMapping(value = "/startSurvey", method = RequestMethod.POST)
public ModelAndView startSurvey(@RequestParam(value = "s", required = false) String s,
        @RequestParam(value = "i", required = false) String i,
        @RequestParam(value = "v", required = false) String v,
        @RequestParam(value = "selectedEntities", required = false) List<Integer> selectedEntities,
        HttpSession session) throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/takeSurvey");
    mav.addObject("surveys", surveys);

    //Set the survey answer array to get ready to hold data
    if (session.getAttribute("questionAnswers") != null) {
        session.removeAttribute("questionAnswers");
    }
    session.setAttribute("questionAnswers", new ArrayList<surveyQuestionAnswers>());

    if (session.getAttribute("selectedContentCriterias") != null) {
        session.removeAttribute("selectedContentCriterias");
    }
    session.setAttribute("selectedContentCriterias", new ArrayList<surveyContentCriteria>());

    if (session.getAttribute("countyList") != null) {
        session.removeAttribute("countyList");
    }
    session.setAttribute("countyList", new ArrayList<county>());

    if (session.getAttribute("seenPages") != null) {
        session.removeAttribute("seenPages");
    }
    session.setAttribute("seenPages", new ArrayList<Integer>());

    int clientId = 0;
    int surveyId = 0;

    /* Get the submitted surveys for the selected survey type */
    if (!"".equals(i) && i != null && !"".equals(v) && v != null) {
        /* Decrypt the url */
        decryptObject decrypt = new decryptObject();

        Object obj = decrypt.decryptObject(i, v);

        String[] result = obj.toString().split((","));

        surveyId = Integer.parseInt(result[0].substring(4));

    } else {
        surveyId = Integer.parseInt(s);
    }

    if (surveyId > 0) {

        surveys surveyDetails = surveyManager.getSurveyDetails(surveyId);

        /* Make sure the survey is part of this program and active */
        if (surveyDetails.getProgramId() != programId || surveyDetails.getStatus() == false) {

            /* Redirect back to the survey list page */
        } /* Set up the survey */ else {
            survey survey = new survey();
            survey.setClientId(clientId);
            survey.setSurveyId(surveyId);
            survey.setSurveyTitle(surveyDetails.getTitle());
            survey.setPrevButton(surveyDetails.getPrevButtonText());
            survey.setNextButton(surveyDetails.getNextButtonText());
            survey.setSaveButton(surveyDetails.getDoneButtonText());
            survey.setSubmittedSurveyId(0);

            encryptObject encrypt = new encryptObject();
            Map<String, String> map;

            map = new HashMap<String, String>();
            map.put("id", Integer.toString(surveyId));
            map.put("topSecret", topSecret);

            String[] encrypted = encrypt.encryptObject(map);

            survey.setEncryptedId(encrypted[0]);
            survey.setEncryptedSecret(encrypted[1]);

            /* Get the pages */
            List<SurveyPages> surveyPages = surveyManager.getSurveyPages(surveyId, false, 0, 0, 0);
            SurveyPages currentPage = surveyManager.getSurveyPage(surveyId, true, 1, clientId, 0, 0, 0, 0);
            survey.setPageTitle(currentPage.getPageTitle());
            survey.setPageDesc(currentPage.getPageDesc());
            survey.setSurveyPageQuestions(currentPage.getSurveyQuestions());
            survey.setTotalPages(surveyPages.size());
            survey.setPageId(currentPage.getId());
            survey.setLastPageId(surveyPages.get(surveyPages.size() - 1).getId());

            mav.addObject("survey", survey);
            mav.addObject("surveyPages", surveyPages);
        }
    } else {
        /* Redirect back to the survey list page */

    }

    User userDetails = (User) session.getAttribute("userDetails");

    /* Get a list of available health departments for the selected districts */
    if (selectedEntities != null && !selectedEntities.isEmpty() && !"".equals(selectedEntities)) {

        encryptObject encrypt = new encryptObject();
        Map<String, String> map;

        List<county> countyList = (List<county>) session.getAttribute("countyList");

        for (Integer entity : selectedEntities) {

            List<healthDepartment> healthDepartmentList = new ArrayList<healthDepartment>();

            county county = new county();
            county.setCountyId(entity);

            programHierarchyDetails countyDetails = hierarchymanager.getProgramHierarchyItemDetails(entity);
            county.setCountyName(countyDetails.getName());

            Integer userId = 0;
            if (userDetails.getRoleId() == 3) {
                userId = userDetails.getId();
            }

            List healthDepartments = hierarchymanager.getProgramOrgHierarchyItems(programId, 2, entity, userId);

            if (!healthDepartments.isEmpty() && healthDepartments.size() > 0) {

                for (ListIterator iter = healthDepartments.listIterator(); iter.hasNext();) {

                    Object[] row = (Object[]) iter.next();

                    healthDepartment healthDepartment = new healthDepartment();
                    healthDepartment.setHealthDepartmentId(Integer.parseInt(row[0].toString()));
                    healthDepartment.setHealthDepartmentName(row[1].toString());

                    //Encrypt the use id to pass in the url
                    map = new HashMap<String, String>();
                    map.put("id", Integer.toString(Integer.parseInt(row[0].toString())));
                    map.put("topSecret", topSecret);

                    String[] encrypted = encrypt.encryptObject(map);

                    healthDepartment.setEncryptedId(encrypted[0]);
                    healthDepartment.setEncryptedSecret(encrypted[1]);

                    healthDepartmentList.add(healthDepartment);

                }

                county.setHealthDepartmentList(healthDepartmentList);

            }

            countyList.add(county);

        }

        mav.addObject("selCounties", countyList);

    }

    mav.addObject("selSurvey", surveyId);

    mav.addObject("selectedEntities", selectedEntities.toString().replace("[", "").replace("]", ""));
    mav.addObject("currentPage", 1);
    mav.addObject("currPageNum", 1);

    mav.addObject("qNum", 0);
    mav.addObject("disabled", false);

    return mav;
}

From source file:org.opentravel.pubs.controllers.PublicationController.java

@RequestMapping({ "/CodeLists.html", "/CodeLists.htm" })
public String codeListPublicPage(Model model, HttpSession session,
        @RequestParam(value = "releaseDate", required = false) String releaseDateStr,
        @RequestParam(value = "newSession", required = false) boolean newSession,
        @ModelAttribute("specificationForm") ViewSpecificationForm specificationForm) {
    String targetPage = "codeListMain";

    try {// w ww .j a  v a2s  .  co m
        RegistrantForm registrantForm = specificationForm.getRegistrantForm();
        CodeListDAO cDao = DAOFactoryManager.getFactory().newCodeListDAO();
        CodeList codeList = null;

        if ((releaseDateStr != null) && (releaseDateStr.trim().length() > 0)) {
            try {
                codeList = cDao.getCodeList(CodeList.labelFormat.parse(releaseDateStr.trim()));

            } catch (ParseException e) {
                setErrorMessage("Invalid release date requested: \"" + releaseDateStr + "\"", model);
            }
        }
        if (codeList == null) {
            codeList = cDao.getLatestCodeList();
        }

        model.addAttribute("codeList", codeList);
        model.addAttribute("registrationPage", "CodeLists.html");

        if (newSession)
            session.removeAttribute("registrantId");
        handleRegistrantInfo(registrantForm, model, session);

        // If we processed the form successfully, clear our model so that its
        // attributes will not show up as URL parameters on redirect
        if (registrantForm.isProcessForm() && (model.asMap().get("registrant") != null)) {
            targetPage = "redirect:/specifications/CodeLists.html";
            model.asMap().clear();
        }
        specificationForm.setProcessForm(true);

    } catch (Throwable t) {
        log.error("Error during publication controller processing.", t);
        setErrorMessage(DEFAULT_ERROR_MESSAGE, model);
    }
    return applyCommonValues(model, targetPage);
}

From source file:com.rr.missouri.ui.surveys.surveyController.java

/**
 * The '/editSurvey' GET request will build out the survey and display the first page of the survey.
 *
 * @param i The encrypted survey id//from   w ww  . ja va2s  .  co m
 * @param v The encrypted decryption key
 *
 * @param session
 * @return
 * @throws Exception
 */
@RequestMapping(value = { "/editSurvey", "/viewSurvey" }, method = RequestMethod.GET)
public ModelAndView editSurvey(@RequestParam String i, @RequestParam String v, HttpSession session,
        HttpServletRequest request) throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/takeSurvey");
    mav.addObject("surveys", surveys);

    //Set the survey answer array to get ready to hold data
    if (session.getAttribute("questionAnswers") != null) {
        session.removeAttribute("questionAnswers");
    }
    session.setAttribute("questionAnswers", new ArrayList<surveyQuestionAnswers>());

    if (session.getAttribute("selectedContentCriterias") != null) {
        session.removeAttribute("selectedContentCriterias");
    }
    session.setAttribute("selectedContentCriterias", new ArrayList<surveyContentCriteria>());

    if (session.getAttribute("districtList") != null) {
        session.removeAttribute("districtList");
    }
    session.setAttribute("districtList", new ArrayList<district>());

    if (session.getAttribute("seenPages") != null) {
        session.removeAttribute("seenPages");
    }
    session.setAttribute("seenPages", new ArrayList<Integer>());

    int clientId = 0;

    /* Decrypt the url */
    decryptObject decrypt = new decryptObject();

    Object obj = decrypt.decryptObject(i, v);

    String[] result = obj.toString().split((","));

    int submittedSurveyId = Integer.parseInt(result[0].substring(4));

    /* Get the survey details */
    submittedSurveys submittedSurveyDetails = surveyManager.getSubmittedSurvey(submittedSurveyId);

    surveys surveyDetails = surveyManager.getSurveyDetails(submittedSurveyDetails.getSurveyId());

    User userDetails = (User) session.getAttribute("userDetails");

    survey survey = new survey();
    survey.setClientId(clientId);
    survey.setSurveyId(submittedSurveyDetails.getSurveyId());
    survey.setSurveyTitle(surveyDetails.getTitle());
    survey.setPrevButton(surveyDetails.getPrevButtonText());
    survey.setNextButton(surveyDetails.getNextButtonText());
    survey.setSaveButton(surveyDetails.getDoneButtonText());
    survey.setSubmittedSurveyId(submittedSurveyId);
    survey.setEntityIds(surveyManager.getSubmittedSurveyEntities(submittedSurveyId, userDetails));

    encryptObject encrypt = new encryptObject();
    Map<String, String> map;

    //Encrypt the use id to pass in the url
    map = new HashMap<String, String>();
    map.put("id", Integer.toString(submittedSurveyDetails.getSurveyId()));
    map.put("topSecret", topSecret);

    String[] encrypted = encrypt.encryptObject(map);

    survey.setEncryptedId(encrypted[0]);
    survey.setEncryptedSecret(encrypted[1]);

    /* Get the pages */
    List<SurveyPages> surveyPages = surveyManager.getSurveyPages(submittedSurveyDetails.getSurveyId(), false, 0,
            0, 0);
    SurveyPages currentPage = surveyManager.getSurveyPage(submittedSurveyDetails.getSurveyId(), true, 1,
            clientId, 0, 0, submittedSurveyId, 0);
    survey.setPageTitle(currentPage.getPageTitle());
    survey.setPageDesc(currentPage.getPageDesc());
    survey.setSurveyPageQuestions(currentPage.getSurveyQuestions());
    survey.setTotalPages(surveyPages.size());
    survey.setLastPageId(surveyPages.get(surveyPages.size() - 1).getId());
    survey.setPageId(currentPage.getId());

    /* Need to update any date functions */
    if (survey.getSurveyPageQuestions() != null && survey.getSurveyPageQuestions().size() > 0) {
        for (SurveyQuestions question : survey.getSurveyPageQuestions()) {
            if (question.getAnswerTypeId() == 6) {
                if (question.getQuestionValue().length() > 0
                        && !question.getQuestionValue().contains("^^^^^")) {
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                    SimpleDateFormat df2 = new SimpleDateFormat("M/dd/yy");
                    SimpleDateFormat df3 = new SimpleDateFormat("M/dd/yyyy");
                    SimpleDateFormat df4 = new SimpleDateFormat("M/d/yy");
                    SimpleDateFormat df5 = new SimpleDateFormat("M/d/yyyy");
                    SimpleDateFormat df6 = new SimpleDateFormat("MM/d/yyyy");
                    SimpleDateFormat df7 = new SimpleDateFormat("MM/d/yy");
                    SimpleDateFormat df8 = new SimpleDateFormat("MM/dd/yyyy");
                    SimpleDateFormat df9 = new SimpleDateFormat("MM/dd/yy");

                    Date formattedDate;
                    try {
                        formattedDate = df.parse(question.getQuestionValue());
                    } catch (Exception ex) {
                        try {
                            formattedDate = df2.parse(question.getQuestionValue());
                        } catch (Exception ex2) {
                            try {
                                formattedDate = df3.parse(question.getQuestionValue());
                            } catch (Exception ex3) {
                                try {
                                    formattedDate = df4.parse(question.getQuestionValue());
                                } catch (Exception ex4) {
                                    try {
                                        formattedDate = df5.parse(question.getQuestionValue());
                                    } catch (Exception ex5) {
                                        try {
                                            formattedDate = df6.parse(question.getQuestionValue());
                                        } catch (Exception ex6) {
                                            try {
                                                formattedDate = df7.parse(question.getQuestionValue());
                                            } catch (Exception ex7) {
                                                try {
                                                    formattedDate = df8.parse(question.getQuestionValue());
                                                } catch (Exception ex8) {
                                                    formattedDate = df9.parse(question.getQuestionValue());
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (question.getDateFormatType() == 2) { //dd/mm/yyyy
                        df.applyPattern("dd/MM/yyyy");
                    } else { //mm/dd/yyyy
                        df.applyPattern("MM/dd/yyyy");
                    }
                    String formattedDateasString = df.format(formattedDate);
                    question.setQuestionValue(formattedDateasString);
                }
            }
        }
    }

    mav.addObject("survey", survey);
    mav.addObject("surveyPages", surveyPages);

    List<Integer> selectedEntities = surveyManager.getSurveyEntities(submittedSurveyId);

    /* Get a list of available schools for the selected districts */
    if (selectedEntities != null && !selectedEntities.isEmpty() && !"".equals(selectedEntities)) {

        List<district> districtList = (List<district>) session.getAttribute("districtList");

        for (Integer entityId : selectedEntities) {

            List<school> schoolList = new ArrayList<school>();

            district district = new district();
            district.setDistrictId(entityId);

            programHierarchyDetails districtDetails = hierarchymanager.getProgramHierarchyItemDetails(entityId);
            district.setDistrictName(districtDetails.getName());

            Integer userId = 0;
            if (userDetails.getRoleId() == 3) {
                userId = userDetails.getId();
            }

            List schools = hierarchymanager.getProgramOrgHierarchyItems(programId, 3, entityId, userId);

            if (!schools.isEmpty() && schools.size() > 0) {

                for (ListIterator iter = schools.listIterator(); iter.hasNext();) {

                    Object[] row = (Object[]) iter.next();

                    school school = new school();
                    school.setSchoolId(Integer.parseInt(row[0].toString()));
                    school.setSchoolName(row[1].toString());

                    //Encrypt the use id to pass in the url
                    map = new HashMap<String, String>();
                    map.put("id", Integer.toString(Integer.parseInt(row[0].toString())));
                    map.put("topSecret", topSecret);

                    String[] encrypted2 = encrypt.encryptObject(map);

                    school.setEncryptedId(encrypted2[0]);
                    school.setEncryptedSecret(encrypted2[1]);

                    schoolList.add(school);

                }

                district.setSchoolList(schoolList);

            }

            districtList.add(district);

        }

        mav.addObject("selDistricts", districtList);

    }

    mav.addObject("selSurvey", submittedSurveyDetails.getSurveyId());
    mav.addObject("selectedEntities", selectedEntities.toString().replace("[", "").replace("]", ""));

    mav.addObject("qNum", 0);
    mav.addObject("currPageNum", 1);

    boolean disabled = false;
    if ("/surveys/viewSurvey".equals(request.getServletPath())) {
        disabled = true;
    }

    mav.addObject("disabled", disabled);

    return mav;
}

From source file:com.rr.moheals.ui.surveys.surveyController.java

/**
 * The '/editSurvey' GET request will build out the survey and display the first page of the survey.
 *
 * @param i The encrypted survey id//from w ww .  j a v a2 s.  c  o m
 * @param v The encrypted decryption key
 *
 * @param session
 * @return
 * @throws Exception
 */
@RequestMapping(value = { "/editSurvey", "/viewSurvey" }, method = RequestMethod.GET)
public ModelAndView editSurvey(@RequestParam String i, @RequestParam String v, HttpSession session,
        HttpServletRequest request) throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/takeSurvey");
    mav.addObject("surveys", surveys);

    //Set the survey answer array to get ready to hold data
    if (session.getAttribute("questionAnswers") != null) {
        session.removeAttribute("questionAnswers");
    }
    session.setAttribute("questionAnswers", new ArrayList<surveyQuestionAnswers>());

    if (session.getAttribute("selectedContentCriterias") != null) {
        session.removeAttribute("selectedContentCriterias");
    }
    session.setAttribute("selectedContentCriterias", new ArrayList<surveyContentCriteria>());

    if (session.getAttribute("countyList") != null) {
        session.removeAttribute("countyList");
    }
    session.setAttribute("countyList", new ArrayList<county>());

    if (session.getAttribute("seenPages") != null) {
        session.removeAttribute("seenPages");
    }
    session.setAttribute("seenPages", new ArrayList<Integer>());

    int clientId = 0;

    /* Decrypt the url */
    decryptObject decrypt = new decryptObject();

    Object obj = decrypt.decryptObject(i, v);

    String[] result = obj.toString().split((","));

    int submittedSurveyId = Integer.parseInt(result[0].substring(4));

    /* Get the survey details */
    submittedSurveys submittedSurveyDetails = surveyManager.getSubmittedSurvey(submittedSurveyId);

    surveys surveyDetails = surveyManager.getSurveyDetails(submittedSurveyDetails.getSurveyId());

    User userDetails = (User) session.getAttribute("userDetails");

    survey survey = new survey();
    survey.setClientId(clientId);
    survey.setSurveyId(submittedSurveyDetails.getSurveyId());
    survey.setSurveyTitle(surveyDetails.getTitle());
    survey.setPrevButton(surveyDetails.getPrevButtonText());
    survey.setNextButton(surveyDetails.getNextButtonText());
    survey.setSaveButton(surveyDetails.getDoneButtonText());
    survey.setSubmittedSurveyId(submittedSurveyId);
    survey.setEntityIds(surveyManager.getSubmittedSurveyEntities(submittedSurveyId, userDetails));

    encryptObject encrypt = new encryptObject();
    Map<String, String> map;

    //Encrypt the use id to pass in the url
    map = new HashMap<String, String>();
    map.put("id", Integer.toString(submittedSurveyDetails.getSurveyId()));
    map.put("topSecret", topSecret);

    String[] encrypted = encrypt.encryptObject(map);

    survey.setEncryptedId(encrypted[0]);
    survey.setEncryptedSecret(encrypted[1]);

    /* Get the pages */
    List<SurveyPages> surveyPages = surveyManager.getSurveyPages(submittedSurveyDetails.getSurveyId(), false, 0,
            0, 0);
    SurveyPages currentPage = surveyManager.getSurveyPage(submittedSurveyDetails.getSurveyId(), true, 1,
            clientId, 0, 0, submittedSurveyId, 0);
    survey.setPageTitle(currentPage.getPageTitle());
    survey.setPageDesc(currentPage.getPageDesc());
    survey.setSurveyPageQuestions(currentPage.getSurveyQuestions());
    survey.setTotalPages(surveyPages.size());
    survey.setLastPageId(surveyPages.get(surveyPages.size() - 1).getId());
    survey.setPageId(currentPage.getId());

    /* Need to update any date functions */
    if (survey.getSurveyPageQuestions() != null && survey.getSurveyPageQuestions().size() > 0) {
        for (SurveyQuestions question : survey.getSurveyPageQuestions()) {

            if (question.getAnswerTypeId() == 6) {
                if (question.getQuestionValue().length() > 0) {
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                    SimpleDateFormat df2 = new SimpleDateFormat("M/dd/yy");
                    SimpleDateFormat df3 = new SimpleDateFormat("M/dd/yyyy");
                    SimpleDateFormat df4 = new SimpleDateFormat("M/d/yy");
                    SimpleDateFormat df5 = new SimpleDateFormat("M/d/yyyy");
                    SimpleDateFormat df6 = new SimpleDateFormat("MM/d/yyyy");
                    SimpleDateFormat df7 = new SimpleDateFormat("MM/d/yy");
                    SimpleDateFormat df8 = new SimpleDateFormat("MM/dd/yyyy");
                    SimpleDateFormat df9 = new SimpleDateFormat("MM/dd/yy");

                    Date formattedDate;
                    try {
                        formattedDate = df.parse(question.getQuestionValue());
                    } catch (Exception ex) {
                        try {
                            formattedDate = df2.parse(question.getQuestionValue());
                        } catch (Exception ex2) {
                            try {
                                formattedDate = df3.parse(question.getQuestionValue());
                            } catch (Exception ex3) {
                                try {
                                    formattedDate = df4.parse(question.getQuestionValue());
                                } catch (Exception ex4) {
                                    try {
                                        formattedDate = df5.parse(question.getQuestionValue());
                                    } catch (Exception ex5) {
                                        try {
                                            formattedDate = df6.parse(question.getQuestionValue());
                                        } catch (Exception ex6) {
                                            try {
                                                formattedDate = df7.parse(question.getQuestionValue());
                                            } catch (Exception ex7) {
                                                try {
                                                    formattedDate = df8.parse(question.getQuestionValue());
                                                } catch (Exception ex8) {
                                                    formattedDate = df9.parse(question.getQuestionValue());
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (question.getDateFormatType() == 2) { //dd/mm/yyyy
                        df.applyPattern("dd/MM/yyyy");
                    } else { //mm/dd/yyyy
                        df.applyPattern("MM/dd/yyyy");
                    }
                    String formattedDateasString = df.format(formattedDate);
                    question.setQuestionValue(formattedDateasString);
                }
            }
        }
    }

    mav.addObject("survey", survey);
    mav.addObject("surveyPages", surveyPages);

    List<Integer> selectedEntities = surveyManager.getSurveyEntities(submittedSurveyId);

    /* Get a list of available health Departments for the selected districts */
    if (selectedEntities != null && !selectedEntities.isEmpty() && !"".equals(selectedEntities)) {

        List<county> countyList = (List<county>) session.getAttribute("countyList");

        for (Integer entityId : selectedEntities) {

            List<healthDepartment> healthDepartmentList = new ArrayList<healthDepartment>();

            county county = new county();
            county.setCountyId(entityId);

            programHierarchyDetails districtDetails = hierarchymanager.getProgramHierarchyItemDetails(entityId);
            county.setCountyName(districtDetails.getName());

            Integer userId = 0;
            if (userDetails.getRoleId() == 3) {
                userId = userDetails.getId();
            }

            List healthDepartments = hierarchymanager.getProgramOrgHierarchyItems(programId, 2, entityId,
                    userId);

            if (!healthDepartments.isEmpty() && healthDepartments.size() > 0) {

                for (ListIterator iter = healthDepartments.listIterator(); iter.hasNext();) {

                    Object[] row = (Object[]) iter.next();

                    healthDepartment healthDepartment = new healthDepartment();
                    healthDepartment.setHealthDepartmentId(Integer.parseInt(row[0].toString()));
                    healthDepartment.setHealthDepartmentName(row[1].toString());

                    //Encrypt the use id to pass in the url
                    map = new HashMap<String, String>();
                    map.put("id", Integer.toString(Integer.parseInt(row[0].toString())));
                    map.put("topSecret", topSecret);

                    String[] encrypted2 = encrypt.encryptObject(map);

                    healthDepartment.setEncryptedId(encrypted2[0]);
                    healthDepartment.setEncryptedSecret(encrypted2[1]);

                    healthDepartmentList.add(healthDepartment);

                }

                county.setHealthDepartmentList(healthDepartmentList);

            }

            countyList.add(county);

        }

        mav.addObject("selCounties", countyList);

    }

    mav.addObject("selSurvey", submittedSurveyDetails.getSurveyId());
    mav.addObject("selectedEntities", selectedEntities.toString().replace("[", "").replace("]", ""));

    mav.addObject("qNum", 0);
    mav.addObject("currPageNum", 1);

    boolean disabled = false;
    if ("/surveys/viewSurvey".equals(request.getServletPath())) {
        disabled = true;
    }

    mav.addObject("disabled", disabled);

    return mav;
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractAuthenticationController.java

@RequestMapping(value = { "/{userParam}/loggedout", "{userParam}/j_spring_security_logout" })
public String loggedout(@PathVariable String userParam, ModelMap map, HttpSession session,
        HttpServletResponse response, HttpServletRequest request) {
    logger.debug("###Entering in loggedout(response) method");
    String showSuffixControl = "false";
    String suffixControlType = "textbox";
    List<String> suffixList = null;
    if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) {
        showSuffixControl = "true";
        if (config.getValue(Names.com_citrix_cpbm_login_screen_tenant_suffix_dropdown_enabled).equals("true")) {
            suffixControlType = "dropdown";
            suffixList = tenantService.getSuffixList();
        }//from  w  w w  .j av  a2s. c om
    }
    map.addAttribute("showSuffixControl", showSuffixControl);
    map.addAttribute("suffixControlType", suffixControlType);
    map.addAttribute("suffixList", suffixList);
    if (config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled)
            && config.getValue(Names.com_citrix_cpbm_directory_mode).equals("pull")) {
        map.addAttribute("directoryServiceAuthenticationEnabled", "true");
    }
    if (config.getValue(Names.com_citrix_cpbm_public_catalog_display).equals("true")
            && channelService.getDefaultServiceProviderChannel() != null) {
        map.addAttribute("showAnonymousCatalogBrowsing", "true");
    }
    map.addAttribute("showLanguageSelection", "true");
    map.addAttribute("supportedLocaleList", this.getLocaleDisplayName(listSupportedLocales()));
    map.addAttribute("logout", true);
    String redirect = null;
    Enumeration<String> en = session.getAttributeNames();
    while (en.hasMoreElements()) {
        String attr = en.nextElement();
        session.removeAttribute(attr);
    }
    Cookie cookie = new Cookie("JforumSSO", "");
    cookie.setMaxAge(0);
    cookie.setPath("/");
    response.addCookie(cookie);
    if (request.getRequestedSessionId() != null && request.isRequestedSessionIdValid()) {
        // create logout notification begins
        User user = userService.get(userParam);
        String message = "logged.out";
        String messageArgs = user.getUsername();
        eventService.createEvent(new Date(), user, message, messageArgs, Source.PORTAL, Scope.USER,
                Category.ACCOUNT, Severity.INFORMATION, true);
    }
    session.invalidate();
    if (config.getAuthenticationService().compareToIgnoreCase(CAS) == 0) {
        try {
            redirect = StringUtils.isEmpty(config.getCasLogoutUrl()) ? null
                    : config.getCasLogoutUrl() + "?service="
                            + URLEncoder.encode(config.getCasServiceUrl(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            logger.error("Exception encoding: " + redirect, e);
        }
        if (redirect == null) {
            throw new InternalError("CAS authentication required, but login url not set");
        }
    }

    SecurityContextHolder.getContext().setAuthentication(null);
    // ends
    logger.debug("###Exiting loggedout(response) method");
    return redirect == null ? "redirect:/j_spring_security_logout" : "redirect:" + redirect;
}