[rhq] Branch 'gwt' - etc/eclipse-tools
by mazz
etc/eclipse-tools/maven/RHQ | 4 ----
1 file changed, 4 deletions(-)
New commits:
commit 728d659e07e02f5603c7fb349e708db9ff137222
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 14:56:20 2010 -0400
eclipse tool to clean test db
diff --git a/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch b/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
index 5309e62..84ca310 100644
--- a/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
+++ b/etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
@@ -6,10 +6,6 @@
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${env_var:M2_HOME}/bin/${MAVEN_EXE}"/>
-<<<<<<< HEAD:etc/eclipse-tools/maven/RHQ Maven Build - DBSetup.launch
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup install"/>
-=======
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-o -Dmaven.test.skip=true -Ddbsetup -Ddb=test install"/>
->>>>>>> master:etc/eclipse-tools/maven/RHQ Maven Build - DBSetup (TEST DB).launch
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/rhq/modules/core/dbutils}"/>
</launchConfiguration>
14 years
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 8cc631d6648b6287a209378f860c34d6cd7064d9
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:45:24 2010 -0400
no need to keep walking the zip file when we found the recipe file we wanted
diff --git a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
index 4c155bf..c0f1b40 100644
--- a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
@@ -175,6 +175,7 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
} catch (Throwable t) {
this.results = null;
}
+ return false; // whether we parsed it or not, we found the file we are looking for so stop walking
}
return true;
}
14 years
[rhq] Branch 'gwt' - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 7d8a48b04837b1dd13ec13c58102f9420b3df9f1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:39:13 2010 -0400
don't assume all plugins will only throw illegal-arg-exception on bad recipe/distro file. catch all exceptions and assume we need to keep going asking other plugins
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
index 9ca73ae..0122720 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
@@ -155,7 +155,7 @@ public class BundleServerPluginManager extends ServerPluginManager {
info = facet.processBundleDistributionFile(distributionFile);
info.setBundleTypeName(descriptor.getBundle().getType());
break;
- } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
info = null;
}
} finally {
14 years
[rhq] Branch 'gwt' - .classpath
by mazz
.classpath | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 6ab91d7e695b3f66db6f72a461aed8f64abafa70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:34:59 2010 -0400
add ant-nodeps to eclipse
diff --git a/.classpath b/.classpath
index fc26ab4..9804072 100644
--- a/.classpath
+++ b/.classpath
@@ -164,6 +164,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/rss4j/rss4j/0.92-on.2/rss4j-0.92-on.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant/1.8.0/ant-1.8.0.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant-nodeps/1.8.0/ant-nodeps-1.8.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/struts/struts/1.2.9/struts-1.2.9.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/servlet/jsp-api/2.0/jsp-api-2.0.jar"/>
14 years
[rhq] Branch 'gwt' - 4 commits - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 10
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 124 ++++++++++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java | 12
modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java | 19 -
4 files changed, 155 insertions(+), 10 deletions(-)
New commits:
commit 87d870e8a980925c43fb6bf4124ae4ad4838fdf6
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:30:20 2010 -0400
unit test coding is done - need to make sure it actually works. this is a wip
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 5c90ded..0889a80 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -24,8 +24,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -279,58 +281,75 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
}
@Test(enabled = TESTS_ENABLED)
- public void testCreateBundleFromDistribution() throws Exception {
+ public void testCreateBundleVersionFromDistributionFile() throws Exception {
File tmpDir = FileUtil.createTempDirectory("createBundleFromDistro", ".dir", null);
-
- String bundleFile1 = "subdir1/bundle-file-1.txt";
- String bundleFile2 = "subdir2/bundle-file-2.txt";
- String bundleFile3 = "bundle-file-3.txt";
- writeFile(new File(tmpDir, bundleFile1), "first bundle file found inside bundle distro");
- writeFile(new File(tmpDir, bundleFile2), "second bundle file found inside bundle distro");
- writeFile(new File(tmpDir, bundleFile3), "third bundle file found inside bundle distro");
-
- String bundleName = "test-bundle-name";
- String bundleVersion = "1.2.3";
- String bundleDescription = "test bundle desc";
- DeploymentProperties bundleMetadata = new DeploymentProperties(0, bundleName, bundleVersion, bundleDescription);
-
- ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
- String propName = "prop1";
- String propDescription = "prop1desc";
- configDef.put(new PropertyDefinitionSimple(propName, propDescription, true, PropertySimpleType.INTEGER));
-
- Set<String> bundleFileNames = new HashSet<String>(3);
- bundleFileNames.add(bundleFile1);
- bundleFileNames.add(bundleFile2);
- bundleFileNames.add(bundleFile3);
-
- File bundleDistroFile = tmpDir; // not a real distro zip, but its just a simulation anyway - SLSB will pass this to our mock PC
- String recipe = "mock recipe";
- BundleType bt1 = createBundleType("one");
-
- ps.parseRecipe_returnValue = new RecipeParseResults(bundleMetadata, configDef, bundleFileNames);
- ps.processBundleDistributionFile_returnValue = new BundleDistributionInfo();
-
- BundleVersion bv;
- bv = bundleManager.createBundleVersionViaUberBundleFileURL(overlord, bundleDistroFile.toURI().toURL());
-
- assert bv.getId() > 0 : bv;
- assert bv.getBundle().getName().equals(bundleName) : bv;
- assert bv.getBundle().getDescription().equals(bundleDescription) : bv;
- assert bv.getDescription().equals(bundleDescription) : "the bundle version desc should be the same as the bundle desc";
- assert bv.getVersion().equals(bundleVersion) : bv;
- assert bv.getBundleFiles().size() == 3 : bv;
- assert bv.getBundleFiles().contains(bundleFile1) : bv;
- assert bv.getBundleFiles().contains(bundleFile2) : bv;
- assert bv.getBundleFiles().contains(bundleFile3) : bv;
- assert bv.getBundleDeployments().isEmpty() : bv;
- assert bv.getConfigurationDefinition().getPropertyDefinitions().size() == 1;
- assert bv.getConfigurationDefinition().get(propName) != null;
- assert bv.getConfigurationDefinition().get(propName).getDescription().equals(propDescription);
- assert bv.getConfigurationDefinition().get(propName).isRequired();
- assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName).getType() == PropertySimpleType.INTEGER;
- assert bv.getRecipe().equals(recipe);
+ try {
+ String bundleFile1 = "subdir1/bundle-file-1.txt";
+ String bundleFile2 = "subdir2/bundle-file-2.txt";
+ String bundleFile3 = "bundle-file-3.txt";
+ writeFile(new File(tmpDir, bundleFile1), "first bundle file found inside bundle distro");
+ writeFile(new File(tmpDir, bundleFile2), "second bundle file found inside bundle distro");
+ writeFile(new File(tmpDir, bundleFile3), "third bundle file found inside bundle distro");
+
+ String bundleName = "test-bundle-name";
+ String bundleVersion = "1.2.3";
+ String bundleDescription = "test bundle desc";
+ DeploymentProperties bundleMetadata = new DeploymentProperties(0, bundleName, bundleVersion,
+ bundleDescription);
+
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+ String propName = "prop1";
+ String propDescription = "prop1desc";
+ configDef.put(new PropertyDefinitionSimple(propName, propDescription, true, PropertySimpleType.INTEGER));
+
+ Map<String, File> bundleFiles = new HashMap<String, File>(3);
+ bundleFiles.put(bundleFile1, new File(tmpDir, bundleFile1));
+ bundleFiles.put(bundleFile2, new File(tmpDir, bundleFile2));
+ bundleFiles.put(bundleFile3, new File(tmpDir, bundleFile3));
+
+ File bundleDistroFile = tmpDir; // not a real distro zip, but its just a simulation anyway - SLSB will pass this to our mock PC
+ String recipe = "mock recipe";
+ BundleType bt1 = createBundleType("one");
+
+ // prepare our mock bundle PC
+ ps.parseRecipe_returnValue = new RecipeParseResults(bundleMetadata, configDef, new HashSet<String>(
+ bundleFiles.keySet()));
+ ps.processBundleDistributionFile_returnValue = new BundleDistributionInfo(recipe,
+ ps.parseRecipe_returnValue, bundleFiles);
+ ps.processBundleDistributionFile_returnValue.setBundleTypeName(bt1.getName());
+
+ // now ask the SLSB to persist our bundle data given our mock distribution
+ BundleVersion bv1 = bundleManager.createBundleVersionViaURL(overlord, bundleDistroFile.toURI().toURL());
+
+ // to a db lookup to make sure our bundle version is queryable
+ BundleVersionCriteria criteria = new BundleVersionCriteria();
+ criteria.addFilterId(bv1.getId());
+ BundleVersion bv2 = bundleManager.findBundleVersionsByCriteria(overlord, criteria).get(0);
+
+ // test that the PC's return value and our own DB lookup match the bundle version we expect to be in the DB
+ BundleVersion[] bvs = new BundleVersion[] { bv1, bv2 };
+ for (BundleVersion bv : bvs) {
+ assert bv.getId() > 0 : bv;
+ assert bv.getBundle().getName().equals(bundleName) : bv;
+ assert bv.getBundle().getDescription().equals(bundleDescription) : bv;
+ assert bv.getDescription().equals(bundleDescription) : "the bundle version desc should be the same as the bundle desc";
+ assert bv.getVersion().equals(bundleVersion) : bv;
+ assert bv.getBundleFiles().size() == 3 : bv;
+ assert bv.getBundleFiles().contains(bundleFile1) : bv;
+ assert bv.getBundleFiles().contains(bundleFile2) : bv;
+ assert bv.getBundleFiles().contains(bundleFile3) : bv;
+ assert bv.getBundleDeployments().isEmpty() : bv;
+ assert bv.getConfigurationDefinition().getPropertyDefinitions().size() == 1;
+ assert bv.getConfigurationDefinition().get(propName) != null;
+ assert bv.getConfigurationDefinition().get(propName).getDescription().equals(propDescription);
+ assert bv.getConfigurationDefinition().get(propName).isRequired();
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName).getType() == PropertySimpleType.INTEGER;
+ assert bv.getRecipe().equals(recipe);
+ }
+ } finally {
+ FileUtil.purge(tmpDir, true);
+ }
}
@Test(enabled = TESTS_ENABLED)
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
index 871c812..42a88f9 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
@@ -62,6 +62,9 @@ public class TestBundleServerPluginService extends ServerPluginService implement
public TestBundleServerPluginContainer bundlePC;
public MasterServerPluginContainerConfiguration masterConfig;
+ public RecipeParseResults parseRecipe_returnValue = null;
+ public BundleDistributionInfo processBundleDistributionFile_returnValue;
+
public TestBundleServerPluginService() {
// build the config at constructor time so tests have it even before the PC is initialized
File dir = new File(System.getProperty("java.io.tmpdir"), "test-server-plugins");
@@ -200,6 +203,10 @@ public class TestBundleServerPluginService extends ServerPluginService implement
public RecipeParseResults parseRecipe(String recipe) throws Exception {
+ if (parseRecipe_returnValue != null) {
+ return parseRecipe_returnValue;
+ }
+
ConfigurationDefinition configDef;
Set<String> bundleFileNames;
DeploymentProperties metadata;
@@ -218,7 +225,10 @@ public class TestBundleServerPluginService extends ServerPluginService implement
}
public BundleDistributionInfo processBundleDistributionFile(File uberBundleFile) throws Exception {
- // TODO: bundle implement me
+ if (processBundleDistributionFile_returnValue != null) {
+ return processBundleDistributionFile_returnValue;
+ }
+
throw new UnsupportedOperationException("this mock object cannot do this");
}
}
commit 52b5b0f077e70a78e6793a322372fcb926700820
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:29:47 2010 -0400
couple fixes
1) don't close ZipInputStream, the walker util will handle that
2) make sure to create subdirectories when extracting visited zip entries
3) no need to put timestamp in temp directory - the utility will ensure uniqueness
diff --git a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
index b68a20f..4c155bf 100644
--- a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.plugins.ant;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -163,15 +164,16 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
}
public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
- if (recipeName.equalsIgnoreCase(entry.getName())) {
+ if (this.recipeName.equalsIgnoreCase(entry.getName())) {
// this should be safe downcast, recipes are not that big
- byte[] recipeBytes = new byte[(int) entry.getSize()];
- recipeBytes = StreamUtil.slurp(stream);
- this.recipe = new String(recipeBytes);
+ ByteArrayOutputStream out = new ByteArrayOutputStream((int) entry.getSize());
+ StreamUtil.copy(stream, out, false);
+ this.recipe = new String(out.toByteArray());
+ out = null; // no need for this anymore, help out GC
try {
- this.results = facet.parseRecipe(this.recipe);
+ this.results = this.facet.parseRecipe(this.recipe);
} catch (Throwable t) {
- results = null;
+ this.results = null;
}
}
return true;
@@ -194,14 +196,15 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
public BundleFileVisitor(String bundleName, Set<String> bundleFileNames) throws IOException {
this.bundleFileNames = bundleFileNames;
this.bundleFiles = new HashMap<String, File>(bundleFileNames.size());
- tmpDir = FileUtil.createTempDirectory("bundle-" + bundleName, String.valueOf(System.currentTimeMillis()),
- null);
+ this.tmpDir = FileUtil.createTempDirectory("bundle-" + bundleName, ".dir", null);
}
public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
if (bundleFileNames.contains(entry.getName())) {
File bundleFile = new File(tmpDir, entry.getName());
+ bundleFile.getParentFile().mkdirs();
+
FileOutputStream fos = null;
try {
fos = new FileOutputStream(bundleFile);
commit 5fbc5da51e31c1465bb8a844b1682ce1b452be51
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 13:27:41 2010 -0400
make sure streams are always closed, even in error conditions
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index b2eaaf0..46ea98c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -342,11 +342,13 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
BundleVersion bundleVersion = null;
try {
- tempDistributionFile = File.createTempFile("bundle-" + distributionFileUrl.hashCode(), "zip");
+ tempDistributionFile = File.createTempFile("bundle-" + distributionFileUrl.hashCode(), ".zip");
is = distributionFileUrl.openStream();
os = new FileOutputStream(tempDistributionFile);
long len = StreamUtil.copy(is, os);
+ is = null;
+ os = null;
log.debug("Copied [" + len + "] bytes from [" + distributionFileUrl + "] into ["
+ tempDistributionFile.getPath() + "]");
@@ -355,6 +357,12 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
if (null != tempDistributionFile) {
tempDistributionFile.delete();
}
+ if (is != null) {
+ is.close();
+ }
+ if (os != null) {
+ os.close();
+ }
}
return bundleVersion;
commit f886b37162a69e01d3a3b95f9a7ff5b9e7511e0b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Apr 29 12:41:03 2010 -0400
start of test
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 78559df..5c90ded 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -19,9 +19,16 @@
package org.rhq.enterprise.server.bundle;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
import javax.persistence.EntityManager;
import javax.persistence.Query;
@@ -47,6 +54,9 @@ import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.bundle.composite.BundleWithLatestVersionComposite;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.content.Architecture;
import org.rhq.core.domain.content.Package;
import org.rhq.core.domain.content.PackageType;
@@ -64,6 +74,9 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
+import org.rhq.core.util.updater.DeploymentProperties;
import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.resource.metadata.test.UpdateSubsytemTestBase;
@@ -266,6 +279,61 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
}
@Test(enabled = TESTS_ENABLED)
+ public void testCreateBundleFromDistribution() throws Exception {
+
+ File tmpDir = FileUtil.createTempDirectory("createBundleFromDistro", ".dir", null);
+
+ String bundleFile1 = "subdir1/bundle-file-1.txt";
+ String bundleFile2 = "subdir2/bundle-file-2.txt";
+ String bundleFile3 = "bundle-file-3.txt";
+ writeFile(new File(tmpDir, bundleFile1), "first bundle file found inside bundle distro");
+ writeFile(new File(tmpDir, bundleFile2), "second bundle file found inside bundle distro");
+ writeFile(new File(tmpDir, bundleFile3), "third bundle file found inside bundle distro");
+
+ String bundleName = "test-bundle-name";
+ String bundleVersion = "1.2.3";
+ String bundleDescription = "test bundle desc";
+ DeploymentProperties bundleMetadata = new DeploymentProperties(0, bundleName, bundleVersion, bundleDescription);
+
+ ConfigurationDefinition configDef = new ConfigurationDefinition("foo", null);
+ String propName = "prop1";
+ String propDescription = "prop1desc";
+ configDef.put(new PropertyDefinitionSimple(propName, propDescription, true, PropertySimpleType.INTEGER));
+
+ Set<String> bundleFileNames = new HashSet<String>(3);
+ bundleFileNames.add(bundleFile1);
+ bundleFileNames.add(bundleFile2);
+ bundleFileNames.add(bundleFile3);
+
+ File bundleDistroFile = tmpDir; // not a real distro zip, but its just a simulation anyway - SLSB will pass this to our mock PC
+ String recipe = "mock recipe";
+ BundleType bt1 = createBundleType("one");
+
+ ps.parseRecipe_returnValue = new RecipeParseResults(bundleMetadata, configDef, bundleFileNames);
+ ps.processBundleDistributionFile_returnValue = new BundleDistributionInfo();
+
+ BundleVersion bv;
+ bv = bundleManager.createBundleVersionViaUberBundleFileURL(overlord, bundleDistroFile.toURI().toURL());
+
+ assert bv.getId() > 0 : bv;
+ assert bv.getBundle().getName().equals(bundleName) : bv;
+ assert bv.getBundle().getDescription().equals(bundleDescription) : bv;
+ assert bv.getDescription().equals(bundleDescription) : "the bundle version desc should be the same as the bundle desc";
+ assert bv.getVersion().equals(bundleVersion) : bv;
+ assert bv.getBundleFiles().size() == 3 : bv;
+ assert bv.getBundleFiles().contains(bundleFile1) : bv;
+ assert bv.getBundleFiles().contains(bundleFile2) : bv;
+ assert bv.getBundleFiles().contains(bundleFile3) : bv;
+ assert bv.getBundleDeployments().isEmpty() : bv;
+ assert bv.getConfigurationDefinition().getPropertyDefinitions().size() == 1;
+ assert bv.getConfigurationDefinition().get(propName) != null;
+ assert bv.getConfigurationDefinition().get(propName).getDescription().equals(propDescription);
+ assert bv.getConfigurationDefinition().get(propName).isRequired();
+ assert bv.getConfigurationDefinition().getPropertyDefinitionSimple(propName).getType() == PropertySimpleType.INTEGER;
+ assert bv.getRecipe().equals(recipe);
+ }
+
+ @Test(enabled = TESTS_ENABLED)
public void testGetBundleTypes() throws Exception {
BundleType bt1 = createBundleType("one");
BundleType bt2 = createBundleType("two");
@@ -889,4 +957,41 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
return resourceGroup;
}
+
+ private String readFile(File file) throws Exception {
+ return new String(StreamUtil.slurp(new FileInputStream(file)));
+ }
+
+ private void writeFile(File file, String content) throws Exception {
+ file.getParentFile().mkdirs();
+ StreamUtil.copy(new ByteArrayInputStream(content.getBytes()), new FileOutputStream(file));
+ }
+
+ private File createZip(File destDir, String zipName, String[] entryNames, String[] contents) throws Exception {
+ FileOutputStream stream = null;
+ ZipOutputStream out = null;
+
+ try {
+ destDir.mkdirs();
+ File zipFile = new File(destDir, zipName);
+ stream = new FileOutputStream(zipFile);
+ out = new ZipOutputStream(stream);
+
+ assert contents.length == entryNames.length;
+ for (int i = 0; i < contents.length; i++) {
+ ZipEntry zipAdd = new ZipEntry(entryNames[i]);
+ zipAdd.setTime(System.currentTimeMillis());
+ out.putNextEntry(zipAdd);
+ out.write(contents[i].getBytes());
+ }
+ return zipFile;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
}
14 years
[rhq] Branch 'gwt' - 3 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java | 76 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/UberBundleFileUploadServlet.java | 77 ------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleDistributionInfo.java | 80 ++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 128 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 43 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/UberBundleFileInfo.java | 84 ------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java | 14 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java | 55 +++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java | 20 +
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java | 30 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java | 2
modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java | 118 ++++++++-
modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java | 4
15 files changed, 512 insertions(+), 223 deletions(-)
New commits:
commit 77f452bdb05782fe0be91384cb75888a0684523e
Merge: e9946ba... 2a9da73...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 29 12:33:50 2010 -0400
Merge branch 'gwt' into gwt-jay
commit e9946babe0658a14bf856e2ead582cd7880c8425
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 29 12:33:10 2010 -0400
first pass at supporting distribution file based bundle version creation.
not yet tested...
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index 9b3f606..a5f918b 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -261,7 +261,7 @@ public class BundleVersion implements Serializable {
@Override
public String toString() {
- return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle + "]";
+ return "BundleVersion[id=" + id + ",name=" + name + ",version=" + version + ",bundle=" + bundle.getName() + "]";
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java
new file mode 100644
index 0000000..e14ce9c
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleDistributionFileUploadServlet.java
@@ -0,0 +1,76 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.server.gwt;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.bundle.BundleVersion;
+import org.rhq.enterprise.server.bundle.BundleManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * Accepts a "bundle distribution file" - which is simply a zip file that contains within it
+ * a bundle recipe and additional bundle files.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleDistributionFileUploadServlet extends FileUploadServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void processUploadedFiles(Subject subject, Map<String, File> files, Map<String, String> formFields,
+ HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ String successMsg;
+
+ try {
+ // note that this assumes 1 and only 1 file is uploaded
+ File file = files.values().iterator().next();
+
+ BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
+ BundleVersion bundleVersion = bundleManager.createBundleVersionViaURL(subject, file.toURI().toURL());
+ successMsg = "success [" + bundleVersion.getId() + "]";
+ } catch (Exception e) {
+ writeExceptionResponse(response, "Failed to upload bundle distribution file", e); // clients will look for this string!
+ return;
+ }
+
+ PrintWriter writer = response.getWriter();
+ writer.println("<html>");
+ writer.println(successMsg);
+ writer.println("</html>");
+ writer.flush();
+ return;
+ }
+
+ private String getFormField(Map<String, String> formFields, String key, String defaultValue) {
+ String value = formFields.get(key);
+ if (value == null) {
+ value = defaultValue;
+ }
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
index 2b14ef5..c76dd44 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/BundleGWTServiceImpl.java
@@ -127,7 +127,7 @@ public class BundleGWTServiceImpl extends AbstractGWTServiceImpl implements Bund
BundleCriteria criteria) throws Exception {
try {
PageList<BundleWithLatestVersionComposite> results;
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(getSessionSubject(), criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(getSessionSubject(), criteria);
return SerialUtility.prepare(results, "findBundlesWithLastestVersionCompositesByCriteria");
} catch (Exception e) {
throw new RuntimeException(ThrowableUtil.getAllMessages(e));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/UberBundleFileUploadServlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/UberBundleFileUploadServlet.java
deleted file mode 100644
index 9033dc8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/UberBundleFileUploadServlet.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.server.gwt;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.bundle.BundleVersion;
-import org.rhq.enterprise.server.bundle.BundleManagerLocal;
-import org.rhq.enterprise.server.util.LookupUtil;
-
-/**
- * Accepts a "uber bundle file" - which is simply a zip file that contains within it
- * a bundle recipe and additional bundle files.
- *
- * @author John Mazzitelli
- */
-public class UberBundleFileUploadServlet extends FileUploadServlet {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void processUploadedFiles(Subject subject, Map<String, File> files, Map<String, String> formFields,
- HttpServletRequest request, HttpServletResponse response) throws IOException {
-
- String successMsg;
-
- try {
- // note that this assumes 1 and only 1 file is uploaded
- File file = files.values().iterator().next();
-
- BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
- BundleVersion bundleVersion = bundleManager.createBundleVersionViaUberBundleFileURL(subject, file.toURI()
- .toURL());
- successMsg = "success [" + bundleVersion.getId() + "]";
- } catch (Exception e) {
- writeExceptionResponse(response, "Failed to upload uber bundle file", e); // clients will look for this string!
- return;
- }
-
- PrintWriter writer = response.getWriter();
- writer.println("<html>");
- writer.println(successMsg);
- writer.println("</html>");
- writer.flush();
- return;
- }
-
- private String getFormField(Map<String, String> formFields, String key, String defaultValue) {
- String value = formFields.get(key);
- if (value == null) {
- value = defaultValue;
- }
- return value;
- }
-}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleDistributionInfo.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleDistributionInfo.java
new file mode 100644
index 0000000..6f7eccd
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleDistributionInfo.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.server.bundle;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ * Information found when a Bundle Distribution file is cracked open and inspected.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleDistributionInfo {
+ private final String recipe;
+ private final RecipeParseResults recipeParseResults;
+ private final Map<String, File> bundleFiles;
+ private String bundleTypeName;
+
+ public BundleDistributionInfo(String recipe, RecipeParseResults recipeParseResults, Map<String, File> bundleFiles) {
+
+ this.recipe = recipe;
+ this.recipeParseResults = recipeParseResults;
+ this.bundleFiles = bundleFiles;
+ this.bundleTypeName = null; // typically set later
+ }
+
+ /**
+ * The information gleened from the recipe that was found in the bundle distribution file.
+ *
+ * @return the recipe information
+ */
+ public RecipeParseResults getRecipeParseResults() {
+ return recipeParseResults;
+ }
+
+ /**
+ * If the bundle distribution file contained within it one or more bundle files that need
+ * to be associated with the bundle version, this map will contain those files.
+ * The key to the map is the name of the bundle file as referenced to it via
+ * the recipe (i.e. the keys will be filenames that are mentioned in the
+ * {@link #getRecipeParseResults() parse results}). The values are files referencing
+ * the bundle files' content - it is the job of the server side plugin to extract
+ * the bundle files from the bundle distribution file and store them on the local file
+ * system.
+ *
+ * @return names and file locations of all bundle files found in the bundle distribution file
+ */
+ public Map<String, File> getBundleFiles() {
+ return bundleFiles;
+ }
+
+ public String getBundleTypeName() {
+ return bundleTypeName;
+ }
+
+ public String getRecipe() {
+ return recipe;
+ }
+
+ public void setBundleTypeName(String bundleTypeName) {
+ this.bundleTypeName = bundleTypeName;
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index dbb2094..b2eaaf0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -19,11 +19,16 @@
package org.rhq.enterprise.server.bundle;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.ejb.EJB;
@@ -73,6 +78,7 @@ import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.NumberUtil;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.authz.AuthorizationManagerLocal;
@@ -81,6 +87,7 @@ import org.rhq.enterprise.server.authz.RequiredPermission;
import org.rhq.enterprise.server.content.ContentManagerLocal;
import org.rhq.enterprise.server.content.RepoManagerLocal;
import org.rhq.enterprise.server.core.AgentManagerLocal;
+import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginManager;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
import org.rhq.enterprise.server.util.HibernateDetachUtility;
@@ -316,9 +323,90 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return bundleVersion;
}
- public BundleVersion createBundleVersionViaUberBundleFileURL(Subject subject, URL uberBundleFile) throws Exception {
- // TODO: bundle implement me
- return null;
+ public BundleVersion createBundleVersionViaFile(Subject subject, File distributionFile) throws Exception {
+
+ BundleServerPluginManager manager = BundleManagerHelper.getPluginContainer().getBundleServerPluginManager();
+ BundleDistributionInfo info = manager.processBundleDistributionFile(distributionFile);
+ BundleVersion bundleVersion = createBundleVersionViaDistributionInfo(subject, info);
+
+ return bundleVersion;
+ }
+
+ public BundleVersion createBundleVersionViaURL(Subject subject, URL distributionFileUrl) throws Exception {
+
+ // get the distro file into a tmp dir
+ // create temp file
+ File tempDistributionFile = null;
+ InputStream is = null;
+ OutputStream os = null;
+ BundleVersion bundleVersion = null;
+
+ try {
+ tempDistributionFile = File.createTempFile("bundle-" + distributionFileUrl.hashCode(), "zip");
+
+ is = distributionFileUrl.openStream();
+ os = new FileOutputStream(tempDistributionFile);
+ long len = StreamUtil.copy(is, os);
+ log.debug("Copied [" + len + "] bytes from [" + distributionFileUrl + "] into ["
+ + tempDistributionFile.getPath() + "]");
+
+ bundleVersion = bundleManager.createBundleVersionViaFile(subject, tempDistributionFile);
+ } finally {
+ if (null != tempDistributionFile) {
+ tempDistributionFile.delete();
+ }
+ }
+
+ return bundleVersion;
+ }
+
+ private BundleVersion createBundleVersionViaDistributionInfo(Subject subject, BundleDistributionInfo info)
+ throws Exception {
+
+ BundleType bundleType = bundleManager.getBundleType(subject, info.getBundleTypeName());
+ String bundleName = info.getRecipeParseResults().getBundleMetadata().getBundleName();
+ String bundleDescription = info.getRecipeParseResults().getBundleMetadata().getDescription();
+ String name = "TODO: bundleVersionName";
+ String description = "TODO: bundleVersionDesc";
+ String version = info.getRecipeParseResults().getBundleMetadata().getBundleVersion();
+ String recipe = info.getRecipe();
+
+ // first see if the bundle exists or not; if not, create one
+ BundleCriteria criteria = new BundleCriteria();
+ criteria.setStrict(true);
+ criteria.addFilterBundleTypeId(bundleType.getId());
+ criteria.addFilterName(bundleName);
+ PageList<Bundle> bundles = findBundlesByCriteria(subject, criteria);
+ Bundle bundle;
+ if (bundles.getTotalSize() == 0) {
+ bundle = createBundle(subject, bundleName, bundleDescription, bundleType.getId());
+ } else {
+ bundle = bundles.get(0);
+ }
+
+ // now create the bundle version with the bundle we either found or created
+ BundleVersion bundleVersion = createBundleVersion(subject, bundle.getId(), name, description, version, recipe);
+
+ // now that we have the bundle version we can actually create the bundle files that were provided in
+ // the bundle distribution
+ Map<String, File> bundleFiles = info.getBundleFiles();
+ for (String fileName : bundleFiles.keySet()) {
+ File file = bundleFiles.get(fileName);
+ InputStream is = null;
+ try {
+ is = new FileInputStream(file);
+ BundleFile bundleFile = bundleManager.addBundleFile(subject, bundleVersion.getId(), fileName, "1.0",
+ null, is);
+ log.debug("Added bundle file [" + bundleFile + "] to BundleVersion [" + bundleVersion + "]");
+ } finally {
+ safeClose(is);
+ if (null != file) {
+ file.delete();
+ }
+ }
+ }
+
+ return bundleVersion;
}
@SuppressWarnings("unchecked")
@@ -690,6 +778,15 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return types;
}
+ @SuppressWarnings("unchecked")
+ public BundleType getBundleType(Subject subject, String bundleTypeName) {
+ // the list of types will be small, no need to support paging
+ Query q = entityManager.createNamedQuery(BundleType.QUERY_FIND_BY_NAME);
+ q.setParameter("name", bundleTypeName);
+ BundleType type = (BundleType) q.getSingleResult();
+ return type;
+ }
+
public PageList<BundleDeployment> findBundleDeploymentsByCriteria(Subject subject, BundleDeploymentCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
@@ -742,8 +839,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return queryRunner.execute();
}
- public PageList<BundleWithLatestVersionComposite> findBundlesWithLastestVersionCompositesByCriteria(
- Subject subject, BundleCriteria criteria) {
+ public PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria(Subject subject,
+ BundleCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(criteria);
String replacementSelectList = ""
@@ -812,4 +909,25 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
return;
}
+
+ private void safeClose(InputStream is) {
+ if (null != is) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ log.warn("Failed to close InputStream", e);
+ }
+ }
+ }
+
+ private void safeClose(OutputStream os) {
+ if (null != os) {
+ try {
+ os.close();
+ } catch (Exception e) {
+ log.warn("Failed to close InputStream", e);
+ }
+ }
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index 534cff1..6ea2bff 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.bundle;
+import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
@@ -167,17 +168,38 @@ public interface BundleManagerRemote {
@WebParam(name = "recipe") String recipe) throws Exception;
/**
- * Creates a bundle version based on a "uber bundle" zip file. The "uber bundle" zip file should contain
- * the recipe for a supported bundle type, along with 0, 1 or more bundle files that will be associated
- * with the bundle version.
+ * Creates a bundle version based on a Bundle Distribution file. Typically a zip file, the bundle distribution
+ * contains the recipe for a supported bundle type, along with 0, 1 or more bundle files that will be associated
+ * with the bundle version. The recipe specifies the bundle name, version, version name and version description.
+ * If this is the initial version for the named bundle the bundle will be implicitly created. The bundle type
+ * is discovered by inspecting the distribution file.
*
* @param subject
- * @param uberBundleZipFile a zip file containing a bundle recipe and bundle files
+ * @param distributionFile a local Bundle Distribution file. It must be read accessible by the RHQ server process.
* @return the persisted BundleVersion (id is assigned)
*/
- BundleVersion createBundleVersionViaUberBundleFileURL( //
- @WebParam(name = "subject") Subject subject, //
- @WebParam(name = "url") URL uberBundleZipFile) throws Exception;
+ BundleVersion createBundleVersionViaFile( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "distributionFile") File distributionFile) throws Exception;
+
+ /**
+ * Creates a bundle version based on a Bundle Distribution file. Typically a zip file, the bundle distribution
+ * contains the recipe for a supported bundle type, along with 0, 1 or more bundle files that will be associated
+ * with the bundle version. The recipe specifies the bundle name, version, version name and version description.
+ * If this is the initial version for the named bundle the bundle will be implicitly created. The bundle type
+ * is discovered by inspecting the distribution file.
+ * <br/></br>
+ * Note, if the file is local it is more efficient to use {@link createBundleVersionViaFile(Subject,File)}.
+ *
+ * @param subject
+ * @param distributionFileUrl a URL to the Bundle Distribution file. It must be live, resolvable and read accessible
+ * by the RHQ server process.
+ *
+ * @return the persisted BundleVersion (id is assigned)
+ */
+ BundleVersion createBundleVersionViaURL( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "distributionFileUrl") URL distributionFileUrl) throws Exception;
/**
* Convienence method that combines {@link #createBundle(Subject, String, int)} and {@link #createBundleVersion(Subject, int, String, String, String)}.
@@ -260,7 +282,7 @@ public interface BundleManagerRemote {
@WebParam(name = "criteria") BundleVersionCriteria criteria);
@WebMethod
- PageList<BundleWithLatestVersionComposite> findBundlesWithLastestVersionCompositesByCriteria( //
+ PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria( //
@WebParam(name = "subject") Subject subject, //
@WebParam(name = "criteria") BundleCriteria criteria);
@@ -268,6 +290,11 @@ public interface BundleManagerRemote {
List<BundleType> getAllBundleTypes( //
@WebParam(name = "subject") Subject subject);
+ @WebMethod
+ BundleType getBundleType( //
+ @WebParam(name = "subject") Subject subject, //
+ @WebParam(name = "bundleTypeName") String bundleTypeName);
+
/**
* Determine the files required for a BundleVersion and return all of the filenames or optionally, just those
* that lack BundleFiles for the BundleVersion. The recipe may be parsed as part of this call.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/UberBundleFileInfo.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/UberBundleFileInfo.java
deleted file mode 100644
index 66881a9..0000000
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/UberBundleFileInfo.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.server.bundle;
-
-import java.io.File;
-import java.util.Map;
-
-import org.rhq.core.domain.bundle.BundleVersion;
-
-/**
- * Information found when a uber bundle file was cracked open and inspected.
- *
- * @author John Mazzitelli
- */
-public class UberBundleFileInfo {
- private final BundleVersion bundleVersion;
- private final RecipeParseResults recipeParseResults;
- private final Map<String, File> bundleFiles;
-
- public UberBundleFileInfo(BundleVersion bundleVersion, RecipeParseResults recipeParseResults,
- Map<String, File> bundleFiles) {
-
- this.bundleVersion = bundleVersion;
- this.recipeParseResults = recipeParseResults;
- this.bundleFiles = bundleFiles;
- }
-
- /**
- * The metadata about the bundle version represented by the uber bundle file.
- * The uber bundle file must have metadata encoded in it that provides details
- * such as the name of the bundle, the version of the bundle, etc. Usually this
- * information is found within the recipe itself but that is not a requirement - the
- * uber bundle file merely has to have the information somewhere that the bundle type
- * server side plugin can find.
- *
- * @return the bundle version information
- */
- public BundleVersion getBundleVersion() {
- return bundleVersion;
- }
-
- /**
- * The information gleened from the recipe that was found in the uber bundle file.
- *
- * @return the recipe information
- */
- public RecipeParseResults getRecipeParseResults() {
- return recipeParseResults;
- }
-
- /**
- * If the uber bundle file contained within it one or more bundle files that need
- * to be associated with the bundle version, this map will contain those files.
- * The key to the map is the name of the bundle file as referenced to it via
- * the recipe (i.e. the keys will be filenames that are mentioned in the
- * {@link #getRecipeParseResults() parse results}). The values are files referencing
- * the bundle files' content - it is the job of the server side plugin to extract
- * the bundle files from the uber bundle file and store them on the local file
- * system.
- *
- * @return names and file locations of all bundle files found in the uber bundle file
- */
- public Map<String, File> getBundleFiles() {
- return bundleFiles;
- }
-
-}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
index f798945..db616d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java
@@ -21,8 +21,8 @@ package org.rhq.enterprise.server.plugin.pc.bundle;
import java.io.File;
+import org.rhq.enterprise.server.bundle.BundleDistributionInfo;
import org.rhq.enterprise.server.bundle.RecipeParseResults;
-import org.rhq.enterprise.server.bundle.UberBundleFileInfo;
/**
* All bundle server plugins must implement this facet.
@@ -41,14 +41,14 @@ public interface BundleServerPluginFacet {
RecipeParseResults parseRecipe(String recipe) throws Exception;
/**
- * The server side plugin is being given an uber bundle file that must be procssed.
+ * The server side plugin is being given an bundle distribution file that must be procssed.
* The results of the processing are to be returned.
*
- * An uber bundle file is a zip file that contains a recipe and 0, 1 or more bundle files.
+ * An bundle distribution file is a zip file that contains a recipe and 0, 1 or more bundle files.
*
- * @param uberBundleFile
- * @return the information gleened by cracking open the uber bundle file and examining its contents
- * @throws Exception if the uber bundle file could not be processed successfully
+ * @param distributionFile
+ * @return the information gleened by cracking open the bundle distribution file and examining its contents
+ * @throws Exception if the bundle distribution file could not be processed successfully
*/
- UberBundleFileInfo processUberBundleFile(File uberBundleFile) throws Exception;
+ BundleDistributionInfo processBundleDistributionFile(File distributionFile) throws Exception;
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
index 1358348..9ca73ae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java
@@ -20,8 +20,8 @@ package org.rhq.enterprise.server.plugin.pc.bundle;
import java.io.File;
+import org.rhq.enterprise.server.bundle.BundleDistributionInfo;
import org.rhq.enterprise.server.bundle.RecipeParseResults;
-import org.rhq.enterprise.server.bundle.UberBundleFileInfo;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment;
import org.rhq.enterprise.server.plugin.pc.ServerPluginManager;
@@ -121,17 +121,52 @@ public class BundleServerPluginManager extends ServerPluginManager {
}
/**
- * Given an uber bundle file, this will find the appropriate server side plugin that can process it
- * and will ask that plugin to crack open the uber bundle file and return information about it.
+ * Given an bundle distribution file, this will find the appropriate server side plugin that can process it
+ * and will ask that plugin to crack open the bundle distribution file and return information about it.
*
- * An uber bundle file is a zip file that contains a recipe and 0, 1 or more bundle files.
+ * An bundle distribution file is a zip file that contains a recipe and 0, 1 or more bundle files.
*
- * @param uberBundleFile
- * @return the information gleened by cracking open the uber bundle file and examining its contents
- * @throws Exception if the uber bundle file could not be processed successfully
+ * @param distributionFile
+ * @return the information gleened by cracking open the bundle distribution file and examining its contents
+ * @throws Exception if the bundle distribution file could not be processed successfully
*/
- public UberBundleFileInfo processUberBundleFile(File uberBundleFile) throws Exception {
- // TODO: bundle implement me
- return null;
+ public BundleDistributionInfo processBundleDistributionFile(File distributionFile) throws Exception {
+
+ if (null == distributionFile) {
+ throw new IllegalArgumentException("bundleDistributionFile == null");
+ }
+
+ // find the bundle plugin that can handle this distribution and get the distro info
+ BundleDistributionInfo info = null;
+
+ for (ServerPluginEnvironment env : getPluginEnvironments()) {
+ BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor();
+
+ // get the facet and see if this plugin can deal with the distro
+ String pluginName = env.getPluginKey().getPluginName();
+ ServerPluginComponent component = getServerPluginComponent(pluginName);
+ BundleServerPluginFacet facet = (BundleServerPluginFacet) component; // we know this cast will work because our loadPlugin ensured so
+ getLog().debug(
+ "Bundle server plugin [" + pluginName + "] is parsing a distribution file [" + distributionFile + "]");
+ ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(env.getPluginClassLoader());
+ try {
+ info = facet.processBundleDistributionFile(distributionFile);
+ info.setBundleTypeName(descriptor.getBundle().getType());
+ break;
+ } catch (IllegalArgumentException e) {
+ info = null;
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalContextClassLoader);
+ }
+ }
+ if (null == info) {
+ throw new IllegalArgumentException(
+ "Invalid bundle distribution file. BundleType/Recipe not recognized by any deployed server bundle plugin.");
+ }
+
+ return info;
}
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
index 05978b8..b33d69a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/webservices/WebservicesManagerBean.java
@@ -22,6 +22,7 @@
*/
package org.rhq.enterprise.server.webservices;
+import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
@@ -353,9 +354,12 @@ public class WebservicesManagerBean implements WebservicesRemote {
return bundleManager.createBundleVersion(subject, bundleId, name, description, version, recipe);
}
- public BundleVersion createBundleVersionViaUberBundleFileURL(Subject subject, URL uberBundleZipFile)
- throws Exception {
- return bundleManager.createBundleVersionViaUberBundleFileURL(subject, uberBundleZipFile);
+ public BundleVersion createBundleVersionViaFile(Subject subject, File distributionFile) throws Exception {
+ return bundleManager.createBundleVersionViaFile(subject, distributionFile);
+ }
+
+ public BundleVersion createBundleVersionViaURL(Subject subject, URL distributionFileUrl) throws Exception {
+ return bundleManager.createBundleVersionViaURL(subject, distributionFileUrl);
}
public BundleVersion createBundleAndBundleVersion(Subject subject, String bundleName, String bundleDescription,
@@ -394,15 +398,19 @@ public class WebservicesManagerBean implements WebservicesRemote {
return bundleManager.findBundleVersionsByCriteria(subject, criteria);
}
- public PageList<BundleWithLatestVersionComposite> findBundlesWithLastestVersionCompositesByCriteria(
- Subject subject, BundleCriteria criteria) {
- return bundleManager.findBundlesWithLastestVersionCompositesByCriteria(subject, criteria);
+ public PageList<BundleWithLatestVersionComposite> findBundlesWithLatestVersionCompositesByCriteria(Subject subject,
+ BundleCriteria criteria) {
+ return bundleManager.findBundlesWithLatestVersionCompositesByCriteria(subject, criteria);
}
public List<BundleType> getAllBundleTypes(Subject subject) {
return bundleManager.getAllBundleTypes(subject);
}
+ public BundleType getBundleType(Subject subject, String bundleTypeName) {
+ return bundleManager.getBundleType(subject, bundleTypeName);
+ }
+
public Set<String> getBundleVersionFilenames(Subject subject, int bundleVersionId, boolean withoutBundleFileOnly)
throws Exception {
return bundleManager.getBundleVersionFilenames(subject, bundleVersionId, withoutBundleFileOnly);
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
index 7fc43f2..78559df 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/BundleManagerBeanTest.java
@@ -221,6 +221,13 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.remove(em.getReference(Repo.class, ((Repo) removeMe).getId()));
}
+ // remove Resource Groups left over from test deployments freeing up test resources
+ q = em.createQuery("SELECT rg FROM ResourceGroup rg WHERE rg.name LIKE '" + TEST_PREFIX + "%'");
+ doomed = q.getResultList();
+ for (Object removeMe : doomed) {
+ em.remove(em.getReference(ResourceGroup.class, ((ResourceGroup) removeMe).getId()));
+ }
+
// remove ResourceTypes which cascade remove BundleTypes
q = em.createQuery("SELECT rt FROM ResourceType rt WHERE rt.name LIKE '" + TEST_PREFIX + "%'");
doomed = q.getResultList();
@@ -242,13 +249,6 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
em.remove(em.getReference(Agent.class, ((Agent) removeMe).getId()));
}
- // remove Resource Groups left over from test deployments
- q = em.createQuery("SELECT rg FROM ResourceGroup rg WHERE rg.name LIKE '" + TEST_PREFIX + "%'");
- doomed = q.getResultList();
- for (Object removeMe : doomed) {
- em.remove(em.getReference(ResourceGroup.class, ((ResourceGroup) removeMe).getId()));
- }
-
getTransactionManager().commit();
em.close();
em = null;
@@ -382,7 +382,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
PageList<BundleWithLatestVersionComposite> results;
// verify there are no bundle versions yet
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
assert results.get(0).getBundleDescription().equals(b1.getDescription());
@@ -393,7 +393,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertNotNull(bv1);
assertEquals("1.0", bv1.getVersion());
assert 0 == bv1.getVersionOrder();
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
assert results.get(0).getBundleDescription().equals(b1.getDescription());
@@ -404,7 +404,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertNotNull(bv2);
assertEquals("2.0", bv2.getVersion());
assert 1 == bv2.getVersionOrder();
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
assert results.get(0).getBundleDescription().equals(b1.getDescription());
@@ -415,7 +415,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertNotNull(bv3);
assertEquals("1.5", bv3.getVersion());
assert 1 == bv3.getVersionOrder();
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
assert results.get(0).getBundleDescription().equals(b1.getDescription());
@@ -475,7 +475,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
// verify our composite criteria query can return more than one item
Bundle b2 = createBundle("two");
assertNotNull(b2);
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.size() == 2 : results;
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
@@ -492,7 +492,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assertNotNull(b2_bv1);
assertEquals("9.1", b2_bv1.getVersion());
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.size() == 2 : results;
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
@@ -507,7 +507,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
// test sorting of the BundleWithLastestVersionComposite
criteria.addSortName(PageOrdering.DESC);
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.size() == 2 : results;
assert results.get(1).getBundleId().equals(b1.getId());
assert results.get(1).getBundleName().equals(b1.getName());
@@ -521,7 +521,7 @@ public class BundleManagerBeanTest extends UpdateSubsytemTestBase {
assert results.get(0).getVersionsCount().longValue() == 1L;
criteria.addSortName(PageOrdering.ASC);
- results = bundleManager.findBundlesWithLastestVersionCompositesByCriteria(overlord, criteria);
+ results = bundleManager.findBundlesWithLatestVersionCompositesByCriteria(overlord, criteria);
assert results.size() == 2 : results;
assert results.get(0).getBundleId().equals(b1.getId());
assert results.get(0).getBundleName().equals(b1.getName());
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
index 196a7f1..871c812 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/bundle/TestBundleServerPluginService.java
@@ -217,7 +217,7 @@ public class TestBundleServerPluginService extends ServerPluginService implement
return new RecipeParseResults(metadata, configDef, bundleFileNames);
}
- public UberBundleFileInfo processUberBundleFile(File uberBundleFile) throws Exception {
+ public BundleDistributionInfo processBundleDistributionFile(File uberBundleFile) throws Exception {
// TODO: bundle implement me
throw new UnsupportedOperationException("this mock object cannot do this");
}
diff --git a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
index 28b8137..b68a20f 100644
--- a/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/ant-bundle/src/main/java/org/rhq/enterprise/server/plugins/ant/AntBundleServerPluginComponent.java
@@ -22,7 +22,12 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,10 +35,12 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.bundle.ant.AntLauncher;
import org.rhq.bundle.ant.BundleAntProject;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.util.ZipUtil;
+import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.core.util.updater.DeploymentProperties;
+import org.rhq.enterprise.server.bundle.BundleDistributionInfo;
import org.rhq.enterprise.server.bundle.RecipeParseResults;
-import org.rhq.enterprise.server.bundle.UberBundleFileInfo;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
import org.rhq.enterprise.server.plugin.pc.ServerPluginContext;
import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginFacet;
@@ -94,8 +101,8 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
BundleAntProject project = antLauncher.parseBundleDeployFile(recipeFile);
// obtain the parse results
- deploymentProps = new DeploymentProperties(0, project.getBundleName(),
- project.getBundleVersion(), project.getBundleDescription()) ;
+ deploymentProps = new DeploymentProperties(0, project.getBundleName(), project.getBundleVersion(), project
+ .getBundleDescription());
bundleFiles = project.getBundleFileNames();
configDef = project.getConfigurationDefinition();
} catch (Throwable t) {
@@ -115,9 +122,108 @@ public class AntBundleServerPluginComponent implements ServerPluginComponent, Bu
return results;
}
- public UberBundleFileInfo processUberBundleFile(File uberBundleFile) throws Exception {
- // TODO: bundle implement me
- return null;
+ public BundleDistributionInfo processBundleDistributionFile(File distributionFile) throws Exception {
+ if (null == distributionFile) {
+ throw new IllegalArgumentException("distributionFile == null");
+ }
+
+ BundleDistributionInfo info = null;
+ String recipe = null;
+ RecipeParseResults recipeParseResults = null;
+
+ // try and parse the recipe, if successful then process the distributionFile completely
+ RecipeVisitor recipeVisitor = new RecipeVisitor(this, "deploy.xml");
+ ZipUtil.walkZipFile(distributionFile, recipeVisitor);
+ recipe = recipeVisitor.getRecipe();
+ recipeParseResults = recipeVisitor.getResults();
+
+ if (null == recipeParseResults) {
+ throw new IllegalArgumentException("Not an Ant Bundle");
+ }
+
+ // if we parsed the recipe then this is a distribution we can deal with, get the bundle file Map
+ BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleMetadata()
+ .getBundleName(), recipeParseResults.getBundleFileNames());
+ ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);
+
+ info = new BundleDistributionInfo(recipe, recipeParseResults, bundleFileVisitor.getBundleFiles());
+
+ return info;
+ }
+
+ private static class RecipeVisitor implements ZipUtil.ZipEntryVisitor {
+ private RecipeParseResults results = null;
+ private String recipeName = null;
+ private BundleServerPluginFacet facet = null;
+ private String recipe = null;
+
+ public RecipeVisitor(BundleServerPluginFacet facet, String recipeName) {
+ this.facet = facet;
+ this.recipeName = recipeName;
+ }
+
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
+ if (recipeName.equalsIgnoreCase(entry.getName())) {
+ // this should be safe downcast, recipes are not that big
+ byte[] recipeBytes = new byte[(int) entry.getSize()];
+ recipeBytes = StreamUtil.slurp(stream);
+ this.recipe = new String(recipeBytes);
+ try {
+ this.results = facet.parseRecipe(this.recipe);
+ } catch (Throwable t) {
+ results = null;
+ }
+ }
+ return true;
+ }
+
+ public RecipeParseResults getResults() {
+ return results;
+ }
+
+ public String getRecipe() {
+ return recipe;
+ }
+ }
+
+ private static class BundleFileVisitor implements ZipUtil.ZipEntryVisitor {
+ private Set<String> bundleFileNames;
+ private Map<String, File> bundleFiles;
+ private File tmpDir;
+
+ public BundleFileVisitor(String bundleName, Set<String> bundleFileNames) throws IOException {
+ this.bundleFileNames = bundleFileNames;
+ this.bundleFiles = new HashMap<String, File>(bundleFileNames.size());
+ tmpDir = FileUtil.createTempDirectory("bundle-" + bundleName, String.valueOf(System.currentTimeMillis()),
+ null);
+ }
+
+ public boolean visit(ZipEntry entry, ZipInputStream stream) throws Exception {
+ if (bundleFileNames.contains(entry.getName())) {
+
+ File bundleFile = new File(tmpDir, entry.getName());
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(bundleFile);
+ StreamUtil.copy(stream, fos, false);
+ } finally {
+ if (null != fos) {
+ try {
+ fos.close();
+ } catch (Exception e) {
+ //
+ }
+ }
+ }
+ this.bundleFiles.put(entry.getName(), bundleFile);
+ }
+
+ return true;
+ }
+
+ public Map<String, File> getBundleFiles() {
+ return bundleFiles;
+ }
}
@Override
diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
index 4d36238..556bab3 100644
--- a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java
@@ -36,7 +36,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.util.updater.DeploymentProperties;
import org.rhq.enterprise.server.bundle.RecipeParseResults;
-import org.rhq.enterprise.server.bundle.UberBundleFileInfo;
+import org.rhq.enterprise.server.bundle.BundleDistributionInfo;
import org.rhq.enterprise.server.plugin.pc.ControlFacet;
import org.rhq.enterprise.server.plugin.pc.ControlResults;
import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent;
@@ -102,7 +102,7 @@ public class BundleServerPluginComponent implements ServerPluginComponent, Bundl
}
- public UberBundleFileInfo processUberBundleFile(File uberBundleFile) throws Exception {
+ public BundleDistributionInfo processBundleDistributionFile(File uberBundleFile) throws Exception {
// TODO: bundle implement me
return null;
}
commit 10995f9ae72be6a2d286fe6db4b928ff1e471109
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 29 10:24:44 2010 -0400
add eclipse lib for new ssh dep
diff --git a/.classpath b/.classpath
index 62622d5..fc26ab4 100644
--- a/.classpath
+++ b/.classpath
@@ -250,5 +250,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-dev/2.0.0/gwt-dev-2.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.1/smartgwt-2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
14 years
[rhq] Branch 'bugfixes' - modules/enterprise
by lkrejci
modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 76a0f63849f0ead3b959bcd7baed56680b8ce811
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Apr 29 18:32:26 2010 +0200
BZ 587317 - revert to using different icons for different resource types.
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
index 6eb65f5..4276b76 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/rhq/resource/navigation/ResourcesTree.xhtml
@@ -92,10 +92,10 @@
</rich:treeNode>
<!-- Tree Node supporting context menu -->
<rich:treeNode type="Resource"
- icon="/images/icons/folder_closed_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png"
+ icon="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png"
iconCollapsed="/images/icons/dir_closed.png"
iconExpanded="/images/icons/dir_open.png"
- iconLeaf="/images/icons/Service_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png">
+ iconLeaf="/images/icons/#{resourceTreeItem.data.resourceType.category}_#{resourceTreeItem.data.currentAvailability.availabilityType == 'DOWN' ? 'down' : 'up'}_16.png">
<a4j:support event="oncontextmenu" reRender="resourceMenu" timeout="5000"
disableDefault="true" status="commonStatus" limitToList="true"
ajaxSingle="true" oncomplete="#{rich:component('resourceMenu')}.show(event, {})">
14 years
[rhq] Branch 'gwt' - 2 commits - .classpath
by Jay Shaughnessy
.classpath | 1 +
1 file changed, 1 insertion(+)
New commits:
commit 2a9da73a934c11cc9b3f2fe9cc0dcb8b014bfaf3
Merge: 46da487... a40874a...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 29 10:28:49 2010 -0400
Merge branch 'gwt' of ssh://git.fedorahosted.org/git/rhq/rhq into gwt
commit 46da487e3339320e0b7e15237d872dbab6890d77
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Apr 29 10:24:44 2010 -0400
add eclipse lib for new ssh dep
diff --git a/.classpath b/.classpath
index 62622d5..fc26ab4 100644
--- a/.classpath
+++ b/.classpath
@@ -250,5 +250,6 @@
<classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-dev/2.0.0/gwt-dev-2.0.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.1/smartgwt-2.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
14 years
[rhq] Branch 'bugfixes' - modules/plugins
by lkrejci
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 52 +++++-----
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java | 50 ++++++---
2 files changed, 64 insertions(+), 38 deletions(-)
New commits:
commit bb5e7a9d039d10ce308c5bcd811c4c1423330a7f
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Apr 29 15:27:19 2010 +0200
BZ 580928, BZ 587250 - RHQ server is identified as such in the resource name, jboss as (4 and 5) are called hostname:jnpPort instead of bindingAddress:jnpPort
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index b02bd01..3b51ec7 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -27,7 +27,9 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.URL;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -288,43 +290,51 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
namingPort = port;
}
- String configName = absoluteConfigPath.getName();
- String baseName = discoveryContext.getSystemInformation().getHostname();
String description = installInfo.getProductType().DESCRIPTION;
File deployDir = new File(absoluteConfigPath, "deploy");
File rhqInstallerWar = new File(deployDir, "rhq-installer.war");
File rhqInstallerWarUndeployed = new File(deployDir, "rhq-installer.war.rej");
boolean isRhqServer = rhqInstallerWar.exists() || rhqInstallerWarUndeployed.exists();
if (isRhqServer) {
- baseName += " RHQ Server, ";
description += " hosting the RHQ Server";
// We know this is an RHQ Server. Let's add an event source for its server log file, but disable it by default.
configureEventSourceForServerLogFile(pluginConfig);
}
- String name = bindAddress+ (namingPort ==null?"":":"+namingPort);
+ String name = formatServerName(bindAddress, namingPort, discoveryContext.getSystemInformation().getHostname(), isRhqServer);
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, installInfo.getVersion(),
description, pluginConfig, processInfo);
}
- /*
- private String formatServerName(String baseName, String bindingAddress, String jnpPort, String configName,
- JBossInstallationInfo installInfo) {
- baseName = baseName + " " + installInfo.getProductType().NAME + " " + installInfo.getVersion() + " "
- + configName;
-
- String details = null;
- if ((bindingAddress != null) && (jnpPort != null && !jnpPort.equals(CHANGE_ME))) {
- details = bindingAddress + ":" + jnpPort;
- } else if ((bindingAddress == null) && (jnpPort != null && !jnpPort.equals(CHANGE_ME))) {
- details = jnpPort;
- } else if (bindingAddress != null) {
- details = bindingAddress;
- }
- return baseName + ((details != null) ? (" (" + details + ")") : "");
-
+ public String formatServerName(String bindingAddress, String jnpPort, String hostname, boolean isRhq) {
+
+ if (isRhq) {
+ return hostname + " RHQ Server";
+ } else {
+ String hostnameToUse = hostname;
+
+ if (bindingAddress != null) {
+ try {
+ InetAddress bindAddr = InetAddress.getByName(bindingAddress);
+ if (!bindAddr.isAnyLocalAddress()) {
+ //if the binding address != 0.0.0.0
+ hostnameToUse = bindAddr.getHostName();
+ }
+ } catch (UnknownHostException e) {
+ //this should not happen?
+ log.warn("Unknown hostname passed in as the binding address for JBoss AS server discovery: "
+ + bindingAddress);
+ }
+ }
+
+ if (jnpPort != null && !jnpPort.equals(CHANGE_ME)) {
+ hostnameToUse += ":" + jnpPort;
+ }
+
+ return hostnameToUse;
+ }
}
-*/
+
private void configureEventSourceForServerLogFile(Configuration pluginConfig) {
File rhqLogFile = resolvePathRelativeToHomeDir(pluginConfig, "../logs/rhq-server-log4j.log");
if (rhqLogFile.exists() && !rhqLogFile.isDirectory()) {
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
index b14027e..05483e4 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/JBossASDiscoveryComponent.java
@@ -24,6 +24,8 @@ package org.rhq.plugins.jbossas;
import java.io.File;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
@@ -294,11 +296,9 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
}
String configName = absoluteConfigPath.getName();
- String baseName = discoveryContext.getSystemInformation().getHostname();
String description = installInfo.getProductType().DESCRIPTION;
- boolean isInServer = isEmbeddedInServer(absoluteConfigPath);
+ boolean isInServer = isRhqServer(absoluteConfigPath);
if (isInServer) {
- baseName += " RHQ Server, ";
description += " hosting the RHQ Server";
// RHQ-633 : We know this is an RHQ Server. Let's auto-configure for tracking its log file, which is not in
@@ -325,7 +325,7 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
}
}
}
- String name = formatServerName(baseName, bindingAddress, namingPort, configName, installInfo);
+ String name = formatServerName(bindingAddress, namingPort, discoveryContext.getSystemInformation().getHostname(), isInServer);
return new DiscoveredResourceDetails(discoveryContext.getResourceType(), key, name, installInfo.getVersion(),
description, pluginConfiguration, processInfo);
@@ -335,7 +335,7 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
* @param absoluteConfigPath
* @return true if this plugin is in an Agent that is embedded in the Server
*/
- private boolean isEmbeddedInServer(File absoluteConfigPath) {
+ private boolean isRhqServer(File absoluteConfigPath) {
File deployDir = new File(absoluteConfigPath, "deploy");
File rhqInstallerWar = new File(deployDir, "rhq-installer.war");
File rhqInstallerWarUndeployed = new File(deployDir, "rhq-installer.war.rej");
@@ -403,8 +403,8 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
// Now set default values on any props that are still not set.
setPluginConfigurationDefaults(pluginConfiguration);
- String resourceName = formatServerName(context.getSystemInformation().getHostname(), bindAddress,
- jnpPort, configName, installInfo);
+ String resourceName = formatServerName(bindAddress, jnpPort,
+ context.getSystemInformation().getHostname(), isRhqServer(configDir));
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), configDir
.getAbsolutePath(), resourceName, version,
"JBoss AS server that the RHQ Plugin Container is running within", pluginConfiguration, null);
@@ -420,16 +420,32 @@ public class JBossASDiscoveryComponent implements ResourceDiscoveryComponent, Ma
return null;
}
- public String formatServerName(String baseName, String bindingAddress, String jnpPort, String configName,
- JBossInstallationInfo installInfo) {
-
- String details = null;
- if ((bindingAddress != null) && (jnpPort != null && !jnpPort.equals(CHANGE_ME))) {
- details = bindingAddress + ":" + jnpPort;
- } else
- details = bindingAddress;
-
- return details;
+ public String formatServerName(String bindingAddress, String jnpPort, String hostname, boolean isRhq) {
+
+ if (isRhq) {
+ return hostname + " RHQ Server";
+ } else {
+ String hostnameToUse = hostname;
+
+ if (bindingAddress != null) {
+ try {
+ InetAddress bindAddr = InetAddress.getByName(bindingAddress);
+ if (!bindAddr.isAnyLocalAddress()) {
+ //if the binding address != 0.0.0.0
+ hostnameToUse = bindAddr.getHostName();
+ }
+ } catch (UnknownHostException e) {
+ //this should not happen?
+ log.warn("Unknown hostname passed in as the binding address for JBoss AS server discovery: " + bindingAddress);
+ }
+ }
+
+ if (jnpPort != null && !jnpPort.equals(CHANGE_ME)) {
+ hostnameToUse += ":" + jnpPort;
+ }
+
+ return hostnameToUse;
+ }
}
private static String getJnpURL(JBossInstanceInfo cmdLine, File installHome, File configDir) {
14 years
[rhq] modules/enterprise
by John Sanda
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java | 6 ++++--
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
New commits:
commit de211f8fc7cbee6258b7dde44a602e9734036b23
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Apr 28 16:09:48 2010 -0400
[BZ 544353] Modifying ui backing bean for edit page so stale values are not used
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
index 09837ec..262c173 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/EditGroupDefinitionGeneralPropertiesUIBean.java
@@ -103,6 +103,8 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
}
public String update() {
+ HttpSession session = FacesContextUtility.getRequest().getSession();
+
try {
GroupDefinition groupDefinition = GroupDefinitionUIBean.lookupGroupDefinition();
@@ -120,8 +122,6 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
groupDefinition.setExpression(expression.replaceAll("\\r", "\n").replaceAll("\\f", "\n").replaceAll("\\n+",
"\n"));
- HttpSession session = FacesContextUtility.getRequest().getSession();
-
session.setAttribute(TEMPORARY_EDIT_MARKER, "marker");
session.setAttribute(TEMPORARY_EXPRESSION_ATTRIBUTE, expression);
session.setAttribute(TEMPORARY_NAME_ATTRIBUTE, name);
@@ -148,6 +148,8 @@ public class EditGroupDefinitionGeneralPropertiesUIBean {
return OUTCOME_FAILURE;
}
+ session.removeAttribute(TEMPORARY_EDIT_MARKER);
+
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "General properties updated.");
return OUTCOME_SUCCESS;
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
index ef3c90d..587ed1b 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/definition/group/NewGroupDefinitionGeneralPropertiesUIBean.java
@@ -99,7 +99,7 @@ public class NewGroupDefinitionGeneralPropertiesUIBean {
return OUTCOME_FAILURE;
}
- session.setAttribute(TEMPORARY_CREATE_MARKER, null);
+ session.removeAttribute(TEMPORARY_CREATE_MARKER);
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO,
"Definition created successfully. Add conditions below.");
14 years