Skip to main content

[glassfish~svn:62358] Fix GLASSFISH-19039: asadmin delete-jms-resource should not delete non-jm

  • From: liang.x.zhao@...
  • To: commits@...
  • Subject: [glassfish~svn:62358] Fix GLASSFISH-19039: asadmin delete-jms-resource should not delete non-jm
  • Date: Wed, 17 Jul 2013 02:37:51 +0000

Project:    glassfish
Repository: svn
Revision:   62358
Author:     liang.x.zhao
Date:       2013-07-17 02:37:48 UTC
Link:       

Log Message:
------------
Fix GLASSFISH-19039: asadmin delete-jms-resource should not delete non-jms 
resources.


Revisions:
----------
62358


Modified Paths:
---------------
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/LocalStrings.properties
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/DeleteJMSResource.java


Diffs:
------
Index: 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/LocalStrings.properties
===================================================================
--- 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/LocalStrings.properties
    (revision 62357)
+++ 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/LocalStrings.properties
    (revision 62358)
@@ -76,6 +76,7 @@
 delete.jms.resource.cannotDeleteJMSAdminObject=Unable to delete Admin Object.
 delete.jms.resource.cannotDeleteJMSResource=Unable to delete Connector 
Resource.
 delete.jms.resource.cannotDeleteJMSPool=Unable to delete Connector 
Connection Pool
+jms.resources.not.found=JMS Resource {0} not found
 
 #list-jms-hosts
 list.jms.host.noTarget=No Target specified for JMS Host.
Index: 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/DeleteJMSResource.java
===================================================================
--- 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/DeleteJMSResource.java
     (revision 62357)
+++ 
trunk/main/appserver/jms/admin/src/main/java/org/glassfish/jms/admin/cli/DeleteJMSResource.java
     (revision 62358)
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -45,6 +45,9 @@
 import com.sun.enterprise.config.serverbeans.Resources;
 import com.sun.enterprise.util.LocalStringManagerImpl;
 import com.sun.enterprise.util.SystemPropertyConstants;
+import java.util.List;
+import java.util.Properties;
+import java.util.Map;
 import javax.inject.Inject;
 import org.glassfish.api.ActionReport;
 import org.glassfish.api.I18n;
@@ -54,6 +57,7 @@
 import org.glassfish.config.support.TargetType;
 import org.glassfish.connectors.config.ConnectorResource;
 import org.glassfish.hk2.api.PerLookup;
+import org.glassfish.hk2.api.ServiceLocator;
 import org.jvnet.hk2.annotations.Service;
 
 /**
@@ -82,6 +86,9 @@
     CommandRunner commandRunner;
     @Inject
     Domain domain;
+    @Inject
+    ServiceLocator habitat;
+
     private static final String JNDINAME_APPENDER = "-Connection-Pool";
     /* As per new requirement all resources should have unique name so 
appending 'JNDINAME_APPENDER' to jndiName
      for creating  jndiNameForConnectionPool.
@@ -132,6 +139,40 @@
                 return;
             }
         } else {
+            ActionReport listReport = habitat.getService(ActionReport.class);
+            ParameterMap listParams = new ParameterMap();
+            //listParams.set("resType", "javax.jms.ConnectionFactory");
+            listParams.set("target", target);
+            commandRunner.getCommandInvocation("list-jms-resources", 
listReport, context.getSubject()).parameters(listParams).execute();
+            if 
(ActionReport.ExitCode.FAILURE.equals(listReport.getActionExitCode())) {
+                
report.setMessage(localStrings.getLocalString("list.jms.resources.fail",
+                        "Unable to list JMS Resources"));
+                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
+                return;
+            }
+            Properties extraProps = listReport.getExtraProperties();
+            if (extraProps != null && extraProps.size() > 0) {
+                boolean resourceExist = false;
+                for (int i=0; i<extraProps.size(); i++) {
+                    List<Map<String, String>> nameList = (List) 
extraProps.get("jmsResources");
+                    for (Map<String,String> m : nameList) {
+                        String jndi = (String) m.get("name");
+                        if (jndiName.equals(jndi)) {
+                            resourceExist = true;
+                            break;
+                        }
+                    }
+                    if (resourceExist)
+                        break;
+                }
+                if (!resourceExist) {
+                    
report.setMessage(localStrings.getLocalString("jms.resources.not.found",
+                        "JMS Resource {0} not found", jndiName));
+                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
+                    return;
+                }
+            }
+
             // Delete the connector resource and connector connection pool
             String defPoolName = jndiNameForConnectionPool;
             String poolName = cresource.getPoolName();





[glassfish~svn:62358] Fix GLASSFISH-19039: asadmin delete-jms-resource should not delete non-jm

liang . x . zhao 07/17/2013
 
 
Close
loading
Please Confirm
Close