modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
| 18 ++++++++++
1 file changed, 18 insertions(+)
New commits:
commit 855123741a423498dfdad6685edb277e120c6bf2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Wed Dec 21 11:03:01 2011 -0600
[BZ 761593] Make use of display version to extract/report the version from the actual
manifest of the deployment.
diff --git
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
index 9a60a57..a956953 100644
---
a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
+++
b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatWarComponent.java
@@ -72,6 +72,8 @@ import org.rhq.core.pluginapi.util.ResponseTimeConfiguration;
import org.rhq.core.pluginapi.util.ResponseTimeLogParser;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.file.ContentFileInfo;
+import org.rhq.core.util.file.JarContentFileInfo;
import org.rhq.plugins.jmx.MBeanResourceComponent;
import org.rhq.plugins.jmx.ObjectNameQueryUtility;
@@ -613,6 +615,7 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
String fileName = new File(fullFileName).getName();
String sha256 = getSHA256(file);
String version = getVersion(sha256);
+ String displayVersion = getDisplayVersion(file);
PackageDetailsKey key = new PackageDetailsKey(fileName, version,
PKG_TYPE_FILE, ARCHITECTURE);
ResourcePackageDetails details = new ResourcePackageDetails(key);
@@ -623,6 +626,7 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
details.setFileCreatedDate(null); // TODO: get created date via SIGAR
details.setInstallationTimestamp(System.currentTimeMillis()); // TODO:
anything better than discovery time
details.setSHA256(sha256);
+ details.setDisplayVersion(displayVersion);
packages.add(details);
}
@@ -655,6 +659,20 @@ public class TomcatWarComponent extends
MBeanResourceComponent<TomcatVHostCompon
return "[sha256=" + sha256 + "]";
}
+ /**
+ * Retrieve the display version for the component. The display version should be
stored
+ * in the manifest of the application (implementation and/or specification version).
+ * It will attempt to retrieve the version for both archived or exploded
deployments.
+ *
+ * @param file component file
+ * @return
+ */
+ private String getDisplayVersion(File file) {
+ //JarContentFileInfo extracts the version from archived and exploded deployments
+ ContentFileInfo contentFileInfo = new JarContentFileInfo(file);
+ return contentFileInfo.getVersion(null);
+ }
+
public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails
packageDetails) {
return null;
}