Author: channa
Date: Thu Jul 10 02:00:10 2008
New Revision: 19078
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19078

Log:
Determining a true add to be the first add operation in a log, marking rest as 
updates. Also disregarding delete logs when resource exists. MASHUP-657.


Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java?rev=19078&r1=19077&r2=19078&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
  Thu Jul 10 02:00:10 2008
@@ -367,6 +367,10 @@
         QueryResults qResults = new QueryResults();
         qResults.setQueryName(queryHeading);
 
+        // Map used to store 'added' log entries, to change to 'update' if 
older entries found.
+        Map updatedResources = new HashMap();
+        String putText;
+
         if (queryPath.equals(MashupConstants.ACTIVITY_QUERY_PATH)) {
 
 
@@ -410,6 +414,13 @@
             LogEntry[] logs =
                     userRegistry.getLogs(params[0], filterValue, params[2], 
fromDate, toDate, true);
 
+            // Operation can only be confirmed as the initial 'add' if all 
logs are processed.
+            if (logs.length < (maxResults + 1)) {
+                putText = "added";
+            } else {
+                putText = "added/updated";
+            }
+
             int shownResults = 0;
             // iterate until we have the minimum number of non-anon logs
             //  plus one more so we can tell whether to refer the user to
@@ -436,7 +447,22 @@
                             if ((logEntry.getResourcePath().startsWith(
                                     MashupConstants.ALL_MASHUPS_PATH)) &&
                                     (pathSegments.length > 3)) {
-                                queryResult.setAction("added");
+                                queryResult.setAction(putText);
+                                // Store 'add' candidate result in a map, 
keyed by path.
+                                if 
(updatedResources.containsKey(logEntry.getResourcePath())) {
+                                    QueryResult storedResult = (QueryResult) 
updatedResources.get(
+                                            logEntry.getResourcePath());
+
+                                    // If new result older than previous 
'add', make that update. 
+                                    if 
(storedResult.getDate().compareTo(queryResult.getDate()) >
+                                            0) {
+                                        storedResult.setAction("updated");
+                                        updatedResources
+                                                
.put(logEntry.getResourcePath(), queryResult);
+                                    }
+                                } else {
+                                    
updatedResources.put(logEntry.getResourcePath(), queryResult);
+                                }
                             } else continue;
                         } else if (action == LogEntry.UPDATE) {
                             String[] pathSegments = 
logEntry.getResourcePath().split("/");
@@ -455,8 +481,10 @@
                             queryResult.setAction("rated");
                             
queryResult.setContentString(logEntry.getActionData());
                         } else if (action == LogEntry.DELETE_RESOURCE) {
+                            // Only log deletes if they're permanent, not 
updates.
                             if (logEntry.getResourcePath()
-                                    
.startsWith(MashupConstants.ALL_MASHUPS_PATH)) {
+                                    
.startsWith(MashupConstants.ALL_MASHUPS_PATH)
+                                    && 
!userRegistry.resourceExists(logEntry.getResourcePath())) {
                                 queryResult.setAction("deleted");
                             } else continue;
                         } else continue;

_______________________________________________
Mashup-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to