Search in sources :

Example 56 with ResourceException

use of javax.resource.ResourceException in project teiid by teiid.

the class AccumuloConnectionImpl method checkTabletServerExists.

private void checkTabletServerExists(ZooKeeperInstance inst, String userName, String password) throws ResourceException {
    ClientService.Client client = null;
    try {
        Pair<String, Client> pair = ServerClient.getConnection(new ClientContext(inst, new Credentials(userName, new PasswordToken(password)), inst.getConfiguration()), true, 10);
        client = pair.getSecond();
    } catch (TTransportException e) {
        throw new ResourceException(AccumuloManagedConnectionFactory.UTIL.getString("no_tserver"), e);
    } finally {
        if (client != null) {
            ServerClient.close(client);
        }
    }
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ClientService(org.apache.accumulo.core.client.impl.thrift.ClientService) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) TTransportException(org.apache.thrift.transport.TTransportException) ResourceException(javax.resource.ResourceException) Client(org.apache.accumulo.core.client.impl.thrift.ClientService.Client) Client(org.apache.accumulo.core.client.impl.thrift.ClientService.Client) ServerClient(org.apache.accumulo.core.client.impl.ServerClient) Credentials(org.apache.accumulo.core.client.impl.Credentials)

Example 57 with ResourceException

use of javax.resource.ResourceException 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)

Example 58 with ResourceException

use of javax.resource.ResourceException in project teiid by teiid.

the class SalesforceConnectionImpl method getCardinality.

@Override
public Long getCardinality(String sobject) throws ResourceException {
    InputStream is = null;
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        is = doRestHttpGet(new URL(restEndpoint + "/query/?explain=select+id+from+" + URLEncoder.encode(sobject, "UTF-8")));
        // $NON-NLS-1$
        String s = ObjectConverterUtil.convertToString(new InputStreamReader(is, Charset.forName("UTF-8")));
        // TODO: introduce a json parser
        // $NON-NLS-1$
        int index = s.indexOf("cardinality");
        if (index < 0) {
            return null;
        }
        // $NON-NLS-1$
        index = s.indexOf(":", index);
        if (index < 0) {
            return null;
        }
        // $NON-NLS-1$
        int end = s.indexOf(",", index);
        if (end < 0) {
            // $NON-NLS-1$
            end = s.indexOf("}", index);
        }
        if (end < 0) {
            return null;
        }
        s = s.substring(index + 1, end);
        return Long.valueOf(s);
    } catch (NumberFormatException e) {
        throw new ResourceException(e);
    } catch (MalformedURLException e) {
        throw new ResourceException(e);
    } catch (UnsupportedEncodingException e) {
        throw new ResourceException(e);
    } catch (IOException e) {
        throw new ResourceException(e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) InputStreamReader(java.io.InputStreamReader) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) URL(java.net.URL)

Example 59 with ResourceException

use of javax.resource.ResourceException in project teiid by teiid.

the class SalesforceConnectionImpl method getDeleted.

public DeletedResult getDeleted(String objectName, Calendar startCalendar, Calendar endCalendar) throws ResourceException {
    GetDeletedResult deleted;
    try {
        deleted = partnerConnection.getDeleted(objectName, startCalendar, endCalendar);
    } catch (InvalidSObjectFault e) {
        throw new ResourceException(e);
    } catch (UnexpectedErrorFault e) {
        throw new ResourceException(e);
    } catch (ConnectionException e) {
        throw new ResourceException(e);
    }
    DeletedResult result = new DeletedResult();
    result.setLatestDateCovered(deleted.getLatestDateCovered());
    result.setEarliestDateAvailable(deleted.getEarliestDateAvailable());
    DeletedRecord[] records = deleted.getDeletedRecords();
    List<DeletedObject> resultRecords = new ArrayList<DeletedObject>();
    if (records != null) {
        for (DeletedRecord record : records) {
            DeletedObject object = new DeletedObject();
            object.setID(record.getId());
            object.setDeletedDate(record.getDeletedDate());
            resultRecords.add(object);
        }
    }
    result.setResultRecords(resultRecords);
    return result;
}
Also used : InvalidSObjectFault(com.sforce.soap.partner.fault.InvalidSObjectFault) DeletedResult(org.teiid.translator.salesforce.execution.DeletedResult) ArrayList(java.util.ArrayList) ResourceException(javax.resource.ResourceException) UnexpectedErrorFault(com.sforce.soap.partner.fault.UnexpectedErrorFault) ConnectionException(com.sforce.ws.ConnectionException) DeletedObject(org.teiid.translator.salesforce.execution.DeletedObject)

Example 60 with ResourceException

use of javax.resource.ResourceException in project teiid by teiid.

the class SalesforceConnectionImpl method addBatch.

@Override
public String addBatch(List<com.sforce.async.SObject> payload, JobInfo job) throws ResourceException {
    try {
        BatchRequest request = this.bulkConnection.createBatch(job);
        request.addSObjects(payload.toArray(new com.sforce.async.SObject[payload.size()]));
        return request.completeRequest().getId();
    } catch (AsyncApiException e) {
        throw new ResourceException(e);
    }
}
Also used : SObject(com.sforce.soap.partner.sobject.SObject) ResourceException(javax.resource.ResourceException)

Aggregations

ResourceException (javax.resource.ResourceException)163 TranslatorException (org.teiid.translator.TranslatorException)26 SQLException (java.sql.SQLException)18 IOException (java.io.IOException)17 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)14 ManagedConnection (javax.resource.spi.ManagedConnection)13 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)13 NamingException (javax.naming.NamingException)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 SObject (com.sforce.soap.partner.sobject.SObject)9 ConnectionException (com.sforce.ws.ConnectionException)9 UnexpectedErrorFault (com.sforce.soap.partner.fault.UnexpectedErrorFault)8 ArrayList (java.util.ArrayList)8 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)7 InvalidSObjectFault (com.sforce.soap.partner.fault.InvalidSObjectFault)6 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)6 Set (java.util.Set)6 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)6 XAResource (javax.transaction.xa.XAResource)6 InvalidFieldFault (com.sforce.soap.partner.fault.InvalidFieldFault)5