return list of oaipmh Sets instead of ids

This commit is contained in:
Konstantinos Spyrou 2024-11-14 15:46:01 +02:00
parent 768004de62
commit 829f5fa392
5 changed files with 12 additions and 18 deletions

View File

@ -60,7 +60,7 @@ public class ValidatorController {
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) { public List<se.kb.oai.pmh.Set> getSetsOfRepository(@RequestParam(value = "url") String url) {
return validatorService.getSetsOfRepository(url); return validatorService.getSetsOfRepository(url);
} }

View File

@ -9,7 +9,7 @@ import java.util.List;
public class InterfaceInformation{ public class InterfaceInformation{
private boolean identified; private boolean identified;
private List<String> sets; private List<se.kb.oai.pmh.Set> sets;
private List<String> adminEmails; private List<String> adminEmails;
public InterfaceInformation() { public InterfaceInformation() {
@ -23,11 +23,11 @@ public class InterfaceInformation{
this.identified = identified; this.identified = identified;
} }
public List<String> getSets() { public List<se.kb.oai.pmh.Set> getSets() {
return sets; return sets;
} }
public void setSets(List<String> sets) { public void setSets(List<se.kb.oai.pmh.Set> sets) {
this.sets = sets; this.sets = sets;
} }

View File

@ -23,7 +23,7 @@ public interface ValidatorService {
List<RuleSet> getRuleSets(String mode); List<RuleSet> getRuleSets(String mode);
List<String> getSetsOfRepository(String url); List<se.kb.oai.pmh.Set> getSetsOfRepository(String url);
boolean identifyRepo(String url); boolean identifyRepo(String url);

View File

@ -208,9 +208,9 @@ public class ValidatorServiceImpl implements ValidatorService {
} }
@Override @Override
public List<String> getSetsOfRepository(String url) { public List<se.kb.oai.pmh.Set> getSetsOfRepository(String url) {
logger.debug("Getting sets of repository with url : {}", url); logger.debug("Getting sets of repository with url : {}", url);
List<String> sets = null; List<se.kb.oai.pmh.Set> sets = null;
try { try {
sets = OaiTools.getSetsOfRepo(url); sets = OaiTools.getSetsOfRepo(url);
} catch (Exception e) { } catch (Exception e) {

View File

@ -15,7 +15,7 @@ import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -27,7 +27,7 @@ public class OaiTools {
private static final Logger logger = LoggerFactory.getLogger(OaiTools.class); private static final Logger logger = LoggerFactory.getLogger(OaiTools.class);
public static List<String> getSetsOfRepo(String baseUrl) throws Exception { public static List<se.kb.oai.pmh.Set> getSetsOfRepo(String baseUrl) throws Exception {
try { try {
logger.debug("Getting sets of repository: {}", baseUrl); logger.debug("Getting sets of repository: {}", baseUrl);
OaiPmhServer harvester = new OaiPmhServer(baseUrl); OaiPmhServer harvester = new OaiPmhServer(baseUrl);
@ -40,18 +40,12 @@ public class OaiTools {
token = setList.getResumptionToken(); token = setList.getResumptionToken();
} }
List<String> ret = new ArrayList<String>(); sets.sort(Comparator.comparing(Set::getName));
for (Set set : sets) { return sets;
ret.add(set.getSpec().trim());
}
if (ret.size() > 0 )
Collections.sort(ret);
return ret;
} catch (Exception e) { } catch (Exception e) {
logger.error("Error getting sets of repository " + baseUrl, e); logger.error("Error getting sets of repository " + baseUrl, e);
return new ArrayList<String>(); return new ArrayList<>();
//throw e;
} }
} }