⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textorgchartaction.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.applis.demo.actions;

import opiam.admin.applis.demo.beans.Person;
import opiam.admin.applis.demo.utils.GenOrgChart;

import opiam.admin.faare.persistence.LdapObjectFilter;
import opiam.admin.faare.service.UserContext;
import opiam.admin.faare.struts.actions.SecureAction;
import opiam.admin.faare.struts.utils.SessionContext;

import org.apache.log4j.Logger;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.io.IOException;


/**
 * This class allows to generate the text orgchart.
 */
public class TextOrgChartAction extends SecureAction
{
    /** Instance of the log4j logger.
     * Used to generate the execution traces. */
    private static Logger _logger =
        Logger.getLogger(TextOrgChartAction.class.getName());

    /**
     * This method is called to execute the action.
     *
     * @param mapping              Struts mapping data.
     * @param actionForm           FormBean associated with the action.
     * @param request              HTTP request.
     * @param httpServletResponse  HTTP response.
     *
     * @return An ActionForward.
     *
     * @throws IOException  An I/O exception if failed or interrupted I/O operations occurs.
     * @throws ServletException  A ServletException if the servlet has a problem.
     */
    public ActionForward secureExecute(ActionMapping mapping,
                                       ActionForm actionForm,
                                       HttpServletRequest request,
                                       HttpServletResponse httpServletResponse
                                      ) throws IOException, ServletException
    {
        SessionContext sessionContext = null;
        UserContext userContext = null;
        ActionMessages msgErrors = new ActionMessages();

        try
        {
            // Gets the session.
            HttpSession session = request.getSession();

            // Gets the session context.
            sessionContext = SessionContext.getInstance(session);

            // Gets the user context.
            userContext = sessionContext.getUserContext();

            String uplevelIdxStr = (String) request.getParameter("uplevelIdx");
            String downlevelIdxStr =
                (String) request.getParameter("downlevelIdx");

            _logger.debug("uplevelIdxStr = " + uplevelIdxStr);
            _logger.debug("downlevelIdxStr = " + downlevelIdxStr);

            //Mise en session des profondeurs de l'organigramme
            session.setAttribute("SELECT_UP", new Integer(uplevelIdxStr));
            session.setAttribute("SELECT_DOWN", new Integer(downlevelIdxStr));

            //G閚閞ation de l'organigramme
            //R閏up閞ation de la personne courante
            Person person = (Person) session.getAttribute("currentEntry");
            userContext.getParameters().put(LdapObjectFilter.VAR_CURRENT_ITEM,
                                            person
                                           );
            _logger.debug("currentEntry = " + person.getDn());

            String result =
                GenOrgChart.genOrgChart(person,
                                        (new Integer(uplevelIdxStr)).intValue(),
                                        (new Integer(downlevelIdxStr)).intValue(),
                                        sessionContext.getUserContext()
                                       );
            session.setAttribute("orgtext", result);

            return (mapping.findForward("success"));
        }
        catch (Exception se)
        {
            _logger.error(se.getMessage());
            msgErrors.add(ActionMessages.GLOBAL_MESSAGE,
                          new ActionMessage("error.service.unknown")
                         );
            saveErrors(request, msgErrors);

            return (mapping.findForward("service_error"));
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -