Skip to content

Commit

Permalink
issue IQSS#3165 final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonokuhn committed Jun 10, 2016
1 parent 929a233 commit 5a75f84
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
8 changes: 8 additions & 0 deletions doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ Toggles superuser mode on the ``AuthenticatedUser`` whose ``identifier`` (withou

POST http://$SERVER/api/admin/superuser/$identifier

System
~~~~~~~~~~~~~~~~
This part of the API exposes settings (namely :DatasetPublishPopupCustomText) necessary for OSF integration.

Get the :DatasetPublishPopupCustomText setting:

GET http://$SERVER/api/system/settings/:DatasetPublishPopupCustomText

IpGroups
^^^^^^^^

Expand Down
Binary file not shown.
11 changes: 7 additions & 4 deletions src/main/java/edu/harvard/iq/dataverse/api/Sys.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ public class Sys extends AbstractApiBean{
@Path("settings/:DatasetPublishPopupCustomText")
public Response getDatasetPublishPopupCustomText(){

String setting = settingsService.get("DatasetPublishPopupCustomText");
String setting = settingsService.getValueForKey(
SettingsServiceBean.Key.DatasetPublishPopupCustomText);

JsonObjectBuilder response = Json.createObjectBuilder();

if(setting != null){
return okResponse(response.add("DatasetPublishPopupCustomText", setting));
return okResponse(response.add(
"message", setting));
} else {
return notFound("Setting DatasetPublishPopupCustomText not found");
return notFound("Setting "
+SettingsServiceBean.Key.DatasetPublishPopupCustomText
+" not found");
}
}

}
35 changes: 19 additions & 16 deletions src/test/java/edu/harvard/iq/dataverse/api/SysIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/
package edu.harvard.iq.dataverse.api;

import static com.jayway.restassured.RestAssured.*;
import static com.jayway.restassured.RestAssured.given;
import com.jayway.restassured.response.Response;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
Expand All @@ -25,24 +26,26 @@ public void testGetDatasetPublishPopupCustomText() {
System.out.println("checking getDatasetPublishPopupCustomText");

given().urlEncodingEnabled(false)
.get("/api/system/settings/:DatasetPublishPopupCustomText")
.then().assertThat().statusCode(404)
.body("message", equalTo("Setting DatasetPublishPopupCustomText not found"));

given().urlEncodingEnabled(false)
.body("Hello world!").put("/api/admin/settings/DatasetPublishPopupCustomText");
.body("Hello world!")
.put("/api/admin/settings/"
+ SettingsServiceBean.Key.DatasetPublishPopupCustomText);

given().urlEncodingEnabled(false)
.get("/api/system/settings/:DatasetPublishPopupCustomText")
.then().assertThat().statusCode(200)
.body("data.DatasetPublishPopupCustomText", equalTo("Hello world!"));
Response response = given().urlEncodingEnabled(false)
.get("/api/system/settings/" + SettingsServiceBean.Key.DatasetPublishPopupCustomText);
response.prettyPrint();
response.then().assertThat().statusCode(200)
.body("data.message", equalTo("Hello world!"));

given().urlEncodingEnabled(false)
.delete("/api/admin/settings/DatasetPublishPopupCustomText");
.delete("/api/admin/settings/"
+ SettingsServiceBean.Key.DatasetPublishPopupCustomText);

given().urlEncodingEnabled(false)
.get("/api/system/settings/:DatasetPublishPopupCustomText")
.then().assertThat().statusCode(404)
.body("message", equalTo("Setting DatasetPublishPopupCustomText not found"));
response = given().urlEncodingEnabled(false)
.get("/api/system/settings/" + SettingsServiceBean.Key.DatasetPublishPopupCustomText);
response.prettyPrint();
response.then().assertThat().statusCode(404)
.body("message", equalTo("Setting "
+ SettingsServiceBean.Key.DatasetPublishPopupCustomText
+ " not found"));
}
}

0 comments on commit 5a75f84

Please sign in to comment.