Java 类com.amazonaws.services.simpledb.model.DeleteAttributesRequest 实例源码

项目:Sqawsh    文件:OptimisticPersister.java   
@Override
public void deleteAllAttributes(String itemName) {

  if (!initialised) {
    throw new IllegalStateException("The optimistic persister has not been initialised");
  }

  logger.log("About to delete all attributes from simpledb item: " + itemName);

  DeleteAttributesRequest deleteAttributesRequest = new DeleteAttributesRequest(
      simpleDbDomainName, itemName);
  AmazonSimpleDB client = getSimpleDBClient();
  client.deleteAttributes(deleteAttributesRequest);

  logger.log("Deleted all attributes from simpledb item.");
}
项目:agathon    文件:SdbCassandraInstanceDaoTest.java   
@Test
public void delete() {
  CassandraInstance instance = createMock(CassandraInstance.class);
  Capture<DeleteAttributesRequest> requestCapture = new Capture<DeleteAttributesRequest>();
  expect(domainFactory.createFromRing(RING_NAME)).andReturn(domain(RING_NAME));
  expect(instance.getId()).andReturn(ID).times(2);
  expect(instance.getDataCenter()).andReturn(DATACENTER);
  expect(instance.getRack()).andReturn(RACK);
  expect(instance.getHostName()).andReturn(HOSTNAME);
  expect(instance.getPublicIpAddress()).andReturn(PUBLIC_IP_ADDRESS);
  expect(instance.getFullyQualifiedDomainName()).andReturn(FULLY_QUALIFIED_DOMAIN_NAME);
  simpleDbClient.deleteAttributes(capture(requestCapture));
  replayAll();

  dao.delete(RING_NAME, instance);

  DeleteAttributesRequest request = requestCapture.getValue();
  assertEquals(DOMAIN, request.getDomainName());
  assertEquals(String.valueOf(ID), request.getItemName());
  assertAttributes(request);
}
项目:agathon    文件:SdbCassandraInstanceDaoTest.java   
private static void assertAttributes(DeleteAttributesRequest request) {
  assertEquals(6, request.getAttributes().size());
  for (Attribute attr : request.getAttributes()) {
    if (attr.getName().equals(SdbCassandraInstanceDao.ID_KEY)) {
      assertEquals(String.valueOf(ID), attr.getValue());
    } else if (attr.getName().equals(SdbCassandraInstanceDao.DATACENTER_KEY)) {
      assertEquals(DATACENTER, attr.getValue());
    } else if (attr.getName().equals(SdbCassandraInstanceDao.RACK_KEY)) {
      assertEquals(RACK, attr.getValue());
    } else if (attr.getName().equals(SdbCassandraInstanceDao.HOSTNAME_KEY)) {
      assertEquals(HOSTNAME, attr.getValue());
    } else if (attr.getName().endsWith(SdbCassandraInstanceDao.PUBLIC_IP_ADDRESS_KEY)) {
      assertEquals(PUBLIC_IP_ADDRESS, attr.getValue());
    } else if (attr.getName().endsWith(SdbCassandraInstanceDao.FULLY_QUALIFIED_DOMAIN_NAME_KEY)) {
      assertEquals(FULLY_QUALIFIED_DOMAIN_NAME, attr.getValue());
    } else {
      assertDuplicateAttribute(attr.getName(), attr.getValue());
    }
  }
}
项目:Sqawsh    文件:OptimisticPersisterTest.java   
public void testDeleteAllAttributesCorrectlyCallsTheDatabase() throws Exception {
  // ARRANGE
  initialiseOptimisticPersister();

  DeleteAttributesRequest deleteAttributesRequest = new DeleteAttributesRequest(
      testSimpleDBDomainName, testItemName);
  mockery.checking(new Expectations() {
    {
      oneOf(mockSimpleDBClient).deleteAttributes(with(equal(deleteAttributesRequest)));
    }
  });

  // ACT
  optimisticPersister.deleteAllAttributes(testItemName);
}
项目:Camel    文件:DeleteAttributesCommand.java   
public void execute() {
    DeleteAttributesRequest request = new DeleteAttributesRequest()
        .withDomainName(determineDomainName())
        .withItemName(determineItemName())
        .withExpected(determineUpdateCondition())
        .withAttributes(determineAttributes());
    log.trace("Sending request [{}] for exchange [{}]...", request, exchange);

    this.sdbClient.deleteAttributes(request);

    log.trace("Request sent");
}
项目:Camel    文件:AmazonSDBClientMock.java   
@Override
public DeleteAttributesResult deleteAttributes(DeleteAttributesRequest deleteAttributesRequest) throws AmazonServiceException, AmazonClientException {
    this.deleteAttributesRequest = deleteAttributesRequest;

    String domainName = deleteAttributesRequest.getDomainName();
    if ("MissingDomain".equals(domainName)) {
        throw new NoSuchDomainException(domainName);
    }
    return new DeleteAttributesResult();
}
项目:aws-cms-plugins    文件:WPBAwsSdbAdminDataStorage.java   
public <T> void delete(String recordid, Class<T> dataClass)
        throws WPBIOException {
    try
    {
        DeleteAttributesRequest deleteAttributesRequest = new DeleteAttributesRequest(domainName, createInternalKey(recordid, dataClass));
        sdbClient.deleteAttributes(deleteAttributesRequest);
    } catch (Exception e)
    {
        throw new WPBIOException("Cannot delete record " + recordid, e);
    }       
}
项目:jcabi-simpledb    文件:AwsItem.java   
/**
 * {@inheritDoc}
 */
@Override
public String remove(final Object key) {
    final String before = this.get(key);
    this.credentials.aws().deleteAttributes(
        new DeleteAttributesRequest()
            .withDomainName(this.table)
            .withItemName(this.label)
            .withAttributes(new Attribute().withName(key.toString()))
    );
    return before;
}
项目:jcabi-simpledb    文件:AwsItem.java   
/**
 * {@inheritDoc}
 */
@Override
public void clear() {
    this.credentials.aws().deleteAttributes(
        new DeleteAttributesRequest()
            .withDomainName(this.table)
            .withItemName(this.label)
    );
}
项目:spring-data-simpledb    文件:SimpleDbTemplate.java   
@Override
public void deleteAttributesImpl(String domainName, String itemName) {
    LOGGER.debug("Delete Domain\"{}\" ItemName \"{}\"", domainName, itemName);

    Assert.notNull(domainName, "Domain name should not be null");
    Assert.notNull(itemName, "Item name should not be null");

    getDB().deleteAttributes(new DeleteAttributesRequest(domainName, itemName));
}
项目:Sqawsh    文件:OptimisticPersister.java   
@Override
public void delete(String itemName, Attribute attribute) throws Exception {

  if (!initialised) {
    throw new IllegalStateException("The optimistic persister has not been initialised");
  }

  logger.log("About to delete attribute from simpledb item: " + itemName);

  AmazonSimpleDB client = getSimpleDBClient();

  // We retry the delete if necessary if we get a
  // ConditionalCheckFailed exception, i.e. if someone else modifies the
  // database between us reading and writing it.
  RetryHelper
      .DoWithRetries(() -> {
        try {
          // Get existing attributes (and version number), via consistent
          // read:
          ImmutablePair<Optional<Integer>, Set<Attribute>> versionedAttributes = get(itemName);

          if (!versionedAttributes.left.isPresent()) {
            logger
                .log("A version number attribute did not exist - this means no attributes exist, so we have nothing to delete.");
            return null;
          }
          if (!versionedAttributes.right.contains(attribute)) {
            logger.log("The attribute did not exist - so we have nothing to delete.");
            return null;
          }

          // Since it seems impossible to update the version number while
          // deleting an attribute, we first mark the attribute as inactive,
          // and then delete it.
          ReplaceableAttribute inactiveAttribute = new ReplaceableAttribute();
          inactiveAttribute.setName(attribute.getName());
          inactiveAttribute.setValue("Inactive" + attribute.getValue());
          inactiveAttribute.setReplace(true);
          put(itemName, versionedAttributes.left, inactiveAttribute);

          // Now we can safely delete the attribute, as other readers will now
          // ignore it.
          UpdateCondition updateCondition = new UpdateCondition();
          updateCondition.setName(inactiveAttribute.getName());
          updateCondition.setValue(inactiveAttribute.getValue());
          // Update will proceed unless the attribute no longer exists
          updateCondition.setExists(true);

          Attribute attributeToDelete = new Attribute();
          attributeToDelete.setName(inactiveAttribute.getName());
          attributeToDelete.setValue(inactiveAttribute.getValue());
          List<Attribute> attributesToDelete = new ArrayList<>();
          attributesToDelete.add(attributeToDelete);
          DeleteAttributesRequest simpleDBDeleteRequest = new DeleteAttributesRequest(
              simpleDbDomainName, itemName, attributesToDelete, updateCondition);
          client.deleteAttributes(simpleDBDeleteRequest);
          logger.log("Deleted attribute from simpledb");
          return null;
        } catch (AmazonServiceException ase) {
          if (ase.getErrorCode().contains("AttributeDoesNotExist")) {
            // Case of trying to delete an attribute that no longer exists -
            // that's ok - it probably just means more than one person was
            // trying to delete the attribute at once. So swallow this
            // exception
            logger
                .log("Caught AmazonServiceException for AttributeDoesNotExist whilst deleting attribute so"
                    + " swallowing and continuing");
            return null;
          } else {
            throw ase;
          }
        }
      }, Exception.class, Optional.of("Database put failed - conditional check failed"), logger);
}
项目:OpenUnison    文件:AmazonSimpleDBProvider.java   
@Override
public void deleteUser(User user,Map<String,Object> request) throws ProvisioningException {


    int approvalID = 0;




    if (request.containsKey("APPROVAL_ID")) {
        approvalID = (Integer) request.get("APPROVAL_ID");
    }

    Workflow workflow = (Workflow) request.get("WORKFLOW");

    String userid = user.getAttribs().get(this.uidAttrName).getValues().get(0);
    this.sdb.deleteAttributes(new DeleteAttributesRequest(this.userDomain,userid));
    this.cfgMgr.getProvisioningEngine().logAction(this.name,true, ActionType.Delete, approvalID, workflow, "userName",userid);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

    }
}
项目:QuotesSocial    文件:SimpleDB.java   
public static void deleteItemAttribute(String domainName, String itemName, String attributeName) {
    getInstance().deleteAttributes(new DeleteAttributesRequest(domainName, itemName)
            .withAttributes(new Attribute[]{new Attribute().withName(attributeName)}));
}
项目:agathon    文件:SdbCassandraInstanceDao.java   
@Override
public void delete(String ring, CassandraInstance instance) {
  DeleteAttributesRequest request = new DeleteAttributesRequest(
      domain(ring), String.valueOf(instance.getId()), buildDeleteAttributes(instance));
  client.deleteAttributes(request);
}
项目:QuotesSocial    文件:SimpleDB.java   
/**
 * Delete an item
 *
 * @param domainName table name
 * @param itemName   itemName for the item
 */
public static void deleteItem(String domainName, String itemName) {
    getInstance().deleteAttributes(new DeleteAttributesRequest(domainName, itemName));
}