[Swift-commit] cog r3883
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Thu Mar 27 20:40:05 CDT 2014
------------------------------------------------------------------------
r3883 | hategan | 2014-03-27 20:39:36 -0500 (Thu, 27 Mar 2014) | 1 line
added filtered list method to file resources
------------------------------------------------------------------------
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceFileFilter.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceFileFilter.java (revision 0)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/FileResourceFileFilter.java (revision 3883)
@@ -0,0 +1,16 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Mar 26, 2014
+ */
+package org.globus.cog.abstraction.impl.file;
+
+import org.globus.cog.abstraction.interfaces.GridFile;
+
+public interface FileResourceFileFilter {
+ boolean accept(GridFile f);
+}
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/AbstractFileResource.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/AbstractFileResource.java (revision 3882)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/AbstractFileResource.java (working copy)
@@ -13,9 +13,11 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.PasswordAuthentication;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
@@ -436,4 +438,24 @@
throw new UnsupportedOperationException("The " + name + " provider does not support partial transfers");
}
}
+
+ /**
+ * Convenience method to implement filtering. Providers should implement their
+ * own, more efficient, filtering
+ * @throws FileResourceException
+ * @throws DirectoryNotFoundException
+ */
+ @Override
+ public Collection<GridFile> list(String dir, FileResourceFileFilter filter)
+ throws DirectoryNotFoundException, FileResourceException {
+
+ List<GridFile> nl = new ArrayList<GridFile>();
+ Collection<GridFile> ol = list(dir);
+ for (GridFile f : ol) {
+ if (filter.accept(f)) {
+ nl.add(f);
+ }
+ }
+ return nl;
+ }
}
Index: modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/FileResource.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/FileResource.java (revision 3882)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/FileResource.java (working copy)
@@ -10,12 +10,14 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
+import java.util.List;
import org.globus.cog.abstraction.impl.common.task.IllegalSpecException;
import org.globus.cog.abstraction.impl.common.task.InvalidSecurityContextException;
import org.globus.cog.abstraction.impl.common.task.TaskSubmissionException;
import org.globus.cog.abstraction.impl.file.DirectoryNotFoundException;
import org.globus.cog.abstraction.impl.file.FileResourceException;
+import org.globus.cog.abstraction.impl.file.FileResourceFileFilter;
import org.globus.cog.abstraction.impl.file.IllegalHostException;
/**
@@ -132,6 +134,9 @@
*/
public Collection<GridFile> list(String directoryName)
throws DirectoryNotFoundException, FileResourceException;
+
+ public Collection<GridFile> list(String dir, FileResourceFileFilter filter)
+ throws DirectoryNotFoundException, FileResourceException;
/**
* Creates a new directory with the given name
@@ -371,4 +376,5 @@
void thirdPartyTransfer(FileResource sourceResource, FileFragment source, FileFragment destination)
throws FileResourceException;
+
}
More information about the Swift-commit
mailing list