/** * Creates and returns a new repository discovery event. * @param location the location of the repository that changed. * @param nickname the repository nickname * @param repositoryType the type of repository that was changed * @param enabled whether the repository is enabled * @return A new repository discovery event * @see IRepository#PROP_NICKNAME */ public static RepositoryEvent newDiscoveryEvent(URI location, String nickname, int repositoryType, boolean enabled) { RepositoryEvent event = new RepositoryEvent(location, repositoryType, DISCOVERED, enabled); event.nickname = nickname; return event; }
public void notify(EventObject o) { if (o instanceof RepositoryEvent) { RepositoryEvent event = (RepositoryEvent) o; if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType()) addRepository(event.getRepositoryLocation(), event.isRepositoryEnabled(), true); } }
/** * Returns the location of the repository associated with this event. * * @return the location of the repository associated with this event. */ public URI getRepositoryLocation() { return (URI) getSource(); }
public void notify(EventObject o) { if (o instanceof RepositoryEvent) { RepositoryEvent event = (RepositoryEvent) o; if (RepositoryEvent.REMOVED == event.getKind() && IRepository.TYPE_METADATA == event.getRepositoryType()) { deleteCache(event.getRepositoryLocation()); } } } };
private void handleRepositoryEvent(RepositoryEvent event) { // Do not handle unless this is the type of repo that we are interested in if ((event.getRepositoryType() == IRepository.TYPE_METADATA && (eventTypes & PROV_EVENT_METADATA_REPOSITORY) == PROV_EVENT_METADATA_REPOSITORY) || (event.getRepositoryType() == IRepository.TYPE_ARTIFACT && (eventTypes & PROV_EVENT_ARTIFACT_REPOSITORY) == PROV_EVENT_ARTIFACT_REPOSITORY)) { if (event.getKind() == RepositoryEvent.ADDED && event.isRepositoryEnabled()) { repositoryAdded(event); } else if (event.getKind() == RepositoryEvent.REMOVED && event.isRepositoryEnabled()) { repositoryRemoved(event); } else if (event.getKind() == RepositoryEvent.DISCOVERED) { repositoryDiscovered(event); } else if (event.getKind() == RepositoryEvent.CHANGED) { repositoryChanged(event); } else if (event.getKind() == RepositoryEvent.ENABLEMENT) { repositoryEnablement(event); } } }
public IStatus execute(Map<String, Object> parameters) { try { IProvisioningAgent agent = getAgent(parameters); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); final RepositoryEvent event = createEvent(parameters); IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers. if (isSelfProfile(registry, profile)) addToSelf(agent, agentLocation, event); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }
/** * Removes the repository corresponding to the given event from the currently running instance. */ protected void removeFromSelf(IProvisioningAgent agent, IAgentLocation agentLocation, RepositoryEvent event) { IRepositoryManager<?> manager = getRepositoryManager(agent, event.getRepositoryType()); Preferences node = getRepositoryPreferenceNode(agentLocation, null, event.getRepositoryLocation(), event.getRepositoryType()); int count = getRepositoryCount(node); // modify the repository count before (potentially) removing the preference node setRepositoryCount(node, --count); if (count < 1 && manager != null) manager.removeRepository(event.getRepositoryLocation()); }
protected void repositoryAdded(final RepositoryEvent event) { makeRepositoryVisible(event.getRepositoryLocation()); }
/** * A repository's enablement state has changed. This is treated * as repository addition or removal by default. Subclasses may * override. May be called from a non-UI thread. * @param event */ protected void repositoryEnablement(RepositoryEvent event) { // We treat enablement of a repository as if one were added. if (event.isRepositoryEnabled()) repositoryAdded(event); else repositoryRemoved(event); }
public IStatus execute(Map<String, Object> parameters) { try { IProvisioningAgent agent = getAgent(parameters); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); final RepositoryEvent event = createEvent(parameters); IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers. if (isSelfProfile(registry, profile)) addToSelf(agent, agentLocation, event); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }
/** * Removes the repository corresponding to the given event from the currently running instance. */ protected void removeFromSelf(IProvisioningAgent agent, IAgentLocation agentLocation, RepositoryEvent event) { IRepositoryManager<?> manager = getRepositoryManager(agent, event.getRepositoryType()); Preferences node = getRepositoryPreferenceNode(agentLocation, null, event.getRepositoryLocation(), event.getRepositoryType()); int count = getRepositoryCount(node); // modify the repository count before (potentially) removing the preference node setRepositoryCount(node, --count); if (count < 1 && manager != null) manager.removeRepository(event.getRepositoryLocation()); }
public void notify(EventObject o) { if (o instanceof RepositoryEvent) { RepositoryEvent event = (RepositoryEvent) o; if (RepositoryEvent.REMOVED == event.getKind() && IRepository.TYPE_METADATA == event.getRepositoryType()) { deleteCache(event.getRepositoryLocation()); } } } };
protected void repositoryAdded(RepositoryEvent e) { fillRepoCombo(getSiteString(e.getRepositoryLocation())); }
public IStatus undo(Map<String, Object> parameters) { try { IProvisioningAgent agent = getAgent(parameters); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); RepositoryEvent event = createEvent(parameters); IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if we are provisioning into the self profile, update the current set of repositories in this configuration if (isSelfProfile(registry, profile)) addToSelf(agent, agentLocation, event); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }
public void notify(EventObject o) { if (o instanceof RepositoryEvent) { RepositoryEvent event = (RepositoryEvent) o; if (event.getKind() == RepositoryEvent.DISCOVERED && event.getRepositoryType() == getRepositoryType()) addRepository(event.getRepositoryLocation(), event.isRepositoryEnabled(), true); } }
/** * Creates and returns a new repository discovery event. * @param location the location of the repository that changed. * @param nickname the repository nickname * @param repositoryType the type of repository that was changed * @param enabled whether the repository is enabled * @return A new repository discovery event * @see IRepository#PROP_NICKNAME */ public static RepositoryEvent newDiscoveryEvent(URI location, String nickname, int repositoryType, boolean enabled) { RepositoryEvent event = new RepositoryEvent(location, repositoryType, DISCOVERED, enabled); event.nickname = nickname; return event; }
public IStatus execute(Map<String, Object> parameters) { try { IProvisioningAgent agent = getAgent(parameters); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); RepositoryEvent event = createEvent(parameters); IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryType()); //if we are provisioning into the self profile, update the current set of repositories in this configuration if (isSelfProfile(registry, profile)) removeFromSelf(agent, agentLocation, event); } catch (CoreException e) { return e.getStatus(); } return Status.OK_STATUS; }
/** * Returns the location of the repository associated with this event. * * @return the location of the repository associated with this event. */ public URI getRepositoryLocation() { return (URI) getSource(); }
public IStatus undo(Map<String, Object> parameters) { try { IProvisioningAgent agent = getAgent(parameters); IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); RepositoryEvent event = createEvent(parameters); IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE); if (profile != null) addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled()); //if we are provisioning into the self profile, update the current set of repositories in this configuration if (isSelfProfile(registry, profile)) addToSelf(agent, agentLocation, event); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } }
private void broadcastChangeEvent(URI location, int repositoryType, int kind, boolean isEnabled) { if (eventBus != null) eventBus.publishEvent(new RepositoryEvent(location, repositoryType, kind, isEnabled)); }