Revision 51620
Added by Alessia Bardi about 6 years ago
CatalogueRegistrator.java | ||
---|---|---|
10 | 10 |
import com.fasterxml.jackson.core.JsonFactory; |
11 | 11 |
import com.fasterxml.jackson.core.JsonGenerator; |
12 | 12 |
import com.google.common.base.Joiner; |
13 |
import eu.dnetlib.parthenos.CRMpe; |
|
13 | 14 |
import eu.dnetlib.parthenos.jrr.ParthenosRegistryResource; |
14 | 15 |
import eu.dnetlib.parthenos.publisher.ParthenosPublisherException; |
15 | 16 |
import eu.dnetlib.parthenos.rdf.ResourceReader; |
... | ... | |
119 | 120 |
*/ |
120 | 121 |
protected void ensureGroups(final Resource res) throws ParthenosPublisherException, IOException, URISyntaxException { |
121 | 122 |
log.debug("Ensuring groups exist"); |
122 |
Iterator<String> providerNames = resourceReader.getProviderNames(res); |
|
123 |
while(providerNames.hasNext()){ |
|
124 |
String name = providerNames.next(); |
|
125 |
if(StringUtils.isNotBlank(name)){ |
|
126 |
String groupName = getNameForCatalogue(name); |
|
127 |
if(!catalogueAPIClient.groupExist(groupName)){ |
|
128 |
String groupJson = String.format(groupTemplate, groupName, groupName, name); |
|
129 |
catalogueAPIClient.registerGroup(groupJson, groupName); |
|
130 |
log.info("NEW GROUP REGISTERED: "+groupName); |
|
123 |
if(res.hasProperty(CRMpe.PP2_provided_by)) { |
|
124 |
Iterator<String> providerNames = resourceReader.getProviderNames(res); |
|
125 |
while (providerNames.hasNext()) { |
|
126 |
String name = providerNames.next(); |
|
127 |
if (StringUtils.isNotBlank(name)) { |
|
128 |
String groupName = getNameForCatalogue(name); |
|
129 |
if (!catalogueAPIClient.groupExist(groupName)) { |
|
130 |
String groupJson = String.format(groupTemplate, groupName, groupName, name); |
|
131 |
catalogueAPIClient.registerGroup(groupJson, groupName); |
|
132 |
log.info("NEW GROUP REGISTERED: " + groupName); |
|
133 |
} |
|
131 | 134 |
} |
132 | 135 |
} |
133 | 136 |
} |
137 |
else{ |
|
138 |
log.debug("Resource "+res.getURI()+" without PP2_provided_by: no groups to register"); |
|
139 |
} |
|
134 | 140 |
} |
135 | 141 |
|
136 | 142 |
protected String getJsonForActivity(final Resource res, final String resNameForCatalogue) throws IOException { |
Also available in: Unified diff
log when groups cannot be created