class ApplicationsResource extends RealmAwareResource {

    @Override
    public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String resourceId,
            DeleteRequest request) {

        final Subject subject = getContextSubject(context);
        if (subject == null) {
            debug.error("ApplicationsResource :: DELETE : Unknown Subject");
            return new BadRequestException().asPromise();
        }

        final String realm = getRealm(context);
        try {
            if (!applicationExists(resourceId, realm, subject)) {
                throw new EntitlementException(EntitlementException.NO_SUCH_APPLICATION, resourceId);
            }
            appService(subject, realm).deleteApplication(resourceId);
            return newResultPromise(newResourceResponse(resourceId, "0", JsonValue.json(JsonValue.object())));
        } catch (EntitlementException e) {
            debug.error("ApplicationsResource :: DELETE by {}: Application failed to delete the resource specified. ",
                    getPrincipalNameFromSubject(subject), e);
            return exceptionMappingHandler.handleError(context, request, e).asPromise();
        }
    }

    @Inject public  ApplicationsResource(@Named("frRest") Debug debug, ApplicationServiceFactory applicationServiceFactory,
            ApplicationTypeManagerWrapper appTypeManagerWrapper,
            ExceptionMappingHandler<EntitlementException, ResourceException> exceptionMappingHandler);

}