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

Seo #942

Closed
wants to merge 10 commits into from
Closed

Seo #942

Show file tree
Hide file tree
Changes from 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ public static int extractServerPort(HttpServletRequest request) {
}
return port;
}


/**
* Returns base url sent by the client.
* The url consists of: <br/>
* <ul>
* <li> scheme - {@link #extractClientScheme(HttpServletRequest)} </li>
* <li> host - {@link #extractClientHost(HttpServletRequest)} </li>
* <li> port - {@link #extractServerPort(HttpServletRequest)} </li>
* </ul>
*/
public static String constructRequestBaseUrl(HttpServletRequest request) {

StringBuilder path = new StringBuilder();

String scheme = extractScheme(request);

int port = extractServerPort(request);

path.append (scheme);
path.append ("://");
path.append (extractHost(request));

if (!isDefaultPort(scheme, port)) {
path.append (':');
path.append (port);
}

return path.toString();
}


/**
Expand All @@ -96,25 +126,44 @@ public static String constructRequestUrl(HttpServletRequest request) {

StringBuilder url = new StringBuilder();

String scheme = extractScheme(request);

int port = extractServerPort(request);

url.append (scheme);
url.append ("://");
url.append (extractHost(request));

if (!isDefaultPort(scheme, port)) {
url.append (':');
url.append (port);
}
url.append(constructRequestBaseUrl(request));

String urlPath = request.getRequestURI();
url.append(urlPath);

return url.toString();

}


/**
* Returns url sent by the client with parameters.
* The url consists of: <br/>
* <ul>
* <li> scheme - {@link #extractClientScheme(HttpServletRequest)} </li>
* <li> host - {@link #extractClientHost(HttpServletRequest)} </li>
* <li> port - {@link #extractServerPort(HttpServletRequest)} </li>
* <li> urlPath - {@link HttpServletRequest#getRequestURI()} </li>
* <li> queryString - {@link HttpServletRequest#getQueryString()} </li>
* </ul>
*/
public static String constructRequestUrlWithParameters(HttpServletRequest request) {

StringBuilder path = new StringBuilder();

String url = constructRequestUrl(request);

String queryString = request.getQueryString();

path.append(url);

if (queryString != null) {
path.append("?").append(queryString);
}

return path.toString();
}


/**
* Is the given port a default port for the given scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,30 @@ public void extractServerPort_NO_X_FORWARDED_PORT() {
assertEquals(123, HttpServletRequestUtils.extractServerPort(request));
}


@Test
public void constructRequestBaseUrl_NON_STANDARD_PORT() {

// given
when(request.getHeader("X-FORWARDED-PROTO")).thenReturn("https");
when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl");
when(request.getIntHeader("X-FORWARDED-PORT")).thenReturn(773);

// execute & assert
assertEquals("https://saos.org.pl:773", HttpServletRequestUtils.constructRequestBaseUrl(request));
}

@Test
public void constructRequestBaseUrl_STANDARD_PORT() {

// given
when(request.getHeader("X-FORWARDED-PROTO")).thenReturn("https");
when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl");
when(request.getIntHeader("X-FORWARDED-PORT")).thenReturn(443);

// execute & assert
assertEquals("https://saos.org.pl", HttpServletRequestUtils.constructRequestBaseUrl(request));
}

@Test
public void constructRequestUrl_NON_STANDARD_PORT() {
Expand All @@ -173,8 +197,49 @@ public void constructRequestUrl_STANDARD_PORT() {
// execute & assert
assertEquals("https://saos.org.pl/search", HttpServletRequestUtils.constructRequestUrl(request));
}



@Test
public void constructRequestUrlWithParameters_NON_STANDARD_PORT() {

// given
when(request.getHeader("X-FORWARDED-PROTO")).thenReturn("https");
when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl");
when(request.getIntHeader("X-FORWARDED-PORT")).thenReturn(773);
when(request.getRequestURI()).thenReturn("/search");
when(request.getQueryString()).thenReturn("searchPhrase=orzeczenie&signatur=ii12");

// execute & assert
assertEquals("https://saos.org.pl:773/search?searchPhrase=orzeczenie&signatur=ii12", HttpServletRequestUtils.constructRequestUrlWithParameters(request));
}

@Test
public void constructRequestUrlWithParameters_STANDARD_PORT() {

// given
when(request.getHeader("X-FORWARDED-PROTO")).thenReturn("https");
when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl");
when(request.getIntHeader("X-FORWARDED-PORT")).thenReturn(443);
when(request.getRequestURI()).thenReturn("/search");
when(request.getQueryString()).thenReturn("searchPhrase=orzeczenie&signatur=ii12");

// execute & assert
assertEquals("https://saos.org.pl/search?searchPhrase=orzeczenie&signatur=ii12", HttpServletRequestUtils.constructRequestUrlWithParameters(request));
}

@Test
public void constructRequestUrlWithParameters_NO_QUERY() {

// given
when(request.getHeader("X-FORWARDED-PROTO")).thenReturn("https");
when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl");
when(request.getIntHeader("X-FORWARDED-PORT")).thenReturn(443);
when(request.getRequestURI()).thenReturn("/search");
when(request.getQueryString()).thenReturn(null);

// execute & assert
assertEquals("https://saos.org.pl/search", HttpServletRequestUtils.constructRequestUrlWithParameters(request));
}

@Test
public void isDefaultPort() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import pl.edu.icm.saos.api.services.interceptor.AccessControlHeaderHandlerInterceptor;
import pl.edu.icm.saos.api.services.interceptor.RestrictParamsHandlerInterceptor;
import pl.edu.icm.saos.persistence.service.LawJournalEntryCodeExtractor;
import pl.edu.icm.saos.webapp.common.RequestURLInterceptor;
import pl.edu.icm.saos.webapp.format.MultiWordFormatterFactory;
import pl.edu.icm.saos.webapp.format.StringTrimmingFormatter;

Expand Down Expand Up @@ -78,6 +79,7 @@ public TilesConfigurer tilesConfigurer() {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("/WEB-INF/static/").setCachePeriod(3600*24*7);
registry.addResourceHandler("/robots.txt").addResourceLocations("/WEB-INF/").setCachePeriod(0);
registry.addResourceHandler("/sitemap.xml").addResourceLocations("/WEB-INF/sitemap.xml").setCachePeriod(0);
registry.addResourceHandler("/files/judgments/**").addResourceLocations(ResourceUtils.FILE_URL_PREFIX + judgmentsContentPath).setCachePeriod(600);

}
Expand All @@ -102,6 +104,7 @@ public void addInterceptors(InterceptorRegistry registry) {
.addPathPatterns("/search/lawJournalEntries*")
.addPathPatterns("/keywords/**");
registry.addInterceptor(new RestrictParamsHandlerInterceptor());
registry.addInterceptor(new RequestURLInterceptor());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package pl.edu.icm.saos.webapp.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import pl.edu.icm.saos.common.http.HttpServletRequestUtils;

/**
* Interceptor adds to request full url with parameters
*
* @author Łukasz Pawełczak
*/
public class RequestURLInterceptor extends HandlerInterceptorAdapter {

/**
* Adds clients request url (with parameters) to request.
*/
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

request.setAttribute("requestUrlWithParameters", HttpServletRequestUtils.constructRequestUrlWithParameters(request));
return true;
}

}

25 changes: 21 additions & 4 deletions saos-webapp/src/main/resources/message/common.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
saos.shortname = SAOS
saos.fullname = System Analizy Orzeczeń Sądowych
saos.fullnameAndShortcut = System Analizy Orzeczeń Sądowych - SAOS

choose = Wybierz
more = Więcej
Expand Down Expand Up @@ -30,6 +32,10 @@ button.resetForm = Czyść formularz
button.close = Zamknij
button.look = Zobacz

meta.language = english

saos.logo.alt = portal orzeczeń polskiego sądownictwa

message.noJavascript = Obsługa języka JavaScript w przeglądarce internetowej jest wyłączona. Włącz ponownie JavaScript, aby korzystać z pełnej funkcjonalności serwisu.

/* Page titles */
Expand Down Expand Up @@ -153,7 +159,8 @@ judgment.judgmentResult = Skrócony wynik sprawy
judgment.lowerCourtJudgments = Wyroki sądu niższej instancji

/* Labels for landing page aka home */
home.meta.pageDescription = Codziennie aktualizowana otwarta baza orzeczeń polskich sądów. Szukaj, przeglądaj, analizuj.
home.meta.pageDescription = Codziennie aktualizowana otwarta baza orzeczeń polskich sądów. Szukaj, przeglądaj, analizuj orzeczenia i wyroki sądowe.
home.meta.keywords = orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
home.beta.message = Serwis znajduje się obecnie w fazie testów i dodawania ostatnich drobnych funkcjonalności. Będziemy bardzo wdzięczni za wszelkie uwagi i sugestie dotyczące działania serwisu. Prosimy o przesyłanie wszelkich opinii na adres
home.welcome.text = Serwis SAOS gromadzi i udostępnia dane orzeczeń polskich sądów. Ułatwia ich przeszukiwanie, przeglądanie oraz zbiorczą analizę. Umożliwia również pobranie metadanych i treści wszystkich zgromadzonych orzeczeń poprzez programowe API.
home.header.idea = Idea Serwisu
Expand All @@ -164,9 +171,9 @@ home.navigation.api = Programowe API
home.navigation.search.desc = Wyszukiwanie i przeglądanie orzeczeń.
home.navigation.analysis.desc = Analiza zbiorcza zgromadzonych danych.
home.navigation.api.desc = Punkt wejścia serwisów API REST<br />(dla programistów).
home.navigation.search.imageAlt = "Ikona lupy"
home.navigation.analysis.imageAlt = "Ikona wykresu"
home.navigation.api.imageAlt = "Ikona tagu"
home.navigation.search.imageAlt = Ikona lupy
home.navigation.analysis.imageAlt = Ikona wykresu
home.navigation.api.imageAlt = Ikona tagu


partners.icm.imageAlt = Logo ICM i napis UNIWERSYTET WARSZAWSKI - przeniesienie do strony ICM
Expand All @@ -187,6 +194,7 @@ context.date.anyValue = Dowolna

/* Judgment search view */
search.meta.pageDescription = Wyszukiwarka orzeczeń sądowych. Przeszukuj setki tysięcy orzeczeń polskich sądów wg dowolnych kryteriów.
search.meta.keywords = wyszukiwarka, wyszukiwarka orzeczeń, orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
judgmentSearch.form.header = Wyszukiwarka
judgmentSearch.form.moreFields = Zobacz dodatkowe pola wyszukiwania
judgmentSearch.form.lessFields = Ukryj dodatkowe pola wyszukiwania
Expand Down Expand Up @@ -288,6 +296,14 @@ courtCriteriaFormSection.hint.administrativeCourt.content = Dane nie zostały na


/* Judgment details view */
details.meta.judgment = Orzeczenie
details.meta.releasedBy.neuter = wydane przez
details.meta.releasedBy.feminine = wydana przez
details.meta.releasedBy.masculine = wydany przez
details.meta.withSignature = o sygnaturze
details.meta.judges = w składzie sędziowskim:
details.meta.nationalAppealChamber = Krajową Izbę Odwoławczą
judgmentDetails.meta.keywords = orzeczenie, portal orzeczeń
judgmentDetails.button.fullText = Zobacz pełny tekst orzeczenia
judgmentDetails.header = Orzeczenie
judgmentDetails.judgmentFullText = Pełny tekst orzeczenia
Expand Down Expand Up @@ -355,6 +371,7 @@ judgmentDetails.linkTooltip.referencedRegulations = Pokaż orzeczenia z takim po

/* Analysis */
analysis.meta.pageDescription = Wizualna analiza orzeczeń sądowych. Badaj, porównuj i analizuj trendy w polskim orzecznictwie.
analysis.meta.keywords = analiza, analiza orzeczeń, orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
analysis.header = Kryteria analizy
analysis.skipLinks.analysis = Go to analysis form
analysis.skipLinks.charts = Go to charts
Expand Down
25 changes: 21 additions & 4 deletions saos-webapp/src/main/resources/message/common_pl.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
saos.shortname = SAOS
saos.fullname = System Analizy Orzeczeń Sądowych
saos.fullnameAndShortcut = System Analizy Orzeczeń Sądowych - SAOS

choose = Wybierz
more = Więcej
Expand Down Expand Up @@ -30,6 +32,10 @@ button.resetForm = Czyść formularz
button.close = Zamknij
button.look = Zobacz

meta.language = polish

saos.logo.alt = portal orzeczeń polskiego sądownictwa

message.noJavascript = Obsługa języka JavaScript w przeglądarce internetowej jest wyłączona. Włącz ponownie JavaScript, aby korzystać z pełnej funkcjonalności serwisu.

/* Page titles */
Expand Down Expand Up @@ -153,7 +159,8 @@ judgment.judgmentResult = Skrócony wynik sprawy
judgment.lowerCourtJudgments = Wyroki sądu niższej instancji

/* Labels for landing page aka home */
home.meta.pageDescription = Codziennie aktualizowana otwarta baza orzeczeń polskich sądów. Szukaj, przeglądaj, analizuj.
home.meta.pageDescription = Codziennie aktualizowana otwarta baza orzeczeń polskich sądów. Szukaj, przeglądaj, analizuj orzeczenia i wyroki sądowe.
home.meta.keywords = orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
home.beta.message = Serwis znajduje się obecnie w fazie testów i dodawania ostatnich drobnych funkcjonalności. Będziemy bardzo wdzięczni za wszelkie uwagi i sugestie dotyczące działania serwisu. Prosimy o przesyłanie wszelkich opinii na adres
home.welcome.text = Serwis SAOS gromadzi i udostępnia dane orzeczeń polskich sądów. Ułatwia ich przeszukiwanie, przeglądanie oraz zbiorczą analizę. Umożliwia również pobranie metadanych i treści wszystkich zgromadzonych orzeczeń poprzez programowe API.
home.header.idea = Idea Serwisu
Expand All @@ -164,9 +171,9 @@ home.navigation.api = Programowe API
home.navigation.search.desc = Wyszukiwanie i przeglądanie orzeczeń.
home.navigation.analysis.desc = Analiza zbiorcza zgromadzonych danych.
home.navigation.api.desc = Punkt wejścia serwisów API REST<br />(dla programistów).
home.navigation.search.imageAlt = "Ikona lupy"
home.navigation.analysis.imageAlt = "Ikona wykresu"
home.navigation.api.imageAlt = "Ikona tagu"
home.navigation.search.imageAlt = Ikona lupy
home.navigation.analysis.imageAlt = Ikona wykresu
home.navigation.api.imageAlt = Ikona tagu

partners.icm.imageAlt = Logo ICM i napis UNIWERSYTET WARSZAWSKI - przeniesienie do strony ICM
partners.ncbir.imageAlt = Logo Narodowego Centrum Badań i Rozwoju - kliknij aby przejść do strony
Expand All @@ -186,6 +193,7 @@ context.date.anyValue = Dowolna

/* Judgment search view */
search.meta.pageDescription = Wyszukiwarka orzeczeń sądowych. Przeszukuj setki tysięcy orzeczeń polskich sądów wg dowolnych kryteriów.
search.meta.keywords = wyszukiwarka, wyszukiwarka orzeczeń, orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
judgmentSearch.form.header = Wyszukiwarka
judgmentSearch.form.moreFields = Zobacz dodatkowe pola wyszukiwania
judgmentSearch.form.lessFields = Ukryj dodatkowe pola wyszukiwania
Expand Down Expand Up @@ -287,6 +295,14 @@ courtCriteriaFormSection.hint.administrativeCourt.content = Dane nie zostały na


/* Judgment details view */
details.meta.judgment = Orzeczenie
details.meta.releasedBy.neuter = wydane przez
details.meta.releasedBy.feminine = wydana przez
details.meta.releasedBy.masculine = wydany przez
details.meta.withSignature = o sygnaturze
details.meta.judges = w składzie sędziowskim:
details.meta.nationalAppealChamber = Krajową Izbę Odwoławczą
judgmentDetails.meta.keywords = orzeczenie, portal orzeczeń
judgmentDetails.button.fullText = Zobacz pełny tekst orzeczenia
judgmentDetails.header = Orzeczenie
judgmentDetails.judgmentFullText = Pełny tekst orzeczenia
Expand Down Expand Up @@ -354,6 +370,7 @@ judgmentDetails.linkTooltip.referencedRegulations = Pokaż orzeczenia z takim po

/* Analysis */
analysis.meta.pageDescription = Wizualna analiza orzeczeń sądowych. Badaj, porównuj i analizuj trendy w polskim orzecznictwie.
analysis.meta.keywords = analiza, analiza orzeczeń, orzeczenia, saos, system analizy orzeczeń sądowych, wyroki sądowe, baza orzeczeń, orzecnictwo sądów powszechnych, orzeczenia sn, orzeczenia kio, orzeczenia tk, portal orzeczeń
analysis.header = Kryteria analizy
analysis.skipLinks.analysis = Przejdź do formularza analizy
analysis.skipLinks.charts = Przejdź do wykresów
Expand Down
4 changes: 3 additions & 1 deletion saos-webapp/src/main/resources/saos.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,6 @@ piwik.siteId = 0


# ehcache configuration file path
ehcache.configurationFilePath = classpath:ehcache.xml
ehcache.configurationFilePath = classpath:ehcache.xml


2 changes: 1 addition & 1 deletion saos-webapp/src/main/resources/saos.version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Generated by Gradle
saos.version=0.9.5
saos.version=0.9.6-SNAPSHOT
Loading