|
|
@@ -868,4 +868,49 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi {
|
|
|
throw SeecoderGitlabException.IO_ERROR;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public VisibilityVO getProjectVisibility(int projectId) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + String.format("/api/project/visibility?projectId=%d", projectId));
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<VisibilityVO>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsTreeItem error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public VisibilityVO setProjectVisibility(VisibilityVO visibilityVO) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + String.format("/api/project/visibility"))
|
|
|
+ .put(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(visibilityVO)));
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<VisibilityVO>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsTreeItem error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|