nikolas.laskaris 2014-06-05 15:51:44 +00:00
parent a68ed9e98b
commit d9f9b205d1
1 changed files with 18 additions and 9 deletions

View File

@ -5,8 +5,10 @@ import java.io.StringReader;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
@ -170,13 +172,12 @@ public class GenericResource implements GenericResourceInfoI {
logger.debug("Remote Exception:" + e.toString());
}
//remove from all collections set, the opensearch ones !
for(String key : pairs.keySet()){
org.gcube.common.resources.gcore.GenericResource collection = pairs.get(key);
Iterator<Map.Entry<String,org.gcube.common.resources.gcore.GenericResource>> iter = pairs.entrySet().iterator();
while (iter.hasNext()) {
org.gcube.common.resources.gcore.GenericResource collection = iter.next().getValue();
Element body = collection.profile().body();
if(body.getElementsByTagName("type").getLength()==0)
pairs.remove(key);
else
logger.debug("Found tree collection: "+key);
if(body.getElementsByTagName("type").getLength()>0) //means opensearch collection
iter.remove();
}
logger.debug("# of Tree Collections found: "+ pairs.size());
return pairs;
@ -195,16 +196,24 @@ public class GenericResource implements GenericResourceInfoI {
query = queryFor(org.gcube.common.resources.gcore.GenericResource.class);
// query.addCondition("$resource/Profile/SecondaryType eq 'GCUBECollection'");
query.addCondition("$resource/Profile/SecondaryType eq 'DataSource'"); //changed from GCUBECollection to DataSource (2 be same as the tree collections)
query.addCondition("$resource/Profile/Body/SourceProperties/type eq 'opensearch'");
// query.addCondition("$resource/Profile/Body/SourceProperties/type eq 'opensearch'");
if(onlyUserCollections)
query.addCondition("$resource/Profile/Body/CollectionInfo/user eq 'true'");
List<org.gcube.common.resources.gcore.GenericResource> results = client.submit(query);
if (results == null || results.size() == 0)
logger.debug("Couldn't find any OpenSearch collections within that scope! Will return empty list.");
else
logger.debug("# of OpenSearch Collections found: "+ results.size());
for (org.gcube.common.resources.gcore.GenericResource gr : results)
pairs.put(gr.id(), gr);
//remove from all collections set, the tree collection ones !
Iterator<Map.Entry<String,org.gcube.common.resources.gcore.GenericResource>> iter = pairs.entrySet().iterator();
while (iter.hasNext()) {
org.gcube.common.resources.gcore.GenericResource collection = iter.next().getValue();
Element body = collection.profile().body();
if(body.getElementsByTagName("type").getLength()==0)
iter.remove();
}
logger.debug("# of Opensearch Collections found: "+ pairs.size());
} catch (Exception e) {
logger.debug("Remote Exception:" + e.toString());
}