public static void applyDefaultLifeCycle(Registry registry, Resource resource, String path, String defaultLifeCycle) throws RegistryException { if (defaultLifeCycle != null && !defaultLifeCycle.isEmpty()) { String[] lifeCycles = defaultLifeCycle.split(","); ArrayUtils.reverse(lifeCycles); if (CurrentSession.getLocalPathMap() != null && !Boolean.valueOf(CurrentSession.getLocalPathMap().get(CommonConstants.ARCHIEVE_UPLOAD))) { for (String lifeCycle : lifeCycles) { if (StringUtils.isNotEmpty(lifeCycle)){ registry.associateAspect(resource.getId(), lifeCycle); } } } else { for (String lifeCycle : lifeCycles) { if (StringUtils.isNotEmpty(lifeCycle)){ registry.associateAspect(path, lifeCycle); } } } } }
/** * Method to associate an aspect with a given resource on the registry. * * @param path the path of the resource. * @param aspect the aspect to add. * @param registry the registry instance on which the resource is available. * @throws RegistryException if the operation failed. */ public static void associateAspect(String path, String aspect, Registry registry) throws RegistryException { try { registry.associateAspect(path, aspect); Resource resource = registry.get(path); if(resource.getAspects().size() == 1) { // Since this is the first life-cycle we make it default resource.setProperty("registry.LC.name", aspect); registry.put(path, resource); } } catch (RegistryException e) { String msg = "Failed to associate aspect with the resource " + path + ". " + e.getMessage(); log.error(msg, e); throw new RegistryException(msg, e); } }
/** * Associates the named lifecycle with the artifact * * @param name the name of the lifecycle to be associated with this artifact. * @throws GovernanceException if an error occurred. */ @Override public void attachLifecycle(String name) throws GovernanceException { try { String path = getPath(); if(name != null && path != null) { registry.associateAspect(path, name); Resource resource = registry.get(path); if(resource.getAspects().size() == 1) { // Since this is the first life-cycle we make it default resource.setProperty("registry.LC.name", name); registry.put(path, resource); } } } catch (RegistryException e) { String msg = "Error in associating lifecycle for the artifact. id: " + id + ", path: " + path + "."; log.error(msg, e); throw new GovernanceException(msg, e); } }
systemRegistry.associateAspect(tempResourcePath, aspectToAdd); Resource r = systemRegistry.get(tempResourcePath); Properties props = r.getProperties();
registry.associateAspect(newPathMappings.get(resourcePath) , aspectName);
registry.associateAspect(newPathMappings.get(resourcePath) , aspectName);
for (String attachingLifeCycle : lifeCycles) { if (StringUtils.isNotEmpty(attachingLifeCycle)) { registry.associateAspect(path, attachingLifeCycle);
for (String lifeCycle : lifeCycles) { if (StringUtils.isNotEmpty(lifeCycle)){ registry.associateAspect(resource.getId(),lifeCycle);