Search in sources :

Example 6 with ScanResult

use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.

the class DynamoDbServiceRegistryFacilitator method count.

/**
 * Count long.
 *
 * @return the long
 */
public long count() {
    final ScanRequest scan = new ScanRequest(dynamoDbProperties.getTableName());
    LOGGER.debug("Scanning table with request [{}] to count items", scan);
    final ScanResult result = this.amazonDynamoDBClient.scan(scan);
    LOGGER.debug("Scanned table with result [{}]", scan);
    return result.getCount();
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult)

Example 7 with ScanResult

use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.

the class DynamoDbServiceRegistryFacilitator method getAll.

/**
 * Gets all.
 *
 * @return the all
 */
public List<RegisteredService> getAll() {
    final List<RegisteredService> services = new ArrayList<>();
    final ScanRequest scan = new ScanRequest(dynamoDbProperties.getTableName());
    LOGGER.debug("Scanning table with request [{}]", scan);
    final ScanResult result = this.amazonDynamoDBClient.scan(scan);
    LOGGER.debug("Scanned table with result [{}]", scan);
    services.addAll(result.getItems().stream().map(this::deserializeServiceFromBinaryBlob).sorted((o1, o2) -> Integer.valueOf(o1.getEvaluationOrder()).compareTo(o2.getEvaluationOrder())).collect(Collectors.toList()));
    return services;
}
Also used : ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) ArrayList(java.util.ArrayList)

Example 8 with ScanResult

use of com.amazonaws.services.dynamodbv2.model.ScanResult in project cas by apereo.

the class DynamoDbTicketRegistryFacilitator method getAll.

/**
 * Gets all.
 *
 * @return the all
 */
public Collection<Ticket> getAll() {
    final Collection<Ticket> tickets = new ArrayList<>();
    final Collection<TicketDefinition> metadata = this.ticketCatalog.findAll();
    metadata.forEach(r -> {
        final ScanRequest scan = new ScanRequest(r.getProperties().getStorageName());
        LOGGER.debug("Scanning table with request [{}]", scan);
        final ScanResult result = this.amazonDynamoDBClient.scan(scan);
        LOGGER.debug("Scanned table with result [{}]", scan);
        tickets.addAll(result.getItems().stream().map(DynamoDbTicketRegistryFacilitator::deserializeTicket).collect(Collectors.toList()));
    });
    return tickets;
}
Also used : Ticket(org.apereo.cas.ticket.Ticket) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) ArrayList(java.util.ArrayList) TicketDefinition(org.apereo.cas.ticket.TicketDefinition)

Aggregations

ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)8 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)7 HashMap (java.util.HashMap)4 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)3 ArrayList (java.util.ArrayList)2 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)1 ConsumedCapacity (com.amazonaws.services.dynamodbv2.model.ConsumedCapacity)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Ticket (org.apereo.cas.ticket.Ticket)1 TicketDefinition (org.apereo.cas.ticket.TicketDefinition)1 PropertiesPropertySource (org.springframework.core.env.PropertiesPropertySource)1