[jboss-cvs] JBossAS SVN: r111202 - in projects/jboss-jca/trunk/rhq/src/main: resources/META-INF and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 19 02:43:35 EDT 2011


Author: gaol
Date: 2011-04-19 02:43:35 -0400 (Tue, 19 Apr 2011)
New Revision: 111202

Modified:
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
Log:
[JBJCA-541] check uploaded file extension and make the deployment configuration optional.

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java	2011-04-18 19:40:34 UTC (rev 111201)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/IronJacamarResourceComponent.java	2011-04-19 06:43:35 UTC (rev 111202)
@@ -28,6 +28,7 @@
 import java.io.OutputStream;
 
 import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.content.PackageDetailsKey;
 import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
 import org.rhq.core.domain.resource.CreateResourceStatus;
 import org.rhq.core.domain.resource.ResourceType;
@@ -45,28 +46,53 @@
 public class IronJacamarResourceComponent extends AbstractResourceComponent implements CreateChildResourceFacet
 {
 
+   /**
+    * loadResourceConfiguration
+    * 
+    * @return Configuration the configuration
+    * @throws Exception exception
+    */
    @Override
    public Configuration loadResourceConfiguration() throws Exception
    {
       return new Configuration();
    }
 
+   /**
+    * createResource
+    * 
+    * @param report the CreateResourceReport
+    * @return CreateResourceReport the report
+    */
    @Override
    public CreateResourceReport createResource(CreateResourceReport report)
    {
-
       ResourceType resType = report.getResourceType();
       String resName = resType.getName();
       ResourcePackageDetails pkgDetail = report.getPackageDetails();
       ContentContext contentContext = getResourceContext().getContentContext();
       ContentServices contentServices = contentContext.getContentServices();
       String tmpDir = System.getProperty("java.io.tmpdir");
+      String fileName = pkgDetail.getFileName();
+      if (!fileName.toLowerCase().endsWith(".rar"))
+      {
+         report.setErrorMessage(fileName + " is not a valid RAR file.");
+         report.setStatus(CreateResourceStatus.FAILURE);
+         return report;
+      }
       File outFile = new File(tmpDir, pkgDetail.getFileName()); // change to plugin configuration ??
       OutputStream output;
       try
       {
          output = new FileOutputStream(outFile);
-         contentServices.downloadPackageBitsForChildResource(contentContext, resName, pkgDetail.getKey(), output);
+         PackageDetailsKey key = pkgDetail.getKey();
+         long bits = contentServices.downloadPackageBitsForChildResource(contentContext, resName, key, output);
+         if (bits < 0)
+         {
+            report.setErrorMessage("Can not download package content.");
+            report.setStatus(CreateResourceStatus.FAILURE);
+            return report;
+         }
          Deploy deployer = (Deploy)ContainerHelper.getEmbeddedDiscover();
          deployer.deploy(outFile.toURI().toURL());
          

Modified: projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-04-18 19:40:34 UTC (rev 111201)
+++ projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-04-19 06:43:35 UTC (rev 111202)
@@ -379,7 +379,7 @@
                 
             <content name="rar-file" displayName="RAR File" category="deployable" isCreationType="true">
                 <configuration>
-                  <c:simple-property name="override" displayName="Override?" type="boolean" defaultValue="true"/>
+                  <c:simple-property name="override" displayName="Override?" required="false" type="boolean" defaultValue="true"/>
                 </configuration>
             </content>
             
@@ -501,7 +501,7 @@
         
         <content name="ds-file" displayName="DataSource File" category="deployable" isCreationType="true">
             <configuration>
-              <c:simple-property name="override" displayName="Override?" type="boolean" defaultValue="true"/>
+              <c:simple-property name="override" displayName="Override?" required="false" type="boolean" defaultValue="true"/>
             </configuration>
         </content>
             



More information about the jboss-cvs-commits mailing list