use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class CreateDataSet method onExecute.
private HttpRequestBase onExecute(String name, String tag, String contentType, long size, InputStream dataSetContent) {
try {
URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets");
uriBuilder.addParameter("name", name);
uriBuilder.addParameter("tag", tag);
uriBuilder.addParameter("size", String.valueOf(size));
final HttpPost post = new HttpPost(uriBuilder.build());
post.addHeader("Content-Type", contentType);
post.setEntity(new InputStreamEntity(dataSetContent));
return post;
} catch (URISyntaxException e) {
throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
}
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class DataSetList method onExecute.
private HttpRequestBase onExecute(Sort sort, Order order, String name, boolean certified, boolean favorite, boolean limit) {
try {
URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets");
uriBuilder.addParameter("sort", sort.camelName());
uriBuilder.addParameter("order", order.camelName());
uriBuilder.addParameter("name", name);
uriBuilder.addParameter("certified", Boolean.toString(certified));
uriBuilder.addParameter("favorite", Boolean.toString(favorite));
uriBuilder.addParameter("limit", Boolean.toString(limit));
return new HttpGet(uriBuilder.build());
} catch (URISyntaxException e) {
throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
}
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class DataSetPreview method onExecute.
private HttpRequestBase onExecute(String dataSetId, boolean metadata, String sheetName) {
try {
URIBuilder uriBuilder = new URIBuilder(datasetServiceUrl + "/datasets/" + dataSetId + "/preview/");
uriBuilder.addParameter("metadata", Boolean.toString(metadata));
if (StringUtils.isNotEmpty(sheetName)) {
// yup this sheet name can contains weird characters space, great french accents or even chinese
// characters
uriBuilder.addParameter("sheetName", sheetName);
}
return new HttpGet(uriBuilder.build());
} catch (URISyntaxException e) {
throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
}
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class PreparationCopyStepsFrom method onExecute.
private HttpRequestBase onExecute(final String to, final String from) {
try {
URIBuilder builder = new URIBuilder(preparationServiceUrl + "/preparations/" + to + "/steps/copy");
builder.addParameter("from", from);
return new HttpPut(builder.build());
} catch (URISyntaxException e) {
throw new TDPException(UNEXPECTED_EXCEPTION, e);
}
}
use of org.talend.dataprep.exception.TDPException in project data-prep by Talend.
the class PreviewAbstract method onExecute.
private HttpRequestBase onExecute() {
final String uri = this.transformationServiceUrl + "/transform/preview";
HttpPost transformationCall = new HttpPost(uri);
final String paramsAsJson;
try {
paramsAsJson = objectMapper.writeValueAsString(parameters);
} catch (JsonProcessingException e) {
throw new TDPException(TransformationErrorCodes.UNABLE_TO_PERFORM_PREVIEW, e);
}
HttpEntity reqEntity = new StringEntity(paramsAsJson, ContentType.APPLICATION_JSON);
transformationCall.setEntity(reqEntity);
return transformationCall;
}
Aggregations