Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ea 2137 api commons disptacher servlet logs #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<artifactId>fulltext</artifactId>
<groupId>eu.europeana</groupId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>eu.europeana.fulltext</groupId>
<artifactId>api</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<packaging>war</packaging>

<name>Europeana Newspapers Fulltext API</name>
Expand All @@ -25,7 +25,13 @@
<dependency>
<groupId>eu.europeana.fulltext</groupId>
<artifactId>common</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>eu.europeana.api.commons</groupId>
<artifactId>commons-logs</artifactId>
<version>${apiCommons.version}</version>
</dependency>

<dependency>
Expand Down
15 changes: 15 additions & 0 deletions api/src/main/java/eu/europeana/fulltext/api/FTApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package eu.europeana.fulltext.api;

import eu.europeana.api.commons.logs.LoggableDispatcherServlet;
import eu.europeana.fulltext.api.web.SocksProxyConfigInjector;
import org.apache.logging.log4j.LogManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand Down Expand Up @@ -37,6 +41,17 @@ public WebMvcConfigurer corsConfigurer() {
return new WebConfig();
}

@Bean
public ServletRegistrationBean dispatcherRegistration() {
return new ServletRegistrationBean(dispatcherServlet());
}

@Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public DispatcherServlet dispatcherServlet() {
return new LoggableDispatcherServlet();
}


/**
* This method is called when starting as a Spring-Boot application (run this class from the IDE)
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package eu.europeana.fulltext.api.config;

import java.util.ArrayList;
import java.util.List;

/**
* Created by luthien on 14/06/2018.
*/
Expand All @@ -12,15 +15,17 @@ public final class FTDefinitions {
public static final String V3_ANNO_BODY_TYPE = "SpecificResource";
public static final String EDM_FULLTEXTRESOURCE_TYPE = "FullTextResource";
public static final String UTF_8 = "charset=UTF-8";
public static final String TYPE_PAGE = "page";
public static final String TYPE_BLOCK = "block";
public static final String TYPE_LINE = "line";
public static final String TYPE_WORD = "word";
public static final String TYPE_MEDIA = "media";
public static final String TYPE_CAPTION = "caption";
public static final String TYPE_PAGE = "Page";
public static final String TYPE_BLOCK = "Block";
public static final String TYPE_LINE = "Line";
public static final String TYPE_WORD = "Word";
public static final String TYPE_MEDIA = "Media";
public static final String TYPE_CAPTION = "Caption";
public static final String TYPE_UNDEFINED = "undefined";
private static final String PROFILE_IS = ";profile=\"";

public static List<String> GRANULARITY_VALUES = new ArrayList<>(
List.of(TYPE_PAGE, TYPE_BLOCK, TYPE_LINE, TYPE_WORD, TYPE_MEDIA, TYPE_CAPTION));

/**
* Media type for IIIF version 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private ResponseEntity<String> annotation(String datasetId,
* @throws SerializationException when serialising to JsonLd fails
*/
@GetMapping(value = "/{datasetId}/{localId}/{resId}", headers = ACCEPT_JSONLD,
produces = MEDIA_TYPE_JSONLD + ";" + UTF_8)
produces = MEDIA_TYPE_JSONLD + ';' + UTF_8)
public ResponseEntity<String> resourceJsonLd(@PathVariable String datasetId,
@PathVariable String localId,
@PathVariable String resId,
Expand All @@ -340,7 +340,7 @@ public ResponseEntity<String> resourceJsonLd(@PathVariable String datasetId,
* @throws SerializationException when serialising to Json fails
*/
@GetMapping(value = "/{datasetId}/{localId}/{resId}", headers = ACCEPT_JSON,
produces = MEDIA_TYPE_JSON + ";" + UTF_8)
produces = MEDIA_TYPE_JSON + ';' + UTF_8)
public ResponseEntity<String> resourceJson(@PathVariable String datasetId,
@PathVariable String localId,
@PathVariable String resId,
Expand Down Expand Up @@ -461,7 +461,7 @@ private List<String> getTextGranularityValues(String textGranularity) {
List<String> preList = new ArrayList<>(Arrays.asList(textGranularity.split("\\+|\\s|,")));
List<String> finalList = new ArrayList<>();
for (String value : preList){
if (StringUtils.containsAny(value, TYPE_PAGE, TYPE_BLOCK, TYPE_LINE, TYPE_WORD, TYPE_MEDIA, TYPE_CAPTION)){
if (GRANULARITY_VALUES.stream().anyMatch(x -> x.equalsIgnoreCase(value))){
finalList.add(value);
}
}
Expand Down
16 changes: 15 additions & 1 deletion api/src/main/resources/fulltext.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ socks.user=[REMOVED]
socks.password=[REMOVED]

#actuator
management.endpoints.web.exposure.include=*
management.endpoints.enabled-by-default=true
management.endpoint.info.enabled=true
management.endpoint.health.enabled=true
#management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.include=httptrace
management.trace.http.include=RESPONSE_HEADERS

#server.tomcat.basedir=target/tomcat-logs
#server.tomcat.basedir = "/Users/luthien/Projects/accesslogs"
#server.tomcat.accesslog.enabled=true
#server.tomcat.accesslog.directory: "/Users/luthien/Projects/accesslogs"
#server.tomcat.accesslog.suffix=.log
#server.tomcat.accesslog.prefix=access_fulltext
#server.tomcat.accesslog.file-date-format=.dd-MM-yyyy
#server.tomcat.accesslog.pattern: "[ACCESS] %{europeana.AccessLog.RemoteAddr}r %l %t %D %F %B %S vcap_request_id:%{X-Vcap-Request-Id}i"
6 changes: 3 additions & 3 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>eu.europeana.fulltext</groupId>
<artifactId>common</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Common functionality (Mongo and Entity definitions)</name>
Expand All @@ -13,14 +13,14 @@
<parent>
<artifactId>fulltext</artifactId>
<groupId>eu.europeana</groupId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>

<dependencies>
Expand Down
6 changes: 3 additions & 3 deletions loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<artifactId>fulltext</artifactId>
<groupId>eu.europeana</groupId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>eu.europeana.fulltext</groupId>
<artifactId>loader</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<packaging>war</packaging>

<name>Europeana Newspapers Fulltext Loader</name>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>eu.europeana.fulltext</groupId>
<artifactId>api</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>

Expand Down
24 changes: 13 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
</parent>

<artifactId>fulltext</artifactId>
<version>0.7-SNAPSHOT</version>
<version>0.8-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Europeana Newspapers Fulltext API &amp; Loader</name>
<description>Europeana Newspapers Fulltext API &amp; Loader (Spring Boot applications)</description>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.1.7.RELEASE</spring-boot.version>
Expand All @@ -35,6 +35,7 @@
<wiremock.version>2.18.0</wiremock.version>
<unitils.version>3.4.6</unitils.version>
<snappy.version>1.1.7.2</snappy.version>
<apiCommons.version>0.2.10</apiCommons.version>
</properties>

<modules>
Expand All @@ -57,13 +58,14 @@
</dependency>

<!-- we should check if this dependency needs to be updated now and then-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RC2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- well, probably not ... and good riddance ;) -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-dependencies</artifactId>-->
<!-- <version>Finchley.RC2</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->

<dependency>
<groupId>dev.morphia.morphia</groupId>
Expand Down