public void addChild(URI childURI) { try { addChild(childURI, true, null, false, null); } catch (ProvisionException e) { //already logged } }
@Override public String toString() { return getChildren().toString(); }
public IMetadataRepository create(URI location, String name, String type, Map<String, String> properties) { return new CompositeMetadataRepository(getManager(), location, name, properties); }
public CompositeRepositoryState toState() { CompositeRepositoryState result = new CompositeRepositoryState(); result.setName(getName()); result.setType(getType()); result.setVersion(getVersion()); result.setLocation(getLocation()); result.setDescription(getDescription()); result.setProvider(getProvider()); result.setProperties(getProperties()); // it is important to directly access the field so we have the relative URIs result.setChildren(childrenURIs.toArray(new URI[childrenURIs.size()])); return result; }
CompositeMetadataRepository contextMetadata = CompositeMetadataRepository.createMemoryComposite(agent); if (contextMetadata != null) { for (int i = 0; i < contextMetadataRepositories.length; i++) contextMetadata.addChild(contextMetadataRepositories[i]); if (contextMetadata.getChildren().size() > 0) publisherInfo.setContextMetadataRepository(contextMetadata);
private void save() { if (!isModifiable()) 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 CompositeRepositoryIO().write(toState(), output, PI_REPOSITORY_TYPE); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, NLS.bind(Messages.io_failedWrite, getLocation()), e));
private void addChild(URI childURI, boolean save, IProgressMonitor monitor, boolean propagateException, List<URI> repositoriesToBeRemovedOnFailure) throws ProvisionException { SubMonitor sub = SubMonitor.convert(monitor); URI absolute = URIUtil.makeAbsolute(childURI, getLocation()); if (childrenURIs.contains(childURI) || childrenURIs.contains(absolute)) { sub.done(); save(); try { boolean currentLoaded = getManager().contains(absolute); IMetadataRepository currentRepo = getManager().loadRepository(absolute, sub); if (!currentLoaded) { getManager().setEnabled(absolute, false); getManager().setRepositoryProperty(absolute, IRepository.PROP_SYSTEM, String.valueOf(true)); if (propagateException) repositoriesToBeRemovedOnFailure.add(absolute); removeFromRepoManager(repositoriesToBeRemovedOnFailure); String msg = NLS.bind(Messages.io_failedRead, getLocation()); throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, e));
.createMemoryComposite(ourAgent); for (URI sr : ms.sourceRepositories) sourceMetadataRepo.addChild(sr); Set<IInstallableUnit> queryResult = sourceMetadataRepo.query(q, monitor).toUnmodifiableSet(); if (queryResult.isEmpty()) throw new RuntimeException("IU not found: " + iu); for (IInstallableUnit iu1 : sourceMetadataRepo.query( QueryUtil.createIUQuery(iu.getId() + ".source", iu.getVersion()), monitor)) if (getType(iu1) == Type.source_bundle) { .query(QueryUtil.createIUQuery(c, iu.getVersion()), monitor)) if (root1.add(iu1)) System.out.println("Adding " + iu1 + " as source of " + iu);
CompositeMetadataRepository(IMetadataRepositoryManager manager, CompositeRepositoryState state, IProgressMonitor monitor) throws ProvisionException { super(manager.getAgent(), state.getName(), state.getType(), state.getVersion(), state.getLocation(), state.getDescription(), state.getProvider(), state.getProperties()); this.manager = manager; SubMonitor sub = SubMonitor.convert(monitor, 100 * state.getChildren().length); List<URI> repositoriesToBeRemovedOnFailure = new ArrayList<URI>(); boolean failOnChildFailure = shouldFailOnChildFailure(state); for (URI child : state.getChildren()) addChild(child, false, sub.newChild(100), failOnChildFailure, repositoriesToBeRemovedOnFailure); }
public void removeChild(URI childURI) { boolean removed = childrenURIs.remove(childURI); // if the child wasn't there make sure and try the other permutation // (absolute/relative) to see if it really is in the list. URI other = childURI.isAbsolute() ? URIUtil.makeRelative(childURI, getLocation()) : URIUtil.makeAbsolute(childURI, getLocation()); if (!removed) removed = childrenURIs.remove(other); if (removed) { // we removed the child from the list so remove the associated repo object as well IMetadataRepository found = null; for (IMetadataRepository current : loadedRepos) { URI repoLocation = current.getLocation(); if (URIUtil.sameURI(childURI, repoLocation) || URIUtil.sameURI(other, repoLocation)) { found = current; break; } } if (found != null) loadedRepos.remove(found); save(); } }
private boolean isLocal() { return "file".equalsIgnoreCase(getLocation().getScheme()); //$NON-NLS-1$ }
public static File getActualLocation(URI location) { return getActualLocation(location, XML_EXTENSION); }
URI jarLocation = CompositeMetadataRepository.getActualLocationURI(location, JAR_EXTENSION); URI xmlLocation = CompositeMetadataRepository.getActualLocationURI(location, XML_EXTENSION);
CompositeMetadataRepository contextMetadata = CompositeMetadataRepository.createMemoryComposite(agent); if (contextMetadata != null) { for (int i = 0; i < contextMetadataRepositories.length; i++) contextMetadata.addChild(contextMetadataRepositories[i]); if (contextMetadata.getChildren().size() > 0) publisherInfo.setContextMetadataRepository(contextMetadata);
public CompositeRepositoryState toState() { CompositeRepositoryState result = new CompositeRepositoryState(); result.setName(getName()); result.setType(getType()); result.setVersion(getVersion()); result.setLocation(getLocation()); result.setDescription(getDescription()); result.setProvider(getProvider()); result.setProperties(getProperties()); // it is important to directly access the field so we have the relative URIs result.setChildren(childrenURIs.toArray(new URI[childrenURIs.size()])); return result; }
private void save() { if (!isModifiable()) 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 CompositeRepositoryIO().write(toState(), output, PI_REPOSITORY_TYPE); } catch (IOException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_WRITE, NLS.bind(Messages.io_failedWrite, getLocation()), e));
private void addChild(URI childURI, boolean save, IProgressMonitor monitor, boolean propagateException, List<URI> repositoriesToBeRemovedOnFailure) throws ProvisionException { SubMonitor sub = SubMonitor.convert(monitor); URI absolute = URIUtil.makeAbsolute(childURI, getLocation()); if (childrenURIs.contains(childURI) || childrenURIs.contains(absolute)) { sub.done(); save(); try { boolean currentLoaded = getManager().contains(absolute); IMetadataRepository currentRepo = getManager().loadRepository(absolute, sub); if (!currentLoaded) { getManager().setEnabled(absolute, false); getManager().setRepositoryProperty(absolute, IRepository.PROP_SYSTEM, String.valueOf(true)); if (propagateException) repositoriesToBeRemovedOnFailure.add(absolute); removeFromRepoManager(repositoriesToBeRemovedOnFailure); String msg = NLS.bind(Messages.io_failedRead, getLocation()); throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, e));
CompositeMetadataRepository(IMetadataRepositoryManager manager, CompositeRepositoryState state, IProgressMonitor monitor) throws ProvisionException { super(manager.getAgent(), state.getName(), state.getType(), state.getVersion(), state.getLocation(), state.getDescription(), state.getProvider(), state.getProperties()); this.manager = manager; SubMonitor sub = SubMonitor.convert(monitor, 100 * state.getChildren().length); List<URI> repositoriesToBeRemovedOnFailure = new ArrayList<URI>(); boolean failOnChildFailure = shouldFailOnChildFailure(state); for (URI child : state.getChildren()) addChild(child, false, sub.newChild(100), failOnChildFailure, repositoriesToBeRemovedOnFailure); }
public void removeChild(URI childURI) { boolean removed = childrenURIs.remove(childURI); // if the child wasn't there make sure and try the other permutation // (absolute/relative) to see if it really is in the list. URI other = childURI.isAbsolute() ? URIUtil.makeRelative(childURI, getLocation()) : URIUtil.makeAbsolute(childURI, getLocation()); if (!removed) removed = childrenURIs.remove(other); if (removed) { // we removed the child from the list so remove the associated repo object as well IMetadataRepository found = null; for (IMetadataRepository current : loadedRepos) { URI repoLocation = current.getLocation(); if (URIUtil.sameURI(childURI, repoLocation) || URIUtil.sameURI(other, repoLocation)) { found = current; break; } } if (found != null) loadedRepos.remove(found); save(); } }
private boolean isLocal() { return "file".equalsIgnoreCase(getLocation().getScheme()); //$NON-NLS-1$ }