@Override
    public void delete(Long pluginId) throws PluginNotFoundException,
            NotAuthorizedException {
        securityContext.checkAdminPermissions();

        try {
            List<PolicyDefinitionSummaryBean> policyDefs = query.listPluginPolicyDefs(pluginId);

            PluginBean pbean = storage.getPlugin(pluginId);
            if (pbean == null) {
                throw ExceptionFactory.pluginNotFoundException(pluginId);
            }
            pbean.setDeleted(true);
            storage.updatePlugin(pbean);

            // Now delete all the policy definitions for this plugin.
            for (PolicyDefinitionSummaryBean policyDef : policyDefs) {
                PolicyDefinitionBean definition = storage.getPolicyDefinition(policyDef.getId());
                if (definition != null) {
                    definition.setDeleted(true);
                    storage.updatePolicyDefinition(definition);
                }
            }

            LOGGER.info(String.format("Deleted plugin mvn:%s:%s:%s", pbean.getGroupId(), pbean.getArtifactId(),  //$NON-NLS-1$
                    pbean.getVersion()));
        } catch (AbstractRestException e) {
            throw e;
        } catch (Exception e) {
            throw new SystemErrorException(e);
        }
    }
@see IPluginResource#delete(java.lang.Long)
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/PluginResourceImpl.java