Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 693 invoked from network); 21 Jul 2005 01:39:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Jul 2005 01:39:27 -0000 Received: (qmail 89489 invoked by uid 500); 21 Jul 2005 01:39:22 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 89453 invoked by uid 500); 21 Jul 2005 01:39:22 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 89355 invoked by uid 99); 21 Jul 2005 01:39:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jul 2005 18:39:21 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 20 Jul 2005 18:39:04 -0700 Received: (qmail 372 invoked by uid 65534); 21 Jul 2005 01:39:06 -0000 Message-ID: <20050721013906.371.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r219976 [7/12] - in /geronimo/trunk: ./ etc/ sandbox/console-core/ sandbox/console-core/src/ sandbox/console-core/src/java/ sandbox/console-core/src/java/org/ sandbox/console-core/src/java/org/apache/ sandbox/console-core/src/java/org/apach... Date: Thu, 21 Jul 2005 01:38:23 -0000 To: scm@geronimo.apache.org From: ammulder@apache.org X-Mailer: svnmailer-1.0.2 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,167 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.handlers; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.List; + +import javax.jms.Queue; +import javax.jms.Topic; +import javax.management.ObjectName; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; + +import org.activemq.message.ActiveMQQueue; +import org.activemq.message.ActiveMQTopic; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.connector.AdminObjectWrapper; +import org.apache.geronimo.console.core.jms.TopicBrowserGBean; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; +import org.apache.geronimo.gbean.DynamicGAttributeInfo; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.gbean.GBeanInfo; +import org.apache.geronimo.gbean.GBeanInfoBuilder; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.apache.geronimo.kernel.config.ConfigurationData; +import org.apache.geronimo.kernel.config.ConfigurationManager; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; +import org.apache.geronimo.kernel.config.ConfigurationUtil; + +public class CreateDestinationHandler extends AbstractJMSManager implements + PortletResponseHandler { + + protected static Log log = LogFactory + .getLog(CreateDestinationHandler.class); + + private static final URI parentId = URI + .create("org/apache/geronimo/Console"); + + static final GBeanInfo QUEUE_INFO; + + static final GBeanInfo TOPIC_INFO; + + static { + GBeanInfoBuilder queueInfoBuilder = new GBeanInfoBuilder( + AdminObjectWrapper.class, AdminObjectWrapper.GBEAN_INFO); + queueInfoBuilder.addAttribute(new DynamicGAttributeInfo("PhysicalName", + String.class.getName(), true, true, true)); + QUEUE_INFO = queueInfoBuilder.getBeanInfo(); + GBeanInfoBuilder topicInfoBuilder = new GBeanInfoBuilder( + AdminObjectWrapper.class, AdminObjectWrapper.GBEAN_INFO); + topicInfoBuilder.addAttribute(new DynamicGAttributeInfo("PhysicalName", + String.class.getName(), true, true, true)); + TOPIC_INFO = topicInfoBuilder.getBeanInfo(); + } + + public void processAction(ActionRequest request, ActionResponse response) + throws IOException, PortletException { + String destinationName = request.getParameter(DESTINATION_NAME); + String destinationPhysicalName = request + .getParameter(DESTINATION_PHYSICAL_NAME); + String destinationType = request.getParameter(DESTINATION_TYPE); + String destinationApplicationName = request + .getParameter(DESTINATION_APPLICATION_NAME); + String destinationModuleName = request + .getParameter(DESTINATION_MODULE_NAME); + try { + ObjectName adminObjectName = NameFactory.getComponentName(null, + null, destinationApplicationName, NameFactory.JCA_RESOURCE, + destinationModuleName, destinationName, null, baseContext); + + GBeanData adminObjectData; + if (Topic.class.getName().equals(destinationType)) { + adminObjectData = new GBeanData(adminObjectName, TOPIC_INFO); + adminObjectData.setAttribute("adminObjectInterface", + Topic.class.getName()); + adminObjectData.setAttribute("adminObjectClass", + ActiveMQTopic.class.getName()); + } else if (Queue.class.getName().equals(destinationType)) { + adminObjectData = new GBeanData(adminObjectName, QUEUE_INFO); + adminObjectData.setAttribute("adminObjectInterface", + Queue.class.getName()); + adminObjectData.setAttribute("adminObjectClass", + ActiveMQQueue.class.getName()); + } else { + throw new PortletException( + "Invalid choice destination, must be FQCL of Topic or Queue, not " + + destinationType); + } + adminObjectData.setAttribute("PhysicalName", + destinationPhysicalName); + + URI configId = new URI(BASE_CONFIG_URI + destinationName); + + ConfigurationManager configurationManager = ConfigurationUtil + .getConfigurationManager(kernel); + List stores = configurationManager.listStores(); + assert stores.size() == 1 : "Piling one hack on another, this code only works with exactly one store"; + + ObjectName storeName = (ObjectName) stores.iterator().next(); + File installDir = (File) kernel.invoke(storeName, + "createNewConfigurationDir"); + //DeploymentContext deploymentContext = new + // DeploymentContext(installDir, configId, + // ConfigurationModuleType.SERVICE, parentId, kernel); + ConfigurationData configData = new ConfigurationData(); + configData.setId(configId); + configData.setParentId(parentId); + configData.setModuleType(ConfigurationModuleType.SERVICE); + //deploymentContext.addGBean(adminObjectData); + configData.addGBean(adminObjectData); + // If we are adding a topic we have to add a browser so we can view + // its messages later. + if (Topic.class.getName().equals(destinationType)) { + GBeanData tBrowserBeanData = new GBeanData(NameFactory + .getComponentName(null, null, + destinationApplicationName, + NameFactory.JCA_RESOURCE, + destinationModuleName, destinationName, + "TopicBrowser", baseContext), + TopicBrowserGBean.GBEAN_INFO); + tBrowserBeanData + .setAttribute("subscriberName", destinationName); + tBrowserBeanData.setReferencePattern( + "ConnectionFactoryWrapper", ObjectName + .getInstance(CONNECTION_FACTORY_NAME)); + tBrowserBeanData.setReferencePattern("TopicWrapper", + adminObjectName); + + configData.addGBean(tBrowserBeanData); + } + + //saves it. + //deploymentContext.close(); + kernel.invoke(storeName, "install", new Object[] {configData, + installDir}, new String[] { + ConfigurationData.class.getName(), File.class.getName() }); + + ObjectName configName = configurationManager.load(configId); + kernel.startRecursiveGBean(configName); + + } catch (Exception e) { + log.info("problem", e); + log.error("problem", e); + } + response.setRenderParameter("processAction", "viewDestinations"); + } + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,31 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.handlers; + +import java.io.IOException; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; + +public interface PortletResponseHandler { + + public void processAction(ActionRequest request, ActionResponse response) + throws IOException, PortletException; + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/PortletResponseHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,90 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.handlers; + +import java.io.IOException; +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import javax.management.ObjectName; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; +import org.apache.geronimo.console.util.ObjectNameConstants; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.kernel.DependencyManager; +import org.apache.geronimo.kernel.config.ConfigurationManager; +import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.jmx.JMXUtil; + +public class RemoveDestinationHandler extends AbstractJMSManager implements + PortletResponseHandler { + + protected static Log log = LogFactory + .getLog(RemoveDestinationHandler.class); + + public void processAction(ActionRequest request, ActionResponse response) + throws IOException, PortletException { + String destinationConfigURIName = request + .getParameter(DESTINATION_CONFIG_URI); + try { + ConfigurationManager configurationManager = ConfigurationUtil + .getConfigurationManager(kernel); + URI destinationConfigURI = new URI(destinationConfigURIName); + + List stores = configurationManager.listStores(); + assert stores.size() == 1 :"Piling one hack on another, this code only works with exactly one store"; + ObjectName storeName = (ObjectName) stores.iterator().next(); + + // Unsubscribe topicbrowser before uninstalling the configuration. + DependencyManager dm = kernel.getDependencyManager(); + //GBeanData topicBrowser = (GBeanData) kernel.invoke(storeName, + // "getConfiguration", new Object[]{destinationConfigURI}, new + // String[]{URI.class.getName()}); + GBeanData topicBrowser = kernel.getGBeanData(JMXUtil + .getObjectName(ObjectNameConstants.CONFIG_GBEAN_PREFIX + + "\"" + destinationConfigURI + "\"")); + java.util.Set children = dm.getChildren(topicBrowser.getName()); + for (Iterator i = children.iterator(); i.hasNext();) { + ObjectName o = (ObjectName) i.next(); + if ("TopicBrowser".equals(o.getKeyProperty("j2eeType"))) { + kernel.invoke(o, "unsubscribe"); + break; + } + } + + // Uninstall configuration + //kernel.stopConfiguration(destinationConfigURI); + kernel.stopGBean(JMXUtil + .getObjectName(ObjectNameConstants.CONFIG_GBEAN_PREFIX + + "\"" + destinationConfigURIName + "\"")); + kernel.invoke(storeName, "uninstall", + new Object[] {destinationConfigURI}, + new String[] {URI.class.getName()}); + } catch (Exception e) { + log.error("problem removing destination: " + + destinationConfigURIName, e); + } + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/RemoveDestinationHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,45 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.handlers; + +import java.io.IOException; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; + +public class StatisticsHandler extends AbstractJMSManager implements + PortletResponseHandler { + + protected static Log log = LogFactory.getLog(StatisticsHandler.class); + + public void processAction(ActionRequest request, ActionResponse response) + throws IOException, PortletException { + String destinationName = request.getParameter(DESTINATION_NAME); + String destinationType = request.getParameter(DESTINATION_TYPE); + + response.setRenderParameter("destinationName", destinationName); + response.setRenderParameter("destinationType", destinationType); + response.setRenderParameter("processAction", "statistics"); + } + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/StatisticsHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,42 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; + +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; + +public class CreateDestinationRenderer extends AbstractJMSManager implements + PortletRenderer { + + protected static Log log = LogFactory + .getLog(CreateDestinationRenderer.class); + + public String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + + return "/WEB-INF/view/jmsmanager/createdestination.jsp"; + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/CreateDestinationRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,31 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; + +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +public interface PortletRenderer { + + String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException; + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/PortletRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,68 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; +import java.util.Hashtable; + +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; + +public class StatisticsRenderer extends AbstractJMSManager implements + PortletRenderer { + + protected static Log log = LogFactory.getLog(StatisticsRenderer.class); + + public String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + + Hashtable statistics = getStatistics(request, response); + + request.setAttribute("statistics", statistics); + + return "/WEB-INF/view/jmsmanager/statistics.jsp"; + } + + public static Hashtable getStatistics(RenderRequest renderRequest, + RenderResponse renderResponse) throws IOException, PortletException { + String description = "My Descrition"; + String currentDepth = "11"; + String openInputCount = "1"; + String openOutputCount = "1"; + String inhibitGet = "false"; + String inhibitPut = "false"; + String sharable = "true"; + String triggerControl = "false"; + String maximumDepth = "10000"; + String maximumMessageLength = "2342344"; + + String destinationName = renderRequest.getParameter("destinationName"); + if (destinationName == null) { + destinationName = ""; + } + Hashtable statsHash = new Hashtable(); + + return statsHash; + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/StatisticsRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,143 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.Session; +import javax.management.ObjectName; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.activemq.service.DeadLetterPolicy; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; + +public class ViewDLQRenderer extends AbstractJMSManager implements + PortletRenderer { + + private Destination destination = null; + + private Destination dlq = null; + + private QueueBrowser dlqBrowser = null; + + private Connection connection = null; + + private Session session = null; + + private String dlqName; + + public ViewDLQRenderer() { + } + + public void setup(RenderRequest request, RenderResponse response) { + String destinationApplicationName = request + .getParameter("destinationApplicationName"); + String destinationModuleName = request + .getParameter("destinationModuleName"); + String destinationName = request.getParameter("destinationName"); + + try { + ObjectName adminObjectName = NameFactory.getComponentName(null, + null, destinationApplicationName, NameFactory.JCA_RESOURCE, + destinationModuleName, destinationName, null, baseContext); + destination = (Destination) kernel.invoke(adminObjectName, + "$getResource"); + ConnectionFactory connectionFactory = (ConnectionFactory) kernel + .invoke(ObjectName.getInstance(CONNECTION_FACTORY_NAME), + "$getResource"); + connection = connectionFactory.createConnection(); + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + DeadLetterPolicy dlp = new DeadLetterPolicy(); + + //dlqName = + // dlp.getDeadLetterNameFromDestination((ActiveMQDestination) + // destination); + // This is a hack to get around the fact that the code commented + // above throws a ClassCastException due to ClassLoader weirdness. + Field f = dlp.getClass().getDeclaredField( + "deadLetterPerDestinationName"); + f.setAccessible(true); + boolean deadLetterPerDestinationName = f.getBoolean(dlp); + f = dlp.getClass().getDeclaredField("deadLetterPrefix"); + f.setAccessible(true); + String deadLetterPrefix = "" + f.get(dlp); + if (deadLetterPerDestinationName) { + dlqName = deadLetterPrefix + + destination.getClass().getMethod("getPhysicalName", + null).invoke(destination, null); + } else { + dlqName = deadLetterPrefix + deadLetterPrefix; + } + + dlq = session.createQueue(dlqName); + dlqBrowser = session.createBrowser((Queue) dlq); + + connection.start(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public List getDLQContents(QueueBrowser qb) { + + List list = new ArrayList(); + + try { + for (Enumeration e = qb.getEnumeration(); e.hasMoreElements();) { + Object o = e.nextElement(); + list.add(o); + } + + connection.stop(); + dlqBrowser.close(); + session.close(); + connection.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + + return list; + } + + public String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + + setup(request, response); + List dlqContents = getDLQContents(dlqBrowser); + request.setAttribute("dlqcontents", dlqContents); + request.setAttribute("dlqname", dlqName); + + return "/WEB-INF/view/jmsmanager/viewDLQ.jsp"; + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDLQRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,114 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import javax.management.ObjectName; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; +import org.apache.geronimo.console.jmsmanager.DestinationInfo; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.apache.geronimo.kernel.DependencyManager; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.KernelRegistry; + +public class ViewDestinationsRenderer extends AbstractJMSManager implements + PortletRenderer { + + protected static Log log = LogFactory + .getLog(ViewDestinationsRenderer.class); + + public String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + + List destinationList = getDestinationList(request, response); + + request.setAttribute(DESTINATION_LIST, destinationList); + + return "/WEB-INF/view/jmsmanager/view.jsp"; + } + + public List getDestinationList(RenderRequest request, + RenderResponse response) { + Kernel kernel = KernelRegistry.getSingleKernel(); + + Set destinations = kernel.listGBeans(DESTINATION_QUERY); + List destinationInfos = new ArrayList(destinations.size()); + DependencyManager dm = kernel.getDependencyManager(); + for (Iterator iterator = destinations.iterator(); iterator.hasNext();) { + ObjectName destinationName = (ObjectName) iterator.next(); + + try { + Class type; + try { + type = Class.forName((String) kernel.getAttribute( + destinationName, "adminObjectInterface")); + } catch (ClassCastException cce) { + type = (Class) kernel.getAttribute(destinationName, + "adminObjectInterface"); + } + Set parents = dm.getParents(destinationName); + Iterator i = parents.iterator(); + // If no parents this is a configuration we don't need those + // here. + if (!i.hasNext()) { + continue; + } + ObjectName parent = (ObjectName) i.next(); + String adminObjectName = destinationName + .getKeyProperty(NameFactory.J2EE_NAME); + if (adminObjectName.equals("MDBTransferBeanOutQueue") + || adminObjectName.equals("SendReceiveQueue")) { + continue; + } + String configURI = parent.getKeyProperty("name"); + if (configURI.startsWith("\"")) { + configURI = configURI.substring(1); + } + if (configURI.endsWith("\"")) { + configURI = configURI.substring(0, configURI.length() - 1); + } + + DestinationInfo info = new DestinationInfo(adminObjectName, + (String) kernel.getAttribute(destinationName, + "PhysicalName"), type, destinationName + .getKeyProperty(NameFactory.J2EE_APPLICATION), + destinationName + .getKeyProperty(NameFactory.JCA_RESOURCE), + configURI); + destinationInfos.add(info); + } catch (Exception e) { + log.error(e); + } + } + Collections.sort(destinationInfos); + return destinationInfos; + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewDestinationsRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewMessagesRenderer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewMessagesRenderer.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewMessagesRenderer.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewMessagesRenderer.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,178 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.jmsmanager.renderers; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Queue; +import javax.jms.QueueBrowser; +import javax.jms.QueueConnection; +import javax.jms.QueueConnectionFactory; +import javax.jms.QueueSession; +import javax.jms.Topic; +import javax.management.ObjectName; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.apache.geronimo.console.jmsmanager.AbstractJMSManager; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; + +public class ViewMessagesRenderer extends AbstractJMSManager implements + PortletRenderer { + + private static final TopicListener topicListener = new TopicListener(); + + public String render(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + List messageList = getMessageList(request, response); + request.setAttribute("messages", messageList); + return "/WEB-INF/view/jmsmanager/viewmessages.jsp"; + } + + public List getMessageList(RenderRequest request, RenderResponse response) + throws PortletException { + String destinationApplicationName = request + .getParameter("destinationApplicationName"); + String destinationModuleName = request + .getParameter("destinationModuleName"); + String destinationName = request.getParameter("destinationName"); + + List ret = new ArrayList(); + try { + ObjectName adminObjectName = NameFactory.getComponentName(null, + null, destinationApplicationName, NameFactory.JCA_RESOURCE, + destinationModuleName, destinationName, null, baseContext); + Destination dest = (Destination) kernel.invoke(adminObjectName, + "$getResource"); + if (dest instanceof Queue) { + Queue queue = (Queue) dest; + QueueConnectionFactory qConFactory = null; + QueueConnection qConnection = null; + QueueSession qSession = null; + QueueBrowser qBrowser = null; + try { + qConFactory = (QueueConnectionFactory) kernel.invoke( + ObjectName.getInstance(CONNECTION_FACTORY_NAME), + "$getResource"); + qConnection = qConFactory.createQueueConnection(); + qSession = qConnection.createQueueSession(false, + QueueSession.AUTO_ACKNOWLEDGE); + qBrowser = qSession.createBrowser(queue); + qConnection.start(); + for (Enumeration e = qBrowser.getEnumeration(); e + .hasMoreElements();) { + Object o = e.nextElement(); + ret.add(o); + } + qConnection.stop(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (qBrowser != null) { + qBrowser.close(); + } + } catch (JMSException ignore) { + } + try { + if (qSession != null) { + qSession.close(); + } + } catch (JMSException ignore) { + } + try { + if (qConnection != null) { + qConnection.close(); + } + } catch (JMSException ignore) { + } + } + } else if (dest instanceof Topic) { + ObjectName tBrowserObjName = NameFactory.getComponentName(null, + null, destinationApplicationName, + NameFactory.JCA_RESOURCE, destinationModuleName, + destinationName, "TopicBrowser", baseContext); + ret = (List) kernel.invoke(tBrowserObjName, "getMessages"); + } + } catch (Exception e) { + e.printStackTrace(); + } + return ret; + } + + static class TopicListener implements MessageListener { + /** + * Hashtable to hold the messages for each topic. Messages are stored as + * Message/Topic key/value pairs. + */ + private Map messagesMap = new Hashtable(); + + public final String name = this.toString(); + + public synchronized void onMessage(Message message) { + try { + Destination dest = message.getJMSDestination(); + List messages = null; + if (!messagesMap.containsKey(dest)) { + register((Topic) dest); + } + messages = (List) messagesMap.get(dest); + + if (!messages.contains(message)) { + messages.add(message); + } + messagesMap.put(dest, messages); + } catch (JMSException e) { + e.printStackTrace(); + } + } + + public void register(Topic topic) { + if (!messagesMap.containsKey(topic)) { + List messages = new ArrayList(); + messagesMap.put(topic, messages); + } + } + + public List getMessages(Topic topic) { + List ret; + if (messagesMap.containsKey(topic)) { + ret = (List) messagesMap.get(topic); + } else { + ret = Collections.EMPTY_LIST; + } + return Collections.unmodifiableList(ret); + } + + public boolean isListeningTo(Topic topic) { + return messagesMap.containsKey(topic); + } + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/jmsmanager/renderers/ViewMessagesRenderer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,88 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.logmanager; + +import java.io.IOException; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletConfig; +import javax.portlet.PortletContext; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +import org.apache.geronimo.console.util.LogHelper; + +public class LogManagerPortlet extends GenericPortlet { + + protected PortletRequestDispatcher normalView; + + protected PortletRequestDispatcher helpView; + + protected void doHelp(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + helpView.include(renderRequest, renderRespose); + } + + protected void doView(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { + return; + } + renderRequest.setAttribute("configFile", LogHelper.getConfigFile()); + renderRequest.setAttribute("configuration", LogHelper + .getConfiguration()); + renderRequest.setAttribute("logLevel", LogHelper.getLogLevel()); + renderRequest.setAttribute("refreshPeriod", LogHelper + .getRefreshPeriod()); + + normalView.include(renderRequest, renderRespose); + } + + public void init(PortletConfig portletConfig) throws PortletException { + PortletContext pc = portletConfig.getPortletContext(); + normalView = pc + .getRequestDispatcher("/WEB-INF/view/logmanager/view.jsp"); + helpView = pc.getRequestDispatcher("/WEB-INF/view/logmanager/help.jsp"); + super.init(portletConfig); + } + + public void processAction(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortletException, IOException { + + String action = actionRequest.getParameter("action"); + String logLevel = actionRequest.getParameter("logLevel"); + String configFile = actionRequest.getParameter("configFile"); + String configuration = actionRequest.getParameter("append"); + String refreshPeriod = actionRequest.getParameter("refreshPeriod"); + + if ("update".equals(action)) { + if (refreshPeriod != null) { + LogHelper.setRefreshPeriod(Integer.parseInt(refreshPeriod)); + } + LogHelper.setConfigFile(configFile); + LogHelper.setLogLevel(logLevel); + + } + } + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogManagerPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,92 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.logmanager; + +import java.io.IOException; + +import javax.portlet.GenericPortlet; +import javax.portlet.PortletConfig; +import javax.portlet.PortletContext; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +import org.apache.geronimo.console.util.LogHelper; + +public class LogViewerPortlet extends GenericPortlet { + + public static final int LOGS_PER_PAGE = 10; + + protected PortletRequestDispatcher searchView; + + protected PortletRequestDispatcher helpView; + + protected void doHelp(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + helpView.include(renderRequest, renderRespose); + } + + protected void doView(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { + return; + } + String action = renderRequest.getParameter("action"); + + if ("refresh".equals(action)) { + LogHelper.refresh(); + } + + String startPos = renderRequest.getParameter("startPos"); + String endPos = renderRequest.getParameter("endPos"); + String logLevel = renderRequest.getParameter("logLevel"); + String searchString = renderRequest.getParameter("searchString"); + + int lines = LogHelper.getLineCount(); + int sPos = (startPos != null && startPos.length() > 0) ? Integer + .parseInt(startPos) : (lines - LOGS_PER_PAGE); + int ePos = (endPos != null && endPos.length() > 0) ? Integer + .parseInt(endPos) : lines; + + try { + renderRequest.setAttribute("searchResults", LogHelper.searchLogs( + sPos, ePos, logLevel, searchString)); + } catch (IOException e) { + throw new PortletException(e.getMessage()); + } + renderRequest.setAttribute("lineCount", new Integer(lines)); + renderRequest.setAttribute("startPos", new Integer(sPos)); + renderRequest.setAttribute("endPos", new Integer(ePos)); + renderRequest.setAttribute("logLevel", logLevel); + renderRequest.setAttribute("searchString", searchString); + + searchView.include(renderRequest, renderRespose); + } + + public void init(PortletConfig portletConfig) throws PortletException { + PortletContext pc = portletConfig.getPortletContext(); + searchView = pc + .getRequestDispatcher("/WEB-INF/view/logmanager/search.jsp"); + helpView = pc + .getRequestDispatcher("/WEB-INF/view/logmanager/viewhelp.jsp"); + super.init(portletConfig); + } + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/LogViewerPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogCriteria.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogCriteria.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogCriteria.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogCriteria.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,96 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.logmanager; + +public class WebAccessLogCriteria { + + private String requestHost; + + private String authUser; + + private String requestMethod; + + private String requestedURI; + + private String message; + + /** + * Get an instance of WebAccessLogCriteria that matches anyother instances + * of new WebAccessLogCriteria. + * + * @return + */ + public static WebAccessLogCriteria getGlobalMatcher() { + return new WebAccessLogCriteria(""); + } + + public WebAccessLogCriteria(String message, String requestHost, + String authUser, String requestMethod, String requestedURI) { + this.message = message; + this.requestHost = requestHost; + this.authUser = authUser; + this.requestMethod = requestMethod; + this.requestedURI = requestedURI; + } + + public WebAccessLogCriteria(String message, String requestHost, + String authUser, String requestMethod) { + this(message, requestHost, authUser, requestMethod, null); + } + + public WebAccessLogCriteria(String message, String requestHost, + String authUser) { + this(message, requestHost, authUser, null); + } + + public WebAccessLogCriteria(String message, String requestHost) { + this(message, requestHost, null); + } + + public WebAccessLogCriteria(String message) { + this(message, null); + } + + public String toString() { + return message; + } + + /** + * Check equality of two object using the following rules: + *
    + *
  1. If one of the arguments is null return true.
  2. + *
  3. If both arguments are not null check for equality.
  4. + *
+ */ + private boolean checkEquality(Object lhs, Object rhs) { + return (lhs == null || rhs == null || lhs.equals(rhs)); + } + + /** + * Check's criteria matches this one. This method checks all the + * relevant(all except message) fields for equality but will also consider + * to fields a match if one of them is null. + */ + public boolean matches(WebAccessLogCriteria rhs) { + return (checkEquality(requestHost, rhs.requestHost) + && checkEquality(authUser, rhs.authUser) + && checkEquality(requestMethod, rhs.requestMethod) && checkEquality( + requestedURI, rhs.requestedURI)); + } + +} \ No newline at end of file Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogCriteria.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogHelper.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogHelper.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogHelper.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,260 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.logmanager; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.TreeMap; +import java.util.regex.Pattern; + +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + +import org.apache.geronimo.console.util.KernelHelper; +import org.apache.geronimo.console.util.ObjectNameConstants; + +public class WebAccessLogHelper extends KernelHelper { + + private static ObjectName objName, serverInfoObjName; + + private static final String LOG_FILE_ATTR = "filename"; + + private static Map logs = new TreeMap(); + + private static boolean loaded = false; + + private static int lines = 0; + + private static Map loadLogs() throws IOException { + if (!loaded) { + refresh(); + } + return logs; + } + + public static ArrayList getLogsByDate(Date logDate) throws IOException { + // Since the two date arg version is inclusive we just call that one + // passing in the logDate as start and end dates. + return filterLogsByDate(WebAccessLogCriteria.getGlobalMatcher(), + logDate, logDate); + } + + public static int getLineCount() throws IOException { + if (!loaded) { + refresh(); + } + return lines; + } + + public static ArrayList getLogs() throws IOException { + return filterLogs(WebAccessLogCriteria.getGlobalMatcher()); + } + + public static ArrayList filterLogs(WebAccessLogCriteria criteria) + throws IOException { + Map log = loadLogs(); + ArrayList ret = new ArrayList(); + for (Iterator i = log.keySet().iterator(); i.hasNext();) { + Date date = (Date) i.next(); + ArrayList msgs = (ArrayList) log.get(date); + for (Iterator j = msgs.iterator(); j.hasNext();) { + WebAccessLogCriteria obj = (WebAccessLogCriteria) j.next(); + if (obj.matches(criteria)) { + ret.add(obj); + } + } + } + return ret; + } + + public static ArrayList filterLogsByDate(WebAccessLogCriteria criteria, + Date startDate, Date endDate) throws IOException { + Map log = loadLogs(); + ArrayList ret = new ArrayList(); + for (Iterator i = log.keySet().iterator(); i.hasNext();) { + Date date = (Date) i.next(); + ArrayList msgs = (ArrayList) log.get(date); + for (Iterator j = msgs.iterator(); j.hasNext();) { + WebAccessLogCriteria obj = (WebAccessLogCriteria) j.next(); + if (obj.matches(criteria) + && isBetween(date, startDate, endDate)) { + ret.add(obj); + } + } + } + return ret; + + } + + public static ArrayList searchLogs(String requestHost, String authUser, + String requestMethod, String requestedURI) throws IOException { + return searchLogs(requestHost, authUser, requestMethod, requestedURI, + null, null); + } + + public static ArrayList searchLogs(String requestHost, String authUser, + String requestMethod, String requestedURI, Date startDate, + Date endDate) throws IOException { + if (requestHost != null && requestHost.trim().length() == 0) { + requestHost = null; + } + if (authUser != null && authUser.trim().length() == 0) { + authUser = null; + } + if (requestMethod != null && requestMethod.trim().length() == 0) { + requestMethod = null; + } + if (requestedURI != null && requestedURI.trim().length() == 0) { + requestedURI = null; + } + WebAccessLogCriteria criteria = new WebAccessLogCriteria("", + requestHost, authUser, requestMethod, requestedURI); + if (startDate == null || endDate == null) { + return filterLogs(criteria); + } else { + return filterLogsByDate(criteria, startDate, endDate); + } + } + + public static File[] getFiles() { + String fileNamePattern = get(objName, LOG_FILE_ATTR).toString(); + if (fileNamePattern.indexOf("/") > -1) { + fileNamePattern = fileNamePattern.substring(fileNamePattern + .lastIndexOf("/") + 1); + } else if (fileNamePattern.indexOf("\\") > -1) { + fileNamePattern = fileNamePattern.substring(fileNamePattern + .lastIndexOf("\\") + 1); + } + + Object[] arg = { get(objName, LOG_FILE_ATTR).toString() }; + String[] parms = { String.class.getName() }; + try { + String logFile = (String) invoke(serverInfoObjName, "resolvePath", + arg, parms); + File f = new File(logFile).getParentFile(); + return (f != null ? f.listFiles(new PatternFilenameFilter( + fileNamePattern)) : new File[0]); + } catch (Exception e) { + return new File[0]; + } + } + + public static void refresh() throws IOException { + loaded = false; + lines = 0; + logs.clear(); + File[] logFiles = getFiles(); + for (int i = 0; i < logFiles.length; i++) { + BufferedReader in = new BufferedReader(new FileReader(logFiles[i])); + for (String line = in.readLine(); line != null; line = in + .readLine()) { + try { + StringTokenizer split = new StringTokenizer(line, " "); + String remoteHost = split.nextToken().trim(); + // Ignore host + split.nextToken(); + String user = split.nextToken("[").trim(); + String dateTime = split.nextToken(" ").substring(1).trim(); + //ignore GMT offset + split.nextToken(); + String reqMethod = split.nextToken().substring(1).trim(); + String reqURI = split.nextToken().trim(); + // Get date time. + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new SimpleDateFormat( + "dd/MMM/yyyy:HH:mm:ss").parse(dateTime)); + // remove time so we can filter by date later. + calendar.clear(Calendar.MILLISECOND); + calendar.clear(Calendar.MINUTE); + calendar.clear(Calendar.SECOND); + // Weird java bug. calling calendar.clear(Calendar.HOUR) + // does not clear the hour but this works. + calendar.clear(calendar.HOUR_OF_DAY); + calendar.clear(calendar.HOUR); + ArrayList msgs; + if (logs.containsKey(calendar.getTime())) { + msgs = (ArrayList) logs.get(calendar.getTime()); + } else { + msgs = new ArrayList(); + } + WebAccessLogCriteria criteria = new WebAccessLogCriteria( + line, remoteHost, user, reqMethod, reqURI); + msgs.add(0, criteria); + logs.put(calendar.getTime(), msgs); + lines++; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + loaded = true; + } + + /** + * Check if a date is between two dates (inclusive). + * + * @return true if date is between(inclusive) startDate and endDate. + */ + private static boolean isBetween(Date date, Date startDate, Date endDate) { + return (date.equals(startDate) || date.after(startDate)) + && (date.equals(endDate) || date.before(endDate)); + } + + static { + try { + objName = new ObjectName( + ObjectNameConstants.REQUEST_LOGGER_OBJECT_NAME); + serverInfoObjName = new ObjectName( + ObjectNameConstants.SERVER_INFO_OBJECT_NAME); + } catch (MalformedObjectNameException e) { + + } + } + + /* + * Static inner class implementation of java.io.Filename. This will help us + * filter for only the files that we are interested in. + */ + static class PatternFilenameFilter implements FilenameFilter { + Pattern pattern; + + PatternFilenameFilter(String fileNamePattern) { + fileNamePattern = fileNamePattern.replaceAll("yyyy", "\\\\d{4}"); + fileNamePattern = fileNamePattern.replaceAll("yy", "\\\\d{2}"); + fileNamePattern = fileNamePattern.replaceAll("mm", "\\\\d{2}"); + fileNamePattern = fileNamePattern.replaceAll("dd", "\\\\d{2}") + + ".*"; + this.pattern = Pattern.compile(fileNamePattern); + } + + public boolean accept(File file, String fileName) { + return pattern.matcher(fileName).matches(); + } + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,134 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.logmanager; + +import java.io.IOException; +import java.util.Calendar; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletConfig; +import javax.portlet.PortletContext; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +public class WebAccessLogViewerPortlet extends GenericPortlet { + + protected PortletRequestDispatcher searchView; + + protected PortletRequestDispatcher helpView; + + protected void doHelp(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + helpView.include(renderRequest, renderRespose); + } + + protected void doView(RenderRequest renderRequest, + RenderResponse renderRespose) throws PortletException, IOException { + if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { + return; + } + String action = renderRequest.getParameter("action"); + if ("refresh".equals(action)) { + WebAccessLogHelper.refresh(); + } + + String startDate = (String) renderRequest.getParameter("startDate"); + String startMonth = (String) renderRequest.getParameter("startMonth"); + String startYear = (String) renderRequest.getParameter("startYear"); + String endDate = (String) renderRequest.getParameter("endDate"); + String endMonth = (String) renderRequest.getParameter("endMonth"); + String endYear = (String) renderRequest.getParameter("endYear"); + + Calendar cal1 = Calendar.getInstance(), cal2 = Calendar.getInstance(); + // If no dates were passed we assume than no fields were passed and just + // filter on the current date. + if (startDate == null || startMonth == null || startDate == null + || endDate == null || endMonth == null || endDate == null) { + // just keep the month date and year + cal1.clear(Calendar.MILLISECOND); + cal1.clear(Calendar.MINUTE); + cal1.clear(Calendar.SECOND); + // Weird java bug. calling calendar.clear(Calendar.HOUR) does not + // clear the hour but this works. + cal1.clear(cal1.HOUR_OF_DAY); + cal1.clear(cal1.HOUR); + + renderRequest.setAttribute("logs", WebAccessLogHelper + .getLogsByDate(cal1.getTime())); + renderRequest.setAttribute("toDate", cal1.getTime()); + } else { + int sdt = Integer.parseInt(startDate), smnth = Integer + .parseInt(startMonth), syr = Integer.parseInt(startYear), edt = Integer + .parseInt(endDate), emnth = Integer.parseInt(endMonth), eyr = Integer + .parseInt(endYear); + boolean ignoreDates = renderRequest.getParameter("ignoreDates") == null; + String requestHost = (String) renderRequest + .getParameter("requestHost"); + String authUser = (String) renderRequest.getParameter("authUser"); + String requestMethod = (String) renderRequest + .getParameter("requestMethod"); + String requestedURI = (String) renderRequest + .getParameter("requestedURI"); + if (ignoreDates) { + cal1.clear(); + cal2.clear(); + cal1.set(Calendar.DATE, sdt); + cal1.set(Calendar.MONTH, smnth); + cal1.set(Calendar.YEAR, syr); + cal2.set(Calendar.DATE, edt); + cal2.set(Calendar.MONTH, emnth); + cal2.set(Calendar.YEAR, eyr); + renderRequest.setAttribute("logs", WebAccessLogHelper + .searchLogs(requestHost, authUser, requestMethod, + requestedURI, cal1.getTime(), cal2.getTime())); + } else { + renderRequest.setAttribute("logs", WebAccessLogHelper + .searchLogs(requestHost, authUser, requestMethod, + requestedURI)); + } + renderRequest.setAttribute("toDate", cal2.getTime()); + renderRequest.setAttribute("ignoreDates", new Boolean(ignoreDates)); + renderRequest.setAttribute("requestHost", requestHost); + renderRequest.setAttribute("authUser", authUser); + renderRequest.setAttribute("requestMethod", requestMethod); + renderRequest.setAttribute("requestedURI", requestedURI); + + } + renderRequest.setAttribute("fromDate", cal1.getTime()); + searchView.include(renderRequest, renderRespose); + } + + public void init(PortletConfig portletConfig) throws PortletException { + PortletContext pc = portletConfig.getPortletContext(); + searchView = pc + .getRequestDispatcher("/WEB-INF/view/webaccesslogmanager/view.jsp"); + helpView = pc + .getRequestDispatcher("/WEB-INF/view/webaccesslogmanager/help.jsp"); + super.init(portletConfig); + } + + public void processAction(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortletException, IOException { + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,202 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.repository; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import javax.management.ObjectName; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.GenericPortlet; +import javax.portlet.PortletConfig; +import javax.portlet.PortletContext; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.portlet.PortletFileUpload; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.KernelRegistry; + +public class RepositoryViewPortlet extends GenericPortlet { + + private static final String REPO_OBJ_NAME = "geronimo.server:name=Repository,J2EEServer=geronimo,J2EEApplication=null,j2eeType=GBean,J2EEModule=org/apache/geronimo/System"; + + private Kernel kernel; + + private PortletContext ctx; + + private PortletRequestDispatcher normalView; + + private PortletRequestDispatcher helpView; + + private URL rootURL; + + public void init(PortletConfig portletConfig) throws PortletException { + super.init(portletConfig); + kernel = KernelRegistry.getSingleKernel(); + ctx = portletConfig.getPortletContext(); + normalView = ctx + .getRequestDispatcher("/WEB-INF/view/repository/normal.jsp"); + helpView = ctx + .getRequestDispatcher("/WEB-INF/view/repository/help.jsp"); + + URI uri = null; + + try { + ObjectName reponame = new ObjectName(REPO_OBJ_NAME); + uri = new URI("."); + rootURL = (URL) kernel.invoke(reponame, "getURL", + new Object[] {uri}, new String[] {"java.net.URI"}); + uri = new URI(rootURL.toString()); + rootURL.getFile(); + } catch (Exception e) { + throw new PortletException(e); + } + + if (!uri.getScheme().equals("file")) { + throw new PortletException("unsupported scheme: repositoryURL = " + + rootURL.toString()); + } + } + + public void processAction(ActionRequest actionRequest, + ActionResponse actionResponse) throws PortletException, IOException { + try { + + File rootDir = new File(rootURL.getFile() + File.separatorChar + + "upload" + File.separatorChar + "jars"); + + if (!rootDir.exists()) { + rootDir.mkdirs(); + } + + PortletFileUpload uploader = new PortletFileUpload( + new DiskFileItemFactory(10240, rootDir)); + + File uploadFile = null; + + try { + + List items = uploader.parseRequest(actionRequest); + for (Iterator i = items.iterator(); i.hasNext();) { + FileItem item = (FileItem) i.next(); + if (!item.isFormField()) { + String fieldName = item.getFieldName().trim(); + String name = item.getName().trim(); + File file; + + if (name.length() == 0) { + file = null; + } else { + // Firefox sends basename, IE sends full path + int index = name.lastIndexOf('\\'); + if (index != -1) { + name = name.substring(index + 1); + } + file = new File(rootDir, name); + } + if ("local".equals(fieldName)) { + uploadFile = file; + } + if (file != null) { + try { + item.write(file); + } catch (Exception e) { + throw new PortletException(e); + } + } + } + } + } catch (FileUploadException e) { + throw new PortletException(e); + } + } catch (PortletException e) { + throw e; + } + } + + protected void doView(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + // i think generic portlet already does this + if (WindowState.MINIMIZED.equals(request.getWindowState())) { + return; + } + + try { + File f = new File(new URI(rootURL.toString())); + List ls = listing(f, f.getCanonicalPath()); + Collections.sort(ls); + + request.setAttribute("org.apache.geronimo.console.repo.root", + rootURL.toString()); + request.setAttribute("org.apache.geronimo.console.repo.list", ls); + } catch (Exception e) { + throw new PortletException(e); + } + + normalView.include(request, response); + } + + public void doHelp(RenderRequest request, RenderResponse response) + throws PortletException, IOException { + helpView.include(request, response); + } + + public List listing(File dir, String basepath) throws java.io.IOException { + if (dir == null) { + throw new IllegalArgumentException("directory argument is null"); + } + + if (!dir.isDirectory()) { + throw new IllegalArgumentException("directory argument expected"); + } + + List listing = new ArrayList(); + + List ls = Arrays.asList(dir.listFiles()); + Iterator iter = ls.iterator(); + + while (iter.hasNext()) { + File f = (File) iter.next(); + + if (f.isDirectory()) { + List listing1 = listing(f, basepath); + listing.addAll(listing1); + } else { + listing.add(f.getCanonicalPath().substring( + basepath.length() + 1)); + } + } + return listing; + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/repository/RepositoryViewPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/securitymanager/AbstractSecurityManagerPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/securitymanager/AbstractSecurityManagerPortlet.java?rev=219976&view=auto ============================================================================== --- geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/securitymanager/AbstractSecurityManagerPortlet.java (added) +++ geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/securitymanager/AbstractSecurityManagerPortlet.java Wed Jul 20 18:38:12 2005 @@ -0,0 +1,57 @@ +/** + * + * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.console.securitymanager; + +import java.io.IOException; + +import javax.portlet.GenericPortlet; +import javax.portlet.PortletException; +import javax.portlet.PortletRequestDispatcher; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.WindowState; + +public abstract class AbstractSecurityManagerPortlet extends GenericPortlet { + + protected PortletRequestDispatcher normalView; + + protected PortletRequestDispatcher addNormalView; + + protected PortletRequestDispatcher maximizedView; + + protected PortletRequestDispatcher addMaximizedView; + + protected PortletRequestDispatcher helpView; + + protected PortletRequestDispatcher errorView; + + protected void doEdit(RenderRequest renderRequest, + RenderResponse renderResponse) throws PortletException, IOException { + if (WindowState.NORMAL.equals(renderRequest.getWindowState())) { + addNormalView.include(renderRequest, renderResponse); + } else { + addMaximizedView.include(renderRequest, renderResponse); + } + } + + protected void doHelp(RenderRequest renderRequest, + RenderResponse renderResponse) throws PortletException, IOException { + helpView.include(renderRequest, renderResponse); + } + +} Propchange: geronimo/trunk/sandbox/console-standard/src/java/org/apache/geronimo/console/securitymanager/AbstractSecurityManagerPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native