protected RestHttpHelper getRestHelper() { if (null == restHelper) { restHelper = new RestHttpHelper(this.socketTimeoutMs); } return restHelper; }
protected String callBridge(RestHttpHelper restHelper, String bridgeURL) { log.info("Making bridge call to restart snapshot. URL: {}", bridgeURL); try { RestHttpHelper.HttpResponse response = restHelper.post(bridgeURL, null, null); int statusCode = response.getStatusCode(); if (statusCode != HttpStatus.SC_ACCEPTED) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "restart snapshot. " + "Error reported: " + e.getMessage(), e); } }
protected String callBridge(RestHttpHelper restHelper, String bridgeURL) { log.info("Making bridge call to get snapshot list. URL: {}", bridgeURL); try { RestHttpHelper.HttpResponse response = restHelper.get(bridgeURL); int statusCode = response.getStatusCode(); if (statusCode != 200) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "get list of snapshots. " + "Error reported: " + e.getMessage(), e); } }
public HttpResponse initializeDurastore(String host, String port, String context) throws Exception { String baseURL = "http://" + host + ":" + port + "/" + context; String storesURL = baseURL + "/stores"; String xml = buildTestAccountXml(); RestHttpHelper restHelper = new RestHttpHelper(getRootCredential()); return restHelper.post(storesURL, xml, null); }
protected String callBridge(RestHttpHelper restHelper, String snapshotURL, String snapshotBody) { log.info("Making RESTORE call to URL {} with body {}", snapshotURL, snapshotBody); try { Map<String, String> headers = new HashMap<>(); headers.put(HttpHeaders.CONTENT_TYPE, "application/json"); RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers); int statusCode = response.getStatusCode(); if (statusCode != 201) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "initiate snapshot request. " + "Error reported: " + e.getMessage(), e); } }
@Override public String cancelStorageReportSchedule() throws ReportException { String url = buildCancelStorageReportScheduleURL(); try { RestHttpHelper.HttpResponse response = getRestHelper().delete(url); checkResponse(response, HttpStatus.SC_OK); return response.getResponseBody(); } catch (Exception e) { String error = "Could not cancel storage report schedule due to: " + e.getMessage(); throw new ReportException(error, e); } }
private Map<String, String> doGetSpaceProperties(String spaceId) throws ContentStoreException { String task = "get space properties"; String url = buildSpaceURL(spaceId); try { HttpResponse response = restHelper.head(url); checkResponse(response, HttpStatus.SC_OK); return extractPropertiesFromHeaders(response); } catch (NotFoundException e) { throw new NotFoundException(task, spaceId, e); } catch (UnauthorizedException e) { throw new UnauthorizedException(task, spaceId, e); } catch (Exception e) { throw new ContentStoreException(task, spaceId, e); } }
protected String callBridge(RestHttpHelper restHelper, String snapshotURL, String snapshotBody) { log.info("Making RESTORE call to URL {} with body {}", snapshotURL, snapshotBody); try { Map<String, String> headers = new HashMap<>(); headers.put(HttpHeaders.CONTENT_TYPE, "application/json"); RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers); int statusCode = response.getStatusCode(); if (statusCode != 201) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "initiate snapshot request. " + "Error reported: " + e.getMessage(), e); } }
@Override public String cancelStorageReport() throws ReportException { String url = buildBaseStorageReportURL(); try { RestHttpHelper.HttpResponse response = getRestHelper().delete(url); checkResponse(response, HttpStatus.SC_OK); return response.getResponseBody(); } catch (Exception e) { String error = "Could not cancel storage report due to: " + e.getMessage(); throw new ReportException(error, e); } }
private Map<String, AclType> doGetSpaceACLs(String spaceId) throws ContentStoreException { String task = "get space ACLs"; String url = buildAclURL(spaceId); try { HttpResponse response = restHelper.head(url); checkResponse(response, HttpStatus.SC_OK); return doGetSpaceACLs(response); } catch (NotFoundException e) { throw new NotFoundException(task, spaceId, e); } catch (UnauthorizedException e) { throw new UnauthorizedException(task, spaceId, e); } catch (Exception e) { throw new ContentStoreException(task, spaceId, e); } }
protected RestHttpHelper getRestHelper() { if (null == this.restHelper) { this.restHelper = new RestHttpHelper(); } return this.restHelper; }
@Override public String startStorageReport() throws ReportException { String url = buildBaseStorageReportURL(); try { RestHttpHelper.HttpResponse response = getRestHelper() .post(url, null, null); checkResponse(response, HttpStatus.SC_OK); return response.getResponseBody(); } catch (Exception e) { String error = "Could not start storage report due to: " + e.getMessage(); throw new ReportException(error, e); } }
protected String callBridge(RestHttpHelper restHelper, String bridgeURL) { log.info("Making bridge call to get snapshot status. URL: {}", bridgeURL); try { RestHttpHelper.HttpResponse response = restHelper.get(bridgeURL); int statusCode = response.getStatusCode(); if (statusCode != 200) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "get snapshot. " + "Error reported: " + e.getMessage(), e); } }
RestHttpHelper.HttpResponse response = restHelper.put(snapshotURL, snapshotBody, headers); int statusCode = response.getStatusCode(); if (statusCode != 200 && statusCode != 201) {
private void doDeleteSpace(String spaceId) throws ContentStoreException { String task = "delete space"; String url = buildSpaceURL(spaceId); try { HttpResponse response = restHelper.delete(url); checkResponse(response, HttpStatus.SC_OK); } catch (NotFoundException e) { throw new NotFoundException(task, spaceId, e); } catch (UnauthorizedException e) { throw new UnauthorizedException(task, spaceId, e); } catch (Exception e) { throw new ContentStoreException(task, spaceId, e); } }
@Override public BitIntegrityReportProperties getBitIntegrityReportProperties(String spaceId) throws ContentStoreException { String task = "get bit integrity report properties"; String url = buildBitIntegrityReportURL(spaceId); try { HttpResponse response = restHelper.head(url); if (hasNoContent(response)) { return null; } checkResponse(response, HttpStatus.SC_OK); return extractBitIntegrityProperties(response); } catch (UnauthorizedException e) { throw new UnauthorizedException(task, spaceId, e); } catch (Exception e) { throw new ContentStoreException(task, spaceId, e); } }
public void logout() { log.debug("logout"); setRestHelper(new RestHttpHelper()); }
/** * This method initializes this application with the provided configuration. * * @param config * @return */ public RestHttpHelper.HttpResponse initialize(AppConfig config) { String xml = config.asXml(); String url = getInitUrl(config); try { Map<String, String> headers = null; return getRestHelper().post(url, xml, headers); } catch (Exception e) { log.error("error initializing app at: " + url, ExceptionUtil.getStackTraceAsString(e)); throw new DuraCloudRuntimeException(e); } }
protected String callBridge(RestHttpHelper restHelper, String bridgeURL) { log.info("Making bridge call to get restore status. URL: {}", bridgeURL); try { RestHttpHelper.HttpResponse response = restHelper.get(bridgeURL); int statusCode = response.getStatusCode(); if (statusCode != 200) { throw new RuntimeException("Unexpected response code: " + statusCode); } return response.getResponseBody(); } catch (Exception e) { throw new TaskException("Exception encountered attempting to " + "get restore. " + "Error reported: " + e.getMessage(), e); } }
HttpResponse response = restHelper.put(url, content, contentMimeType,