71859: Endpoint path sitemaps changed

This commit is contained in:
Marie Verdonck
2020-07-15 13:27:55 +02:00
parent d0a7104e9f
commit c911a0f79a
3 changed files with 11 additions and 13 deletions

View File

@@ -61,7 +61,7 @@ public class GenerateSitemaps {
private static final ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
public static final String SITEMAPS_ENDPOINT = "/api/discover/sitemaps";
public static final String SITEMAPS_ENDPOINT = "/sitemaps";
/**
* Default constructor

View File

@@ -18,17 +18,16 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.connector.ClientAbortException;
import org.apache.logging.log4j.Logger;
import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.utils.ContextUtil;
import org.dspace.app.rest.utils.MultipartFileSender;
import org.dspace.core.Context;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.stereotype.Controller;
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.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* This is a specialized controller to provide access to the sitemap files, generated by
@@ -37,14 +36,14 @@ import org.springframework.web.bind.annotation.RestController;
* The mapping for requested endpoint try to resolve a valid sitemap file name, for example
* <pre>
* {@code
* https://<dspace.server.url>/api/discover/sitemaps/26453b4d-e513-44e8-8d5b-395f62972eff/sitemap0.html
* https://<dspace.server.url>/sitemaps/26453b4d-e513-44e8-8d5b-395f62972eff/sitemap0.html
* }
* </pre>
*
* @author Maria Verdonck (Atmire) on 08/07/2020
*/
@RestController
@RequestMapping("/api/" + RestModel.DISCOVER + "/sitemaps")
@Controller
@RequestMapping("/sitemaps")
public class SitemapRestController {
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SitemapRestController.class);
@@ -64,7 +63,7 @@ public class SitemapRestController {
* @throws SQLException if db error while completing DSpace context
* @throws IOException if IO error surrounding sitemap file
*/
@RequestMapping(method = {RequestMethod.GET, RequestMethod.HEAD}, value = "/{name}")
@GetMapping("/{name}")
public void retrieve(@PathVariable String name, HttpServletResponse response,
HttpServletRequest request) throws IOException, SQLException {
// Find sitemap with given name in dspace/sitemaps

View File

@@ -15,7 +15,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.content.Collection;
import org.dspace.content.Community;
@@ -27,7 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.web.servlet.MvcResult;
/**
* Integration test to test the /api/discover/sitemaps/{name} endpoint, see {@link SitemapRestController}
* Integration test to test the /sitemaps/{name} endpoint, see {@link SitemapRestController}
*
* @author Maria Verdonck (Atmire) on 08/07/2020
*/
@@ -36,7 +35,7 @@ public class SitemapRestControllerIT extends AbstractControllerIntegrationTest {
@Autowired
ConfigurationService configurationService;
private final static String SITEMAPS_ENDPOINT = "/api/" + RestModel.DISCOVER + "/sitemaps";
private final static String SITEMAPS_ENDPOINT = "/sitemaps";
private Item item1;
private Item item2;
@@ -86,7 +85,7 @@ public class SitemapRestControllerIT extends AbstractControllerIntegrationTest {
.andReturn();
String response = result.getResponse().getContentAsString();
// contains a link to /api/discover/sitemaps/sitemap0.html
// contains a link to /sitemaps/sitemap0.html
assertTrue(response.contains(SITEMAPS_ENDPOINT + "/sitemap0.html"));
}
@@ -119,7 +118,7 @@ public class SitemapRestControllerIT extends AbstractControllerIntegrationTest {
.andReturn();
String response = result.getResponse().getContentAsString();
// contains a link to /api/discover/sitemaps/sitemap0.html
// contains a link to /sitemaps/sitemap0.html
assertTrue(response.contains(SITEMAPS_ENDPOINT + "/sitemap0.xml"));
}