use of com.amazonaws.AmazonClientException in project simplejpa by appoxy.
the class EntityManagerSimpleJPA method renameSubclass.
public void renameSubclass(String oldClassName, Class newClass) {
logger.info("Renaming DTYPE for " + oldClassName + " to " + newClass.getSimpleName());
try {
String newClassName = newClass.getSimpleName();
String domainName = factory.getDomainName(newClass);
SelectResult result;
List<Item> items;
int i = 0;
String nextToken = null;
while (i == 0 || nextToken != null) {
result = executeQueryForRenameSubclass(oldClassName, newClass, domainName, nextToken);
items = result.getItems();
putNewValue(domainName, items, EntityManagerFactoryImpl.DTYPE, newClassName);
nextToken = result.getNextToken();
i++;
if (i % 100 == 0) {
System.out.println("Renamed " + i + " subclassed objects so far...");
}
}
} catch (AmazonClientException e) {
e.printStackTrace();
}
}
use of com.amazonaws.AmazonClientException in project simplejpa by appoxy.
the class EntityManagerFactoryImpl method loadDomains.
private synchronized void loadDomains() {
if (domainSet != null)
return;
try {
domainSet = new HashSet<String>();
logger.info("getting all domains");
AmazonSimpleDB db = getSimpleDb();
ListDomainsResult listDomainsResult = db.listDomains();
domainSet.addAll(listDomainsResult.getDomainNames());
while (listDomainsResult.getNextToken() != null) {
ListDomainsRequest request = new ListDomainsRequest().withNextToken(listDomainsResult.getNextToken());
listDomainsResult = db.listDomains(request);
domainSet.addAll(listDomainsResult.getDomainNames());
}
} catch (AmazonClientException e) {
throw new PersistenceException(e);
}
}
use of com.amazonaws.AmazonClientException in project siena by mandubian.
the class SdbPersistenceManager method count.
public <T> int count(Query<T> query) {
StringBuffer domainBuf = new StringBuffer();
SelectRequest req = SdbMappingUtils.buildCountQuery(query, prefix, domainBuf);
try {
checkDomain(domainBuf.toString());
req.setConsistentRead(isReadConsistent());
SelectResult res = sdb.select(req);
return SdbMappingUtils.mapSelectResultToCount(res);
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
}
use of com.amazonaws.AmazonClientException in project siena by mandubian.
the class SdbPersistenceManager method insert.
public void insert(Object obj) {
Class<?> clazz = obj.getClass();
ClassInfo info = ClassInfo.getClassInfo(clazz);
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
try {
checkDomain(domain);
sdb.putAttributes(SdbMappingUtils.createPutRequest(domain, clazz, info, obj));
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
}
use of com.amazonaws.AmazonClientException in project siena by mandubian.
the class SdbPersistenceManager method delete.
public void delete(Object obj) {
Class<?> clazz = obj.getClass();
String domain = SdbMappingUtils.getDomainName(clazz, prefix);
try {
checkDomain(domain);
sdb.deleteAttributes(SdbMappingUtils.createDeleteRequest(domain, clazz, obj));
} catch (AmazonClientException ex) {
throw new SienaException(ex);
}
}
Aggregations