Example usage for javax.servlet.http HttpSession isNew

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

Introduction

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

Prototype

public boolean isNew();

Source Link

Document

Returns true if the client does not yet know about the session or if the client chooses not to join the session.

Usage

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String loadAdd(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|loadAdd|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }//from  ww w. j a  v a 2  s.co m

    baseDBForm.resetForm();

    session.setAttribute(DisplayConstants.CURRENT_ACTION, DisplayConstants.ADD);
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    session.removeAttribute(DisplayConstants.SEARCH_RESULT);
    session.setAttribute(DisplayConstants.CREATE_WORKFLOW, DisplayConstants.CREATE_WORKFLOW);

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|loadAdd|Success|Loading the Add Page||");
    return ForwardConstants.LOAD_ADD_SUCCESS;
}

From source file:org.inbio.modeling.web.controller.LayerController.java

@Override
protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response,
        BindException errors) {/*from w  w w. ja v a 2s . c om*/

    CurrentInstanceData currentInstanceData = null;
    ListLayerForm layerListForm = null;
    HttpSession session = null;
    ModelAndView model = null;

    // Create the object that will retain all the user information trought the process.
    currentInstanceData = new CurrentInstanceData();
    currentInstanceData.setUserSessionId(Calendar.getInstance().getTimeInMillis());

    // Asing the SessionInfo Object to the session
    session = request.getSession(true);

    //validate the new Session
    if (!session.isNew()) {
        session.invalidate();
        session = request.getSession(true);
    }

    session.setAttribute("CurrentSessionInfo", currentInstanceData);

    //creates the form to the page and upload it.
    layerListForm = new ListLayerForm();
    layerListForm.setLayerList(FormDTOConverter.convert(layerManager.getLayerList(), Layer.class));

    // Send the layer list to the JSP
    model = new ModelAndView();
    if (errors != null && errors.hasErrors())
        model.addAllObjects(errors.getModel());

    model.setViewName("layers");
    model.addObject("layersForm", layerListForm);

    return model;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String loadSearchResult(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|loadSearchResult|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*from   ww w .ja v a  2 s  .  co m*/

    if (session.getAttribute(DisplayConstants.CREATE_WORKFLOW) != null) {
        //session.removeAttribute(DisplayConstants.CREATE_WORKFLOW);
        session.removeAttribute(DisplayConstants.SEARCH_RESULT);
        session.removeAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT);
        return ForwardConstants.LOAD_HOME_SUCCESS;
    } else {
        if (session.getAttribute(DisplayConstants.SEARCH_RESULT) == null
                && session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT) != null) {
            session.setAttribute(DisplayConstants.SEARCH_RESULT,
                    session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT));
            //session.removeAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT);
        }
    }

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|loadSearchResult|Success|Loading the Search Result Page||");
    return ForwardConstants.LOAD_SEARCH_RESULT_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

/**
* Added this method to handle pre-popup search results.
*///from ww w .  j  ava 2  s  . c  o  m

public String loadOriginalSearchResult(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|loadSearchResult|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }

    if (session.getAttribute(DisplayConstants.CREATE_WORKFLOW) != null) {
        session.removeAttribute(DisplayConstants.CREATE_WORKFLOW);
        //session.removeAttribute(DisplayConstants.SEARCH_RESULT);
        return ForwardConstants.LOAD_HOME_SUCCESS;
    } else {
        if (session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT) != null) {
            session.setAttribute(DisplayConstants.SEARCH_RESULT,
                    session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT));
            session.removeAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT);
        }
    }

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|loadSearchResult|Success|Loading the Search Result Page||");
    return ForwardConstants.LOAD_SEARCH_RESULT_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String delete(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|delete|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*  w  ww .j ava  2s.  co  m*/
    UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(),
            session.getId());
    try {
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        baseDBForm.buildDisplayForm(userProvisioningManager);
        baseDBForm.removeDBObject(userProvisioningManager);
        addActionMessage("Delete Successful");
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|delete|Failure|Error Deleting the "
                    + baseDBForm.getFormName() + " object|" + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|delete|Success|Success Deleting " + baseDBForm.getFormName()
                + " object|" + "|");
    return ForwardConstants.DELETE_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String read(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();
    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|read|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*from  w  ww .  j  a v a 2s .  c o  m*/
    if (baseDBForm.getPrimaryId() == null || baseDBForm.getPrimaryId().equalsIgnoreCase("")) {
        addActionError("A record needs to be selected first to view details");
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|read|Failure|No Primary Id for " + baseDBForm.getFormName()
                    + " object||");
        return ForwardConstants.READ_FAILURE;
    }
    try {
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        baseDBForm.buildDisplayForm(userProvisioningManager);
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|read|Failure|Error Reading the " + baseDBForm.getFormName()
                    + " object|" + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|read|Success|Success reading " + baseDBForm.getFormName()
                + " object|" + "|");

    return ForwardConstants.READ_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String create(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|create|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }//from  ww  w.  j  a  v  a  2 s. co m
    UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(),
            session.getId());
    try {
        List<String> errors = baseDBForm.validate();
        if (errors != null && errors.size() > 0) {
            for (String error : errors) {
                addActionError(error);
            }
            session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
            if (logDB.isDebugEnabled())
                logDB.debug(session.getId() + "|"
                        + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                        + baseDBForm.getFormName() + "|create|Failure|Error validating the "
                        + baseDBForm.getFormName() + " object|" + baseDBForm.toString() + "|");
            return "input";
        }
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        baseDBForm.buildDBObject(userProvisioningManager);
        addActionMessage("Add Successful");
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|create|Failure|Error Adding the " + baseDBForm.getFormName()
                    + " object|" + baseDBForm.toString() + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|create|Success|Adding a  new " + baseDBForm.getFormName()
                + " object|" + baseDBForm.toString() + "|");
    return ForwardConstants.CREATE_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String update(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|update|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*from  www.jav  a 2  s .  co  m*/
    UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(),
            session.getId());
    try {
        List<String> errors = baseDBForm.validate();
        if (errors != null && errors.size() > 0) {
            for (String error : errors)
                addActionError(error);
            session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
            if (logDB.isDebugEnabled())
                logDB.debug(session.getId() + "|"
                        + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                        + baseDBForm.getFormName() + "|update|Failure|Error validating the "
                        + baseDBForm.getFormName() + " object|" + "|");
            return "input";
        }
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        baseDBForm.buildDBObject(userProvisioningManager);
        addActionMessage("Update Successful");
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|update|Failure|Error Updating the "
                    + baseDBForm.getFormName() + " object|" + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|update|Success|Updating existing " + baseDBForm.getFormName()
                + " object|" + "|");
    return ForwardConstants.UPDATE_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String testConnection(BaseDBForm form) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + form.getFormName()
                    + "|Test Connection|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*from w  ww  .ja  v a 2  s  . c o m*/
    UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(),
            session.getId());
    try {
        List<String> errors = form.validate();
        if (errors != null && errors.size() > 0) {
            for (String error : errors)
                addActionError(error);
            session.setAttribute(DisplayConstants.CURRENT_FORM, form);
            if (logDB.isDebugEnabled())
                logDB.debug(session.getId() + "|"
                        + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                        + form.getFormName()
                        + "|Test Connection|Failure|Error testing Aplication Database Connection" + "|");
            return "input";
        }

        // Test JDBC Database Connection Properties.
        //String message = JDBCHelper.testConnectionHibernate(baseDBForm);
        String message = JDBCHelper.testConnectionJDBC(form);

        //
        addActionMessage(message);
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + form.getFormName()
                    + "|Test Connection|Failure|Error Testing Application Database Connection." + "|"
                    + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, form);

    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + form.getFormName() + "|Test Connection|Success|Testing Application Database connection."
                + "|");
    return ForwardConstants.UPDATE_SUCCESS;
}

From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java

public String search(BaseDBForm baseDBForm) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession session = request.getSession();

    if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {
        if (logDB.isDebugEnabled())
            logDB.debug("||" + baseDBForm.getFormName()
                    + "|search|Failure|No Session or User Object Forwarding to the Login Page||");
        return ForwardConstants.LOGIN_PAGE;
    }/*w w  w .jav  a2s  . c om*/
    UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(),
            session.getId());
    try {
        UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession())
                .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER);
        baseDBForm.setRequest(request);
        SearchResult searchResult = baseDBForm.searchObjects(userProvisioningManager);
        if (searchResult.getSearchResultObjects() == null || searchResult.getSearchResultObjects().isEmpty()) {
            addActionError("The search criteria returned zero results");
            if (logDB.isDebugEnabled())
                logDB.debug(session.getId() + "|"
                        + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                        + baseDBForm.getFormName() + "|search|Failure|No Records found for "
                        + baseDBForm.getFormName() + " object|" + "|");
            baseDBForm.resetForm();
            return ForwardConstants.SEARCH_FAILURE;
        }
        if (searchResult.getSearchResultMessage() != null
                && !(searchResult.getSearchResultMessage().trim().equalsIgnoreCase(""))) {
            addActionMessage(searchResult.getSearchResultMessage());
        }

        session.setAttribute(DisplayConstants.SEARCH_RESULT, null);
        session.setAttribute(DisplayConstants.CREATE_WORKFLOW, null);
        session.setAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT, null);
        session.setAttribute(DisplayConstants.CURRENT_FORM, null);
        if (session.getAttribute(DisplayConstants.SEARCH_RESULT) != null) {
            String str = (String) session.getAttribute(DisplayConstants.CREATE_WORKFLOW);
            if (session.getAttribute(DisplayConstants.CREATE_WORKFLOW) == null) {
                if (session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT) == null) {
                    session.setAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT,
                            session.getAttribute(DisplayConstants.SEARCH_RESULT));
                }
            }
        }
        session.setAttribute(DisplayConstants.SEARCH_RESULT, searchResult);
    } catch (CSException cse) {
        addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage()));
        if (logDB.isDebugEnabled())
            logDB.debug(session.getId() + "|"
                    + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                    + baseDBForm.getFormName() + "|search|Failure|Error Searching the "
                    + baseDBForm.getFormName() + " object|" + "|" + cse.getMessage());
    }
    session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);
    if (logDB.isDebugEnabled())
        logDB.debug(session.getId() + "|"
                + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|"
                + baseDBForm.getFormName() + "|search|Success|Success in searching " + baseDBForm.getFormName()
                + " object|" + "|");
    return ForwardConstants.SEARCH_SUCCESS;
}