@Override public void initialize(RepositoryState state) { synchronized (this) { setName(state.Name); setType(state.Type); setVersion(state.Version.toString()); setProvider(state.Provider); setDescription(state.Description); setLocation(state.Location); setProperties(state.Properties); this.units.addAll(state.Units); this.repositories.addAll(Arrays.asList(state.Repositories)); } publishRepositoryReferences(); }
@Override public void addReferences(Collection<? extends IRepositoryReference> references) { assertModifiable(); // only write out the repository if we made changes if (repositories.addAll(references)) save(); }
public static File getActualLocation(URI location) { return getActualLocation(location, XML_EXTENSION); }
if (disableSave) return; File file = getActualLocation(getLocation()); File jarFile = getActualLocation(getLocation(), JAR_EXTENSION); boolean compress = "true".equalsIgnoreCase(getProperty(PROP_COMPRESSED)); //$NON-NLS-1$ try { OutputStream output = null; new MetadataRepositoryIO(getProvisioningAgent()).write(this, output); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, "Error saving metadata repository: " + getLocation(), e)); //$NON-NLS-1$
@Override public String setProperty(String key, String newValue, IProgressMonitor monitor) { try { String oldValue = null; synchronized (this) { oldValue = super.setProperty(key, newValue, monitor); if (oldValue == newValue || (oldValue != null && oldValue.equals(newValue))) return oldValue; save(); } //force repository manager to reload this repository because it caches properties MetadataRepositoryManager manager = (MetadataRepositoryManager) getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); if (manager.removeRepository(getLocation())) manager.addRepository(this); return oldValue; } finally { if (monitor != null) monitor.done(); } }
/** * This constructor is used when creating a new local repository. * @param location The location of the repository * @param name The name of the repository */ public LocalMetadataRepository(IProvisioningAgent agent, URI location, String name, Map<String, String> properties) { super(agent, name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$ if (!location.getScheme().equals("file")) //$NON-NLS-1$ throw new IllegalArgumentException("Invalid local repository location: " + location); //$NON-NLS-1$ //when creating a repository, we must ensure it exists on disk so a subsequent load will succeed save(); }
/** * Broadcast discovery events for all repositories referenced by this repository. */ public void publishRepositoryReferences() { IProvisioningEventBus bus = (IProvisioningEventBus) getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME); if (bus == null) return; List<IRepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot(); for (IRepositoryReference reference : repositoriesSnapshot) { boolean isEnabled = (reference.getOptions() & IRepository.ENABLED) != 0; bus.publishEvent(new RepositoryEvent(reference.getLocation(), reference.getType(), RepositoryEvent.DISCOVERED, isEnabled)); } }
public IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) { if (location.getScheme().equals("file")) //$NON-NLS-1$ return new LocalMetadataRepository(getAgent(), location, name, properties); return new URLMetadataRepository(getAgent(), location, name, properties); }
return null; if (result instanceof LocalMetadataRepository) ((LocalMetadataRepository) result).initializeAfterLoad(location); if (result instanceof URLMetadataRepository) ((URLMetadataRepository) result).initializeAfterLoad(location);
public void initializeRepository(IMetadataRepository repository, URI location, IProgressMonitor monitor) throws ProvisionException { UpdateSite updateSite = UpdateSite.load(location, (Transport) getAgent().getService(Transport.SERVICE_NAME), monitor); String savedChecksum = repository.getProperties().get(PROP_SITE_CHECKSUM); if (savedChecksum != null && savedChecksum.equals(updateSite.getChecksum())) return; repository.setProperty(PROP_SITE_CHECKSUM, updateSite.getChecksum()); repository.removeAll(); IStatus status = generateMetadata(updateSite, repository, monitor); //site references should be published on load if (repository instanceof LocalMetadataRepository) ((LocalMetadataRepository) repository).publishRepositoryReferences(); if (monitor.isCanceled()) throw new OperationCanceledException(); if (!status.isOK()) throw new ProvisionException(status); }
if (disableSave) return; File file = getActualLocation(getLocation()); File jarFile = getActualLocation(getLocation(), JAR_EXTENSION); boolean compress = "true".equalsIgnoreCase(getProperty(PROP_COMPRESSED)); //$NON-NLS-1$ try { OutputStream output = null; new MetadataRepositoryIO(getProvisioningAgent()).write(this, output); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, "Error saving metadata repository: " + getLocation(), e)); //$NON-NLS-1$
@Override public String setProperty(String key, String newValue, IProgressMonitor monitor) { try { String oldValue = null; synchronized (this) { oldValue = super.setProperty(key, newValue, monitor); if (oldValue == newValue || (oldValue != null && oldValue.equals(newValue))) return oldValue; save(); } //force repository manager to reload this repository because it caches properties MetadataRepositoryManager manager = (MetadataRepositoryManager) getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); if (manager.removeRepository(getLocation())) manager.addRepository(this); return oldValue; } finally { if (monitor != null) monitor.done(); } }
/** * This constructor is used when creating a new local repository. * @param location The location of the repository * @param name The name of the repository */ public LocalMetadataRepository(IProvisioningAgent agent, URI location, String name, Map<String, String> properties) { super(agent, name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$ if (!location.getScheme().equals("file")) //$NON-NLS-1$ throw new IllegalArgumentException("Invalid local repository location: " + location); //$NON-NLS-1$ //when creating a repository, we must ensure it exists on disk so a subsequent load will succeed save(); }
/** * Broadcast discovery events for all repositories referenced by this repository. */ public void publishRepositoryReferences() { IProvisioningEventBus bus = (IProvisioningEventBus) getProvisioningAgent().getService(IProvisioningEventBus.SERVICE_NAME); if (bus == null) return; List<IRepositoryReference> repositoriesSnapshot = createRepositoriesSnapshot(); for (IRepositoryReference reference : repositoriesSnapshot) { boolean isEnabled = (reference.getOptions() & IRepository.ENABLED) != 0; bus.publishEvent(new RepositoryEvent(reference.getLocation(), reference.getType(), RepositoryEvent.DISCOVERED, isEnabled)); } }
public IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) { if (location.getScheme().equals("file")) //$NON-NLS-1$ return new LocalMetadataRepository(getAgent(), location, name, properties); return new URLMetadataRepository(getAgent(), location, name, properties); }
return null; if (result instanceof LocalMetadataRepository) ((LocalMetadataRepository) result).initializeAfterLoad(location); if (result instanceof URLMetadataRepository) ((URLMetadataRepository) result).initializeAfterLoad(location);
@Override public void initialize(RepositoryState state) { synchronized (this) { setName(state.Name); setType(state.Type); setVersion(state.Version.toString()); setProvider(state.Provider); setDescription(state.Description); setLocation(state.Location); setProperties(state.Properties); this.units.addAll(state.Units); this.repositories.addAll(Arrays.asList(state.Repositories)); } publishRepositoryReferences(); }
if (disableSave) return; File file = getActualLocation(getLocation()); File jarFile = getActualLocation(getLocation(), JAR_EXTENSION); boolean compress = "true".equalsIgnoreCase(getProperty(PROP_COMPRESSED)); //$NON-NLS-1$ try { OutputStream output = null; new MetadataRepositoryIO(getProvisioningAgent()).write(this, output); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, "Error saving metadata repository: " + getLocation(), e)); //$NON-NLS-1$
@Override public String setProperty(String key, String newValue, IProgressMonitor monitor) { try { String oldValue = null; synchronized (this) { oldValue = super.setProperty(key, newValue, monitor); if (oldValue == newValue || (oldValue != null && oldValue.equals(newValue))) return oldValue; save(); } //force repository manager to reload this repository because it caches properties MetadataRepositoryManager manager = (MetadataRepositoryManager) getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); if (manager.removeRepository(getLocation())) manager.addRepository(this); return oldValue; } finally { if (monitor != null) monitor.done(); } }
/** * This constructor is used when creating a new local repository. * @param location The location of the repository * @param name The name of the repository */ public LocalMetadataRepository(IProvisioningAgent agent, URI location, String name, Map<String, String> properties) { super(agent, name == null ? (location != null ? location.toString() : "") : name, REPOSITORY_TYPE, REPOSITORY_VERSION.toString(), location, null, null, properties); //$NON-NLS-1$ if (!location.getScheme().equals("file")) //$NON-NLS-1$ throw new IllegalArgumentException("Invalid local repository location: " + location); //$NON-NLS-1$ //when creating a repository, we must ensure it exists on disk so a subsequent load will succeed save(); }