mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
70815: Angular feedback
This commit is contained in:
@@ -12,9 +12,8 @@ import java.util.Map;
|
|||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||||
|
import org.dspace.app.rest.model.PlainTextValueRest;
|
||||||
import org.dspace.app.rest.model.SubmissionCCLicenseRest;
|
import org.dspace.app.rest.model.SubmissionCCLicenseRest;
|
||||||
import org.dspace.app.rest.utils.Utils;
|
import org.dspace.app.rest.utils.Utils;
|
||||||
import org.dspace.license.service.CreativeCommonsService;
|
import org.dspace.license.service.CreativeCommonsService;
|
||||||
@@ -24,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,8 +33,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
"/rightsByQuestions")
|
"/rightsByQuestions")
|
||||||
public class SubmissionCCLicenseSearchController {
|
public class SubmissionCCLicenseSearchController {
|
||||||
|
|
||||||
private static final Logger log = LogManager.getLogger();
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected Utils utils;
|
protected Utils utils;
|
||||||
|
|
||||||
@@ -52,8 +48,7 @@ public class SubmissionCCLicenseSearchController {
|
|||||||
* @return the CC License URI as a string
|
* @return the CC License URI as a string
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
@ResponseBody
|
public PlainTextValueRest findByRightsByQuestions() {
|
||||||
public String findByRightsByQuestions() {
|
|
||||||
ServletRequest servletRequest = requestService.getCurrentRequest()
|
ServletRequest servletRequest = requestService.getCurrentRequest()
|
||||||
.getServletRequest();
|
.getServletRequest();
|
||||||
Map<String, String[]> requestParameterMap = servletRequest
|
Map<String, String[]> requestParameterMap = servletRequest
|
||||||
@@ -90,6 +85,7 @@ public class SubmissionCCLicenseSearchController {
|
|||||||
if (StringUtils.isBlank(licenseUri)) {
|
if (StringUtils.isBlank(licenseUri)) {
|
||||||
throw new ResourceNotFoundException("No CC License URI could be found for ID: " + licenseId);
|
throw new ResourceNotFoundException("No CC License URI could be found for ID: " + licenseId);
|
||||||
}
|
}
|
||||||
return licenseUri;
|
PlainTextValueRest plainTextValueRest = new PlainTextValueRest(licenseUri);
|
||||||
|
return plainTextValueRest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* The contents of this file are subject to the license and copyright
|
||||||
|
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||||
|
* tree and available online at
|
||||||
|
*
|
||||||
|
* http://www.dspace.org/license/
|
||||||
|
*/
|
||||||
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rest object used to represent a plain text value
|
||||||
|
*/
|
||||||
|
public class PlainTextValueRest {
|
||||||
|
public static final String TYPE = "plaintextvalue";
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public PlainTextValueRest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlainTextValueRest(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(final String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
}
|
@@ -8,8 +8,9 @@
|
|||||||
package org.dspace.app.rest;
|
package org.dspace.app.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||||
@@ -32,14 +33,16 @@ public class SubmissionCCLicenseSearchControllerIT extends AbstractControllerInt
|
|||||||
"/api/config/submissioncclicenses/search/rightsByQuestions?license=license2&answer_license2-field0" +
|
"/api/config/submissioncclicenses/search/rightsByQuestions?license=license2&answer_license2-field0" +
|
||||||
"=license2-field0-enum1"))
|
"=license2-field0-enum1"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("mock-license-uri"));
|
.andExpect(jsonPath("$.value", is("mock-license-uri")))
|
||||||
|
.andExpect(jsonPath("$.type", is("plaintextvalue")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searchRightsByQuestionsTestLicenseWithoutFields() throws Exception {
|
public void searchRightsByQuestionsTestLicenseWithoutFields() throws Exception {
|
||||||
getClient().perform(get("/api/config/submissioncclicenses/search/rightsByQuestions?license=license3"))
|
getClient().perform(get("/api/config/submissioncclicenses/search/rightsByQuestions?license=license3"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("mock-license-uri"));
|
.andExpect(jsonPath("$.value", is("mock-license-uri")))
|
||||||
|
.andExpect(jsonPath("$.type", is("plaintextvalue")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user