/** * Clean up the policies for the specified component resource. * * @param componentResource the resource for the component */ private void cleanUpPolicies(final Resource componentResource) { // ensure the authorizer supports configuration if (accessPolicyDAO.supportsConfigurableAuthorizer()) { final List<Resource> resources = new ArrayList<>(); resources.add(componentResource); resources.add(ResourceFactory.getDataResource(componentResource)); resources.add(ResourceFactory.getProvenanceDataResource(componentResource)); resources.add(ResourceFactory.getDataTransferResource(componentResource)); resources.add(ResourceFactory.getPolicyResource(componentResource)); for (final Resource resource : resources) { for (final RequestAction action : RequestAction.values()) { try { // since the component is being deleted, also delete any relevant access policies final AccessPolicy readPolicy = accessPolicyDAO.getAccessPolicy(action, resource.getIdentifier()); if (readPolicy != null) { accessPolicyDAO.deleteAccessPolicy(readPolicy.getIdentifier()); } } catch (final Exception e) { logger.warn(String.format("Unable to remove access policy for %s %s after component removal.", action, resource.getIdentifier()), e); } } } } }
/** * Attempts to roll back all policies for the specified component. This includes the component resource, data resource * for the component, view provenance resource for the component, data transfer resource for the component, and policy resource for the component. * * @param componentResource component resource */ private void rollbackClonedPolicy(final Resource componentResource) { if (!accessPolicyDAO.supportsConfigurableAuthorizer()) { return; } final List<Resource> resources = new ArrayList<>(); resources.add(componentResource); resources.add(ResourceFactory.getDataResource(componentResource)); resources.add(ResourceFactory.getProvenanceDataResource(componentResource)); resources.add(ResourceFactory.getDataTransferResource(componentResource)); resources.add(ResourceFactory.getPolicyResource(componentResource)); for (final Resource resource : resources) { for (final RequestAction action : RequestAction.values()) { final AccessPolicy accessPolicy = accessPolicyDAO.getAccessPolicy(action, resource.getIdentifier()); if (accessPolicy != null) { try { accessPolicyDAO.deleteAccessPolicy(accessPolicy.getIdentifier()); } catch (final Exception e) { logger.warn(String.format("Unable to clean up cloned access policy for %s %s after failed copy/paste action.", action, componentResource.getIdentifier()), e); } } } } }
final Resource cloneResource = entry.getValue(); for (final RequestAction action : RequestAction.values()) { final AccessPolicy accessPolicy = accessPolicyDAO.getAccessPolicy(action, originalResource.getIdentifier());