Revision 53508
Added by Michele Artini over 5 years ago
FixRepoMdstoreSizesJobNode.java | ||
---|---|---|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.StringReader; |
5 | 5 |
import java.util.Date; |
6 |
import java.util.HashMap; |
|
6 | 7 |
import java.util.List; |
8 |
import java.util.Map; |
|
7 | 9 |
import java.util.Objects; |
8 | 10 |
import java.util.Set; |
9 | 11 |
import java.util.stream.Collectors; |
... | ... | |
65 | 67 |
private ISRegistryService registry; |
66 | 68 |
private ISLookUpService lookup; |
67 | 69 |
|
70 |
private final Map<String, String> openaireIds = new HashMap<>(); |
|
68 | 71 |
private boolean alwaysUpdate = false; |
69 | 72 |
|
70 | 73 |
private static final Log log = LogFactory.getLog(FixRepoMdstoreSizesJobNode.class); |
... | ... | |
74 | 77 |
this.total = total; |
75 | 78 |
this.lookup = serviceLocator.getService(ISLookUpService.class); |
76 | 79 |
this.registry = serviceLocator.getService(ISRegistryService.class); |
80 |
try { |
|
81 |
openaireIds.putAll(lookup.quickSearchProfile( |
|
82 |
"for $x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType') return concat($x//DATASOURCE_ORIGINAL_ID, ' @@@ ', $x//RESOURCE_IDENTIFIER/@value)") |
|
83 |
.stream() |
|
84 |
.collect(Collectors.toMap( |
|
85 |
s -> StringUtils.substringBefore(s, "@@@").trim(), |
|
86 |
s -> StringUtils.substringAfter(s, "@@@").trim()))); |
|
87 |
} catch (final ISLookUpException e) { |
|
88 |
// TODO Auto-generated catch block |
|
89 |
e.printStackTrace(); |
|
90 |
} |
|
91 |
|
|
77 | 92 |
} |
78 | 93 |
|
79 | 94 |
@Override |
... | ... | |
86 | 101 |
log.info("Processing ds: " + dsId); |
87 | 102 |
|
88 | 103 |
current++; |
104 |
|
|
89 | 105 |
try { |
90 | 106 |
for (final Api<ApiParam> api : dsManager.getApis(dsId)) { |
91 | 107 |
verifyApi(dsId, api); |
... | ... | |
154 | 170 |
|
155 | 171 |
private List<Document> executeXquery(final String template, final String dsId, final String apiId) throws ISLookUpException, IOException { |
156 | 172 |
final StringTemplate st = new StringTemplate(IOUtils.toString(getClass().getResourceAsStream(template))); |
157 |
st.setAttribute("dsId", dsId);
|
|
173 |
st.setAttribute("dsId", openaireIds.get(dsId));
|
|
158 | 174 |
st.setAttribute("apiId", apiId); |
159 | 175 |
|
160 | 176 |
final SAXReader reader = new SAXReader(); |
Also available in: Unified diff
fixed a bug with openaire Ids