Revision 51063
Added by Alessia Bardi over 6 years ago
modules/dnet-parthenos-publisher/trunk/src/main/java/eu/dnetlib/parthenos/registry/GCubeResourceRegistrator.java | ||
---|---|---|
4 | 4 |
import java.io.ByteArrayOutputStream; |
5 | 5 |
import java.io.IOException; |
6 | 6 |
import java.util.List; |
7 |
import java.util.Map; |
|
7 | 8 |
import javax.annotation.PostConstruct; |
8 | 9 |
|
9 | 10 |
import com.fasterxml.jackson.core.JsonEncoding; |
... | ... | |
20 | 21 |
import org.apache.commons.lang3.StringUtils; |
21 | 22 |
import org.apache.commons.logging.Log; |
22 | 23 |
import org.apache.commons.logging.LogFactory; |
24 |
import org.apache.jena.ext.com.google.common.collect.Maps; |
|
23 | 25 |
import org.apache.jena.rdf.model.Property; |
24 | 26 |
import org.apache.jena.rdf.model.Resource; |
25 | 27 |
import org.apache.jena.rdf.model.StmtIterator; |
... | ... | |
28 | 30 |
import org.gcube.common.authorization.library.AuthorizationEntry; |
29 | 31 |
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; |
30 | 32 |
import org.gcube.common.scope.api.ScopeProvider; |
33 |
import org.gcube.informationsystem.model.entity.facet.IdentifierFacet; |
|
34 |
import org.gcube.informationsystem.model.relation.IsIdentifiedBy; |
|
31 | 35 |
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; |
32 | 36 |
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException; |
33 | 37 |
import org.gcube.informationsystem.resourceregistry.client.ParthenosRegistryClientSetter; |
... | ... | |
470 | 474 |
facetWriter.writeInfoFacet(jg, res); |
471 | 475 |
} |
472 | 476 |
|
473 |
public ParthenosRegistryResource findInRegistry(final String uri) throws InvalidQueryException, ResourceRegistryException { |
|
474 |
//TODO: build query |
|
475 |
String res = this.resourceRegistryClient.query("",0,""); |
|
476 |
//TODO: build PRR from res, need to have type and uuid |
|
477 |
ParthenosRegistryResource prr = null; |
|
477 |
public ParthenosRegistryResource findInRegistry(final String uri) { |
|
478 |
Map<String, Object> queryMap = Maps.newHashMap(); |
|
479 |
queryMap.put("value", uri); |
|
480 |
List<org.gcube.informationsystem.model.entity.Resource> resources = resourceRegistryClient.getFilteredResources(Resource.class, IsIdentifiedBy.class, IdentifierFacet.class, true, map); |
|
481 |
if(resources.isEmpty()) return null; |
|
482 |
org.gcube.informationsystem.model.entity.Resource resource = resources.get(0); |
|
483 |
if(resources.size() > 1){ |
|
484 |
log.warn("More than one resource in registry with uri "+uri+" -- considering the first, with uuid: "+resource.getHeader().getUUID()); |
|
485 |
} |
|
486 |
//build PRR from res, need to have type and uuid |
|
487 |
//TODO: check the type is what we want |
|
488 |
ParthenosRegistryResource prr = new ParthenosRegistryResource().setUuid(resource.getHeader().getUUID().toString()).setType(resource.getClass().getSimpleName()) |
|
489 |
log.debug(prr.toString()); |
|
478 | 490 |
return prr; |
479 | 491 |
} |
480 | 492 |
|
Also available in: Unified diff
implemented findInRegistry method