eu.unicore.uas.metadata.FederatedSearchProvider Maven / Gradle / Ivy
The newest version!
package eu.unicore.uas.metadata;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.regex.Pattern;
import eu.unicore.client.Endpoint;
import eu.unicore.client.core.EnumerationClient;
import eu.unicore.client.core.SiteClient;
import eu.unicore.client.core.StorageClient;
import eu.unicore.security.Client;
import eu.unicore.services.Kernel;
import eu.unicore.services.registry.IRegistry;
import eu.unicore.services.registry.RegistryHandler;
import eu.unicore.services.rest.client.IAuthCallback;
import eu.unicore.services.rest.client.RegistryClient;
import eu.unicore.services.rest.jwt.JWTDelegation;
import eu.unicore.services.rest.jwt.JWTServerProperties;
/**
* Federated metada search provider
*
* @author Konstantine Muradov
* @author schuller
*/
public class FederatedSearchProvider implements
Callable {
private final Kernel kernel;
private final Client client;
private final List acceptedStorageURLPatterns;
private final String keyWord;
public FederatedSearchProvider(Kernel kernel, Client client, String keyWord, List patterns) {
this.kernel = kernel;
this.client = client;
this.keyWord = keyWord;
this.acceptedStorageURLPatterns = createPatterns(patterns);
}
private List createPatterns(List patterns){
List res=new ArrayList();
if(patterns!=null){
for(String p: patterns){
res.add(Pattern.compile(p));
}
}
return res;
}
@Override
public FederatedSearchResultCollection call() throws Exception {
FederatedSearchResultCollection result = new FederatedSearchResultCollection();
IRegistry registryClient = getRegistryClient();
IAuthCallback jwt = new JWTDelegation(kernel.getContainerSecurityConfiguration(),
new JWTServerProperties(kernel.getContainerProperties().getRawProperties()),
client.getDistinguishedName());
List storageURLs = new ArrayList<>();
Iterator