[Ejtools-cvs] CVS: applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/web/action
Brought to you by:
letiemble
From: Laurent E. <let...@us...> - 2002-05-24 21:19:16
|
Update of /cvsroot/ejtools/applications/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/web/action In directory usw-pr-cvs1:/tmp/cvs-serv31461/jndi.browser/src/main/net/sourceforge/ejtools/jndibrowser/web/action Added Files: ConnectAction.java DetailAction.java Log Message: Initial import --- NEW FILE: ConnectAction.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jndibrowser.web.action; import java.io.IOException; import java.util.Locale; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ejtools.jndibrowser.web.Constants; import net.sourceforge.ejtools.jndibrowser.web.JNDIContainer; import org.apache.log4j.Category; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; /** * Description of the Class * * @author letiemble * @created 12 novembre 2001 * @todo Javadoc to complete */ public class ConnectAction extends Action { /** Description of the Field */ private static Category cat = Category.getInstance(ConnectAction.class.getName()); /** Constructor for the FilterAction object */ public ConnectAction() { } /** * Description of the Method * * @param mapping Description of Parameter * @param form Description of Parameter * @param request Description of Parameter * @param response Description of Parameter * @return Description of the Returned Value * @exception IOException Description of Exception * @exception ServletException Description of Exception */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { JNDIContainer javaTree = null; JNDIContainer globalTree = null; // Extract attributes we will need Locale locale = getLocale(request); MessageResources messages = getResources(); // Validate the request parameters specified by the user ActionErrors errors = new ActionErrors(); System.out.println("Connecting"); // Report any errors we have discovered back to the original form if (!errors.empty()) { saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } ServletContext context = this.getServlet().getServletContext(); javaTree = (JNDIContainer) context.getAttribute(Constants.JAVA_TREE); globalTree = (JNDIContainer) context.getAttribute(Constants.GLOBAL_TREE); if (javaTree == null) { javaTree = new JNDIContainer(); javaTree.setContext("java:"); context.setAttribute(Constants.JAVA_TREE, javaTree); } if (globalTree == null) { globalTree = new JNDIContainer(); globalTree.setContext(""); context.setAttribute(Constants.GLOBAL_TREE, globalTree); } javaTree.connect(); globalTree.connect(); return (mapping.findForward("view")); } } --- NEW FILE: DetailAction.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package net.sourceforge.ejtools.jndibrowser.web.action; import java.io.IOException; import java.util.Locale; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ejtools.jndibrowser.model.JNDIContext; import net.sourceforge.ejtools.jndibrowser.web.Constants; import net.sourceforge.ejtools.jndibrowser.web.JNDIContainer; import org.apache.log4j.Category; import org.apache.struts.action.Action; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; /** * Description of the Class * * @author letiemble * @created 12 novembre 2001 * @todo Javadoc to complete */ public class DetailAction extends Action { /** Description of the Field */ private static Category cat = Category.getInstance(DetailAction.class.getName()); /** Constructor for the SearchLoginAction object */ public DetailAction() { } /** * Description of the Method * * @param mapping Description of Parameter * @param form Description of Parameter * @param request Description of Parameter * @param response Description of Parameter * @return Description of the Returned Value * @exception IOException Description of Exception * @exception ServletException Description of Exception */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { JNDIContainer tree = null; // Extract attributes we will need Locale locale = getLocale(request); MessageResources messages = getResources(); // Validate the request parameters specified by the user ActionErrors errors = new ActionErrors(); // TODO : put in Constants String scope = request.getParameter("scope"); String ref = request.getParameter("reference"); ServletContext context = this.getServlet().getServletContext(); if ("java".equals(scope)) { tree = (JNDIContainer) context.getAttribute(Constants.JAVA_TREE); } if ("global".equals(scope)) { tree = (JNDIContainer) context.getAttribute(Constants.GLOBAL_TREE); } if (tree == null) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.cannot.connect")); } System.out.println("Root " + tree); JNDIContext o = (JNDIContext) tree.searchContext(ref); if (o != null) { context.setAttribute(Constants.DETAIL, o); System.out.println("Object " + o); } else { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.cannot.connect")); } // Report any errors we have discovered back to the original form if (!errors.empty()) { saveErrors(request, errors); return (mapping.findForward("error")); } return (mapping.findForward("detail")); } } |