develop #1
|
@ -210,7 +210,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||||
|
|
||||||
// here page should be 0
|
// here page should be 0
|
||||||
UriComponents uriComponents = searchSnipperDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
UriComponents uriComponents = searchSnippetDatasource(Integer.toString(Math.abs(page)), Integer.toString(Math.abs(size)));
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -218,7 +218,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
requestFilter.setId(repoId);
|
requestFilter.setId(repoId);
|
||||||
|
|
||||||
DatasourceResponse rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
DatasourceResponse rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||||
if ( rs == null ) {
|
if (rs == null) {
|
||||||
logger.error("The \"DatasourceResponse\" is null!");
|
logger.error("The \"DatasourceResponse\" is null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -259,31 +259,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
logger.debug("Country code equals : {} | Filter mode equals : {}", country, filterKey);
|
logger.debug("Country code equals : {} | Filter mode equals : {}", country, filterKey);
|
||||||
|
|
||||||
UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
UriComponents uriComponents = searchSnippetDatasource(String.valueOf(page), String.valueOf(size));
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setCountry(country);
|
requestFilter.setCountry(country);
|
||||||
requestFilter.setEoscDatasourceType(filterKey);
|
requestFilter.setEoscDatasourceType(filterKey);
|
||||||
|
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
Map rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, Map.class);
|
||||||
if ( rs == null ) {
|
if (rs != null) {
|
||||||
logger.error("The result is null!");
|
resultSet.addAll(mapper.readValue(mapper.writeValueAsString(rs.get("datasourceInfo")),
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
|
||||||
while (jsonArray.length() > 0) {
|
|
||||||
|
|
||||||
resultSet.addAll(mapper.readValue(String.valueOf(jsonArray),
|
|
||||||
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class)));
|
||||||
page += 1;
|
|
||||||
uriComponents = searchSnipperDatasource(String.valueOf(page), String.valueOf(size));
|
|
||||||
rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
|
||||||
if ( rs == null ) {
|
|
||||||
logger.error("The result is null!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
|
|
||||||
}
|
}
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
@ -385,12 +369,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
logger.debug("Retrieving repositories with id : {}", id);
|
logger.debug("Retrieving repositories with id : {}", id);
|
||||||
RepositorySnippet repo;
|
RepositorySnippet repo;
|
||||||
UriComponents uriComponents = searchSnipperDatasource("0", "100");
|
UriComponents uriComponents = searchSnippetDatasource("0", "100");
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setId(id);
|
requestFilter.setId(id);
|
||||||
|
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
String rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String.class);
|
||||||
if ( rs == null ) {
|
if (rs == null) {
|
||||||
logger.error("The result is null!");
|
logger.error("The result is null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -418,7 +402,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
DatasourceResponse response;
|
DatasourceResponse response;
|
||||||
response = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
response = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||||
if ( response == null ) {
|
if (response == null) {
|
||||||
logger.error("The response is null!");
|
logger.error("The response is null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +447,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||||
ApiDetailsResponse rs = restTemplate.getForObject(uriComponents.toUri(), ApiDetailsResponse.class);
|
ApiDetailsResponse rs = restTemplate.getForObject(uriComponents.toUri(), ApiDetailsResponse.class);
|
||||||
if ( rs == null ) {
|
if (rs == null) {
|
||||||
logger.error("The ApiDetailsResponse was null!");
|
logger.error("The ApiDetailsResponse was null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -471,9 +455,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// TODO STOP FILTERING OUT "sword", "rest" AND FIX UI!
|
// TODO STOP FILTERING OUT "sword", "rest" AND FIX UI!
|
||||||
List<ApiDetails> res = new ArrayList<>();
|
List<ApiDetails> res = new ArrayList<>();
|
||||||
|
|
||||||
for (ApiDetails det: rs.getApi()) {
|
for (ApiDetails det : rs.getApi()) {
|
||||||
String protocol = det.getProtocol();
|
String protocol = det.getProtocol();
|
||||||
if ( !protocol.equals("sword") &&
|
if (!protocol.equals("sword") &&
|
||||||
!protocol.equals("rest") &&
|
!protocol.equals("rest") &&
|
||||||
!protocol.equals("ftp")) {
|
!protocol.equals("ftp")) {
|
||||||
res.add(det);
|
res.add(det);
|
||||||
|
@ -564,7 +548,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||||
} else {
|
} else {
|
||||||
Object responseBody = responseEntity.getBody();
|
Object responseBody = responseEntity.getBody();
|
||||||
if ( responseBody != null )
|
if (responseBody != null)
|
||||||
logger.error("Error updating repository: {}", responseBody);
|
logger.error("Error updating repository: {}", responseBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +574,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
|
emailUtils.sendAdminUpdateRepositoryInfoEmail(repository, authentication);
|
||||||
} else {
|
} else {
|
||||||
Object responseBody = responseEntity.getBody();
|
Object responseBody = responseEntity.getBody();
|
||||||
if ( responseBody != null )
|
if (responseBody != null)
|
||||||
logger.error("Error updating repository: {}", responseBody);
|
logger.error("Error updating repository: {}", responseBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,7 +602,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||||
} else {
|
} else {
|
||||||
Object responseBody = responseEntity.getBody();
|
Object responseBody = responseEntity.getBody();
|
||||||
if ( responseBody != null )
|
if (responseBody != null)
|
||||||
logger.error("Error storing repository: {}", responseBody);
|
logger.error("Error storing repository: {}", responseBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,7 +641,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
||||||
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
||||||
|
|
||||||
if (desiredCompatibilityLevel!= null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
|
if (desiredCompatibilityLevel != null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
|
||||||
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
interfaceComplianceService.create(request);
|
interfaceComplianceService.create(request);
|
||||||
}
|
}
|
||||||
|
@ -680,7 +664,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
||||||
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
||||||
|
|
||||||
if (desiredCompatibilityLevel!= null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
|
if (desiredCompatibilityLevel != null && !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel)) {
|
||||||
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
interfaceComplianceService.create(request);
|
interfaceComplianceService.create(request);
|
||||||
}
|
}
|
||||||
|
@ -814,18 +798,17 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL))
|
||||||
return compatibilityClasses;
|
return compatibilityClasses;
|
||||||
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) {
|
||||||
if ( ValidatorServiceImpl.OPENAIRE_DATA_REGEX.matcher(entry.getKey()).matches() ) {
|
if (ValidatorServiceImpl.OPENAIRE_DATA_REGEX.matcher(entry.getKey()).matches()) {
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
}
|
} else if (mode.equalsIgnoreCase("cris")) {
|
||||||
else if (mode.equalsIgnoreCase("cris")) {
|
|
||||||
if (entry.getKey().contains("openaire-cris")) {
|
if (entry.getKey().contains("openaire-cris")) {
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
foundData = true;
|
foundData = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( ValidatorServiceImpl.OPENAIRE_OR_DRIVER_REGEX.matcher(entry.getKey()).matches() )
|
if (ValidatorServiceImpl.OPENAIRE_OR_DRIVER_REGEX.matcher(entry.getKey()).matches())
|
||||||
retMap.put(entry.getKey(), entry.getValue());
|
retMap.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,8 +908,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
dates.put("re3data", re3Date);
|
dates.put("re3data", re3Date);
|
||||||
|
|
||||||
return dates;
|
return dates;
|
||||||
}
|
} else if (mode.equals("cris"))
|
||||||
else if (mode.equals("cris"))
|
|
||||||
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("eurocrisdris::dris").get(0).getLastCollectionDate()));
|
||||||
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
else if (mode.equals("opendoar")) // TODO: remove this and else clause
|
||||||
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||||
|
@ -1010,7 +992,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
.build().expand(page, size).encode();
|
.build().expand(page, size).encode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UriComponents searchSnipperDatasource(String page, String size) {
|
private UriComponents searchSnippetDatasource(String page, String size) {
|
||||||
|
|
||||||
return UriComponentsBuilder
|
return UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
.fromHttpUrl(baseAddress + "/ds/searchsnippet/")
|
||||||
|
|
Loading…
Reference in New Issue