- Improve performance of "ValidatorController.getRuleSet()" endpoint.
- Improve exception-handling. - Replace deprecated method-calls. - Code polishing.
This commit is contained in:
parent
a239164f97
commit
8bf0f76ad6
|
@ -95,7 +95,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50)) {
|
||||
job.setValidationStatus("failed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +139,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return retJobs;
|
||||
|
||||
}
|
||||
|
||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||
|
@ -166,13 +164,12 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException {
|
||||
public StoredJob getJobSummary(String jobId, String groupBy) {
|
||||
logger.debug("Getting job summary with id : " + jobId);
|
||||
StoredJob job = null;
|
||||
try {
|
||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (ValidatorServiceException e) {
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -189,4 +186,5 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
return job;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -226,12 +226,12 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
|
||||
@Override
|
||||
public Integer getTotal() {
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, new Object[]{}, Integer.class);
|
||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, Integer.class, new Object[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValidated(boolean validated) {
|
||||
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where validated = ?";
|
||||
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, new Object[]{validated}, Integer.class);
|
||||
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, Integer.class, validated);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,22 +95,20 @@ public class SushiliteServiceImpl implements SushiliteService {
|
|||
Customer customer = reportResponseWrapper.getReportResponse().getReportWrapper().getReport().getCustomer();
|
||||
List<ReportItem> allReportItems = customer.getReportItems();
|
||||
|
||||
if ( allReportItems != null) {
|
||||
if ( allReportItems != null ) {
|
||||
try {
|
||||
int totalItems = allReportItems.size();
|
||||
int size = Integer.parseInt(pageSize);
|
||||
int offset = (Integer.parseInt(page) * size);
|
||||
|
||||
if (offset < totalItems ) {
|
||||
if ( offset < totalItems ) {
|
||||
int upperIndex = (offset + size);
|
||||
if (upperIndex > totalItems) {
|
||||
if ( upperIndex > totalItems ) {
|
||||
upperIndex = totalItems;
|
||||
}
|
||||
requestedItemList = allReportItems.subList(offset, upperIndex);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
logger.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
//emailUtils.reportException(e);
|
||||
logger.error("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (ruleSet != null){
|
||||
if (ruleSet != null) {
|
||||
for (int ruleId : job.getRules()) {
|
||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||
contentRules.add(ruleId);
|
||||
|
@ -210,16 +210,13 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
@Override
|
||||
public List<String> getSetsOfRepository(String url) {
|
||||
logger.debug("Getting sets of repository with url : {}", url);
|
||||
|
||||
List<String> sets = null;
|
||||
|
||||
try {
|
||||
sets = OaiTools.getSetsOfRepo(url);
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception on getSetsOfRepository", e);
|
||||
}
|
||||
|
||||
return sets;
|
||||
return sets; // It may be null.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -239,13 +236,16 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
RuleSet ruleSet = null;
|
||||
try {
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
for (RuleSet rSet : ruleSets)
|
||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
||||
for ( RuleSet rSet : ruleSets ) {
|
||||
if ( rSet.getGuidelinesAcronym().equals(acronym) ) {
|
||||
ruleSet = rSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ruleSet != null )
|
||||
break;
|
||||
}
|
||||
return ruleSet;
|
||||
return ruleSet; // It may be null.
|
||||
} catch (Exception e) {
|
||||
logger.error("Error getting ruleset", e);
|
||||
return null;
|
||||
|
|
|
@ -49,16 +49,14 @@ public class HttpUtils {
|
|||
public JsonElement get(String path, Map<String, String> params) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = registryUrl + path + ((params != null) ? createParams(params) : null);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
||||
(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
public JsonElement delete(String path) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
String url = registryUrl + path;
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
||||
(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||
return getResponseEntityAsJsonElement(responseEntity);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class OaiTools {
|
|||
disableSslVerification();
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
||||
|
||||
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
||||
try {
|
||||
|
@ -36,8 +36,8 @@ public class OaiTools {
|
|||
List<Set> sets = new ArrayList<>(setList.asList());
|
||||
while (token != null) {
|
||||
setList = harvester.listSets(token);
|
||||
token = setList.getResumptionToken();
|
||||
sets.addAll(setList.asList());
|
||||
token = setList.getResumptionToken();
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
|
Loading…
Reference in New Issue