use of org.eclipse.che.api.core.ApiException in project che by eclipse.
the class WorkspaceHolder method updateProject.
/**
* Updates project on WS-master side.
*
* @param project
* project to update
* @throws ServerException
*/
protected void updateProject(ProjectConfig project) throws ServerException {
final UriBuilder builder = UriBuilder.fromUri(apiEndpoint).path(WorkspaceService.class).path(WorkspaceService.class, "updateProject");
if (userToken != null)
builder.queryParam("token", userToken);
final String href = builder.build(new String[] { workspaceId, project.getPath() }, false).toString();
try {
httpJsonRequestFactory.fromUrl(href).usePutMethod().setBody(asDto(project)).request();
} catch (IOException | ApiException e) {
throw new ServerException(e.getMessage());
}
}
use of org.eclipse.che.api.core.ApiException in project che by eclipse.
the class WorkspaceHolder method addProject.
/**
* Add project on WS-master side.
*
* @param project
* project to add
* @throws ServerException
*/
protected void addProject(ProjectConfig project) throws ServerException {
final UriBuilder builder = UriBuilder.fromUri(apiEndpoint).path(WorkspaceService.class).path(WorkspaceService.class, "addProject");
if (userToken != null)
builder.queryParam("token", userToken);
final String href = builder.build(workspaceId).toString();
try {
httpJsonRequestFactory.fromUrl(href).usePostMethod().setBody(asDto(project)).request();
} catch (IOException | ApiException e) {
throw new ServerException(e.getMessage());
}
}
use of org.eclipse.che.api.core.ApiException in project che by eclipse.
the class WorkspaceHolder method workspaceDto.
/**
* @return WorkspaceDto
* @throws ServerException
*/
private WorkspaceDto workspaceDto() throws ServerException {
final UriBuilder builder = UriBuilder.fromUri(apiEndpoint).path(WorkspaceService.class).path(WorkspaceService.class, "getByKey");
if (userToken != null)
builder.queryParam("token", userToken);
final String href = builder.build(workspaceId).toString();
try {
return httpJsonRequestFactory.fromUrl(href).useGetMethod().request().asDto(WorkspaceDto.class);
} catch (IOException | ApiException e) {
throw new ServerException(e);
}
}
use of org.eclipse.che.api.core.ApiException in project che by eclipse.
the class WorkspaceHolder method removeProject.
protected void removeProject(ProjectConfig project) throws ServerException {
final UriBuilder builder = UriBuilder.fromUri(apiEndpoint).path(WorkspaceService.class).path(WorkspaceService.class, "deleteProject");
if (userToken != null)
builder.queryParam("token", userToken);
final String href = builder.build(new String[] { workspaceId, project.getPath() }, false).toString();
try {
httpJsonRequestFactory.fromUrl(href).useDeleteMethod().request();
} catch (IOException | ApiException e) {
throw new ServerException(e.getMessage());
}
}
use of org.eclipse.che.api.core.ApiException in project che by eclipse.
the class WsAgentHealthCheckerImpl method check.
@Override
public WsAgentHealthStateDto check(Machine machine) throws ServerException {
Server wsAgent = getWsAgent(machine);
final WsAgentHealthStateDto agentHealthStateDto = newDto(WsAgentHealthStateDto.class);
if (wsAgent == null) {
return agentHealthStateDto.withCode(NOT_FOUND.getStatusCode()).withReason("Workspace Agent not available");
}
try {
final HttpJsonRequest pingRequest = createPingRequest(machine);
final HttpJsonResponse response = pingRequest.request();
return agentHealthStateDto.withCode(response.getResponseCode());
} catch (ApiException | IOException e) {
return agentHealthStateDto.withCode(SERVICE_UNAVAILABLE.getStatusCode()).withReason(e.getMessage());
}
}
Aggregations