diff --git a/biopax-validator-client/src/test/java/BiopaxValidatorClientTest.java b/biopax-validator-client/src/test/java/BiopaxValidatorClientTest.java index c2f016eb..0ba51ba8 100644 --- a/biopax-validator-client/src/test/java/BiopaxValidatorClientTest.java +++ b/biopax-validator-client/src/test/java/BiopaxValidatorClientTest.java @@ -37,8 +37,7 @@ public void testClientHtml() throws IOException { () -> Assertions.assertTrue(res.contains("testBiopaxElementIdRule.owl")), () -> Assertions.assertTrue(res.contains("testSyntaxErrors.owl")) ); -// System.out.println(baos); - } + } @Test public void testClientXml() throws IOException, JAXBException { diff --git a/biopax-validator-web/pom.xml b/biopax-validator-web/pom.xml index e9b22224..ef654e50 100644 --- a/biopax-validator-web/pom.xml +++ b/biopax-validator-web/pom.xml @@ -7,7 +7,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.18 + 3.2.4 @@ -282,14 +282,14 @@ true - taglibs - standard - 1.1.2 + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + 3.0.0 - javax.servlet - jstl - 1.2 + org.glassfish.web + jakarta.servlet.jsp.jstl + 3.0.1 commons-fileupload @@ -340,6 +340,18 @@ logback-classic runtime + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.2.0 + + + org.yaml + snakeyaml + + + diff --git a/biopax-validator-web/src/main/java/org/biopax/validator/web/Application.java b/biopax-validator-web/src/main/java/org/biopax/validator/web/Application.java index b23f1c37..6b1745e6 100644 --- a/biopax-validator-web/src/main/java/org/biopax/validator/web/Application.java +++ b/biopax-validator-web/src/main/java/org/biopax/validator/web/Application.java @@ -2,8 +2,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.config.annotation.*; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; @@ -21,6 +19,10 @@ public static void main(String[] args) { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); } @Override @@ -32,11 +34,4 @@ public void configureViewResolvers(ViewResolverRegistry registry) { registry.viewResolver(resolver); } - @Bean(name = "multipartResolver") - public CommonsMultipartResolver multipartResolver() { - CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(); - multipartResolver.setMaxUploadSize(-1); - return multipartResolver; - } - } diff --git a/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/SuggesterController.java b/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/SuggesterController.java index 14ad13ba..ae46eebc 100644 --- a/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/SuggesterController.java +++ b/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/SuggesterController.java @@ -1,15 +1,15 @@ package org.biopax.validator.web.controller; +import jakarta.servlet.http.HttpServletResponse; import org.biopax.validator.web.dto.Clue; import org.biopax.validator.web.service.Suggester; import org.biopax.validator.web.dto.Xref; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.*; @RestController public class SuggesterController { @@ -17,7 +17,7 @@ public class SuggesterController { @Autowired private Suggester service; - @GetMapping(value = "/xref/{db}/{id}/", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/xref/{db}/{id}/", produces = TEXT_PLAIN_VALUE) public String xrefDbId(@PathVariable String db, @PathVariable String id, HttpServletResponse response) throws IOException { String uri = null; @@ -26,7 +26,6 @@ public String xrefDbId(@PathVariable String db, @PathVariable String id, } catch (IllegalArgumentException e) { response.sendError(400, e.toString()); } - return uri; } diff --git a/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/ValidatorController.java b/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/ValidatorController.java index e798c05c..29fb278c 100644 --- a/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/ValidatorController.java +++ b/biopax-validator-web/src/main/java/org/biopax/validator/web/controller/ValidatorController.java @@ -5,9 +5,8 @@ import java.net.MalformedURLException; import java.util.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.biopax.paxtools.normalizer.Normalizer; @@ -27,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; -import static org.springframework.http.MediaType.APPLICATION_XML_VALUE; +import static org.springframework.http.MediaType.*; @Controller public class ValidatorController { @@ -42,24 +41,24 @@ public ValidatorController(ValidatorAdapter service) { this.service = service; } - @RequestMapping(value = {"schema","schema.html"}, method = RequestMethod.GET, produces = APPLICATION_XML_VALUE) - @ResponseBody public String getSchema() { + @GetMapping(value = {"schema","schema.html"}, produces = APPLICATION_XML_VALUE) + @ResponseBody public String getSchema() { return service.getSchema(); } //Views (pages) - @RequestMapping({"/", "home", "home.html"}) + @GetMapping({"/", "home", "home.html"}) public String home() { return "home"; } - @RequestMapping({"ws","ws.html"}) + @GetMapping({"ws","ws.html"}) public String ws() { return "ws"; } - @RequestMapping(value={"check","check.html"}, method=RequestMethod.GET) + @GetMapping(value={"check","check.html"}) public void check(Model model) { model.addAttribute("normalizer", new Normalizer()); //user can edit some of normalizer's options in the 'check' view @@ -89,18 +88,18 @@ public void check(Model model) { * @return results view name (or null if XML or normalized RDF/XML were requested) * @throws IOException when data cannot be read from the files or URL, etc. */ - @RequestMapping(value={"check","check.html"}, method=RequestMethod.POST) + @PostMapping(value={"check","check.html"}, + produces = {APPLICATION_XML_VALUE, TEXT_HTML_VALUE, "application/vnd.biopax.rdf+xml"}) public String check(HttpServletRequest request, HttpServletResponse response, Model mvcModel, Writer writer, - @RequestParam(required=false) String url, - @RequestParam(required=false) String retDesired, - @RequestParam(required=false) Boolean autofix, - @RequestParam(required=false) Behavior filter, - @RequestParam(required=false) Integer maxErrors, - @RequestParam(required=false) String profile, - //normalizer!=null when called from the JSP; - //but it's usually null when from the validator-client or a web script - @ModelAttribute("normalizer") Normalizer normalizer) throws IOException + @RequestParam(required=false) String url, + @RequestParam(required=false) String retDesired, + @RequestParam(required=false) Boolean autofix, + @RequestParam(required=false) Behavior filter, + @RequestParam(required=false) Integer maxErrors, + @RequestParam(required=false) String profile, + //normalizer!=null when called from the JSP (browser); null when called from validator-client or script + @ModelAttribute("normalizer") Normalizer normalizer) throws IOException { Resource resource; //to validate final int lim = (maxErrors != null)? maxErrors.intValue() : 0; //0->no error limit @@ -110,7 +109,7 @@ public String check(HttpServletRequest request, HttpServletResponse response, ValidatorResponse validatorResponse = new ValidatorResponse(); if(url != null && url.length()>0) { - log.info("url : " + url); + log.info("validate from url : " + url); try { resource = new UrlResource(url); diff --git a/biopax-validator-web/src/main/java/org/biopax/validator/web/service/ValidatorService.java b/biopax-validator-web/src/main/java/org/biopax/validator/web/service/ValidatorService.java index b82370d8..d2389e3c 100644 --- a/biopax-validator-web/src/main/java/org/biopax/validator/web/service/ValidatorService.java +++ b/biopax-validator-web/src/main/java/org/biopax/validator/web/service/ValidatorService.java @@ -36,8 +36,9 @@ public Validation validate(Resource data, Behavior errorLevel, String profile, Normalizer normalizer) throws IOException { + String dataDescr = data.getDescription(); Validation validationResult = new Validation(new BiopaxIdentifier(), - data.getDescription(), isFix, errorLevel, errMax, profile); + dataDescr, isFix, errorLevel, errMax, profile); //run the biopax-validator (this updates the validationResult object) biopaxValidator.importModel(validationResult, data.getInputStream()); biopaxValidator.validate(validationResult); diff --git a/biopax-validator-web/src/main/resources/application.properties b/biopax-validator-web/src/main/resources/application.properties index 220214ba..6c301655 100644 --- a/biopax-validator-web/src/main/resources/application.properties +++ b/biopax-validator-web/src/main/resources/application.properties @@ -3,7 +3,8 @@ spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp #spring.mvc.view.view-names:* server.error.whitelabel.enabled=false -#server.servlet.context-path = / +#server.servlet.context-path = /validate + spring.main.banner-mode=off application.message: Hello BioPAX users! @@ -14,11 +15,17 @@ management.endpoint.health.enabled=true management.endpoints.web.exposure.include=health #management.endpoints.web.exposure.exclude= -#due to migration from spring-boot 2.0 to 2.1 +#due to migration from spring-boot 2.0 to 2.1, then 3.x spring.main.allow-bean-definition-overriding=true #for rest docs spring.jackson.serialization.indent-output=true -servlet.multipart.enabled: false -servlet.multipart.max-file-size: 100MB +#servlet.multipart.enabled=false +server.tomcat.max-swallow-size=-1 +spring.servlet.multipart.max-file-size=100MB +spring.servlet.multipart.max-request-size=10MB + +#server.servlet.encoding.charset=UTF-8 +#server.servlet.encoding.enabled=false +#server.servlet.encoding.force-response=true diff --git a/biopax-validator-web/src/main/webapp/jsp/ws.jsp b/biopax-validator-web/src/main/webapp/jsp/ws.jsp index 692a1403..af8e1739 100644 --- a/biopax-validator-web/src/main/webapp/jsp/ws.jsp +++ b/biopax-validator-web/src/main/webapp/jsp/ws.jsp @@ -54,15 +54,14 @@ to save locally and view off-line
-As an example, there is a basic BioPAX validator client module -(it connects to the http://www.biopax.org/validator/check), and the +As an example, there is a BioPAX validator-client library +(it connects to http://www.biopax.org/validator/check); the -sources are here (see test classes there as well). +source code is here (see test classes there as well).
- +
-

See also

-BioPAX Validator API documentation with examples (OpenAPI/Swagger). +See also: OpenAPI/Swagger page (autogenerated, needs work...)
diff --git a/biopax-validator-web/src/test/java/org/biopax/validator/web/controller/SuggesterControllerTest.java b/biopax-validator-web/src/test/java/org/biopax/validator/web/controller/SuggesterControllerTest.java index 5628e6d7..95275b0e 100644 --- a/biopax-validator-web/src/test/java/org/biopax/validator/web/controller/SuggesterControllerTest.java +++ b/biopax-validator-web/src/test/java/org/biopax/validator/web/controller/SuggesterControllerTest.java @@ -43,12 +43,12 @@ public void before() { // valid synonym and valid id String anXrefId = "6.1.1.5"; given(service.xrefDbIdToUri("ec", anXrefId)) - .willReturn("http://identifiers.org/ec-code/" + anXrefId); + .willReturn("http://bioregistry.io/eccode:" + anXrefId); // test typo (fixable) name given(service.xrefDbIdToUri("ec_code", anXrefId)) - .willReturn("http://identifiers.org/ec-code/" + anXrefId); + .willReturn("http://bioregistry.io/eccode:" + anXrefId); given(service.xrefDbIdToUri("Enzyme Nomenclature", anXrefId)) - .willReturn("http://identifiers.org/ec-code/" + anXrefId); + .willReturn("http://bioregistry.io/eccode:" + anXrefId); // bad not-fixable name given(service.xrefDbIdToUri("foo", anXrefId)) .willThrow(new IllegalArgumentException("Datatype not found")); @@ -59,15 +59,14 @@ public void before() { @Test public void shouldReturnUri() throws Exception { - mvc.perform(get("/xref/ec/6.1.1.5/").accept(MediaType.APPLICATION_JSON)) + mvc.perform(get("/xref/ec/6.1.1.5/").accept(MediaType.TEXT_PLAIN)) .andDo(print()) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(content().string(equalTo("http://identifiers.org/ec-code/6.1.1.5"))); + .andExpect(content().string(equalTo("http://bioregistry.io/eccode:6.1.1.5"))); - mvc.perform(get("/xref/ec_code/6.1.1.5/").accept(MediaType.APPLICATION_JSON)) + mvc.perform(get("/xref/ec_code/6.1.1.5/").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) - .andExpect(content().string(equalTo("http://identifiers.org/ec-code/6.1.1.5"))); + .andExpect(content().string(equalTo("http://bioregistry.io/eccode:6.1.1.5"))); } @Test @@ -106,14 +105,14 @@ public void shouldReturnCheckedXrefs() throws Exception { y.setId("foo"); //invalid Xref xx = new Xref(); xx.setDb("ec"); //ok - xx.setNamespace("ec-code"); + xx.setNamespace("eccode"); xx.setDbOk(true); xx.setId("1.1.1.1"); //ok xx.setIdOk(true); Xref yy = new Xref(); yy.setDb("ec"); // ok yy.setDbOk(true); - yy.setNamespace("ec-code"); + yy.setNamespace("eccode"); yy.setId("foo"); //invalid Clue xyClue = new Clue("some info"); xyClue.addValue(xx); diff --git a/biopax-validator/src/main/java/org/biopax/validator/rules/UnificationXrefLimitedRule.java b/biopax-validator/src/main/java/org/biopax/validator/rules/UnificationXrefLimitedRule.java index 628f9ac7..9653b0b1 100644 --- a/biopax-validator/src/main/java/org/biopax/validator/rules/UnificationXrefLimitedRule.java +++ b/biopax-validator/src/main/java/org/biopax/validator/rules/UnificationXrefLimitedRule.java @@ -67,11 +67,10 @@ void initInternalMaps() { } private void addDbSynonymsTo(Map,Set> map) { - for (Map.Entry,Set> entry : map.entrySet()) { - Set val = entry.getValue(); - for (String db : new HashSet<>(val)) - for (String s : helper.getSynonymsForDbName(db)) - val.add(s); + for (Set val : map.values()) { + for (String db : new HashSet<>(val)) { + val.addAll(helper.getSynonymsForDbName(db)); + } } } diff --git a/pom.xml b/pom.xml index c72dea96..8f123002 100644 --- a/pom.xml +++ b/pom.xml @@ -177,7 +177,7 @@ UTF-8 UTF-8 github - 5.3.31 + 6.1.5 2.0.11 ${settings.localRepository}/org/springframework/spring-instrument/${spring-framework.version}/spring-instrument-${spring-framework.version}.jar 6.0.0-SNAPSHOT @@ -484,24 +484,6 @@ commons-collections 3.2.2 - - taglibs - standard - 1.1.2 - runtime - - - javax.servlet - javax.servlet-api - 4.0.1 - provided - - - javax.servlet - jstl - 1.2 - runtime - commons-fileupload commons-fileupload