[embjopr-commits] EMBJOPR SVN: r260 - in trunk/core/src/main/java/org/jboss/on/embedded: util and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Fri Mar 27 17:26:05 EDT 2009


Author: ips
Date: 2009-03-27 17:26:05 -0400 (Fri, 27 Mar 2009)
New Revision: 260

Modified:
   trunk/core/src/main/java/org/jboss/on/embedded/ui/content/UpdateBackingContentAction.java
   trunk/core/src/main/java/org/jboss/on/embedded/util/ContentUtility.java
Log:
add more debug logging to help debug https://jira.jboss.org/jira/browse/EMBJOPR-81 and throw exception during retrieval of backing package that was getting swallowed


Modified: trunk/core/src/main/java/org/jboss/on/embedded/ui/content/UpdateBackingContentAction.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/ui/content/UpdateBackingContentAction.java	2009-03-26 19:06:21 UTC (rev 259)
+++ trunk/core/src/main/java/org/jboss/on/embedded/ui/content/UpdateBackingContentAction.java	2009-03-27 21:26:05 UTC (rev 260)
@@ -81,14 +81,17 @@
     @Begin(join = true)
     public String init()
     {
+        log.debug("Initializing updateBackingContentAction Seam component...");
         JONTreeNode selectedNode = this.navigationAction.getSelectedNode();
         ResourceTreeNode resourceTreeNode = (ResourceTreeNode)selectedNode;
         this.resource = resourceTreeNode.getResource();
-        this.resourceType = resource.getResourceType();
+        log.debug("Current Resource is " + this.resource);
+        this.resourceType = this.resource.getResourceType();
 
         this.packageType = ContentUtility.getCreationPackageType(this.resourceType);
         if (this.packageType == null)
         {
+            log.error(this.resourceType + " has no associated creation package type.");
             facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_ERROR, "content.resourceInstance.create.resourceTypeHasNoCreationPackageType");
             return FAILURE_OUTCOME;
         }
@@ -96,24 +99,27 @@
         try {
             this.packageDetails = getBackingPackage();
         }
-        catch (Exception e) {
+        catch (Exception e) {            
             facesMessages.add(FacesMessage.SEVERITY_ERROR, e.getLocalizedMessage());
             return FAILURE_OUTCOME;
         }
-
+        
         return SUCCESS_OUTCOME;
     }
 
     @End(ifOutcome={"success"})
     public String updateBackingContent() {
+        // NOTE: This check is necessary, because the "required" attribute of the Seam FileUpload component doesn't
+        //       work.
         if (getFileName() == null) {
-            // NOTE: This check is necessary, because the "required" attribute of the Seam FileUpload component doesn't
-            //       work.
+            log.error("No file was specified in request to update backing file for " + this.resource + ".");
             facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_ERROR,
                     "content.resourceInstance.update.noFileSelected");
             return FAILURE_OUTCOME;
         }
         if (!getFileName().equals(this.packageDetails.getFileName())) {
+            log.error("Specified file '" + getFileName() + "' does not have same filename as existing file '"
+                    + this.packageDetails.getFileName() + "' for " + this.resource + ".");
             facesMessages.addFromResourceBundle(FacesMessage.SEVERITY_WARN,
                     "content.resourceInstance.update.wrongFileName", this.packageType.getDisplayName(), 
                     this.packageDetails.getFileName());
@@ -169,18 +175,19 @@
     }
 
     private ResourcePackageDetails getBackingPackage() throws Exception {
-        ContentDiscoveryReport report = null;
+        ContentDiscoveryReport report;
         try {
             report = PluginContainer.getInstance().getContentManager().executeResourcePackageDiscoveryImmediately(
                     this.resource.getId(), this.packageType.getName());
-            if (report.getDeployedPackages().size() != 1) {
-                throw new Exception("ContentManager.executeResourcePackageDiscoveryImmediately() returned more than one package.");
-            }
+            if (report.getDeployedPackages().size() != 1)
+                throw new IllegalStateException("ContentManager.executeResourcePackageDiscoveryImmediately() returned more than one package.");
         }
         catch (PluginContainerException e) {
-            log.error("Failed to discover underlying " + this.packageType.getName() + " package for "
+            throw new Exception("Failed to discover underlying " + this.packageType.getName() + " package for "
                     + this.resourceType.getName() + " Resource.", e);
         }
-        return report.getDeployedPackages().iterator().next();
+        ResourcePackageDetails packageDetails = report.getDeployedPackages().iterator().next();
+        log.debug("Backing package for " + this.resource + " is " + packageDetails + ".");
+        return packageDetails;
     }
 }
\ No newline at end of file

Modified: trunk/core/src/main/java/org/jboss/on/embedded/util/ContentUtility.java
===================================================================
--- trunk/core/src/main/java/org/jboss/on/embedded/util/ContentUtility.java	2009-03-26 19:06:21 UTC (rev 259)
+++ trunk/core/src/main/java/org/jboss/on/embedded/util/ContentUtility.java	2009-03-27 21:26:05 UTC (rev 260)
@@ -27,12 +27,16 @@
 import org.rhq.core.domain.content.PackageType;
 import org.rhq.core.domain.resource.ResourceType;
 import org.rhq.core.domain.resource.ResourceCreationDataType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @author Ian Springer
  */
 public abstract class ContentUtility
 {
+    private static final Log LOG = LogFactory.getLog(ContentUtility.class);
+
     private ContentUtility()
     {
     }
@@ -45,15 +49,18 @@
     @Nullable
     public static PackageType getCreationPackageType(ResourceType resourceType)
     {
+        PackageType creationPackageType = null;
         Set<PackageType> packageTypes = resourceType.getPackageTypes();
         for (PackageType packageType : packageTypes)
         {
             if (packageType.isCreationData())
             {
-                return packageType;
+                creationPackageType = packageType;
+                break;
             }
         }
-        return null;
+        LOG.debug("Creation package type for " + resourceType + " is " + creationPackageType + ".");
+        return creationPackageType;
     }
 
     @Nullable




More information about the embjopr-commits mailing list