|
|
@ -1,6 +1,7 @@
|
|
|
|
package SAE.ApiREST.WebService.controller;
|
|
|
|
package SAE.ApiREST.WebService.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.hateoas.EntityModel;
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@ -13,6 +14,9 @@ import SAE.ApiREST.WebService.service.IArticleService;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
|
|
|
|
|
|
|
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
@RequestMapping("/ArticleWebService")
|
|
|
|
@RequestMapping("/ArticleWebService")
|
|
|
|
public class ArticleControler {
|
|
|
|
public class ArticleControler {
|
|
|
@ -25,10 +29,18 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response addArticle(
|
|
|
|
public @ResponseBody EntityModel<Response> addArticle(
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.addArticle(article);
|
|
|
|
Response res = articleService.addArticle(article);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).addArticle(article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
|
@ -38,11 +50,20 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article updateTitle(
|
|
|
|
public @ResponseBody EntityModel<Article> updateTitle(
|
|
|
|
@PathVariable("title") String title,
|
|
|
|
@PathVariable("title") String title,
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.updateTitle(article, title);
|
|
|
|
Article res = articleService.updateTitle(article, title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).updateTitle(title, article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByTitle(article.getTitle())).withRel("getArticlesByTitle"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
@PutMapping(
|
|
|
@ -50,11 +71,20 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article updateUrl(
|
|
|
|
public @ResponseBody EntityModel<Article> updateUrl(
|
|
|
|
@PathVariable("url") String url,
|
|
|
|
@PathVariable("url") String url,
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.updateUrl(article, url);
|
|
|
|
Article res = articleService.updateUrl(article, url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).updateUrl(url, article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByUrl(article.getUrl())).withRel("getArticlesByUrl"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
@PutMapping(
|
|
|
@ -62,11 +92,21 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article updateDatePublished(
|
|
|
|
public @ResponseBody EntityModel<Article> updateDatePublished(
|
|
|
|
@PathVariable("datePublished") String datePublished,
|
|
|
|
@PathVariable("datePublished") String datePublished,
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.updateDatePublished(article, datePublished);
|
|
|
|
Article res = articleService.updateDatePublished(article, datePublished);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).updateDatePublished(datePublished, article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedBefore(article.getDatePublished().toString())).withRel("getArticlesPublishedBefore"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedAfter(article.getDatePublished().toString())).withRel("getArticlesPublishedAfter"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
@PutMapping(
|
|
|
@ -74,11 +114,21 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article updateDateAdded(
|
|
|
|
public @ResponseBody EntityModel<Article> updateDateAdded(
|
|
|
|
@PathVariable("dateAdded") String dateAdded,
|
|
|
|
@PathVariable("dateAdded") String dateAdded,
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.updateDateAdded(article, dateAdded);
|
|
|
|
Article res = articleService.updateDateAdded(article, dateAdded);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).updateDateAdded(dateAdded, article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedBefore(article.getDateAdded().toString())).withRel("getArticlesAddedBefore"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedAfter(article.getDateAdded().toString())).withRel("getArticlesAddedAfter"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
@PutMapping(
|
|
|
@ -86,10 +136,20 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article changeVisibility(
|
|
|
|
public @ResponseBody EntityModel<Article> changeVisibility(
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.changeVisibility(article);
|
|
|
|
Article res = articleService.changeVisibility(article);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).changeVisibility(article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getVisibleArticles()).withRel("getVisibleArticle"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getInvisibleArticles()).withRel("getInvisibleArticle"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(
|
|
|
|
@PutMapping(
|
|
|
@ -97,142 +157,214 @@ public class ArticleControler {
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Article updateType(
|
|
|
|
public @ResponseBody EntityModel<Article> updateType(
|
|
|
|
@PathVariable("type") Integer type,
|
|
|
|
@PathVariable("type") Integer type,
|
|
|
|
@RequestBody Article article
|
|
|
|
@RequestBody Article article
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.updateType(article, type);
|
|
|
|
Article res = articleService.updateType(article, type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).updateType(type, article)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByType(article.getType())).withRel("getArticlesByType"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(article.getId())).withRel("deleteArticle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
|
|
|
|
|
|
|
|
// region GET
|
|
|
|
// region GET
|
|
|
|
@GetMapping(value = "/getAllArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getAllArticle", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getAllArticles() {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getAllArticles() {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getAllArticles();
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getAllArticles();
|
|
|
|
|
|
|
|
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
throw new ArticleException("No articles available");
|
|
|
|
throw new ArticleException("No articles available");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withSelfRel()
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticleById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticleById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody Article getArticlesById(@PathVariable(value = "id") Integer id) {
|
|
|
|
public @ResponseBody EntityModel<Article> getArticleById(@PathVariable(value = "id") Integer id) {
|
|
|
|
Article results = articleService.getArticlesById(id);
|
|
|
|
Article results = articleService.getArticlesById(id);
|
|
|
|
|
|
|
|
|
|
|
|
if(results == null) {
|
|
|
|
if(results == null) {
|
|
|
|
throw new ArticleException("Undefined id");
|
|
|
|
throw new ArticleException("Undefined id");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(id)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(id)).withRel("deleteArticleFromUrl")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesByTitle/{title}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesByTitle/{title}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesByTitle(@PathVariable(value = "title") String title) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesByTitle(@PathVariable(value = "title") String title) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByTitle(title);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByTitle(title);
|
|
|
|
|
|
|
|
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
throw new ArticleException("Undefined title");
|
|
|
|
throw new ArticleException("Undefined title");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByTitle(title)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromTitle(title)).withRel("deleteArticleFromTitle")
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesByUrl/{url}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesByUrl(@PathVariable(value = "url") String url) {
|
|
|
|
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByUrl(url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(results.isEmpty()) {
|
|
|
|
|
|
|
|
throw new ArticleException("Undefined title");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByUrl(url)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromUrl(url)).withRel("deleteArticleFromId")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesByType/{type}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesByType/{type}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesByType(@PathVariable(value = "type") Integer type) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesByType(@PathVariable(value = "type") Integer type) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByType(type);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesByType(type);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No content of type %d", type));
|
|
|
|
throw new ArticleException(String.format("No content of type %d", type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByType(type)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromType(type)).withRel("deleteArticleFromType")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getVisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getVisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getVisibleArticles() {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getVisibleArticles() {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getVisibleArticles();
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getVisibleArticles();
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException("No visible article");
|
|
|
|
throw new ArticleException("No visible article");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getVisibleArticles()).withSelfRel()
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getInvisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getInvisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getInvisibleArticles() {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getInvisibleArticles() {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getInvisibleArticles();
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getInvisibleArticles();
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException("No invisible article");
|
|
|
|
throw new ArticleException("No invisible article");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getInvisibleArticles()).withSelfRel()
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesAddedBefore/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesAddedBefore/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesAddedBefore(@PathVariable(value = "dateAdded") String dateAdded) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesAddedBefore(@PathVariable(value = "dateAdded") String dateAdded) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBefore(dateAdded);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBefore(dateAdded);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article added before %t", dateAdded));
|
|
|
|
throw new ArticleException(String.format("No article added before %t", dateAdded));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedBefore(dateAdded)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedBefore(dateAdded)).withRel("deleteArticleAddedBefore")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesAddedAfter/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesAddedAfter/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesAddedAfter(@PathVariable(value = "dateAdded") String dateAdded) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesAddedAfter(@PathVariable(value = "dateAdded") String dateAdded) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedAfter(dateAdded);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedAfter(dateAdded);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article added after %t", dateAdded));
|
|
|
|
throw new ArticleException(String.format("No article added after %t", dateAdded));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedAfter(dateAdded)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedAfter(dateAdded)).withRel("deleteArticleAddedAfter")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesAddedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesAddedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesAddedAfter(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesAddedBetween(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBetween(beginning, end);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesAddedBetween(beginning, end);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article added between %t and %t", beginning, end));
|
|
|
|
throw new ArticleException(String.format("No article added between %t and %t", beginning, end));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results;
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedBetween(beginning, end)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedBetween(beginning, end)).withRel("deleteArticleAddedBetween")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesPublishedBefore/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesPublishedBefore/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesPublishedBefore(@PathVariable(value = "datePublished") String datePublished) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesPublishedBefore(@PathVariable(value = "datePublished") String datePublished) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBefore(datePublished);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBefore(datePublished);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article published before %t", datePublished));
|
|
|
|
throw new ArticleException(String.format("No article published before %t", datePublished));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedBefore(datePublished)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBefore(datePublished)).withRel("deleteArticlePublishedBefore")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesPublishedAfter/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesPublishedAfter/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesPublishedAfter(@PathVariable(value = "datePublished") String datePublished) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesPublishedAfter(@PathVariable(value = "datePublished") String datePublished) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedAfter(datePublished);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedAfter(datePublished);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article published after %t", datePublished));
|
|
|
|
throw new ArticleException(String.format("No article published after %t", datePublished));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedAfter(datePublished)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedAfter(datePublished)).withRel("deleteArticlePublishedAfter")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/getArticlesPublishedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
@GetMapping(value = "/getArticlesPublishedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
|
public @ResponseBody List<Article> getArticlesPublishedAfter(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
|
|
|
public @ResponseBody EntityModel<List<Article>> getArticlesPublishedBetween(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) {
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBetween(beginning, end);
|
|
|
|
ArrayList<Article> results = (ArrayList<Article>) articleService.getArticlesPublishedBetween(beginning, end);
|
|
|
|
|
|
|
|
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
if (results.isEmpty()) {
|
|
|
|
throw new ArticleException(String.format("No article published between %t and %t", beginning, end));
|
|
|
|
throw new ArticleException(String.format("No article published between %t and %t", beginning, end));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
results,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedBetween(beginning, end)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBetween(beginning, end)).withRel("getArticlesPublishedBetween")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
@ -242,90 +374,172 @@ public class ArticleControler {
|
|
|
|
value = "/deleteArticleFromId/{id}",
|
|
|
|
value = "/deleteArticleFromId/{id}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleFromId(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleFromId(
|
|
|
|
@PathVariable("id") Integer id
|
|
|
|
@PathVariable("id") Integer id
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleFromId(id);
|
|
|
|
Response res = articleService.deleteArticleFromId(id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromId(id)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticleById(id)).withRel("getArticleById")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticleFromTitle/{title}",
|
|
|
|
value = "/deleteArticleFromTitle/{title}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleFromTitle(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleFromTitle(
|
|
|
|
@PathVariable("title") String title
|
|
|
|
@PathVariable("title") String title
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleFromTitle(title);
|
|
|
|
Response res = articleService.deleteArticleFromTitle(title);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromTitle(title)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByTitle(title)).withRel("getArticleByTitle")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticleFromUrl/{url}",
|
|
|
|
value = "/deleteArticleFromUrl/{url}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleFromUrl(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleFromUrl(
|
|
|
|
@PathVariable("url") String url
|
|
|
|
@PathVariable("url") String url
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleFromUrl(url);
|
|
|
|
Response res = articleService.deleteArticleFromTitle(url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromUrl(url)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByUrl(url)).withRel("getArticlesByUrl")
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
|
|
|
|
value = "/deleteArticleFromType/{type}",
|
|
|
|
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleFromType(
|
|
|
|
|
|
|
|
@PathVariable("type") Integer type
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
Response res = articleService.deleteArticleFromType(type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleFromType(type)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesByType(type)).withRel("getArticlesByType")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticleAddedBefore/{date}",
|
|
|
|
value = "/deleteArticleAddedBefore/{date}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleAddedBefore(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleAddedBefore(
|
|
|
|
@PathVariable("date") String date
|
|
|
|
@PathVariable("date") String date
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleAddedBefore(date);
|
|
|
|
Response res = articleService.deleteArticleAddedBefore(date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedBefore(date)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedBefore(date)).withRel("getArticlesAddedBefore")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticleAddedAfter/{date}",
|
|
|
|
value = "/deleteArticleAddedAfter/{date}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleAddedAfter(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleAddedAfter(
|
|
|
|
@PathVariable("date") String date
|
|
|
|
@PathVariable("date") String date
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleAddedAfter(date);
|
|
|
|
Response res = articleService.deleteArticleAddedAfter(date);
|
|
|
|
}@DeleteMapping(
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedAfter(date)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedAfter(date)).withRel("getArticlesAddedAfter")
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticleAddedBetween/{beginning}/{end}",
|
|
|
|
value = "/deleteArticleAddedBetween/{beginning}/{end}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticleAddedBetween(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticleAddedBetween(
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
@PathVariable("end") String end
|
|
|
|
@PathVariable("end") String end
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticleAddedBetween(beginning, end);
|
|
|
|
Response res = articleService.deleteArticleAddedBetween(beginning, end);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticleAddedBetween(beginning, end)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesAddedBetween(beginning, end)).withRel("getArticlesAddedBetween")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticlePublishedBefore/{date}",
|
|
|
|
value = "/deleteArticlePublishedBefore/{date}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticlePublishedBefore(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticlePublishedBefore(
|
|
|
|
@PathVariable("date") String date
|
|
|
|
@PathVariable("date") String date
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticlePublishedBefore(date);
|
|
|
|
Response res = articleService.deleteArticlePublishedBefore(date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBefore(date)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedBefore(date)).withRel("getArticlesPublishedBefore")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticlePublishedAfter/{date}",
|
|
|
|
value = "/deleteArticlePublishedAfter/{date}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticlePublishedAfter(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticlePublishedAfter(
|
|
|
|
@PathVariable("date") String date
|
|
|
|
@PathVariable("date") String date
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticlePublishedAfter(date);
|
|
|
|
Response res = articleService.deleteArticlePublishedBefore(date);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedAfter(date)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedAfter(date)).withRel("getArticlesPublishedAfter")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(
|
|
|
|
@DeleteMapping(
|
|
|
|
value = "/deleteArticlePublishedBetween/{beginning}/{end}",
|
|
|
|
value = "/deleteArticlePublishedBetween/{beginning}/{end}",
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
produces = MediaType.APPLICATION_JSON_VALUE
|
|
|
|
)
|
|
|
|
)
|
|
|
|
public @ResponseBody Response deleteArticlePublishedBetween(
|
|
|
|
public @ResponseBody EntityModel<Response> deleteArticlePublishedBetween(
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
@PathVariable("beginning") String beginning,
|
|
|
|
@PathVariable("end") String end
|
|
|
|
@PathVariable("end") String end
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
return articleService.deleteArticlePublishedBetween(beginning, end);
|
|
|
|
Response res = articleService.deleteArticlePublishedBetween(beginning, end);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return EntityModel.of(
|
|
|
|
|
|
|
|
res,
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBetween(beginning, end)).withSelfRel(),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"),
|
|
|
|
|
|
|
|
linkTo(methodOn(ArticleControler.class).getArticlesPublishedBetween(beginning, end)).withRel("getArticlesPublishedBetween")
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// endregion
|
|
|
|
// endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|