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);
}
}
}
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);
}
}
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) {
}
}
}
}
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;
}
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);
}
}
Aggregations