[rhq] Branch 'release/jon3.1.x' - modules/plugins
snegrea
snegrea at fedoraproject.org
Wed Aug 8 16:56:21 UTC 2012
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java | 38 ++++++++--
1 file changed, 34 insertions(+), 4 deletions(-)
New commits:
commit 288295bd2dc0d244f98fb16dcb11c206e10bc8d8
Author: Stefan Negrea <snegrea at redhat.com>
Date: Wed Aug 8 11:56:10 2012 -0500
[BZ 836527] Added a create content method for backwards compatiblity with the SOA-P plugin.
(cherry picked from commit b97ed4379723df4bd78d5a101094ada80097025e)
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java
index f82b5ec..6b967b8 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java
@@ -84,15 +84,14 @@ public class FileContentDelegate {
}
/**
- * Creates a new package described by the specified details. The destination of the content in the provided input
- * stream will be determined by the package name.
+ * Creates a new package described by the specified details. The destination of the content in the provided
+ * file will be determined by the package name.
*
* @param details describes the package being created
- * @param content content to be written for the package. NOTE this Stream will be closed by this method.
+ * @param sourceContentFile content file to be written for the package.
* @param unzip if <code>true</code>, the content stream will be treated like a ZIP file and be unzipped as
* it is written, using the package name as the base directory; if <code>false</code> the
* @param createBackup If <code>true</code>, the original file will be backed up to file.bak
- * @param shaString the SHA-256 of the specified input stream
*/
public void createContent(PackageDetails details, File sourceContentFile, boolean unzip, boolean createBackup) {
File destinationContentFile = getPath(details);
@@ -115,6 +114,37 @@ public class FileContentDelegate {
}
/**
+ * Creates a new package described by the specified details. The destination of the content in the provided input
+ * stream will be determined by the package name.
+ *
+ * @param details describes the package being created
+ * @param content content to be written for the package. NOTE this Stream will be closed by this method.
+ * @param unzip if <code>true</code>, the content stream will be treated like a ZIP file and be unzipped as
+ * it is written, using the package name as the base directory; if <code>false</code> the
+ * @param createBackup If <code>true</code>, the original file will be backed up to file.bak
+ * @deprecated Method deprecated because of SHA256 computations. Method added only for backwards compatibility with SOA-P plugin.
+ * Replaced by {@link #createContent(PackageDetails, File, boolean, boolean)}
+ */
+ @Deprecated
+ public void createContent(PackageDetails details, InputStream content, boolean unzip, boolean createBackup) {
+ File destinationContentFile = getPath(details);
+ try {
+ if (createBackup) {
+ moveToBackup(destinationContentFile, ".bak");
+ }
+ if (unzip) {
+ ZipUtil.unzipFile(content, destinationContentFile);
+ computeAndSaveSHA(destinationContentFile);
+ } else {
+ FileUtil.writeFile(content, destinationContentFile);
+ }
+ details.setFileName(destinationContentFile.getPath());
+ } catch (IOException e) {
+ throw new RuntimeException("Error creating artifact from details: " + destinationContentFile, e);
+ }
+ }
+
+ /**
* Try to move the passed contentFile to a backup named contentFile + suffix
* @param contentFile File object pointing to the original file
* @param suffix the suffix to tack on
More information about the rhq-commits
mailing list