modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java | 10 ++- modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java | 28 +++++++++- 2 files changed, 33 insertions(+), 5 deletions(-)
New commits: commit 8d2ea937758b5454b6c2774eaeef0a04cd221658 Author: Stefan Negrea snegrea@redhat.com Date: Thu Dec 8 12:14:16 2011 -0600
[BZ 761593] Add SHA to manifest for exploded WAR deployments.
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java index 7f600a7..0f63e1f 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/TomcatVHostComponent.java @@ -54,6 +54,7 @@ import org.rhq.core.pluginapi.content.ContentServices; import org.rhq.core.pluginapi.inventory.ApplicationServerComponent; import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet; import org.rhq.core.pluginapi.inventory.CreateResourceReport; +import org.rhq.core.util.MessageDigestGenerator; import org.rhq.core.util.exception.ThrowableUtil; import org.rhq.plugins.jmx.MBeanResourceComponent;
@@ -231,6 +232,7 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom return report; }
+ @SuppressWarnings("static-access") private void warCreate(CreateResourceReport report) throws Exception { ResourcePackageDetails details = report.getPackageDetails(); PackageDetailsKey key = details.getKey(); @@ -307,11 +309,11 @@ public class TomcatVHostComponent extends MBeanResourceComponent<TomcatServerCom
FileContentDelegate fileContent = new FileContentDelegate(deployDir, details.getPackageTypeName()); InputStream isForTempDir = new BufferedInputStream(new FileInputStream(tempFile)); - fileContent.createContent(path, isForTempDir, explodeOnDeploy); - - // Resource key is a canonical objectName similar to : - // Catalina:j2eeType=WebModule,name=//<vHost>/<path>,J2EEApplication=none,J2EEServer=none + String sha = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).getDigestString(tempFile); + fileContent.createContent(path, isForTempDir, explodeOnDeploy, sha);
+ // Resource key is a canonical objectName similar to: + // Catalina:j2eeType=WebModule,name=//<vHost>/<path>,J2EEApplication=none,J2EEServer=none String objectName = "Catalina:j2eeType=WebModule,J2EEApplication=none,J2EEServer=none,name=//" + getName() + "/" + contextRoot;
diff --git a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java index 1d2b6b2..709c6b7 100644 --- a/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java +++ b/modules/plugins/tomcat/src/main/java/org/jboss/on/plugins/tomcat/helper/FileContentDelegate.java @@ -26,9 +26,12 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Set; +import java.util.jar.Attributes; +import java.util.jar.Manifest;
import org.rhq.core.domain.content.PackageDetails; import org.rhq.core.domain.content.PackageDetailsKey; @@ -77,10 +80,33 @@ public class FileContentDelegate { * it is written, using the package name as the base directory; if <code>false</code> the * content will be written to directly to a file using the package name as the file name */ - public void createContent(File contentFile, InputStream content, boolean unzip) { + public void createContent(File contentFile, InputStream content, boolean unzip, String sha) { try { if (unzip) { ZipUtil.unzipFile(content, contentFile); + + File manifestFile = new File(contentFile, "META-INF/MANIFEST.MF"); + Manifest manifest; + if (manifestFile.exists()) { + FileInputStream inputStream = new FileInputStream(manifestFile); + try { + manifest = new Manifest(inputStream); + } finally { + inputStream.close(); + } + } else { + manifest = new Manifest(); + } + + Attributes attribs = manifest.getMainAttributes(); + attribs.putValue("RHQ-Sha256", sha); + + FileOutputStream outputStream = new FileOutputStream(manifestFile); + try { + manifest.write(outputStream); + } finally { + outputStream.close(); + } } else { FileUtil.writeFile(content, contentFile); }
rhq-commits@lists.fedorahosted.org