use of com.amazonaws.AmazonClientException in project teiid by teiid.
the class SimpleDBConnectionImpl method performSelect.
/**
* Performs select expression. This expression must be in format which is understandable to SimpleDB database
* @param selectExpression
* @param columns
* @return Iterator of List<String> results
*/
@Override
public SelectResult performSelect(String selectExpression, String nextToken) throws TranslatorException {
try {
SelectRequest selectRequest = new SelectRequest(selectExpression);
if (nextToken != null) {
selectRequest.setNextToken(nextToken);
}
selectRequest.setConsistentRead(true);
return client.select(selectRequest);
} catch (AmazonServiceException e) {
throw new TranslatorException(e);
} catch (AmazonClientException e) {
throw new TranslatorException(e);
}
}
use of com.amazonaws.AmazonClientException in project teiid by teiid.
the class SimpleDBConnectionImpl method performUpdate.
/**
* Performs update on given domain and items
* @param domainName
* @param items
*/
@Override
public int performUpdate(String domainName, Map<String, Object> updateAttributes, String selectExpression) throws TranslatorException {
try {
List<ReplaceableAttribute> attributes = new ArrayList<ReplaceableAttribute>();
for (Map.Entry<String, Object> column : updateAttributes.entrySet()) {
addAttribute(column.getKey(), column.getValue(), attributes);
}
List<ReplaceableItem> updateItems = new ArrayList<ReplaceableItem>();
int count = 0;
String nextToken = null;
do {
SelectResult result = performSelect(selectExpression, nextToken);
nextToken = result.getNextToken();
Iterator<Item> iter = result.getItems().iterator();
while (iter.hasNext()) {
Item item = iter.next();
updateItems.add(new ReplaceableItem(item.getName(), attributes));
count++;
if (count % 25 == 0) {
executeBatch(domainName, updateItems);
updateItems.clear();
}
}
executeBatch(domainName, updateItems);
} while (nextToken != null);
return count;
} catch (AmazonServiceException e) {
throw new TranslatorException(e);
} catch (AmazonClientException e) {
throw new TranslatorException(e);
}
}
use of com.amazonaws.AmazonClientException in project opencast by opencast.
the class AwsS3DistributionServiceImpl method retractElement.
/**
* Retracts the media package element with the given identifier from the distribution channel.
*
* @param channelId
* the channel id
* @param mediaPackage
* the media package
* @param element
* the element
* @return the retracted element or <code>null</code> if the element was not retracted
*/
protected MediaPackageElement retractElement(String channelId, MediaPackage mediaPackage, MediaPackageElement element) throws DistributionException {
notNull(mediaPackage, "mediaPackage");
notNull(element, "element");
try {
String objectName = getDistributedObjectName(element);
if (objectName != null) {
s3.deleteObject(bucketName, objectName);
logger.info("Retracted element {}, object {}", element.getIdentifier(), objectName);
}
return element;
} catch (AmazonClientException e) {
throw new DistributionException("AWS error: " + e.getMessage(), e);
}
}
use of com.amazonaws.AmazonClientException in project spring-integration-aws by spring-projects.
the class S3MessageHandler method handleRequestMessage.
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
Command command = this.commandExpression.getValue(this.evaluationContext, requestMessage, Command.class);
Assert.state(command != null, "'commandExpression' [" + this.commandExpression.getExpressionString() + "] cannot evaluate to null.");
Transfer transfer = null;
switch(command) {
case UPLOAD:
transfer = upload(requestMessage);
break;
case DOWNLOAD:
transfer = download(requestMessage);
break;
case COPY:
transfer = copy(requestMessage);
break;
}
if (this.produceReply) {
return transfer;
} else {
try {
AmazonClientException amazonClientException = transfer.waitForException();
if (amazonClientException != null) {
throw amazonClientException;
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return null;
}
}
use of com.amazonaws.AmazonClientException in project thunder by RohanNagar.
the class UsersDao method insert.
/**
* Insert a new PilotUser into the data store.
*
* @param user The object to insert.
* @return The PilotUser object that was created.
* @throws DatabaseException If the user already exists or if the database is down.
*/
public PilotUser insert(PilotUser user) {
checkNotNull(user);
long now = Instant.now().toEpochMilli();
Item item = new Item().withPrimaryKey("email", user.getEmail().getAddress()).withString("id", UUID.randomUUID().toString()).withString("version", UUID.randomUUID().toString()).withLong("creation_time", now).withLong("update_time", now).withJSON("document", toJson(mapper, user));
try {
table.putItem(item, new Expected("email").notExist());
} catch (ConditionalCheckFailedException e) {
LOG.error("The user {} already exists in the database. Throwing DatabaseException.", user.getEmail());
throw new DatabaseException("The user already exists.", DatabaseError.CONFLICT);
} catch (AmazonServiceException e) {
LOG.error("The database rejected the create request.", e);
throw new DatabaseException("The database rejected the create request.", DatabaseError.REQUEST_REJECTED);
} catch (AmazonClientException e) {
LOG.error("The database is currently unresponsive.", e);
throw new DatabaseException("The database is currently unavailable.", DatabaseError.DATABASE_DOWN);
}
return user;
}
Aggregations