Compare commits

...

3 Commits

3 changed files with 34 additions and 11 deletions

View File

@ -13,6 +13,7 @@ import eu.dnetlib.validatorapi.repositories.ValidationJobRepository;
import eu.dnetlib.validatorapi.repositories.ValidationResultRepository;
import eu.dnetlib.validatorapi.routes.FairOaiPmhRoute2;
import eu.dnetlib.validatorapi.routes.SimpleOaiPmhRoute;
import eu.dnetlib.validatorapi.utils.CheckCertificate;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
@ -208,12 +209,28 @@ public class ValidationController {
ValidationJob validationJob = new ValidationJob(baseURL, set, numberOfRecords);
validationJob.guidelines = profile.name();
validationJobRepository.save(validationJob);
log.info("Initial validation job id "+ validationJob.id);
log.info("\n\n\n\n\n" + numberOfRecords + "\n\n\n\n");
int record = 0;
double resultSum = 0;
try {
if (new URL(baseURL).getProtocol().equalsIgnoreCase("https")) {
if (!CheckCertificate.isValidCertificate(baseURL)) {
validationJob.exceptionMessage = "The SSL certificate could not be validated.";
validationJob.progress = "STOPPED";
validationJob.endDate = new Date();
validationJob.score = resultSum / validationJob.recordsTested;
validationJob.status = validationResultRepository.getStatus(validationJob.id);
validationJobRepository.save(validationJob);
return ResponseEntity.status(HttpStatus.SC_OK).body(validationJob);
}
}
UUID uuid = UUID.randomUUID();
RouteBuilder oaiPmhRouteBuilder;

View File

@ -32,8 +32,6 @@ public class SumUpNCleanProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
Thread stop=null;
ValidationJob validationJob = new ValidationJob();
validationJob.id = (Integer)exchange.getIn().getHeader("validationId");
validationJob.baseUrl = (String)(exchange.getIn().getHeader("baseUrl"));

View File

@ -15,7 +15,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.TypeConversionException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.engine.DefaultShutdownStrategy;
import org.apache.http.client.ClientProtocolException;
import java.net.UnknownHostException;
@ -73,9 +72,8 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
String date = new Date().toString();
// Access the DefaultShutdownStrategy
DefaultShutdownStrategy shutdownStrategy = (DefaultShutdownStrategy) getContext().getShutdownStrategy();
// Set the shutdown timeout in milliseconds (e.g., 10 seconds)
shutdownStrategy.setTimeout(1);
/* DefaultShutdownStrategy shutdownStrategy = (DefaultShutdownStrategy) getContext().getShutdownStrategy();
shutdownStrategy.setTimeout(1);*/
onException(TypeConversionException.class)
.process(new ExceptionProcessor(validationJob))
@ -133,30 +131,34 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
.endChoice()
.end();
from("direct:guidelinesProcessor")
.routeId(routeid)
.split(xpath("//*[local-name()='record']"))
.process(new XmlProcessor(profile, validationJob, maxNumberOfRecords))
.choice()
.when(simple("${body[results]} && ${header.MyHeader} != 'stop'"))
//.log("HEADER ${header.MyHeader}")
.split(simple("${body[results]}"))
.to("jpa:" + ValidationRuleResult.class.getName() + "?usePersist=true")
.endChoice()
.end()
.choice()
.when(simple("${body[issues]} && ${header.MyHeader} != 'stop'"))
.when(simple("${body[issues]} && ${header.MyHedddader} != 'stop'"))
//.log("HEADER ${header.MyHeader}")
.split(simple("${body[issues]}"))
.to("jpa:"+ ValidationIssue.class.getName()+ "?usePersist=true")
.endChoice()
.end()
.choice()
.when(header("MyHeader").isEqualTo("stop"))
//.log("HEADER ${header.MyHeader}")
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
profile))
profile))
/*.process(new DataBaseProcessor())
.to("jpa:" + ValidationJob.class.getName() + "?useExecuteUpdate=true")//;.to("direct:saveToDatabase")*/
.to("controlbus:route?routeId="+routeid+"&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.endChoice()
.end();
@ -178,15 +180,21 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
.end()
.choice()
.when(header("MyHeader").isEqualTo("stop"))
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
fairProfile))
/*.process(new DataBaseProcessor())
.to("jpa:" + ValidationJob.class.getName() + "?useExecuteUpdate=true")//;.to("direct:saveToDatabase")*/
.to("controlbus:route?routeId="+routeid2+"&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.endChoice()
.end();
/*
from("direct:afterMulticast")
.log("All processes completed")
.to("controlbus:route?routeId=1&action=stop&async=true");
*/
/*
from("direct:saveToDatabase")
.routeId(routeid2)