Skip to content

Commit

Permalink
Make controller bean creation configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlkoch committed Jan 29, 2021
1 parent 35fd694 commit 33446ba
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
16 changes: 16 additions & 0 deletions shogun-config/src/main/resources/application-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ keycloakauth:
master-realm: master
admin-client: admin-cli

controller:
applications:
enabled: true
cache:
enabled: true
files:
enabled: true
groups:
enabled: true
imagefiles:
enabled: true
layers:
enabled: true
users:
enabled: true

upload:
file:
supportedContentTypes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import de.terrestris.shogun.lib.model.Application;
import de.terrestris.shogun.lib.service.ApplicationService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/applications")
public class ApplicationController extends BaseController<ApplicationService, Application> {
}
@ConditionalOnExpression("${controller.applications.enabled:true}")
public class ApplicationController extends BaseController<ApplicationService, Application> { }
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.terrestris.shogun.lib.service.CacheService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
Expand All @@ -15,6 +16,7 @@
@Log4j2
@RestController
@RequestMapping("/cache")
@ConditionalOnExpression("${controller.cache.enabled:true}")
public class CacheController {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import de.terrestris.shogun.lib.model.File;
import de.terrestris.shogun.lib.service.FileService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;

@RestController
@RequestMapping("/files")
@ConditionalOnExpression("${controller.files.enabled:true}")
public class FileController extends BaseFileController<FileService, File> { }
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
import de.terrestris.shogun.lib.model.User;
import de.terrestris.shogun.lib.service.GroupService;
import de.terrestris.shogun.lib.service.UserService;
import java.util.List;
import java.util.Optional;
import org.keycloak.representations.idm.GroupRepresentation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("/groups")
@ConditionalOnExpression("${controller.groups.enabled:true}")
public class GroupController extends BaseController<GroupService, Group> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@

import de.terrestris.shogun.lib.model.ImageFile;
import de.terrestris.shogun.lib.service.ImageFileService;
import java.util.Optional;
import java.util.UUID;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.*;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

import java.util.Optional;
import java.util.UUID;

@RestController
@RequestMapping("/imagefiles")
@ConditionalOnExpression("${controller.imagefiles.enabled:true}")
public class ImageFileController extends BaseFileController<ImageFileService, ImageFile> {

@GetMapping("/{fileUuid}/thumbnail")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import de.terrestris.shogun.lib.model.Layer;
import de.terrestris.shogun.lib.service.LayerService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/layers")
@ConditionalOnExpression("${controller.layers.enabled:true}")
public class LayerController extends BaseController<LayerService, Layer> { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import de.terrestris.shogun.lib.model.User;
import de.terrestris.shogun.lib.service.UserService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
@ConditionalOnExpression("${controller.users.enabled:true}")
public class UserController extends BaseController<UserService, User> { }

0 comments on commit 33446ba

Please sign in to comment.