Search in sources :

Example 51 with AmazonClientException

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();
    }
}
Also used : SelectResult(com.amazonaws.services.simpledb.model.SelectResult) Item(com.amazonaws.services.simpledb.model.Item) AmazonClientException(com.amazonaws.AmazonClientException)

Example 52 with AmazonClientException

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);
    }
}
Also used : ListDomainsResult(com.amazonaws.services.simpledb.model.ListDomainsResult) ListDomainsRequest(com.amazonaws.services.simpledb.model.ListDomainsRequest) AmazonSimpleDB(com.amazonaws.services.simpledb.AmazonSimpleDB) AmazonClientException(com.amazonaws.AmazonClientException) PersistenceException(javax.persistence.PersistenceException)

Example 53 with AmazonClientException

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);
    }
}
Also used : SelectResult(com.amazonaws.services.simpledb.model.SelectResult) AmazonClientException(com.amazonaws.AmazonClientException) SienaException(siena.SienaException) SelectRequest(com.amazonaws.services.simpledb.model.SelectRequest)

Example 54 with AmazonClientException

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);
    }
}
Also used : AmazonClientException(com.amazonaws.AmazonClientException) SienaException(siena.SienaException) ClassInfo(siena.ClassInfo)

Example 55 with AmazonClientException

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);
    }
}
Also used : AmazonClientException(com.amazonaws.AmazonClientException) SienaException(siena.SienaException)

Aggregations

AmazonClientException (com.amazonaws.AmazonClientException)202 IOException (java.io.IOException)70 AmazonServiceException (com.amazonaws.AmazonServiceException)32 ArrayList (java.util.ArrayList)32 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)23 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)19 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)17 HashMap (java.util.HashMap)16 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)14 Test (org.junit.Test)14 SienaException (siena.SienaException)12 AWSCredentials (com.amazonaws.auth.AWSCredentials)11 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)11 GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)11 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)11 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)10 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)10 InterruptedIOException (java.io.InterruptedIOException)10 DeleteObjectsRequest (com.amazonaws.services.s3.model.DeleteObjectsRequest)9 File (java.io.File)9