diff --git a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java index 650116b1fd93c2bc9336f70221d1342942c2f7a1..e72ba07aaf4f5667aed62be19d4e2425b2aa9c75 100644 --- a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java @@ -6,18 +6,13 @@ package eu.hbp.mip.controllers; import com.github.slugify.Slugify; -import eu.hbp.mip.model.Article; -import io.swagger.annotations.*; -import org.apache.log4j.Logger; import eu.hbp.mip.configuration.SecurityConfiguration; +import eu.hbp.mip.model.Article; import eu.hbp.mip.model.User; import eu.hbp.mip.repositories.ArticleRepository; +import io.swagger.annotations.*; +import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; -import org.springframework.context.annotation.Scope; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -32,7 +27,6 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController @RequestMapping(value = "/articles", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/articles", description = "the articles API") -@Scope("session") public class ArticlesApi { private static final Logger LOGGER = Logger.getLogger(ArticlesApi.class); @@ -44,7 +38,6 @@ public class ArticlesApi { private ArticleRepository articleRepository; @ApiOperation(value = "Get articles", response = Article.class, responseContainer = "List") - @Cacheable(value = "Articles", key = "(#own != null and #own).toString() + #status + #root.target") @RequestMapping(method = RequestMethod.GET) public ResponseEntity<Iterable> getArticles( @ApiParam(value = "Only ask own articles") @RequestParam(value = "own", required = false) Boolean own, @@ -82,13 +75,6 @@ public class ArticlesApi { @ApiOperation(value = "Create an article") @ApiResponses(value = { @ApiResponse(code = 201, message = "Article created") }) - @CachePut(value = "Article", key = "#article.getSlug() + #root.target") - @Caching(evict = { - @CacheEvict(value = "Articles", key = "'false' + 'draft' + #root.target"), - @CacheEvict(value = "Articles", key = "'false' + 'published' + #root.target"), - @CacheEvict(value = "Articles", key = "'true' + 'draft' + #root.target"), - @CacheEvict(value = "Articles", key = "'true' + 'published' + #root.target") - }) @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Void> addAnArticle( @RequestBody @ApiParam(value = "Article to create", required = true) @Valid Article article @@ -150,7 +136,6 @@ public class ArticlesApi { @ApiOperation(value = "Get an article", response = Article.class) - @Cacheable(value = "Article", key = "#slug + #root.target") @RequestMapping(value = "/{slug}", method = RequestMethod.GET) public ResponseEntity<Article> getAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug @@ -178,13 +163,6 @@ public class ArticlesApi { @ApiOperation(value = "Update an article") @ApiResponses(value = { @ApiResponse(code = 204, message = "Article updated") }) - @CachePut(value = "Article", key = "#slug + #root.target") - @Caching(evict = { - @CacheEvict(value = "Articles", key = "'false' + 'draft' + #root.target"), - @CacheEvict(value = "Articles", key = "'false' + 'published' + #root.target"), - @CacheEvict(value = "Articles", key = "'true' + 'draft' + #root.target"), - @CacheEvict(value = "Articles", key = "'true' + 'published' + #root.target") - }) @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, diff --git a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java index 1cce4e2526a3fb3e432e57e4df71c8a6da98ebed..ada7e3b85d5738205036bdad2103512e089cad17 100644 --- a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java @@ -17,11 +17,6 @@ import io.swagger.annotations.*; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.cache.annotation.Caching; -import org.springframework.context.annotation.Scope; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -34,7 +29,6 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController @RequestMapping(value = "/models", produces = {APPLICATION_JSON_VALUE}) @Api(value = "/models", description = "the models API") -@Scope("session") public class ModelsApi { private static final Logger LOGGER = Logger.getLogger(ModelsApi.class); @@ -63,7 +57,6 @@ public class ModelsApi { @ApiOperation(value = "Get models", response = Model.class, responseContainer = "List") - @Cacheable(value = "Models", key = "(#own != null and #own).toString() + (#valid != null and #valid).toString() + #root.target") @RequestMapping(method = RequestMethod.GET) public ResponseEntity<List> getModels( @ApiParam(value = "Only ask own models") @RequestParam(value = "own", required = false) Boolean own, @@ -108,13 +101,6 @@ public class ModelsApi { @ApiOperation(value = "Create a model", response = Model.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Model created") }) - @CachePut(value = "Model", key = "#model.getSlug() + #root.target") - @Caching(evict = { - @CacheEvict(value = "Models", key = "'false' + 'false' + #root.target"), - @CacheEvict(value = "Models", key = "'false' + 'true' + #root.target"), - @CacheEvict(value = "Models", key = "'true' + 'false' + #root.target"), - @CacheEvict(value = "Models", key = "'true' + 'true' + #root.target") - }) @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Model> addAModel( @RequestBody @ApiParam(value = "Model to create", required = true) Model model @@ -201,7 +187,6 @@ public class ModelsApi { } @ApiOperation(value = "Get a model", response = Model.class) - @Cacheable(value = "model", key = "#slug + #root.target") @RequestMapping(value = "/{slug}", method = RequestMethod.GET) public ResponseEntity<Model> getAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug @@ -233,13 +218,6 @@ public class ModelsApi { @ApiOperation(value = "Update a model", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Model updated") }) - @CachePut(value = "model", key = "#slug + #root.target") - @Caching(evict = { - @CacheEvict(value = "Models", key = "'false' + 'false' + #root.target"), - @CacheEvict(value = "Models", key = "'false' + 'true' + #root.target"), - @CacheEvict(value = "Models", key = "'true' + 'false' + #root.target"), - @CacheEvict(value = "Models", key = "'true' + 'true' + #root.target") - }) @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,