本文整理汇总了Java中org.eclipse.equinox.p2.core.ProvisionException类的典型用法代码示例。如果您正苦于以下问题:Java ProvisionException类的具体用法?Java ProvisionException怎么用?Java ProvisionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProvisionException类属于org.eclipse.equinox.p2.core包,在下文中一共展示了ProvisionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryRepositoryForInstallableUnit
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Queries a repository for a specific {@link IInstallableUnit} (IU).
*
* @param repositoryURI the repository URI
* @param installableUnitID the ID of the IU
* @return the {@link IQueryResult}
*/
private IQueryResult<IInstallableUnit> queryRepositoryForInstallableUnit(URI repositoryURI, String installableUnitID) {
// --- Load the repository ------------
IQueryResult<IInstallableUnit> queryResult = null;
try {
IMetadataRepository metadataRepository = this.getMetadataRepositoryManager().loadRepository(repositoryURI, this.getProgressMonitor());
// --- Query for the IU of interest -----
if (metadataRepository != null) {
queryResult = metadataRepository.query(QueryUtil.createIUQuery(installableUnitID), this.getProgressMonitor());
}
} catch (ProvisionException | OperationCanceledException e) {
System.err.println("Error loading the repository at " + repositoryURI);
e.printStackTrace();
}
return queryResult;
}
示例2: getUpdatedGroups
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
private List<IInstallableUnit> getUpdatedGroups() {
nullProgressMonitor = new NullProgressMonitor();
this.agent = agent;
MetadataRepositoryManager metadataRepositoryManager = new MetadataRepositoryManager(
agent);
try {
loadRepository = metadataRepositoryManager.loadRepository(uri, 0,
nullProgressMonitor);
} catch (ProvisionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IQuery<IInstallableUnit> createQuery = QueryUtil.createIUGroupQuery();
IQueryResult<IInstallableUnit> query = loadRepository.query(
createQuery, nullProgressMonitor);
List<IInstallableUnit> list = toList(query);
return list;
}
示例3: queryP2Repository
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
private Iterator<IInstallableUnit> queryP2Repository(IProgressMonitor monitor, String updateURL)
throws URISyntaxException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
SubMonitor progress = SubMonitor.convert(monitor, "", 6);
// get all available IUs in update repository
IMetadataRepository metadataRepo = null;
try {
metadataRepo = metadataRepoManager.loadRepository(new URI(updateURL), progress.newChild(1));
} catch (ProvisionException e) {
System.exit(1);
}
IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
IQueryResult<IInstallableUnit> allIUQueryResult = metadataRepo.query(allIUQuery, progress.newChild(1));
Iterator<IInstallableUnit> iterator = allIUQueryResult.iterator();
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
return iterator;
}
示例4: getAgent
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
public static IProvisioningAgent getAgent ( final URI location ) throws ProvisionException
{
final IProvisioningAgentProvider provider = INSTANCE.tracker.getService ();
if ( provider == null )
{
throw new IllegalStateException ( "Provisioning agent provider not found. Is P2 started?" );
}
return provider.createAgent ( location );
}
示例5: compareToDestination
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Takes an IArtifactDescriptor descriptor and the ProvisionException that was thrown when destination.getOutputStream(descriptor)
* and compares descriptor to the duplicate descriptor in the destination.
*
* Callers should verify the ProvisionException was thrown due to the artifact existing in the destination before invoking this method.
* @param descriptor
* @return the status of the compare
*/
private IStatus compareToDestination(IArtifactDescriptor descriptor) {
IArtifactDescriptor[] destDescriptors = destination.getArtifactDescriptors(descriptor.getArtifactKey());
IArtifactDescriptor destDescriptor = null;
for (int i = 0; destDescriptor == null && i < destDescriptors.length; i++) {
if (destDescriptors[i].equals(descriptor))
destDescriptor = destDescriptors[i];
}
if (destDescriptor == null)
return new Status(IStatus.INFO, Activator.ID, ProvisionException.ARTIFACT_EXISTS, Messages.Mirroring_noMatchingDescriptor, null);
return compare(source, descriptor, destination, destDescriptor);
}
示例6: createProfile
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Creates a profile.
*
* @param profileId Profile identifier
* @return Profile
* @throws ProvisionException on failure
*/
public IProfile createProfile(String profileId) throws ProvisionException {
IProfileRegistry profileRegistry = (IProfileRegistry)getAgent().getService(IProfileRegistry.SERVICE_NAME);
IProfile profile = profileRegistry.getProfile(profileId);
// Note: On uninstall, the profile will always be available
if (profile == null) {
Map<String, String> properties = new HashMap<String, String>();
// Install location - this is where the p2 directory will be located
properties.put(IProfile.PROP_INSTALL_FOLDER, getInstallLocation().toString());
// Environment
EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(Installer.getDefault().getContext(), EnvironmentInfo.class.getName());
String env = "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
properties.put(IProfile.PROP_ENVIRONMENTS, env);
// Profile identifier
properties.put(IProfile.PROP_NAME, profileId);
// Cache location - this is where features and plugins will be deployed
properties.put(IProfile.PROP_CACHE, getInstallLocation().toOSString());
// Set roaming. This will put a path relative to the OSGi configuration area in the config.ini
// so that the installation can be moved. Without roaming, absolute paths will be written
// to the config.ini and Software Update will not work correctly for a moved installation.
properties.put(IProfile.PROP_ROAMING, Boolean.TRUE.toString());
// Profile properties specified in install description
if (Installer.getDefault().getInstallManager().getInstallDescription().getProfileProperties() != null)
properties.putAll(Installer.getDefault().getInstallManager().getInstallDescription().getProfileProperties());
profile = profileRegistry.addProfile(profileId, properties);
}
return profile;
}
示例7: getInstallProfile
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Returns the profile for this installation. The profile is created if
* necessary.
*
* @return Profile Profile or <code>null</code> if no install location was specified
* @throws ProvisionException on failure to create the profile
*/
public IProfile getInstallProfile() throws ProvisionException {
IProfile profile = null;
if (getInstallLocation() != null) {
String profileId = getProfileId();
profile = getProfile(profileId);
if (profile == null) {
profile = createProfile(profileId);
}
}
return profile;
}
示例8: initializeRepositoryData
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Sets up the p2 repository
*
* @param repoLocation the string representation of a valid p2 repository
*/
public boolean initializeRepositoryData(String repoLocation){
File f = new File(repoLocation);
repositoryURI = f.toURI();
repositoryIUs = new ArrayList<IInstallableUnit>();
try{
metaRepo = InstallUtils.loadRepository(agent, repositoryURI);
repositoryIUs = InstallUtils.generateIUList(metaRepo);
}
catch(ProvisionException pe){
return false;
//pe.printStackTrace();
}
return true;
}
示例9: loadRepository
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Establishes all the repositories and repository managers needed for the install job
*
* @param agent the current ProvisioningAgent
* @param repositoryLocation the valid p2 repository location
* @return metadata repository object from a valid p2 repository
* @throws ProvisionException
*/
@SuppressWarnings("restriction")
public static IMetadataRepository loadRepository(IProvisioningAgent agent, URI repositoryLocation) throws ProvisionException{
final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
IArtifactRepositoryManager artifactManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
artifactManager.addRepository(repositoryLocation);
IMetadataRepository repository = manager.loadRepository(repositoryLocation, new NullProgressMonitor());
return repository;
}
示例10: findSources
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
@Override
public IPath findSources(File jar, IProgressMonitor monitor) {
if (!BundleUtil.isBundle(jar)) {
return null;
}
IArtifactKey artifactKey = BundleUtil.getArtifactKey(jar);
if (artifactKey == null || blackList.contains(artifactKey.getId())) {
return null;
}
IArtifactKey sourceKey = BundleUtil.toSourceKey(artifactKey);
ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
List<URI> uris = Arrays
.asList(provisioningUI.getRepositoryTracker().getKnownRepositories(provisioningUI.getSession()));
Collections.sort(uris);// stupid trick to make eclipse.org repos being
// searched almost first
Path cacheFolder = SourceLookupPreferences.getInstance().getDownloadedSourcesDirectory();
for (URI repo : uris) {
if (monitor.isCanceled()) {
return null;
}
IArtifactRepository artifactRepo = null;
try {
artifactRepo = provisioningUI.loadArtifactRepository(repo, false, monitor);
} catch (ProvisionException ignored) {
ignored.printStackTrace();
// local urls seem to fail
}
if (artifactRepo == null || !artifactRepo.contains(sourceKey)) {
continue;
}
IArtifactDescriptor[] results = artifactRepo.getArtifactDescriptors(sourceKey);
if (results.length > 0) {
try {
return saveArtifact(artifactRepo, results[0], cacheFolder, monitor);
} catch (Exception e) {
e.printStackTrace();
}
}
}
return null;
}
示例11: loadRepository
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
@Override
public synchronized List<IInstallableUnit> loadRepository(String uriString,
IProvisioningAgent agent) {
uri = null;
nullProgressMonitor = new NullProgressMonitor();
this.agent = agent;
if (!containsString(uriString, "http", false)
&& !(uriString.contains(".jar") || uriString.contains(".zip"))) {
uri = new File(uriString).toURI();
}
if (uri == null)
System.out.println("InstallNewSoftwareService uri " + uriString);
try {
uri = new URI(uriString);
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MetadataRepositoryManager metadataRepositoryManager = new MetadataRepositoryManager(
agent);
try {
loadRepository = metadataRepositoryManager.loadRepository(uri,
IRepositoryManager.REPOSITORIES_ALL, nullProgressMonitor);
} catch (ProvisionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
IQuery<IInstallableUnit> createQuery = QueryUtil
.createIUAnyQuery();
// createIUCategoryQuery();
IQueryResult<IInstallableUnit> query = loadRepository.query(
createQuery, nullProgressMonitor);
List<IInstallableUnit> list = toList(query);
return list;
}
示例12: mirror
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
private IStatus mirror(IArtifactDescriptor sourceDescriptor, boolean verbose) {
if (!includePacked && IArtifactDescriptor.FORMAT_PACKED.equals(sourceDescriptor.getProperty(IArtifactDescriptor.FORMAT)))
return Status.OK_STATUS;
IArtifactDescriptor targetDescriptor = raw ? sourceDescriptor : new ArtifactDescriptor(sourceDescriptor);
IArtifactDescriptor baselineDescriptor = getBaselineDescriptor(sourceDescriptor);
if (verbose)
System.out.println("Mirroring: " + sourceDescriptor.getArtifactKey() + " (Descriptor: " + sourceDescriptor + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
MultiStatus compareStatus = new MultiStatus(Activator.ID, IStatus.OK, null, null);
boolean comparing = compare && !compareExclusions.contains(sourceDescriptor);
if (comparing) {
if (baselineDescriptor != null) {
//compare source & baseline
compareStatus.add(compare(baseline, baselineDescriptor, source, sourceDescriptor));
//compare baseline & destination
if (destination.contains(baselineDescriptor)) {
compareStatus.add(compareToDestination(baselineDescriptor));
return compareStatus;
}
} else if (destination.contains(targetDescriptor)) {
compareStatus.add(compareToDestination(sourceDescriptor));
return compareStatus;
}
}
//from source or baseline
IArtifactRepository sourceRepository = baselineDescriptor != null ? baseline : source;
sourceDescriptor = baselineDescriptor != null ? baselineDescriptor : sourceDescriptor;
targetDescriptor = baselineDescriptor != null ? baselineDescriptor : targetDescriptor;
IStatus status = null;
if (!destination.contains(targetDescriptor))
//actual download
status = downloadArtifact(sourceRepository, targetDescriptor, sourceDescriptor);
else {
String message = NLS.bind(Messages.mirror_alreadyExists, sourceDescriptor, destination);
status = new Status(IStatus.INFO, Activator.ID, ProvisionException.ARTIFACT_EXISTS, message, null);
}
if (comparing) {
compareStatus.add(status);
return compareStatus;
}
return status;
}
示例13: loadCacheRepository
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Loads the cache repository if it is available. If the cache repository has already been loaded then it will be
* refreshed.
*
* @return <code>true</code> if cache repository was loaded.
* @throws ProvisionException on provisioning failure.
* @throws OperationCanceledException if operation was cancelled.
*/
private synchronized boolean loadCacheRepository() throws ProvisionException, OperationCanceledException {
boolean loaded = false;
IPath cacheLocation = getCacheLocation();
if (cacheLocation != null) {
// If cache repository is already loaded then refresh it
if ((cacheMetadataRepository != null) && (cacheArtifactRepository != null)) {
getMetadataRepositoryManager().refreshRepository(cacheMetadataRepository.getLocation(), null);
getArtifactRepositoryManager().refreshRepository(cacheArtifactRepository.getLocation(), null);
loaded = true;
}
// Load the cache repository
else {
File cacheFile = cacheLocation.toFile();
if (cacheFile.exists()) {
// Cache location (co-located)
URI repositoryLocation = cacheFile.toURI();
fireRepositoryStatus(IInstallRepositoryListener.RepositoryStatus.loadingStarted);
try {
getMetadataRepositoryManager().addRepository(repositoryLocation);
cacheMetadataRepository = getMetadataRepositoryManager().loadRepository(repositoryLocation, null);
if (cacheMetadataRepository != null) {
getArtifactRepositoryManager().addRepository(repositoryLocation);
cacheArtifactRepository = getArtifactRepositoryManager().loadRepository(repositoryLocation, null);
loaded = true;
}
}
catch (Exception e) {
unloadCacheRepository();
fireRepositoryError(repositoryLocation, e.getLocalizedMessage());
throw e;
}
}
}
// Load components
if (loaded) {
// Load components available in cache repository
IInstallComponent[] components = loadComponents(cacheMetadataRepository);
if (components.length > 0) {
// Mark the components as coming from the cache
for (IInstallComponent component : components) {
component.setProperty(PROPERTY_CACHE, Boolean.TRUE.toString());
}
// Fire notification
fireComponentsChanged();
}
fireRepositoryStatus(IInstallRepositoryListener.RepositoryStatus.loadingCompleted);
}
}
return loaded;
}
示例14: addInstallComponent
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Adds a new install component for an installable unit. If the installable
* unit is a category, it's member units will also be added.
*
* @param unit Installable unit
* @param parentGroup Parent component or <code>null</code>
* @return Added components or <code>null</code> if the component has already been added
* @throws ProvisionException on failure
*/
private List<IInstallComponent> addInstallComponent(IInstallableUnit unit, InstallComponent parentGroup) throws ProvisionException {
IInstallComponent existingComponent = getInstallComponent(unit.getId());
ArrayList<IInstallComponent> addedComponents = new ArrayList<IInstallComponent>();
InstallComponent component = null;
// Category IU
boolean isCategory = isCategoryIu(unit);
// If there is an existing component for the unit
if (existingComponent != null) {
// If category, add to existing component
if (isCategory)
component = (InstallComponent)existingComponent;
// Else do not allow duplicates units
else
return null;
}
// Create component
if (component == null) {
component = new InstallComponent(unit);
}
// If category unit, add members
if (isCategory) {
IQuery<IInstallableUnit> categoryQuery = QueryUtil.createIUCategoryMemberQuery(unit);
IQueryResult<IInstallableUnit> query = getMetadataRepositoryManager().query(categoryQuery, null);
Iterator<IInstallableUnit> iter = query.iterator();
while (iter.hasNext()) {
IInstallableUnit categoryMemberUnit = iter.next();
List<IInstallComponent> members = addInstallComponent(categoryMemberUnit, component);
if (members != null) {
addedComponents.addAll(members);
}
}
}
// Add component
if (existingComponent == null) {
if (parentGroup != null) {
parentGroup.addComponent(component);
}
// Set component parent
component.setParent(parentGroup);
// Add component
components.add(component);
addedComponents.add(component);
}
return addedComponents;
}
示例15: checkForAvailableUpdates
import org.eclipse.equinox.p2.core.ProvisionException; //导入依赖的package包/类
/**
* Finds available WSO2 features in current profile and search for updates
* to them in WSO2 p2 repository for updates.
*
* @param monitor
* @throws Exception
*/
public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);
// get all available IUs in update repository
IMetadataRepository metadataRepo = null;
try {
metadataRepo = metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
} catch (ProvisionException e) {
UpdateMetaFileReaderJob.promptUserError(
"The P2 Does not existed at the given location, please set the update/releases P2 for Developer Studio in the Preference Store",
"P2 Repository Error");
throw e;
}
IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
IQueryResult<IInstallableUnit> allIUQueryResult = metadataRepo.query(allIUQuery, progress.newChild(1));
// read artifact repository for updates
IArtifactRepository artifactRepo = artifactRepoManager.loadRepository(getDevStudioUpdateSite(),
progress.newChild(1));
// read meta-data of all available features
Map<String, EnhancedFeature> unsortedMap = loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult,
progress.newChild(1));
// sort the map in alphabetical order
Map<String, EnhancedFeature> allFeaturesInUpdateRepo = new TreeMap<String, EnhancedFeature>(unsortedMap);
// get all installed wso2 features
Collection<IInstallableUnit> installedWSO2Features = getInstalledWSO2Features(progress.newChild(1));
installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
}
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
URI[] repos = new URI[] { getDevStudioUpdateSite() };
updateOperation = new UpdateOperation(session, installedWSO2Features);
updateOperation.getProvisioningContext().setArtifactRepositories(repos);
updateOperation.getProvisioningContext().setMetadataRepositories(repos);
// resolve update operation
IStatus status = updateOperation.resolveModal(progress.newChild(1));
// user cancelled the job while resolving
if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
throw new OperationCanceledException();
}
// there is nothing to update
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
log.info(Messages.UpdateManager_19);
} else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
// something wrong with the updates
log.info(Messages.UpdateManager_20);
} else {
// good to proceed installing updates
setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
}
// sort the available updates in alphabetical order
}