class ScriptConfigurationService implements ScriptingService, ServiceListener {

    @Override
    public void delete(String uuid) throws ScriptException {
        Reject.ifTrue(lock.getReadHoldCount() > 0, "Should not already be locked for reading");
        lock.readLock().lock();
        try {
            failIfUuidDoesNotExist(uuid);
            ScriptConfiguration scriptConfig = get(uuid);
            if (containsGlobalUuid(uuid) || isDefaultScript(scriptConfig)) {
                throw new ScriptException(DELETING_DEFAULT_SCRIPT, scriptConfig.getName());
            }
            lock.readLock().unlock();
            lock.writeLock().lock();
            try {
                int usageCount = getUsageCount(scriptConfig);
                if (usageCount > 0) {
                    if (usageCount == 1) {
                        throw new ScriptException(DELETING_SCRIPT_IN_USE_SINGULAR, scriptConfig.getName());
                    }
                    throw new ScriptException(DELETING_SCRIPT_IN_USE_PLURAL,
                            scriptConfig.getName(), Integer.toString(usageCount));
                }
                getSubOrgConfig().removeSubConfig(uuid);
                realmConfigurations.remove(uuid);
            } catch (SSOException | SMSException e) {
                throw createAndLogError(logger, DELETE_FAILED, e, uuid, realm);
            } finally {
                lock.readLock().lock();
                lock.writeLock().unlock();
            }
        } finally {
            lock.readLock().unlock();
        }
    }

    @Inject public  ScriptConfigurationService(Logger logger, String realm, CoreWrapper coreWrapper, ServiceConfigManager scm);

}