Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 105662 Details for
Bug 238169
A metadatarepo to represent a profile
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
exploratory patch
profilemetadatarepo.txt (text/plain), 10.45 KB, created by
Simon Kaegi
on 2008-06-23 16:09:05 EDT
(
hide
)
Description:
exploratory patch
Filename:
MIME Type:
Creator:
Simon Kaegi
Created:
2008-06-23 16:09:05 EDT
Size:
10.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.p2.metadata.repository >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF,v >retrieving revision 1.21 >diff -u -r1.21 MANIFEST.MF >--- META-INF/MANIFEST.MF 29 May 2008 16:04:38 -0000 1.21 >+++ META-INF/MANIFEST.MF 23 Jun 2008 20:04:05 -0000 >@@ -22,7 +22,7 @@ > org.eclipse.equinox.p2.installer, > org.eclipse.equinox.p2.reconciler.dropins, > org.eclipse.pde.p2.ui", >- org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;x-friends:="org.eclipse.equinox.p2.extensionlocation,org.eclipse.equinox.p2.updatesite" >+ org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository;x-friends:="org.eclipse.equinox.p2.extensionlocation,org.eclipse.equinox.p2.updatesite,org.eclipse.equinox.p2.engine" > Import-Package: org.eclipse.core.runtime.preferences, > org.eclipse.equinox.app;resolution:=optional, > org.eclipse.equinox.internal.p2.core.helpers, >#P org.eclipse.equinox.p2.engine >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.p2.engine/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 30 Sep 2007 18:55:52 -0000 1.2 >+++ plugin.xml 23 Jun 2008 20:04:05 -0000 >@@ -10,4 +10,14 @@ > class="org.eclipse.equinox.internal.p2.engine.NullTouchpoint" > version="1.0.0"/> > </extension> >+ <extension >+ id="metadataRepository" >+ point="org.eclipse.equinox.p2.metadata.repository.metadataRepositories"> >+ <factory >+ class="org.eclipse.equinox.internal.p2.engine.repo.ProfileMetadataRepositoryFactory"> >+ </factory> >+ <filter >+ suffix="profile"> >+ </filter> >+ </extension> > </plugin> >Index: src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepositoryFactory.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepositoryFactory.java >diff -N src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepositoryFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepositoryFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.equinox.internal.p2.engine.repo; >+ >+import java.net.URL; >+import java.util.Map; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; >+import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.IMetadataRepositoryFactory; >+ >+public class ProfileMetadataRepositoryFactory implements IMetadataRepositoryFactory { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.IMetadataRepositoryFactory#create(java.net.URL, java.lang.String, java.lang.String, java.util.Map) >+ */ >+ public IMetadataRepository create(URL location, String name, String type, Map properties) { >+ return null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.IMetadataRepositoryFactory#validate(java.net.URL, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ >+ public IStatus validate(URL location, IProgressMonitor monitor) { >+ try { >+ ProfileMetadataRepository.validate(location, monitor); >+ } catch (ProvisionException e) { >+ return e.getStatus(); >+ } >+ return Status.OK_STATUS; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.IMetadataRepositoryFactory#load(java.net.URL, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public IMetadataRepository load(URL location, IProgressMonitor monitor) throws ProvisionException { >+ return new ProfileMetadataRepository(location, monitor); >+ } >+} >Index: src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepository.java >=================================================================== >RCS file: src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepository.java >diff -N src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepository.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/equinox/internal/p2/engine/repo/ProfileMetadataRepository.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,121 @@ >+package org.eclipse.equinox.internal.p2.engine.repo; >+ >+import java.io.File; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; >+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; >+import org.eclipse.equinox.internal.p2.engine.EngineActivator; >+import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; >+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; >+import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; >+import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent; >+import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; >+import org.eclipse.equinox.internal.provisional.p2.query.Collector; >+import org.eclipse.equinox.internal.provisional.p2.query.Query; >+import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository; >+ >+public class ProfileMetadataRepository extends AbstractMetadataRepository { >+ >+ public static final String TYPE = "org.eclipse.equinox.p2.engine.repo.metadataRepository"; //$NON-NLS-1$ >+ public static final Integer VERSION = new Integer(1); >+ private IProfile profile; >+ >+ public ProfileMetadataRepository(URL location, IProgressMonitor monitor) throws ProvisionException { >+ super(location.toExternalForm(), TYPE, VERSION.toString(), location, null, null, null); >+ >+ try { >+ profile = getProfile(location); >+ } catch (RuntimeException e) { >+ throw new ProvisionException(new Status(IStatus.ERROR, EngineActivator.ID, ProvisionException.REPOSITORY_FAILED_READ, e.getMessage(), e)); >+ } >+ >+ publishArtifactRepos(); >+ } >+ >+ private void publishArtifactRepos() { >+ List artifactRepos = new ArrayList(); >+ String bundlePool = profile.getProperty(IProfile.PROP_CACHE); >+ if (bundlePool != null) { >+ try { >+ artifactRepos.add(new File(bundlePool).toURL().toExternalForm()); >+ } catch (MalformedURLException e) { >+ LogHelper.log(new Status(IStatus.WARNING, EngineActivator.ID, "invalid repo reference with location: " + bundlePool, e)); //$NON-NLS-1$ >+ } >+ } >+ >+ String sharedBundlePool = profile.getProperty(IProfile.PROP_SHARED_CACHE); >+ if (sharedBundlePool != null) { >+ try { >+ artifactRepos.add(new File(sharedBundlePool).toURL().toExternalForm()); >+ } catch (MalformedURLException e) { >+ LogHelper.log(new Status(IStatus.WARNING, EngineActivator.ID, "invalid repo reference with location: " + sharedBundlePool, e)); //$NON-NLS-1$ >+ } >+ } >+ >+ String dropinRepositories = profile.getProperty("org.eclipse.equinox.p2.cache.extensions"); >+ if (dropinRepositories != null) { >+ StringTokenizer tokenizer = new StringTokenizer(dropinRepositories, "|"); >+ while (tokenizer.hasMoreTokens()) { >+ artifactRepos.add(tokenizer.nextToken()); >+ } >+ } >+ >+ IProvisioningEventBus bus = (IProvisioningEventBus) ServiceHelper.getService(EngineActivator.getContext(), IProvisioningEventBus.SERVICE_NAME); >+ if (bus == null) >+ return; >+ for (Iterator it = artifactRepos.iterator(); it.hasNext();) { >+ String repo = (String) it.next(); >+ try { >+ URL artifactRepo = new URL(repo); >+ bus.publishEvent(new RepositoryEvent(artifactRepo, IRepository.TYPE_ARTIFACT, RepositoryEvent.DISCOVERED, true)); >+ } catch (MalformedURLException e) { >+ LogHelper.log(new Status(IStatus.WARNING, EngineActivator.ID, "invalid repo reference with location: " + repo, e)); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ public void initialize(RepositoryState state) { >+ // nothing to do >+ } >+ >+ public Collector query(Query query, Collector collector, IProgressMonitor monitor) { >+ return profile.query(query, collector, monitor); >+ } >+ >+ public static void validate(URL location, IProgressMonitor monitor) throws ProvisionException { >+ try { >+ getProfile(location); >+ } catch (RuntimeException e) { >+ throw new ProvisionException(new Status(IStatus.ERROR, "org.eclipse.equinox.p2.engine", ProvisionException.REPOSITORY_FAILED_READ, e.getMessage(), e)); >+ } >+ } >+ >+ private static IProfile getProfile(URL location) { >+ if (!"file".equalsIgnoreCase(location.getProtocol())) >+ throw new IllegalArgumentException("Profile Registry must use 'file' protocol."); >+ >+ File registryDirectory = new File(location.getPath()); >+ if (!registryDirectory.isDirectory()) >+ throw new IllegalArgumentException("Profile Registry not found. " + registryDirectory + " is not a directory."); >+ >+ String query = location.getQuery(); >+ //expect profileid=xyz >+ if (query == null || query.indexOf("profileid=") == -1) >+ throw new IllegalArgumentException("'profileid' query parameter not specified."); >+ >+ String profileid = query.substring(query.indexOf("profileid=") + "profileid=".length()); >+ if (profileid == null || profileid.length() == 0 || profileid.indexOf('&') != -1) >+ throw new IllegalArgumentException("bad 'profileid' query parameter: " + profileid); >+ >+ SimpleProfileRegistry profileRegistry = new SimpleProfileRegistry(registryDirectory, null, false); >+ IProfile profile = profileRegistry.getProfile(profileid); >+ if (profile == null) >+ throw new IllegalArgumentException("No profile found for : " + profileid); >+ >+ return profile; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 238169
: 105662