Commit c0972333 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'update-jetty-9.4.30' into 'master'

Update jetty 9.4.30

See merge request genesys-pgr/genesys-server!558
parents 60813fdd d2540890
#
# Build Genesys server on top of jetty-alpine
# Build Genesys server on top of jetty
#
FROM jetty:9.4.27-jre8
FROM jetty:9.4.30-jre8
LABEL maintainer "Matija Obreza <matija.obreza@croptrust.org>"
......
......@@ -95,7 +95,7 @@
<swagger.version>2.9.2</swagger.version>
<!--Container -->
<jetty.version>9.4.27.v20200227</jetty.version>
<jetty.version>9.4.30.v20200611</jetty.version>
<maven.test.skip>false</maven.test.skip>
......@@ -758,7 +758,7 @@
<plugin>
<inherited>true</inherited>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.8.1</version>
<configuration>
<source>${jdk.source}</source>
<target>${jdk.target}</target>
......
......@@ -21,8 +21,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.ValidationException;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.api.ModelValidationException;
import org.genesys2.server.api.Pagination;
......@@ -111,7 +109,7 @@ public class KPIController extends ApiBaseController {
* @throws ValidationException
*/
@RequestMapping(value = "/parameter", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody KPIParameter createParameter(@RequestBody KPIParameter parameter) throws ValidationException {
public @ResponseBody KPIParameter createParameter(@RequestBody KPIParameter parameter) {
LOG.info("Updating parameter: {}", parameter.getName());
final Validator validator = new Validator();
final List<ConstraintViolation> violations = validator.validate(parameter);
......@@ -168,7 +166,7 @@ public class KPIController extends ApiBaseController {
* @throws ValidationException
*/
@RequestMapping(value = "/dimension", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody Dimension<?> updateBooleanDimension(@RequestBody Dimension<?> dimension) throws ValidationException {
public @ResponseBody Dimension<?> updateBooleanDimension(@RequestBody Dimension<?> dimension) {
LOG.info("Updating dimension: {}", dimension.getName());
final Validator validator = new Validator();
final List<ConstraintViolation> violations = validator.validate(dimension);
......@@ -258,7 +256,7 @@ public class KPIController extends ApiBaseController {
* @throws ValidationException
*/
@RequestMapping(value = "/execution", method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ExecutionJson updateExecution(@RequestBody ExecutionJson ej) throws ValidationException {
public @ResponseBody ExecutionJson updateExecution(@RequestBody ExecutionJson ej) {
LOG.info("Updating execution: {}", ej.title);
final Validator validator = new Validator();
final List<ConstraintViolation> violations = validator.validate(ej);
......
......@@ -18,8 +18,6 @@ package org.genesys2.server.api.v0;
import java.util.List;
import javax.xml.bind.ValidationException;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.api.ModelValidationException;
import org.genesys2.server.exception.AuthorizationException;
......@@ -82,7 +80,7 @@ public class CropsController extends ApiBaseController {
* @throws ValidationException
*/
@RequestMapping(value = { "/save" }, method = { RequestMethod.PUT, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public Crop saveCrop(@RequestBody Crop cropJson) throws ValidationException {
public Crop saveCrop(@RequestBody Crop cropJson) {
LOG.info("Creating crop");
final Validator validator = new Validator();
final List<ConstraintViolation> violations = validator.validate(cropJson);
......
......@@ -22,8 +22,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
import javax.xml.bind.ValidationException;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.api.ModelValidationException;
import org.genesys2.server.exception.AuthorizationException;
......@@ -85,7 +83,7 @@ public class OrganizationController extends ApiBaseController {
*/
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
PGRFANetwork updateOrganization(@RequestBody PGRFANetwork organizationJson) throws ValidationException {
PGRFANetwork updateOrganization(@RequestBody PGRFANetwork organizationJson) {
final Validator validator = new Validator();
final List<ConstraintViolation> violations = validator.validate(organizationJson);
if (violations.size() > 0) {
......
......@@ -81,6 +81,11 @@ public class RepositoryDownloadController {
return;
}
data = this.byteStorageService.get(path.resolve(filename));
if (data == null) {
throw new NotFoundElement("No thumbnail at " + path.resolve(filename));
}
response.setDateHeader(HttpHeaders.LAST_MODIFIED, repositoryFile.getLastModifiedDate().getTime());
response.setHeader(HttpHeaders.ETAG, repositoryFile.getSha1Sum());
response.setContentType(ImageGalleryService.THUMB_CONTENT_TYPE);
......@@ -96,11 +101,6 @@ public class RepositoryDownloadController {
throw new NotFoundElement("No file for thumb " + name);
}
data = this.byteStorageService.get(path.resolve(filename));
if (data == null) {
throw new NotFoundElement("No thumbnail at " + path.resolve(filename));
}
} else {
// Regular repository file
......
......@@ -294,36 +294,28 @@ public class WorldClimUpdater implements InitializingBean {
* @throws IOException
*/
public File download(String fileName) throws IOException {
InputStream istream = null;
OutputStream ostream = null;
File tempFile = File.createTempFile("worldclim", ".zip");
final CloseableHttpClient httpclient = HttpClientBuilder.create().build();
final HttpGet httpget = new HttpGet(WORLDCLIM_ORG_FILEBASE + fileName);
HttpResponse response = null;
try {
response = httpclient.execute(httpget);
try (CloseableHttpClient httpclient = HttpClientBuilder.create().build()) {
HttpResponse response = httpclient.execute(new HttpGet(WORLDCLIM_ORG_FILEBASE + fileName));
// Get hold of the response entity
final HttpEntity entity = response.getEntity();
LOG.debug("{} {}", entity.getContentType(), entity.getContentLength());
istream = new BufferedInputStream(entity.getContent());
ostream = new BufferedOutputStream(new FileOutputStream(tempFile));
LOG.info("Downloading {} {}", fileName, entity.getContentLength());
IOUtils.copy(istream, ostream);
ostream.flush();
LOG.info("Retrieved {}", fileName);
try (InputStream istream = new BufferedInputStream(entity.getContent()); OutputStream ostream = new BufferedOutputStream(new FileOutputStream(tempFile))) {
LOG.info("Downloading {} {}", fileName, entity.getContentLength());
IOUtils.copy(istream, ostream);
ostream.flush();
LOG.info("Retrieved {}", fileName);
}
} catch (final ClientProtocolException e) {
LOG.error(e.getMessage(), e);
tempFile.delete();
throw new IOException(e);
} finally {
IOUtils.closeQuietly(istream);
IOUtils.closeQuietly(ostream);
IOUtils.closeQuietly(httpclient);
}
return tempFile;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment