You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/07/26 10:03:03 UTC

svn commit: r1365908 - /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java

Author: suat
Date: Thu Jul 26 08:03:03 2012
New Revision: 1365908

URL: http://svn.apache.org/viewvc?rev=1365908&view=rev
Log:
STANBOL-498: Implemented removeAll() method

Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java?rev=1365908&r1=1365907&r2=1365908&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java Thu Jul 26 08:03:03 2012
@@ -239,17 +239,16 @@ public class FileStore implements Store<
     }
 
     @Override
-    public void remove(Iterable<String> uris)
-    		throws StoreException {
-    	List<ContentItem> removed = new ArrayList<ContentItem>();
-    	for(String uri : uris){
-    		ContentItem ci = remove(uri);
-    		if(ci != null){
-    			removed.add(ci);
-    		}
-    	}
+    public void remove(Iterable<String> uris) throws StoreException {
+        List<ContentItem> removed = new ArrayList<ContentItem>();
+        for (String uri : uris) {
+            ContentItem ci = remove(uri);
+            if (ci != null) {
+                removed.add(ci);
+            }
+        }
     }
-    
+
     @Override
     public ContentItem remove(String id) throws StoreException {
         checkStoreFolder();
@@ -259,19 +258,25 @@ public class FileStore implements Store<
         if (f.exists()) {
             ci = get(id);
             f.delete();
-            updateTablesForDelete(id);
         } else {
             log.warn("There is no file corresponding to the id: {}", id);
         }
+        updateTablesForDelete(id);
         return ci;
     }
 
     @Override
     public void removeAll() throws StoreException {
-    	//TODO: implement
-    	throw new UnsupportedOperationException("TODO: implement!!");
+        ChangeSet<ContentItem> changes = changes(Long.MIN_VALUE, Integer.MAX_VALUE);
+        List<ContentItem> removed = new ArrayList<ContentItem>();
+        for (String id : changes.changed()) {
+            ContentItem ci = remove(id);
+            if (ci != null) {
+                removed.add(ci);
+            }
+        }
     }
-    
+
     private void updateTablesForDelete(String id) throws StoreException {
         // update revision
         revisionManager.updateRevision(id);
@@ -303,13 +308,13 @@ public class FileStore implements Store<
 
     @Override
     public Iterable<String> put(Iterable<ContentItem> cis) throws StoreException {
-    	List<String> uris = new ArrayList<String>();
-    	for(ContentItem ci : cis){
-    		uris.add(put(ci));
-    	}
-    	return null;
+        List<String> uris = new ArrayList<String>();
+        for (ContentItem ci : cis) {
+            uris.add(put(ci));
+        }
+        return uris;
     }
-    
+
     @Override
     public String put(ContentItem ci) throws StoreException {
         try {