use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method publishDataSource.
@Override
public GeneralResponse<Map> publishDataSource(String clusterName, String authUser, Long dataSourceId, Long versionId) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
String url = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourcePublish()).path(dataSourceId.toString()).path(versionId.toString()).toString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", authUser);
headers.add("Token-Code", clusterInfo.getLinkisToken());
HttpEntity<Object> entity = new HttpEntity<>(headers);
LOGGER.info("Start to publish data source by user and cluster by linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.POST, entity);
Map<String, Object> response = restTemplate.exchange(url, HttpMethod.POST, entity, Map.class).getBody();
LOGGER.info("Finish to publish data source by user and cluster by linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
LOGGER.error("Error! Can not get meta data from linkis, message: " + message);
throw new MetaDataAcquireFailedException("Error! Can not get meta data from linkis, exception: " + message);
}
Map data = (Map) response.get(LinkisResponseKeyEnum.DATA.getKey());
return new GeneralResponse<>("200", "Success to publish datasource", data);
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method getDataSourceInfoDetailByName.
@Override
public GeneralResponse<Map> getDataSourceInfoDetailByName(String clusterName, String authUser, String dataSourceName) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
UriBuilder uriBuilder = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceInfoName()).path(dataSourceName);
String url = uriBuilder.toString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", authUser);
headers.add("Token-Code", clusterInfo.getLinkisToken());
HttpEntity<Object> entity = new HttpEntity<>(headers);
LOGGER.info("Start to get data source info detail by user and cluster and name by linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.GET, entity);
Map<String, Object> response = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody();
LOGGER.info("Finish to get data source info detail by user and cluster and name by linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
LOGGER.error("Error! Can not get meta data from linkis, message: " + message);
throw new MetaDataAcquireFailedException("Error! Can not get meta data from linkis, exception: " + message);
}
Map data = (Map) response.get(LinkisResponseKeyEnum.DATA.getKey());
return new GeneralResponse<>("200", "Success to get datasource info detail by datasource name", data);
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method modifyDataSource.
@Override
public GeneralResponse<Map> modifyDataSource(String clusterName, String authUser, Long dataSourceId, String jsonRequest) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
String url = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceModify()).toString().replace("{DATA_SOURCE_ID}", dataSourceId.toString());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", authUser);
headers.add("Token-Code", clusterInfo.getLinkisToken());
HttpEntity<Object> entity = new HttpEntity<>(jsonRequest, headers);
LOGGER.info("Start to modify data source by user and cluster by linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.PUT, entity);
Map<String, Object> response = restTemplate.exchange(url, HttpMethod.PUT, entity, Map.class).getBody();
LOGGER.info("Finish to modify data source by user and cluster by linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
LOGGER.error("Error! Can not get meta data from linkis, message: " + message);
throw new MetaDataAcquireFailedException("Error! Can not get meta data from linkis, exception: " + message);
}
Map data = (Map) response.get(LinkisResponseKeyEnum.DATA.getKey());
return new GeneralResponse<>("200", "Success to modify datasource", data);
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method createDataSource.
@Override
public GeneralResponse<Map> createDataSource(String clusterName, String authUser, String jsonRequest) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
String url = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceCreate()).toString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", authUser);
headers.add("Token-Code", clusterInfo.getLinkisToken());
HttpEntity<Object> entity = new HttpEntity<>(jsonRequest, headers);
LOGGER.info("Start to create data source by user and cluster by linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.POST, entity);
Map<String, Object> response = restTemplate.exchange(url, HttpMethod.POST, entity, Map.class).getBody();
LOGGER.info("Finish to create data source by user and cluster by linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
LOGGER.error("Error! Can not get meta data from linkis, message: " + message);
throw new MetaDataAcquireFailedException("Error! Can not get meta data from linkis, exception: " + message);
}
Map data = (Map) response.get(LinkisResponseKeyEnum.DATA.getKey());
return new GeneralResponse<>("200", "Success to create datasource", data);
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method getDataSourceInfoPage.
@Override
public GeneralResponse<Map> getDataSourceInfoPage(String clusterName, String authUser, int page, int size, String searchName, Long typeId) throws UnExpectedRequestException, MetaDataAcquireFailedException, UnsupportedEncodingException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
UriBuilder uriBuilder = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceInfo()).queryParam("currentPage", page).queryParam("pageSize", size);
if (StringUtils.isNotBlank(searchName)) {
uriBuilder.queryParam("name", searchName);
}
if (typeId != null) {
uriBuilder.queryParam("typeId", typeId);
}
String url = uriBuilder.toString();
url = URLDecoder.decode(url, "UTF-8");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Token-User", authUser);
headers.add("Token-Code", clusterInfo.getLinkisToken());
HttpEntity<Object> entity = new HttpEntity<>(headers);
LOGGER.info("Start to get data source info by user and cluster by linkis. url: {}, method: {}, body: {}", url, javax.ws.rs.HttpMethod.GET, entity);
Map<String, Object> response = restTemplate.exchange(url, HttpMethod.GET, entity, Map.class).getBody();
LOGGER.info("Finish to get data source info by user and cluster by linkis. response: {}", response);
if (!checkResponse(response)) {
String message = (String) response.get("message");
LOGGER.error("Error! Can not get meta data from linkis, message: " + message);
throw new MetaDataAcquireFailedException("Error! Can not get meta data from linkis, exception: " + message);
}
Map data = (Map) response.get(LinkisResponseKeyEnum.DATA.getKey());
List<Map> types = (List<Map>) data.get("query_list");
return new GeneralResponse<>("200", "Success to get datasource info", data);
}
Aggregations