Search in sources :

Example 6 with TranslatorException

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();
}
Also used : N1qlQueryResult(com.couchbase.client.java.query.N1qlQueryResult) ResourceException(javax.resource.ResourceException) TranslatorException(org.teiid.translator.TranslatorException)

Example 7 with TranslatorException

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();
}
Also used : N1qlQueryResult(com.couchbase.client.java.query.N1qlQueryResult) ResourceException(javax.resource.ResourceException) TranslatorException(org.teiid.translator.TranslatorException)

Example 8 with TranslatorException

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);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) TranslatorException(org.teiid.translator.TranslatorException) URL(java.net.URL)

Example 9 with TranslatorException

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()));
        }
    }
}
Also used : Argument(org.teiid.language.Argument) TranslatorException(org.teiid.translator.TranslatorException)

Example 10 with TranslatorException

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);
    }
}
Also used : ResourceException(javax.resource.ResourceException) TranslatorException(org.teiid.translator.TranslatorException)

Aggregations

TranslatorException (org.teiid.translator.TranslatorException)227 ArrayList (java.util.ArrayList)51 Column (org.teiid.metadata.Column)47 List (java.util.List)32 Table (org.teiid.metadata.Table)30 IOException (java.io.IOException)26 SQLException (java.sql.SQLException)26 ResourceException (javax.resource.ResourceException)26 Test (org.junit.Test)16 Expression (org.teiid.language.Expression)16 Literal (org.teiid.language.Literal)16 DataNotAvailableException (org.teiid.translator.DataNotAvailableException)16 Blob (java.sql.Blob)15 Argument (org.teiid.language.Argument)13 DBObject (com.mongodb.DBObject)11 HashMap (java.util.HashMap)11 ColumnReference (org.teiid.language.ColumnReference)11 ExecutionContext (org.teiid.translator.ExecutionContext)11 BasicDBObject (com.mongodb.BasicDBObject)10 RuntimeMetadata (org.teiid.metadata.RuntimeMetadata)10