admin@glassfish.java.net

CODE REVIEW for GlassFish 9.1ur1 IT 3754

From: Jane Young <Jane.Young_at_Sun.COM>
Date: Fri, 26 Oct 2007 15:49:37 -0700

Hi,

Please review by 12:00pm (noon), Monday, Oct 29, 2007.

https://glassfish.dev.java.net/issues/show_bug.cgi?id=3754

The fix is to check if the xml-file is in absolute path. If not, then
check if the file exists on the client side (asadmin) then convert the
relative path to absolute path and send it to the server side.

Here's the diff:

+++ AddResourcesCommand.java Fri Oct 26 15:41:12 2007
@@ -45,8 +45,11 @@
 // jdk imports
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.io.File;
 
-public class AddResourcesCommand extends GenericCommand{
+public class AddResourcesCommand extends GenericCommand
+{
+ private final static String TARGET_OPTION = "target";
 
    
     /**
@@ -56,14 +59,25 @@
     public void runCommand()throws CommandException,
CommandValidationException{
         if (!validateOptions())
             throw new CommandValidationException("Validation failed");
+
+ String sXMLFile = (String) getOperands().get(0);
+ final File fXMLFile = new File(sXMLFile);
        
- String objectName = getObjectName();
- Object[] params = getParamsInfo();
- String operationName = getOperationName();
- String[] types = getTypesInfo();
+ //if file exists on client side and not absolute path then
send the
+ //absolute path to the server side.
+ if (fXMLFile.isFile() && !fXMLFile.isAbsolute()) {
+ sXMLFile = fXMLFile.getAbsolutePath();
+ }
+ Object[] params = new Object[2];
+ params[0] = sXMLFile;
+ params[1] = getOption(TARGET_OPTION);
+
+ final String objectName = getObjectName();
+ final String operationName = getOperationName();
+ final String[] types = getTypesInfo();
                        
- MBeanServerConnection mbsc =
getMBeanServerConnection(getHost(), getPort(),
- getUser(), getPassword());
+ MBeanServerConnection mbsc =
getMBeanServerConnection(getHost(), getPort(),
+
getUser(), getPassword());
         try {
             ArrayList returnValue =(ArrayList) mbsc.invoke(new
ObjectName(objectName),
                                             operationName, params, types);


Thanks!
Jane