public void deleteClient(String organizationId, String clientId)
        throws OrganizationNotFoundException, NotAuthorizedException, EntityStillActiveException {

        tryAction(() -> {
            ClientBean client = getClientFromStorage(organizationId, clientId);
            Iterator<ClientVersionBean> clientVersions = storage.getAllClientVersions(organizationId, clientId);
            Iterable<ClientVersionBean> iterable = () -> clientVersions;

            List<ClientVersionBean> registeredElems = StreamSupport.stream(iterable.spliterator(), false)
                .filter(clientVersion -> clientVersion.getStatus() == ClientStatus.Registered)
                .limit(5)
                .collect(toList());

            if (!registeredElems.isEmpty()) {
                throw ExceptionFactory.entityStillActiveExceptionClientVersions(registeredElems);
            }

            storage.deleteClient(client);
            if (client.getImage() != null) {
                blobstore.remove(client.getImage());
            }
            LOGGER.debug("Deleted ClientApp: {0}", client.getName()); //$NON-NLS-1$
        });
    }
@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ClientAppService.java