private Command<Void> getDeleteCommand(final Resource resource) {
    return new Command<Void>() {
      @Override
      public Void invoke() throws AmbariException {
        // flatten out key properties as is expected by createForeignKeyMap()
        Map<String, Object> keyProperties = new HashMap<>();
        for (Map.Entry<String, Object> entry : resource.getPropertiesMap().get(RESPONSE_KEY).entrySet()) {
          keyProperties.put(String.format("Artifacts/%s", entry.getKey()), entry.getValue());
        }

        // find entity to remove
        String artifactName = String.valueOf(resource.getPropertyValue(ARTIFACT_NAME_PROPERTY));
        TreeMap<String, String> artifactForeignKeys = createForeignKeyMap(keyProperties);
        ArtifactEntity entity = artifactDAO.findByNameAndForeignKeys(artifactName, artifactForeignKeys);

        if (entity != null) {
          LOG.info("Deleting Artifact: name = {}, foreign keys = {}",
              entity.getArtifactName(), entity.getForeignKeys());
          artifactDAO.remove(entity);
        } else {
          LOG.info("Cannot find Artifact to delete, ignoring: name = {}, foreign keys = {}",
              artifactName, artifactForeignKeys);
        }

        return null;
      }
    };
  }
Create a command to delete a resource.

@param resource the resource to delete

@return  a delete resource command
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ArtifactResourceProvider.java