Implementation of deleteScope REST API.

@param scopeName           The scope name of stream.
@param securityContext     The security for API access.
@param asyncResponse       AsyncResponse provides means for asynchronous server side response processing.
167878
@Override
    public void deleteScope(final String scopeName, final SecurityContext securityContext,
            final AsyncResponse asyncResponse) {
        long traceId = LoggerHelpers.traceEnter(log, "deleteScope");

        try {
            restAuthHelper.authenticateAuthorize(getAuthorizationHeader(),
                    AuthResourceRepresentation.ofScopes(), READ_UPDATE);
        } catch (AuthException e) {
            log.warn("Delete scope for {} failed due to authentication failure.", scopeName);
            asyncResponse.resume(Response.status(Status.fromStatusCode(e.getResponseCode())).build());
            LoggerHelpers.traceLeave(log, "createStream", traceId);
            return;
        }

        controllerService.deleteScope(scopeName).thenApply(scopeStatus -> {
            if (scopeStatus.getStatus() == DeleteScopeStatus.Status.SUCCESS) {
                log.info("Successfully deleted scope: {}", scopeName);
                return Response.status(Status.NO_CONTENT).build();
            } else if (scopeStatus.getStatus() == DeleteScopeStatus.Status.SCOPE_NOT_FOUND) {
                log.warn("Scope: {} not found", scopeName);
                return Response.status(Status.NOT_FOUND).build();
            } else if (scopeStatus.getStatus() == DeleteScopeStatus.Status.SCOPE_NOT_EMPTY) {
                log.warn("Cannot delete scope: {} with non-empty streams", scopeName);
                return Response.status(Status.PRECONDITION_FAILED).build();
            } else {
                log.warn("deleteScope for {} failed", scopeName);
                return Response.status(Status.INTERNAL_SERVER_ERROR).build();
            }
        }).exceptionally(exception -> {
            log.warn("deleteScope for {} failed with exception: {}", scopeName, exception);
            return Response.status(Status.INTERNAL_SERVER_ERROR).build();
        }).thenApply(asyncResponse::resume)
        .thenAccept(x -> LoggerHelpers.traceLeave(log, "deleteScope", traceId));
    }
807180
public CompletableFuture<TxnStatus> abortTxn(final String scope,
                                                 final String stream,
                                                 final UUID txId,
                                                 final Version version,
                                                 final OperationContext contextOpt) {
        final OperationContext context = getNonNullOperationContext(scope, stream, contextOpt);
        return withRetriesAsync(() -> sealTxnBody(hostId, scope, stream, false, txId, version, context),
                RETRYABLE_PREDICATE, 3, executor);
    }
476717
protected void deactivate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "CommsClientServiceFacade deactivated, reason=");

        performAction(destroyChainAction);
        _sslOptions.deactivate(context);
        _sslFactoryProvider.deactivate(context);
        _isActivated = false;
    }
216606
@Override
    public java.util.concurrent.Future<DeleteMessageResult> deleteMessageAsync(String queueUrl, String receiptHandle) {

        return deleteMessageAsync(new DeleteMessageRequest().withQueueUrl(queueUrl).withReceiptHandle(receiptHandle));
    }
302496
@Override
    public void close() {
        try {
            if (clientSidePolicy != null) {
                clientSidePolicy.removePropertyChangeListener(this);
            }

        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Finished servicing http request on conduit. ");
            }
            //clean up address within threadlocal of EndPointInfo
            endpointInfo.resetAddress();    //Liberty #3669
        }

    }
1163544
@DELETE
    @Path("/{name}")
    public Response delete(@Auth final DbCredential credential, @PathParam("name") final String name){
        if(!credential.getRoles().contains(DbCredential.AvailableRoles.DATA_DELETER)){
            throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build());
        }

        LOG.info("Got a delete organization request.");
        getOrganizationHandler().deleteOrganization(name);

        return Response.ok("done").build();
    }
1012665
@Override
    public java.util.concurrent.Future<RemovePermissionResult> removePermissionAsync(String queueUrl, String label) {

        return removePermissionAsync(new RemovePermissionRequest().withQueueUrl(queueUrl).withLabel(label));
    }
982791
public static void putServiceResponseIntoRequestScope(final RequestContext requestContext, final Response response) {
        requestContext.getRequestScope().put("parameters", response.getAttributes());
        putServiceRedirectUrl(requestContext, response.getUrl());
    }
364265
public TypeUsage.Builder scope(Optional<? extends QualifiedName> scope) {
    if (scope.isPresent()) {
      return scope(scope.get());
    } else {
      return clearScope();
    }
  }
460651
public TypeUsage.Builder nullableScope(QualifiedName scope) {
    if (scope != null) {
      return scope(scope);
    } else {
      return clearScope();
    }
  }
143306
public void addScope(ApiAppOauthScopeType scope) {
        if (oauth == null) {
            oauth = new ApiAppOauth();
        }
        oauth.addScope(scope);
    }
326333
private CompletableFuture<Void> tryDeleteSealedCollection(String scope, String stream, Integer collectionNum) {
        // purge garbage znodes
        // attempt to delete entities node
        // delete collection
        return getLatestCollection(scope, stream)
                .thenCompose(latestcollectionNum ->
                        // 1. purge
                        storeHelper.getChildren(getEntitiesPath(scope, stream, collectionNum))
                                   .thenCompose(entitiesPos -> {
                                       String entitiesPath = getEntitiesPath(scope, stream, collectionNum);

                                       // delete entities greater than max pos
                                       return Futures.allOf(entitiesPos.stream().filter(pos -> getPositionFromPath(pos) > rollOverAfter)
                                                                    .map(pos -> storeHelper.deletePath(ZKPaths.makePath(entitiesPath, pos), false))
                                                                    .collect(Collectors.toList()));
                                   }))
                .thenCompose(x -> {
                    // 2. Try deleting entities root path. 
                    // if we are able to delete entities node then we can delete the whole thing
                    return Futures.exceptionallyExpecting(storeHelper.deletePath(getEntitiesPath(scope, stream, collectionNum), false)
                                                                     .thenCompose(v -> storeHelper.deleteTree(getCollectionPath(scope, stream, collectionNum))),
                            e -> Exceptions.unwrap(e) instanceof StoreException.DataNotEmptyException, null);
                });
    }
1269188
public static void purgeOAuthAccessTokens(RequestContext requestContext, String provider) {
    String key = String.format(PROVIDER_ACCESS_TOKENS, provider);
    HttpSession session = requestContext.getRequest().getSession();
    OAuthAccessToken[] accessTokens = (OAuthAccessToken[]) session.getAttribute(key);
    if (accessTokens != null) {
      session.removeAttribute(key);
    }
  }
996427
@DELETE
    @Timed
    public void deleteResource(@Suspended final AsyncResponse response, @Context final Request request,
            @Context final UriInfo uriInfo, @Context final HttpHeaders headers,
            @Context final SecurityContext secContext) {
        final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext);
        final String urlBase = getBaseUrl(req);
        final IRI identifier = rdf.createIRI(TRELLIS_DATA_PREFIX + req.getPath());
        final DeleteHandler deleteHandler = new DeleteHandler(req, trellis, urlBase);

        getParent(identifier).thenCombine(trellis.getResourceService().get(identifier), deleteHandler::initialize)
            .thenCompose(deleteHandler::deleteResource).thenApply(ResponseBuilder::build)
            .exceptionally(this::handleException).thenApply(response::resume);
    }
7578
public CompletableFuture<CreateScopeStatus> createScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        try {
            NameUtils.validateScopeName(scope);
        } catch (IllegalArgumentException | NullPointerException e) {
            log.warn("Create scope failed due to invalid scope name {}", scope);
            return CompletableFuture.completedFuture(CreateScopeStatus.newBuilder().setStatus(
                    CreateScopeStatus.Status.INVALID_SCOPE_NAME).build());
        }
        return streamStore.createScope(scope);
    }
1054305
public CompletableFuture<Map<String, StreamConfiguration>> listStreamsInScope(final String scope) {
        Exceptions.checkNotNullOrEmpty(scope, "scope");
        return streamStore.listStreamsInScope(scope);
    }
1050204
public Observable<SecretBundle> deleteSecretAsync(String vaultBaseUrl, String secretName) {
        return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1<ServiceResponse<SecretBundle>, SecretBundle>() {
            @Override
            public SecretBundle call(ServiceResponse<SecretBundle> response) {
                return response.body();
            }
        });
    }