Search-2096: Added missing API to update Site (#37)

This commit is contained in:
Meenal Bhave
2020-02-11 16:19:15 +00:00
committed by GitHub
parent bed12e40ca
commit c2e587d640
2 changed files with 45 additions and 0 deletions

View File

@@ -166,6 +166,19 @@ public class JsonBodyGenerator
.add("title", title).build();
return value.toString();
}
/**
* Method to create a Json object for SiteBody with site title, description, visibility
* @param siteModel
* @return String
*/
public static String updateSiteRequest(SiteModel siteModel)
{
JsonObject value = defineJSON()
.add("title", siteModel.getTitle())
.add("description", siteModel.getDescription())
.add("visibility", siteModel.getVisibility().toString()).build();
return value.toString();
}
public static String process(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority)
{

View File

@@ -192,6 +192,38 @@ public class Site extends ModelRequest<Site>
return restWrapper.processModel(RestSiteModel.class, request);
}
/**
* Update a site: Site title, description, visibility can be updated
* Body:
* {
* "title": "string",
* "description": "string",
* "visibility": "PRIVATE"
* }
*
* Response:
* {
* "entry": {
* "id": "string",
* "guid": "string",
* "title": "string",
* "description": "string",
* "visibility": "PRIVATE",
* "preset": "string",
* "role": "SiteConsumer"
* }
* }
*
* @return the properties of an updated site
* @throws Exception
*/
public RestSiteModel updateSite(SiteModel site) throws Exception
{
String siteBody = JsonBodyGenerator.updateSiteRequest(site);
RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, siteBody, "sites/{siteId}", site.getId());
return restWrapper.processModel(RestSiteModel.class, request);
}
/**
* Get site membership requests by using GET /site-membership-requests
*