[jboss-svn-commits] JBL Code SVN: r15860 - labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Oct 16 13:44:47 EDT 2007


Author: dejp
Date: 2007-10-16 13:44:47 -0400 (Tue, 16 Oct 2007)
New Revision: 15860

Modified:
   labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java
Log:
bug fix

Modified: labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java
===================================================================
--- labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java	2007-10-16 16:54:04 UTC (rev 15859)
+++ labs/jbosslabs/trunk/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDB.java	2007-10-16 17:44:47 UTC (rev 15860)
@@ -29,6 +29,8 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.jboss.forge.common.ejb3.LabsServices;
+import org.jboss.forge.common.projects.project.Categories;
+import org.jboss.forge.common.projects.project.Category;
 import org.jboss.forge.common.projects.project.Downloads;
 import org.jboss.forge.common.projects.project.File;
 import org.jboss.forge.common.projects.project.Files;
@@ -115,6 +117,47 @@
         return counters;
     }
     
+    private boolean checkInFiles(Files files, String link) {
+
+        if (files != null) {
+            for (File file : files.getFile()) {
+                if (link.startsWith("http://") || link.startsWith("https://")) {
+                    if (link.endsWith(file.getId())) {
+                        return true;
+                    }
+                } else {
+                    if (link.endsWith(file.getFullName())) {
+                        return true;
+                    }
+                }
+            }
+        }
+        
+        return false;
+    }
+    
+    private boolean checkInCategories(Categories categories, String link) {
+        boolean exists = false;
+        
+        if (categories != null) {
+            for (Category category : categories.getCategory()) {
+                exists = checkInFiles(category.getFiles(), link);
+                
+                if (exists) {
+                    return true;
+                }
+                
+                exists = checkInCategories(category.getCategories(), link);
+                
+                if (exists) {
+                    return true;
+                }
+            }
+        }
+        
+        return false;
+    }
+    
     /**
      * Method simply just increments the counter value for
      * given in parameter <link>.
@@ -133,23 +176,15 @@
     				(CountersServiceInterface) ctx.lookup(CountersServiceInterface.jndiName);
     		
     		if (!downloadCounters.containsKey(link)) {
-    		
                 Downloads downloads = LabsServices.getProjectsService().getProjectDownloads(projectId);
-                Files files = downloads.getFiles();
                 
                 boolean exists = false;
                 
-                for (File file : files.getFile()) {
-                    if (link.startsWith("http://") || link.startsWith("https://")) {
-                        if (link.endsWith(file.getId())) {
-                            exists = true;
-                            break;
-                        }
-                    } else {
-                        if (link.endsWith(file.getFullName())) {
-                            exists = true;
-                            break;
-                        }
+                if (downloads != null) {
+                    exists = checkInFiles(downloads.getFiles(), link);
+                
+                    if (!exists) {
+                        exists = checkInCategories(downloads.getCategories(), link);
                     }
                 }
                 




More information about the jboss-svn-commits mailing list