use of org.teiid.translator.TranslatorException in project teiid by teiid.
the class CouchbaseProcedureExecution method execute.
@Override
public void execute() throws TranslatorException {
this.visitor = this.executionFactory.getN1QLVisitor();
this.visitor.append(call);
String n1ql = this.visitor.toString();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, CouchbasePlugin.Util.gs(CouchbasePlugin.Event.TEIID29002, call, n1ql));
executionContext.logCommand(n1ql);
N1qlQueryResult queryResult;
try {
queryResult = connection.execute(n1ql);
} catch (ResourceException e) {
throw new TranslatorException(e);
}
this.results = queryResult.iterator();
}
use of org.teiid.translator.TranslatorException in project teiid by teiid.
the class CouchbaseQueryExecution method execute.
@Override
public void execute() throws TranslatorException {
this.visitor = this.executionFactory.getN1QLVisitor();
this.visitor.append(this.command);
String n1ql = this.visitor.toString();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, CouchbasePlugin.Util.gs(CouchbasePlugin.Event.TEIID29001, n1ql));
executionContext.logCommand(n1ql);
N1qlQueryResult queryResult;
try {
queryResult = connection.execute(n1ql);
} catch (ResourceException e) {
throw new TranslatorException(e);
}
this.results = queryResult.iterator();
}
use of org.teiid.translator.TranslatorException in project teiid by teiid.
the class S3ProcedureExecution method deleteFile.
private BinaryWSProcedureExecution deleteFile(List<Argument> arguments) throws TranslatorException {
String name = (String) arguments.get(0).getArgumentValue().getValue();
String bucket = (String) arguments.get(1).getArgumentValue().getValue();
String region = (String) arguments.get(2).getArgumentValue().getValue();
this.endpoint = (String) arguments.get(3).getArgumentValue().getValue();
String accessKey = (String) arguments.get(4).getArgumentValue().getValue();
String secretKey = (String) arguments.get(5).getArgumentValue().getValue();
if (bucket == null) {
bucket = this.ef.getBucket();
}
if (region == null) {
region = this.ef.getRegion();
}
if (endpoint == null) {
if (region.equals("us-east-1")) {
endpoint = "https://s3.amazonaws.com/" + bucket + "/" + name;
} else {
endpoint = "https://s3-" + region + ".amazonaws.com/" + bucket + "/" + name;
}
}
if (accessKey == null) {
accessKey = this.ef.getAccesskey();
}
if (secretKey == null) {
secretKey = this.ef.getSecretkey();
}
try {
Map<String, String> headers = new HashMap<String, String>();
if (accessKey != null) {
AWS4SignerForAuthorizationHeader signer = new AWS4SignerForAuthorizationHeader(new URL(endpoint), "DELETE", "s3", region);
String authorization = // no query parameters
signer.computeSignature(// no query parameters
headers, // no query parameters
null, AWS4SignerBase.EMPTY_BODY_SHA256, accessKey, secretKey);
headers.put("Authorization", authorization);
headers.put("x-amz-content-sha256", AWS4SignerBase.EMPTY_BODY_SHA256);
}
headers.put("Content-Type", "text/plain");
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_WS, "Deleting", endpoint);
return invokeHTTP("DELETE", endpoint, null, headers);
} catch (MalformedURLException e) {
throw new TranslatorException(e);
}
}
use of org.teiid.translator.TranslatorException in project teiid by teiid.
the class S3ProcedureExecution method execute.
@Override
public void execute() throws TranslatorException {
List<Argument> arguments = this.command.getArguments();
if (command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.SAVEFILE)) {
this.execution = saveFile(arguments);
this.execution.execute();
if (this.execution.getResponseCode() != 200) {
throw new TranslatorException(S3ExecutionFactory.UTIL.gs("error_writing", this.endpoint, this.execution.getResponseCode(), getErrorDescription()));
}
} else if (command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.DELETEFILE)) {
this.execution = deleteFile(arguments);
this.execution.execute();
if (this.execution.getResponseCode() != 204) {
throw new TranslatorException(S3ExecutionFactory.UTIL.gs("error_deleting", this.endpoint, this.execution.getResponseCode(), getErrorDescription()));
}
} else if (command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.GETFILE) || command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.GETTEXTFILE)) {
if (command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.GETTEXTFILE)) {
this.isText = true;
}
this.execution = getFile(arguments);
this.execution.execute();
if (this.execution.getResponseCode() != 200) {
throw new TranslatorException(S3ExecutionFactory.UTIL.gs("error_reading", this.endpoint, this.execution.getResponseCode(), getErrorDescription()));
}
} else if (command.getProcedureName().equalsIgnoreCase(S3ExecutionFactory.LISTBUCKET)) {
this.execution = listBucket(arguments);
this.execution.execute();
if (this.execution.getResponseCode() != 200) {
throw new TranslatorException(S3ExecutionFactory.UTIL.gs("error_list", this.endpoint, this.execution.getResponseCode(), getErrorDescription()));
}
}
}
use of org.teiid.translator.TranslatorException in project teiid by teiid.
the class CouchbaseDirectQueryExecution method execute.
@Override
public void execute() throws TranslatorException {
String n1ql = (String) this.arguments.get(0).getArgumentValue().getValue();
LogManager.logDetail(LogConstants.CTX_CONNECTOR, CouchbasePlugin.Util.gs(CouchbasePlugin.Event.TEIID29001, n1ql));
executionContext.logCommand(n1ql);
try {
this.results = connection.execute(n1ql).iterator();
} catch (ResourceException e) {
throw new TranslatorException(e);
}
}
Aggregations