use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class IndexController method getTodaySubmitApplications.
/**
* Paging get applications information that was submitted today.
* Including details of applications
* @return
*/
@POST
@Path("application/today")
@Produces(MediaType.APPLICATION_JSON)
public GeneralResponse<?> getTodaySubmitApplications(@Context HttpServletRequest httpServletRequest, PageRequest pageRequest) throws UnExpectedRequestException {
PageRequest.checkRequest(pageRequest);
String user = HttpUtils.getUserName(httpServletRequest);
try {
IndexApplicationTodayResponse response = indexService.getTodaySubmitApplications(user, pageRequest);
return new GeneralResponse<>("200", "{&QUERY_SUCCESSFULLY}", response);
} catch (Exception e) {
LOG.error("[Home overview]Failed to query API: application/today, internal error", e);
return new GeneralResponse<>("500", e.getMessage(), -1);
}
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class Filter2TokenFilter method writeToResponse.
private void writeToResponse(String message, ServletResponse response) throws IOException {
ServletOutputStream out = response.getOutputStream();
GeneralResponse generalResponse = new GeneralResponse<>("401", message, null);
out.write(objectMapper.writeValueAsBytes(generalResponse));
out.flush();
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class LinkisConfigurationController method getFullTree.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public GeneralResponse<?> getFullTree(@QueryParam("cluster_name") String clusterName) throws UnExpectedRequestException {
String userName = HttpUtils.getUserName(httpServletRequest);
try {
Map<String, Map> reponse = linkisConfiguration.getFullTree(clusterName, userName);
LinkisConfigurationResponse linkisConfigurationResponse = new LinkisConfigurationResponse();
linkisConfigurationResponse.setQueueName(reponse.get("full_tree_queue_name"));
linkisConfigurationResponse.setQueue(reponse.get("full_tree"));
return new GeneralResponse<>("200", "{&SUCCESS_TO_GET_STARTUP_PATAM}", reponse);
} catch (UnExpectedRequestException e) {
throw new UnExpectedRequestException(e.getMessage());
} catch (Exception e) {
LOGGER.error("Failed to , caused by: {}", e.getMessage(), e);
return new GeneralResponse<>("500", "{&FAILED_TO_GET_STARTUP_PATAM}", null);
}
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method getDataSourceVersions.
@Override
public GeneralResponse<Map> getDataSourceVersions(String clusterName, String authUser, Long dataSourceId) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
String url = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceVersions()).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<>(headers);
LOGGER.info("Start to get data source versions 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 versions 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("versions");
return new GeneralResponse<>("200", "Success to get datasource version", data);
}
use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.
the class MetaDataClientImpl method expireDataSource.
@Override
public GeneralResponse<Map> expireDataSource(String clusterName, String authUser, Long dataSourceId) throws UnExpectedRequestException, MetaDataAcquireFailedException {
// Check existence of cluster name
ClusterInfo clusterInfo = checkClusterNameExists(clusterName);
// send request to get dbs
String url = getPath(clusterInfo.getLinkisAddress()).path(linkisConfig.getDatasourceExpire()).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<>(headers);
LOGGER.info("Start to expire 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 expire 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 expire datasource", data);
}
Aggregations