Skip to content

Commit

Permalink
Merge pull request #3 from openminted/version/3.0.2
Browse files Browse the repository at this point in the history
Version/3.0.2
  • Loading branch information
courado authored Jun 25, 2018
2 parents 416faf0 + ed8d7d5 commit 8743531
Show file tree
Hide file tree
Showing 24 changed files with 77 additions and 41 deletions.
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>eu.openminted</groupId>
<artifactId>omtd-registry-rest</artifactId>
<version>2.0.3-SNAPSHOT</version>

<version>2.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>eu.openminted</groupId>
Expand Down Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.0.0</version>
<version>5.6.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down Expand Up @@ -128,6 +128,11 @@
<artifactId>tika-core</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service;
package eu.openminted.registry.controllers;

import eu.openminted.registry.core.domain.Browsing;
import eu.openminted.registry.core.domain.FacetFilter;
Expand All @@ -9,7 +9,6 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.domain.Component;
import eu.openminted.registry.service.ValidateInterface;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/request/application")
@Api(value = "/request/application", description = "Operations about OMTD Applications.", tags="Applications")
public class ApplicationController extends OmtdRestController<Component>{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.domain.Component;
import eu.openminted.registry.service.ValidateInterface;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/request/component")
@Api(value = "/request/component", description = "Operations about OMTD Components.", tags="Components")
public class ComponentController extends OmtdRestController<Component>{

private ValidateInterface<Component> validateInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.core.domain.Browsing;
import eu.openminted.registry.domain.Corpus;
Expand All @@ -9,6 +9,7 @@
import eu.openminted.registry.service.CorpusService;
import eu.openminted.registry.service.StoreService;
import eu.openminted.registry.service.ValidateInterface;
import io.swagger.annotations.Api;
import org.apache.commons.io.IOUtils;
import org.apache.tika.exception.TikaException;
import org.apache.tika.parser.ParseContext;
Expand All @@ -29,13 +30,13 @@

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Response;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

@RestController
@RequestMapping("/request/corpus")
@Api(value = "/request/corpus", description = "Operations about OMTD Corpora.",tags="Corpora")
public class CorpusController extends OmtdRestController<Corpus> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.domain.Corpus;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.controllers.GenericRestController;
import eu.openminted.registry.service.IncompleteCorpusService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/request/incompleteCorpus")
@Api(value = "/request/incompleteCorpus", description = "Operations about OMTD Incomplete corpora.", hidden = true)
@ApiIgnore
public class IncompleteCorpusController extends GenericRestController<Corpus> {

final private IncompleteCorpusService corpusService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.domain.LanguageDescription;
import eu.openminted.registry.service.AncillaryService;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.controllers.GenericRestController;
import eu.openminted.registry.service.StoreService;
import eu.openminted.registry.service.ValidateInterface;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -21,6 +22,7 @@
*/
@RestController
@RequestMapping("/request/language")
@Api(value = "/request/language", description = "Operations about OMTD Models and Grammars.",tags="Models and Grammars")
public class LanguageController extends GenericRestController<LanguageDescription> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.domain.Lexical;
import eu.openminted.registry.service.AncillaryService;
import eu.openminted.registry.service.StoreService;
import eu.openminted.registry.service.ValidateInterface;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -20,6 +21,7 @@
*/
@RestController
@RequestMapping("/request/lexical")
@Api(value = "/request/lexical", description = "Operations about OMTD Annotation Resources.", tags="Annotation Resources")
public class LexicalController extends OmtdRestController<Lexical> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.core.exception.ServerError;
import org.apache.logging.log4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package eu.openminted.registry.service.omtd;
package eu.openminted.registry.controllers.omtd;

import eu.openminted.registry.core.exception.ResourceNotFoundException;
import eu.openminted.registry.core.service.ServiceException;
import eu.openminted.registry.domain.*;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.controllers.GenericRestController;
import eu.openminted.registry.service.ValidateInterface;
import eu.openminted.registry.service.policy.PolicyInterface;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PostAuthorize;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package eu.openminted.registry.service.other;
package eu.openminted.registry.controllers.other;

import eu.openminted.corpus.CorpusBuildingState;
import eu.openminted.registry.core.exception.ResourceNotFoundException;
import eu.openminted.registry.core.service.ResourceCRUDService;
import eu.openminted.registry.service.CorpusBuildingStatusService;
import eu.openminted.registry.service.GenericRestController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -17,10 +18,11 @@

@RestController
@RequestMapping("/request/corpusbuildingstate")
@Api(value = "/request/corpusbuildingstate", description = "Operations about OMTD corpus building states.", tags="Corpus Building State")
public class CorpusBuildingStateController extends OtherRestController<CorpusBuildingState> {

@Autowired
CorpusBuildingStateController(ResourceCRUDService<CorpusBuildingState> service) {
CorpusBuildingStateController(@Qualifier("corpusBuildingStateService") ResourceCRUDService<CorpusBuildingState> service) {
super(service);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package eu.openminted.registry.service.other;
package eu.openminted.registry.controllers.other;

import eu.openminted.registry.core.service.ResourceCRUDService;
import eu.openminted.registry.domain.operation.Operation;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.service.OperationService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -17,7 +17,8 @@
*/

@RestController
@RequestMapping({"operation", "/request/operation"})
@RequestMapping({"/request/operation"})
@Api(value = "/request/operation", description = "Creates and controls the operations executed on Galaxy", tags="Operations")
public class OperationController extends OtherRestController<Operation> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package eu.openminted.registry.service.other;
package eu.openminted.registry.controllers.other;

import eu.openminted.registry.core.exception.ResourceNotFoundException;
import eu.openminted.registry.core.service.ResourceCRUDService;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.controllers.GenericRestController;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import springfox.documentation.annotations.ApiIgnore;

public class OtherRestController<T> extends GenericRestController<T> {

Expand All @@ -20,18 +21,21 @@ public ResponseEntity<T> get(@PathVariable("id") String id) throws ResourceNotFo
}

@Override
@ApiIgnore
@PreAuthorize("hasRole('ROLE_ADMIN') or denyAll()")
public ResponseEntity<T> update(@RequestBody T component) throws ResourceNotFoundException {
return super.update(component);
}

@Override
@ApiIgnore
@PreAuthorize("hasRole('ROLE_ADMIN') or denyAll()")
public ResponseEntity<String> delete(@RequestBody T component) throws ResourceNotFoundException {
return super.delete(component);
}

@Override
@ApiIgnore
@PreAuthorize("hasRole('ROLE_ADMIN') or denyAll()")
public ResponseEntity<T> add(@RequestBody T component) {
return super.add(component);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package eu.openminted.registry.service.other;
package eu.openminted.registry.controllers.other;

import eu.openminted.registry.core.exception.ResourceNotFoundException;
import eu.openminted.registry.core.service.ResourceCRUDService;
import eu.openminted.registry.domain.workflow.WorkflowDefinition;
import eu.openminted.registry.service.GenericRestController;
import eu.openminted.registry.service.WorkflowService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand All @@ -20,7 +22,8 @@
*/

@RestController
@RequestMapping({"workflow", "/request/workflow"})
@RequestMapping({"/request/workflow"})
@Api(value = "/request/workflow", description = "Operations about Galaxy workflows.", tags="Galaxy Workflows")
public class WorkflowDefinitionController extends OtherRestController<WorkflowDefinition> {

WorkflowService workflowService;
Expand All @@ -33,18 +36,21 @@ public class WorkflowDefinitionController extends OtherRestController<WorkflowDe

@RequestMapping(value = "create", method = RequestMethod.GET)
@PreAuthorize("hasRole('ROLE_USER')")
public ResponseEntity<WorkflowDefinition> createWorkflow() {
public ResponseEntity<WorkflowDefinition> createWorkflow(Authentication authentication) {
System.out.println(authentication);
return ResponseEntity.ok(workflowService.createWorkflow());
}

@RequestMapping(value = "update/{workflowId}", method = {RequestMethod.GET, RequestMethod.POST})
@PreAuthorize("hasRole('ROLE_USER')")
@PostAuthorize("hasRole('ROLE_ADMIN') or returnObject.body.personIdentifier==principal['sub']")
public ResponseEntity<WorkflowDefinition> updateWorkflow(@PathVariable("workflowId") String workflowID) throws ResourceNotFoundException {
return ResponseEntity.ok(workflowService.updateWorkflow(workflowID));
}

@RequestMapping(value = "restore/{workflowId}", method = {RequestMethod.GET, RequestMethod.POST})
@PreAuthorize("hasRole('ROLE_USER')")
@PostAuthorize("hasRole('ROLE_ADMIN') or returnObject.body.personIdentifier==principal['sub']")
public ResponseEntity<WorkflowDefinition> restoreWorkflow(@PathVariable("workflowId") String workflowID) throws ResourceNotFoundException {
return ResponseEntity.ok(workflowService.restoreWorkflow(workflowID));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.requests;
package eu.openminted.registry.controllers.requests;

public class AnnotationStateChangeMessage {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.requests;
package eu.openminted.registry.controllers.requests;

public class DocumentStateChangeMessage {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.requests;
package eu.openminted.registry.controllers.requests;

public class ProjectStateChangeMessage {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package eu.openminted.registry.service.tools;
package eu.openminted.registry.controllers.tools;

import eu.openminted.registry.domain.MavenComponent;
import eu.openminted.registry.service.MavenResolverService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -13,6 +14,7 @@
import java.util.List;

@RestController
@Api(description = "Resolve mvn coordinates.", tags="Maven Resolver")
public class MavenResolverController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package eu.openminted.registry.service.tools;
package eu.openminted.registry.controllers.tools;

import eu.openminted.registry.core.domain.Browsing;
import eu.openminted.registry.core.domain.FacetFilter;
import eu.openminted.registry.core.service.ResourceService;
import eu.openminted.registry.service.RequestService;
import io.swagger.annotations.Api;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand All @@ -20,6 +21,7 @@
import java.util.Map;

@RestController
@Api(description = "Search all OMTD resources", tags="Search")
public class RequestController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.openminted.registry.service.tools;
package eu.openminted.registry.controllers.tools;

import eu.openminted.registry.service.DockerService;
import eu.openminted.registry.service.StatsService;
Expand Down
Loading

0 comments on commit 8743531

Please sign in to comment.