summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Negrea <snegrea@redhat.com>2012-08-08 16:37:36 (GMT)
committerStefan Negrea <snegrea@redhat.com>2012-08-08 16:38:15 (GMT)
commitb97ed4379723df4bd78d5a101094ada80097025e (patch)
tree889eabe66e7e59f5625606c8bd9b249d5b4a5d11
parent581324eeb3d32f4d8879d4749423fbde0f76de8c (diff)
downloadrhq-b97ed4379723df4bd78d5a101094ada80097025e.zip
rhq-b97ed4379723df4bd78d5a101094ada80097025e.tar.gz
rhq-b97ed4379723df4bd78d5a101094ada80097025e.tar.xz
[BZ 836527] Added a create content method for backwards compatiblity with the SOA-P plugin.
-rw-r--r--modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/util/FileContentDelegate.java38
1 files changed, 34 insertions, 4 deletions
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