Author: dejanb
Date: Tue Sep 30 03:23:22 2008
New Revision: 700405

URL: http://svn.apache.org/viewvc?rev=700405&view=rev
Log:
patch for AMQ-1326 applied (with a few more code improvements)

Added:
    
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java
   (with props)
    
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java
   (with props)
Modified:
    
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java
    
activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml
    activemq/trunk/activemq-web-console/src/main/webapp/js/common.js
    activemq/trunk/activemq-web-console/src/main/webapp/message.jsp

Added: 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java?rev=700405&view=auto
==============================================================================
--- 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java
 (added)
+++ 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java
 Tue Sep 30 03:23:22 2008
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.activemq.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.web.BrokerFacade;
+import org.apache.activemq.web.DestinationFacade;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+/**
+ * Copies a message from one to another queue
+ * 
+ * @author <a href="http://www.nighttale.net";>Dejan Bosanac</a>
+ * @version $Revision$
+ */
+public class CopyMessage extends DestinationFacade implements Controller {
+    private String messageId;
+    private String destination;
+    private static final Log log = LogFactory.getLog(CopyMessage.class);
+
+    public CopyMessage(BrokerFacade brokerFacade) {
+        super(brokerFacade);
+    }
+
+    public ModelAndView handleRequest(HttpServletRequest request, 
HttpServletResponse response) throws Exception {
+        if (messageId != null) {
+            QueueViewMBean queueView = getQueueView();
+            if (queueView != null) {
+               log.info(getJMSDestination() + "(" + messageId + ")" + " copy 
to " + destination);
+                queueView.copyMessageTo(messageId, destination);
+            } else {
+               log.warn("No queue named: " + getPhysicalDestinationName());
+            }
+        }
+        return redirectToBrowseView();
+    }
+
+    public String getMessageId() {
+        return messageId;
+    }
+
+    public void setMessageId(String messageId) {
+        this.messageId = messageId;
+    }
+    
+    
+
+    public String getDestination() {
+               return destination;
+       }
+
+       public void setDestination(String destination) {
+               this.destination = destination;
+       }
+
+}

Propchange: 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CopyMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java?rev=700405&r1=700404&r2=700405&view=diff
==============================================================================
--- 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java
 (original)
+++ 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java
 Tue Sep 30 03:23:22 2008
@@ -22,6 +22,8 @@
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
 
@@ -30,6 +32,7 @@
  */
 public class DeleteMessage extends DestinationFacade implements Controller {
     private String messageId;
+    private static final Log log = LogFactory.getLog(DeleteMessage.class);
 
     public DeleteMessage(BrokerFacade brokerFacade) {
         super(brokerFacade);
@@ -37,12 +40,12 @@
 
     public ModelAndView handleRequest(HttpServletRequest request, 
HttpServletResponse response) throws Exception {
         if (messageId != null) {
-            QueueViewMBean queueView = getQueue();
+            QueueViewMBean queueView = getQueueView();
             if (queueView != null) {
-                System.out.println("#### removing message: " + messageId);
+                log.info("Removing message " + getJMSDestination() + "(" + 
messageId + ")");
                 queueView.removeMessage(messageId);
             } else {
-                System.out.println("#### NO QUEUE!");
+               log.warn("No queue named: " + getPhysicalDestinationName());
             }
         }
         return redirectToBrowseView();
@@ -56,9 +59,4 @@
         this.messageId = messageId;
     }
 
-    protected QueueViewMBean getQueue() throws Exception {
-        String name = getPhysicalDestinationName();
-        System.out.println("####ĂŠlooking up queue: " + name);
-        return getBrokerFacade().getQueue(name);
-    }
 }

Added: 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java?rev=700405&view=auto
==============================================================================
--- 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java
 (added)
+++ 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java
 Tue Sep 30 03:23:22 2008
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.activemq.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.web.BrokerFacade;
+import org.apache.activemq.web.DestinationFacade;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.Controller;
+
+/**
+ * Moves a message from one to another queue
+ * 
+ * @author <a href="http://www.nighttale.net";>Dejan Bosanac</a>
+ * @version $Revision$
+ */
+public class MoveMessage extends DestinationFacade implements Controller {
+    private String messageId;
+    private String destination;
+    private static final Log log = LogFactory.getLog(MoveMessage.class);
+
+    public MoveMessage(BrokerFacade brokerFacade) {
+        super(brokerFacade);
+    }
+
+    public ModelAndView handleRequest(HttpServletRequest request, 
HttpServletResponse response) throws Exception {
+        if (messageId != null) {
+            QueueViewMBean queueView = getQueueView();
+            if (queueView != null) {
+               log.info("Moving message " + getJMSDestination() + "(" + 
messageId + ")" + " to " + destination);
+                queueView.moveMessageTo(messageId, destination);
+            } else {
+               log.warn("No queue named: " + getPhysicalDestinationName());
+            }
+        }
+        return redirectToBrowseView();
+    }
+
+    public String getMessageId() {
+        return messageId;
+    }
+
+    public void setMessageId(String messageId) {
+        this.messageId = messageId;
+    }
+    
+    
+
+    public String getDestination() {
+               return destination;
+       }
+
+       public void setDestination(String destination) {
+               this.destination = destination;
+       }
+
+}

Propchange: 
activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/MoveMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=700405&r1=700404&r2=700405&view=diff
==============================================================================
--- 
activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml
 (original)
+++ 
activemq/trunk/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml
 Tue Sep 30 03:23:22 2008
@@ -33,6 +33,8 @@
   <bean name="/sendMessage.action" 
class="org.apache.activemq.web.controller.SendMessage" autowire="constructor"  
singleton="false"/>
   <bean name="/purgeDestination.action" 
class="org.apache.activemq.web.controller.PurgeDestination" 
autowire="constructor"  singleton="false"/>
   <bean name="/deleteMessage.action" 
class="org.apache.activemq.web.controller.DeleteMessage" autowire="constructor" 
 singleton="false"/>
+  <bean name="/copyMessage.action" 
class="org.apache.activemq.web.controller.CopyMessage" autowire="constructor"  
singleton="false"/>  
+  <bean name="/moveMessage.action" 
class="org.apache.activemq.web.controller.MoveMessage" autowire="constructor"  
singleton="false"/>
 
   <!--
     - This bean resolves specific types of exception to corresponding error 
views.

Modified: activemq/trunk/activemq-web-console/src/main/webapp/js/common.js
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/js/common.js?rev=700405&r1=700404&r2=700405&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/webapp/js/common.js (original)
+++ activemq/trunk/activemq-web-console/src/main/webapp/js/common.js Tue Sep 30 
03:23:22 2008
@@ -106,3 +106,16 @@
        return targ;
 }
 
+function confirmAction(id, url) {
+       //TODO i18n messages
+       var select = document.getElementById(id);
+       var selectedIndex = select.selectedIndex; 
+       if (select.selectedIndex == 0) {
+               alert("Please select a value");
+               return;
+       }
+       var value = select.options[selectedIndex].value;
+       url = url.replace(/%target%/gi, value);
+       if (confirm("Are you sure?"))
+         location.href=url;
+}
\ No newline at end of file

Modified: activemq/trunk/activemq-web-console/src/main/webapp/message.jsp
URL: 
http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/webapp/message.jsp?rev=700405&r1=700404&r2=700405&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/webapp/message.jsp (original)
+++ activemq/trunk/activemq-web-console/src/main/webapp/message.jsp Tue Sep 30 
03:23:22 2008
@@ -136,6 +136,41 @@
                        </table>
                </td>
        </tr>
+       <tr>
+               <td class="layout" colspan="2">
+                       <table id="body" width="100%">
+                               <thead>
+                                       <tr>
+                                               <th colspan="2">
+                                                   Message Actions
+                                               </th>
+                                       </tr>
+                               </thead>
+                               <tbody>
+                                       <tr>
+                                               <td colspan="2"><a 
href="deleteMessage.action?JMSDestination=${row.JMSDestination}&messageId=${row.JMSMessageID}">Delete</a></td>
+                                       </tr>
+                                       <tr class="odd">
+                                       <td><a 
href="javascript:confirmAction('queue', 
'copyMessage.action?destination=%target%&JMSDestination=${row.JMSDestination}&messageId=${row.JMSMessageID}&JMSDestinationType=queue')">Copy</a></td>
+                                               <td rowspan="2">
+                                                       <select id="queue">
+                                                               <option 
value=""> -- Please select --</option>
+                                                       <c:forEach 
items="${requestContext.brokerQuery.queues}" var="queues">
+                                                               <c:if 
test="${queues.name != requestContext.messageQuery.JMSDestination}">
+                                                               <option 
value="${queues.name}">${queues.name}</option>
+                                                               </c:if>
+                                                       </c:forEach>
+                                                   </select>
+                                               </td>
+                                               
+                                       </tr>
+                                       <tr class="odd">
+                                               <td><a 
href="javascript:confirmAction('queue', 
'moveMessage.action?destination=%target%&JMSDestination=${row.JMSDestination}&messageId=${row.JMSMessageID}&JMSDestinationType=queue')">Move</a></td>
+                                       </tr>
+                               </tbody>
+                       </table>
+               </td>
+       </tr>   
 </table>
 
 


Reply via email to