Skip to content

Commit

Permalink
Merge pull request #117 from FAIRDataTeam/release/1.8.0
Browse files Browse the repository at this point in the history
Release 1.8.0
  • Loading branch information
MarekSuchanek authored Mar 10, 2021
2 parents 818a703 + 668d4c0 commit 795a061
Show file tree
Hide file tree
Showing 51 changed files with 1,912 additions and 241 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.github
.idea
src
LICENSE
README.ms
docs
target/**
!target/fdp-spring-boot.jar
!target/classes/application-production.yml
nb-configuration.xml
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
target-branch: "develop"
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
PRIVATE_IMAGE: ${{ secrets.PRIVATE_REGISTRY_URL }}/fairdatapoint
TAG_DEVELOP: develop
TAG_LATEST: latest
JDK_VERSION: 11
JDK_FILE: openjdk-14.0.1_linux-x64_bin.tar.gz
JDK_URL: https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_linux-x64_bin.tar.gz
JDK_VERSION: 15
JDK_FILE: openjdk-15.0.2_linux-x64_bin.tar.gz
JDK_URL: https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz

services:
mongo:
Expand Down Expand Up @@ -48,17 +48,17 @@ jobs:
key: ${{ env.JDK_FILE }}

# (2) -> Prepare Java
- name: Download Oracle JDK
- name: Download JDK
run: |
if [ ! -f ~/jdk/$JDK_FILE ]; then
wget --quiet $JDK_URL -O ~/jdk/$JDK_FILE
fi
cp ~/jdk/$JDK_FILE .
- name: Setup Java
uses: actions/setup-java@master
uses: actions/setup-java@v1
with:
version: ${{ env.JDK_VERSION }}
java-version: ${{ env.JDK_VERSION }}
jdkFile: ${{ env.JDK_FILE }}

- name: Verify Maven and Java
Expand Down
25 changes: 23 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.8.0]

### Added

- Denylist for FDP Index pings
- Endpoints for managing Index settings from [Client]

### Changed

- Upgrade Java JDK from 14 to 15
- Rate limits use forwarded IP by proxy based on config
- Index settings are moved to the database
- Admin trigger now accepts the same DTO as ping

### Fixed

- Fix metadata not found error

## [1.7.0]

### Added
Expand Down Expand Up @@ -155,4 +173,7 @@ The first release of reference FAIR Data Point implementation.
[1.4.0]: /../../tree/v1.4.0
[1.5.0]: /../../tree/v1.5.0
[1.6.0]: /../../tree/v1.6.0

[1.7.0]: /../../tree/v1.7.0

[1.8.0]: /../../tree/v1.8.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# THE SOFTWARE.
#

FROM openjdk:14-jdk-slim
FROM openjdk:15-jdk-slim

WORKDIR /fdp

Expand Down
42 changes: 42 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# The MIT License
# Copyright © 2017 DTL
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
################################################################################
# BUILD STAGE
FROM maven:3-openjdk-15 as builder

WORKDIR /builder

ADD . /builder

RUN mvn --quiet -B -U --fail-fast -DskipTests package

################################################################################
# RUN STAGE
FROM openjdk:15-jdk-slim

WORKDIR /fdp

COPY --from=builder /builder/target/fdp-spring-boot.jar /fdp/app.jar
COPY --from=builder /builder/target/classes/application-production.yml /fdp/application.yml

ENTRYPOINT java -jar app.jar --spring.profiles.active=production --spring.config.location=classpath:/application.yml,classpath:/application-production.yml,file:/fdp/application.yml
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ More information about FDP and how to deploy can be found at [FDP Deployment Doc

**Stack:**

- **Java** (minimally JDK 14, or higher)
- **Maven** (recommended 3.2.5 or higher)
- **Docker** (recommended 17.09.0-ce or higher) - *for build of production image*
- **Java** (minimal: JDK 15)
- **Maven** (recommended: 3.2.5 or higher)
- **Docker** (recommended: 17.09.0-ce or higher) - *for build of production image*

### Build & Run

To run the application, a mongodb instance is required to be running. To configure the mongodb address, instruct spring-boot to use the `development` profile. Run these commands from the root of the project.
To run the application, a MongoDB instance is required to be running. To configure the mongodb address, instruct spring-boot to use the `development` profile. Run these commands from the root of the project.

```bash
$ mvn spring-boot:run -Dspring-boot.run.profiles=development
Expand All @@ -40,26 +40,34 @@ $ mvn spring-boot:run

### Run tests

Run these commands from the root of the project
Run these commands from the root of the project:

```bash
$ mvn test
```

### Package the application

Run these commands from the root of the project
Run these commands from the root of the project:

```bash
$ mvn package
```

### Create a Docker image

Run these commands from the root of the project
Run these commands from the root of the project (requires building jar file using `mvn package`):

```bash
$ docker build -t fairdata/fairdatapoint .
$ docker build -t fairdatapoint:local .
```

### Build using Docker

If you do not have Java and Maven locally, you can build the Docker image using Docker (instead of using locally built jar file):

```bash
$ docker build -f Dockefile.build -t fairdatapoint:local .
```

## Security
Expand Down
27 changes: 21 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>nl.dtls</groupId>
<artifactId>fairdatapoint</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<packaging>jar</packaging>

<name>FairDataPoint</name>
Expand Down Expand Up @@ -41,8 +41,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!-- Maven -->
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>

<!-- Project related -->
<spring.rdf.migration.version>1.1.0.RELEASE</spring.rdf.migration.version>
Expand All @@ -54,15 +54,15 @@
<logback.version>1.2.3</logback.version>
<rdf4j.version>3.0.0</rdf4j.version>
<unirest.version>1.4.9</unirest.version>
<jwt.version>0.10.5</jwt.version>
<lombok.version>1.18.10</lombok.version>
<jwt.version>0.11.2</jwt.version>
<lombok.version>1.18.18</lombok.version>

<!-- Plugins -->
<plugin.license.version>3.0</plugin.license.version>
<plugin.jacoco.version>0.7.6.201602180812</plugin.jacoco.version>
<plugin.coveralls.version>4.3.0</plugin.coveralls.version>
<plugin.javax_xml_bind.version>2.3.1</plugin.javax_xml_bind.version>
<plugin.git_commit_id.version>2.2.4</plugin.git_commit_id.version>
<plugin.git_commit_id.version>4.0.3</plugin.git_commit_id.version>
<plugin.rdf4j_generator.version>0.2.0</plugin.rdf4j_generator.version>
</properties>

Expand Down Expand Up @@ -315,6 +315,21 @@
<verbose>false</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<excludes>
<exclude>**/*Fixtures.java</exclude>
<exclude>**/*Config.java</exclude>
<exclude>**/Common.java</exclude>
<exclude>**/common/*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.github.kburger</groupId>
<artifactId>rdf4j-generator-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import nl.dtls.fairdatapoint.api.dto.index.ping.PingDTO;
import nl.dtls.fairdatapoint.entity.index.event.Event;
import nl.dtls.fairdatapoint.service.UtilityService;
import nl.dtls.fairdatapoint.service.index.event.EventService;
import nl.dtls.fairdatapoint.service.index.webhook.WebhookService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -33,13 +35,17 @@
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.UUID;

@Log4j2
@RestController
@RequestMapping("/index/admin")
public class AdminController {

@Autowired
private UtilityService utilityService;

@Autowired
private EventService eventService;

Expand All @@ -50,9 +56,20 @@ public class AdminController {
@PostMapping("/trigger")
@PreAuthorize("hasRole('ADMIN')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void triggerMetadataRetrieve(@RequestParam(required = false) String clientUrl, HttpServletRequest request) {
log.info("Received ping from {}", request.getRemoteAddr());
final Event event = eventService.acceptAdminTrigger(request, clientUrl);
public void triggerMetadataRetrieve(@RequestBody @Valid PingDTO reqDto, HttpServletRequest request) {
log.info("Received ping from {}", utilityService.getRemoteAddr(request));
final Event event = eventService.acceptAdminTrigger(request, reqDto);
webhookService.triggerWebhooks(event);
eventService.triggerMetadataRetrieval(event);
}

@ApiOperation(value = "trigger-all", hidden = true)
@PostMapping("/trigger-all")
@PreAuthorize("hasRole('ADMIN')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void triggerMetadataRetrieveAll(HttpServletRequest request) {
log.info("Received ping from {}", utilityService.getRemoteAddr(request));
final Event event = eventService.acceptAdminTriggerAll(request);
webhookService.triggerWebhooks(event);
eventService.triggerMetadataRetrieval(event);
}
Expand All @@ -62,7 +79,7 @@ public void triggerMetadataRetrieve(@RequestParam(required = false) String clien
@PreAuthorize("hasRole('ADMIN')")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void webhookPing(@RequestParam(required = true) UUID webhook, HttpServletRequest request) {
log.info("Received webhook {} ping trigger from {}", webhook, request.getRemoteAddr());
log.info("Received webhook {} ping trigger from {}", webhook, utilityService.getRemoteAddr(request));
final Event event = webhookService.handleWebhookPing(request, webhook);
webhookService.triggerWebhooks(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@
import nl.dtls.fairdatapoint.api.dto.index.entry.IndexEntryDTO;
import nl.dtls.fairdatapoint.api.dto.index.entry.IndexEntryDetailDTO;
import nl.dtls.fairdatapoint.api.dto.index.entry.IndexEntryInfoDTO;
import nl.dtls.fairdatapoint.service.index.entry.IndexEntryMapper;
import nl.dtls.fairdatapoint.service.index.entry.IndexEntryService;
import nl.dtls.fairdatapoint.service.index.event.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

@RestController
@RequestMapping("/index/entries")
Expand All @@ -45,27 +42,26 @@ public class IndexEntryController {
@Autowired
private IndexEntryService service;

@Autowired
private EventService eventService;

@Autowired
private IndexEntryMapper mapper;

@GetMapping("")
public Page<IndexEntryDTO> getEntriesPage(Pageable pageable,
@RequestParam(required = false, defaultValue = "") String state) {
return service.getEntriesPage(pageable, state).map(mapper::toDTO);
return service.getEntriesPageDTOs(pageable, state);
}

@RequestMapping(value = "/{uuid}", method = RequestMethod.GET)
public Optional<IndexEntryDetailDTO> getEntry(@PathVariable final String uuid) {
return service.getEntry(uuid).map(entry -> mapper.toDetailDTO(entry,
eventService.getEvents(entry.getUuid())));
return service.getEntryDetailDTO(uuid);
}

@RequestMapping(value = "/{uuid}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteEntry(@PathVariable final String uuid) {
service.deleteEntry(uuid);
}

@GetMapping("/all")
public List<IndexEntryDTO> getEntriesAll() {
return StreamSupport.stream(service.getAllEntries().spliterator(), true).map(mapper::toDTO).collect(Collectors.toList());
return service.getAllEntriesAsDTOs();
}

@GetMapping("/info")
Expand Down
Loading

0 comments on commit 795a061

Please sign in to comment.