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

Introduce conditional controller instances (v3) #180

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -2,10 +2,11 @@

import de.terrestris.shoguncore.model.Application;
import de.terrestris.shoguncore.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 @@ -2,20 +2,31 @@

import de.terrestris.shoguncore.model.File;
import de.terrestris.shoguncore.service.FileService;
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
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.*;
import org.springframework.web.bind.annotation.*;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ResponseStatusException;

import java.util.UUID;

@RestController
@RequestMapping("/files")
@ConditionalOnExpression("${controller.files.enabled:true}")
public class FileController {

protected final Logger LOG = LogManager.getLogger(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import de.terrestris.shoguncore.model.Group;
import de.terrestris.shoguncore.service.GroupService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/groups")
public class GroupController extends BaseController<GroupService, Group> {
}
@ConditionalOnExpression("${controller.groups.enabled:true}")
public class GroupController extends BaseController<GroupService, Group> { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import de.terrestris.shoguncore.model.ImageFile;
import de.terrestris.shoguncore.service.ImageFileService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/imagefiles")
public class ImageFileController extends BaseController<ImageFileService, ImageFile> {
}
@ConditionalOnExpression("${controller.imagefiles.enabled:true}")
public class ImageFileController extends BaseController<ImageFileService, ImageFile> { }
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import de.terrestris.shoguncore.model.Layer;
import de.terrestris.shoguncore.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")
public class LayerController extends BaseController<LayerService, Layer> {
}
@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,10 +2,11 @@

import de.terrestris.shoguncore.model.Role;
import de.terrestris.shoguncore.service.RoleService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/roles")
public class RoleController extends BaseController<RoleService, Role> {
}
@ConditionalOnExpression("${controller.roles.enabled:true}")
public class RoleController extends BaseController<RoleService, Role> { }
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.env.Environment;
Expand All @@ -33,6 +34,7 @@

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

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
import de.terrestris.shoguncore.service.GroupService;
import de.terrestris.shoguncore.service.UserService;
import de.terrestris.shoguncore.service.security.IdentityService;
import java.util.List;
import java.util.Optional;
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.RestController;
import org.springframework.web.server.ResponseStatusException;

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

@RestController
@RequestMapping("/identities")
@ConditionalOnExpression("${controller.identities.enabled:true}")
public class IdentityController extends BaseController<IdentityService, Identity> {

@Autowired
Expand Down