org.eclipse.equinox.p2.touchpoint.eclipse_2.1.100.v20120428-0117

16:44:28.685 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.touchpoint.eclipse_2.1.100.v20120428-0117.jar
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator
  implements BundleActivator
{
  public static final String ID = "org.eclipse.equinox.p2.touchpoint.eclipse";
  private static BundleContext context = null;
  
  public void start(BundleContext ctx)
    throws Exception
  {
    context = ctx;
  }
  
  public void stop(BundleContext ctx)
    throws Exception
  {
    context = null;
  }
  
  public static BundleContext getContext()
  {
    return context;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.io.File;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;

public class AggregatedBundleRepository
  extends AbstractArtifactRepository
  implements IFileArtifactRepository
{
  private static final String REPOSITORY_TYPE = AggregatedBundleRepository.class.getName();
  private final Collection<IFileArtifactRepository> bundleRepositories;
  
  public AggregatedBundleRepository(IProvisioningAgent agent, Collection<IFileArtifactRepository> bundleRepositories)
  {
    super(agent, REPOSITORY_TYPE, REPOSITORY_TYPE, "1.0", null, null, null, null);
    this.bundleRepositories = bundleRepositories;
  }
  
  public File getArtifactFile(IArtifactKey key)
  {
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      File artifactFile = repository.getArtifactFile(key);
      if (artifactFile != null) {
        return artifactFile;
      }
    }
    return null;
  }
  
  public File getArtifactFile(IArtifactDescriptor descriptor)
  {
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      File artifactFile = repository.getArtifactFile(descriptor);
      if (artifactFile != null) {
        return artifactFile;
      }
    }
    return null;
  }
  
  public boolean contains(IArtifactDescriptor descriptor)
  {
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      if (repository.contains(descriptor)) {
        return true;
      }
    }
    return false;
  }
  
  public boolean contains(IArtifactKey key)
  {
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      if (repository.contains(key)) {
        return true;
      }
    }
    return false;
  }
  
  public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key)
  {
    Set<IArtifactDescriptor> artifactDescriptors = new HashSet();
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
      if (descriptors != null) {
        artifactDescriptors.addAll(Arrays.asList(descriptors));
      }
    }
    return (IArtifactDescriptor[])artifactDescriptors.toArray(new IArtifactDescriptor[artifactDescriptors.size()]);
  }
  
  public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)
  {
    throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
  }
  
  public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)
  {
    throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
  }
  
  public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor)
  {
    throw new UnsupportedOperationException(Messages.artifact_retrieval_unsupported);
  }
  
  public OutputStream getOutputStream(IArtifactDescriptor descriptor)
  {
    throw new UnsupportedOperationException(Messages.artifact_write_unsupported);
  }
  
  public Collection<IFileArtifactRepository> testGetBundleRepositories()
  {
    return bundleRepositories;
  }
  
  public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor)
  {
    IQueryable<IArtifactKey> queryable = QueryUtil.compoundQueryable(bundleRepositories);
    return queryable.query(query, monitor);
  }
  
  public IQueryable<IArtifactDescriptor> descriptorQueryable()
  {
    List<IQueryable<IArtifactDescriptor>> descQueryables = new ArrayList(bundleRepositories.size());
    for (Iterator localIterator = bundleRepositories.iterator(); localIterator.hasNext();)
    {
      IFileArtifactRepository repository = (IFileArtifactRepository)localIterator.next();
      descQueryables.add(repository.descriptorQueryable());
    }
    return QueryUtil.compoundQueryable(descQueryables);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.AggregatedBundleRepository
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.net.URI;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;

public class DirectorUtil
{
  public static IStatus validateProfile(IProfile profile)
  {
    IPlanner planner = (IPlanner)profile.getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
    IProfileChangeRequest pcr = planner.createChangeRequest(profile);
    ProvisioningContext ctx = new ProvisioningContext(profile.getProvisioningAgent());
    ctx.setMetadataRepositories(new URI[0]);
    return planner.getProvisioningPlan(pcr, ctx, null).getStatus();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.DirectorUtil
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.garbagecollector.MarkSet;
import org.eclipse.equinox.internal.p2.garbagecollector.MarkSetProvider;
import org.eclipse.equinox.internal.p2.update.Configuration;
import org.eclipse.equinox.internal.p2.update.Feature;
import org.eclipse.equinox.internal.p2.update.Site;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;

public class EclipseMarkSetProvider
  extends MarkSetProvider
{
  private static final String ARTIFACT_CLASSIFIER_OSGI_BUNDLE = "osgi.bundle";
  private static final String ARTIFACT_CLASSIFIER_FEATURE = "org.eclipse.update.feature";
  private Collection<IArtifactKey> artifactKeyList = null;
  
  public MarkSet[] getMarkSets(IProvisioningAgent agent, IProfile inProfile)
  {
    artifactKeyList = new HashSet();
    IArtifactRepository repositoryToGC = Util.getBundlePoolRepository(agent, inProfile);
    if (repositoryToGC == null) {
      return new MarkSet[0];
    }
    addArtifactKeys(inProfile);
    IProfile currentProfile = getCurrentProfile(agent);
    if ((currentProfile != null) && (inProfile.getProfileId().equals(currentProfile.getProfileId())))
    {
      addRunningBundles(repositoryToGC);
      addRunningFeatures(inProfile, repositoryToGC);
    }
    return new MarkSet[] { new MarkSet((IArtifactKey[])artifactKeyList.toArray(new IArtifactKey[artifactKeyList.size()]), repositoryToGC) };
  }
  
  private void addRunningFeatures(IProfile profile, IArtifactRepository repositoryToGC)
  {
    try
    {
      List<Feature> allFeatures = getAllFeatures(Configuration.load(new File(Util.getConfigurationFolder(profile), "org.eclipse.update/platform.xml"), null));
      for (Iterator localIterator = allFeatures.iterator(); localIterator.hasNext();)
      {
        Feature f = (Feature)localIterator.next();
        IArtifactKey match = searchArtifact(f.getId(), Version.create(f.getVersion()), "org.eclipse.update.feature", repositoryToGC);
        if (match != null) {
          artifactKeyList.add(match);
        }
      }
    }
    catch (ProvisionException localProvisionException) {}
  }
  
  private List<Feature> getAllFeatures(Configuration cfg)
  {
    if (cfg == null) {
      return CollectionUtils.emptyList();
    }
    List<Site> sites = cfg.getSites();
    ArrayList<Feature> result = new ArrayList();
    Feature[] features;
    int i;
    for (Iterator localIterator = sites.iterator(); localIterator.hasNext(); i < features.length)
    {
      Site object = (Site)localIterator.next();
      features = object.getFeatures();
      i = 0; continue;
      result.add(features[i]);i++;
    }
    return result;
  }
  
  private IProfile getCurrentProfile(IProvisioningAgent agent)
  {
    IProfileRegistry pr = (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
    if (pr == null) {
      return null;
    }
    return pr.getProfile("_SELF_");
  }
  
  private void addArtifactKeys(IProfile aProfile)
  {
    Iterator<IInstallableUnit> installableUnits = aProfile.query(QueryUtil.createIUAnyQuery(), null).iterator();
    while (installableUnits.hasNext())
    {
      Collection<IArtifactKey> keys = ((IInstallableUnit)installableUnits.next()).getArtifacts();
      if (keys != null) {
        artifactKeyList.addAll(keys);
      }
    }
  }
  
  public IArtifactRepository getRepository(IProvisioningAgent agent, IProfile aProfile)
  {
    return Util.getBundlePoolRepository(agent, aProfile);
  }
  
  private void addRunningBundles(IArtifactRepository repo)
  {
    artifactKeyList.addAll(findCorrespondinArtifacts(new WhatIsRunning().getBundlesBeingRun(), repo));
  }
  
  private IArtifactKey searchArtifact(String searchedId, Version searchedVersion, String classifier, IArtifactRepository repo)
  {
    VersionRange range = searchedVersion != null ? new VersionRange(searchedVersion, true, searchedVersion, true) : null;
    ArtifactKeyQuery query = new ArtifactKeyQuery(classifier, searchedId, range);
    
    IQueryResult<IArtifactKey> keys = repo.query(query, null);
    if (!keys.isEmpty()) {
      return (IArtifactKey)keys.iterator().next();
    }
    return null;
  }
  
  private List<IArtifactKey> findCorrespondinArtifacts(BundleInfo[] bis, IArtifactRepository repo)
  {
    ArrayList<IArtifactKey> toRetain = new ArrayList();
    for (int i = 0; i < bis.length; i++)
    {
      Version version = "0.0.0".equals(bis[i].getVersion()) ? null : Version.create(bis[i].getVersion());
      IArtifactKey match = searchArtifact(bis[i].getSymbolicName(), version, "osgi.bundle", repo);
      if (match != null) {
        toRetain.add(match);
      }
    }
    return toRetain;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseMarkSetProvider
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.spi.Touchpoint;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;

public class EclipseTouchpoint
  extends Touchpoint
{
  public static final String PROFILE_PROP_LAUNCHER_NAME = "eclipse.touchpoint.launcherName";
  public static final String PARM_MANIPULATOR = "manipulator";
  public static final String PARM_PLATFORM_CONFIGURATION = "platformConfiguration";
  public static final String PARM_SOURCE_BUNDLES = "sourceBundles";
  public static final String PARM_IU = "iu";
  public static final String PARM_ARTIFACT = "artifact";
  public static final String PARM_ARTIFACT_LOCATION = "artifact.location";
  private static final Object PARM_AGENT = "agent";
  private static final String NATIVE_TOUCHPOINT_ID = "org.eclipse.equinox.p2.touchpoint.natives";
  private static List<String> NATIVE_ACTIONS = Arrays.asList(new String[] { "mkdir", "rmdir" });
  private static final String VALIDATE_PROFILE = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile";
  private static Map<IProfile, LazyManipulator> manipulators = new WeakHashMap();
  private static Map<IProfile, PlatformConfigurationWrapper> wrappers = new WeakHashMap();
  private static Map<IProfile, SourceManipulator> sourceManipulators = new WeakHashMap();
  private static Map<IProfile, Map<IInstallableUnit, IInstallableUnit>> preparedIUs = new WeakHashMap();
  
  private static synchronized LazyManipulator getManipulator(IProvisioningAgent agent, IProfile profile)
  {
    LazyManipulator manipulator = (LazyManipulator)manipulators.get(profile);
    if (manipulator == null)
    {
      manipulator = new LazyManipulator(agent, profile);
      manipulators.put(profile, manipulator);
    }
    return manipulator;
  }
  
  private static synchronized void saveManipulator(IProfile profile)
    throws FrameworkAdminRuntimeException, IOException
  {
    LazyManipulator manipulator = (LazyManipulator)manipulators.remove(profile);
    if (manipulator != null) {
      manipulator.save(false);
    }
  }
  
  private static synchronized PlatformConfigurationWrapper getPlatformConfigurationWrapper(IProvisioningAgent agent, IProfile profile, LazyManipulator manipulator)
  {
    PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper)wrappers.get(profile);
    if (wrapper == null)
    {
      File configLocation = Util.getConfigurationFolder(profile);
      URI poolURI = Util.getBundlePoolLocation(agent, profile);
      wrapper = new PlatformConfigurationWrapper(configLocation, poolURI, manipulator);
      wrappers.put(profile, wrapper);
    }
    return wrapper;
  }
  
  private static synchronized void savePlatformConfigurationWrapper(IProfile profile)
    throws ProvisionException
  {
    PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper)wrappers.remove(profile);
    if (wrapper != null) {
      wrapper.save();
    }
  }
  
  private static synchronized SourceManipulator getSourceManipulator(IProfile profile)
  {
    SourceManipulator sourceManipulator = (SourceManipulator)sourceManipulators.get(profile);
    if (sourceManipulator == null)
    {
      sourceManipulator = new SourceManipulator(profile);
      sourceManipulators.put(profile, sourceManipulator);
    }
    return sourceManipulator;
  }
  
  private static synchronized void saveSourceManipulator(IProfile profile)
    throws IOException
  {
    SourceManipulator sourceManipulator = (SourceManipulator)sourceManipulators.remove(profile);
    if (sourceManipulator != null) {
      sourceManipulator.save();
    }
  }
  
  private static synchronized IInstallableUnit getPreparedIU(IProfile profile, IInstallableUnit iu)
  {
    Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = (Map)preparedIUs.get(profile);
    if (preparedProfileIUs == null) {
      return null;
    }
    return (IInstallableUnit)preparedProfileIUs.get(iu);
  }
  
  private static synchronized void savePreparedIU(IProfile profile, IInstallableUnit iu)
  {
    Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = (Map)preparedIUs.get(profile);
    if (preparedProfileIUs == null)
    {
      preparedProfileIUs = new HashMap();
      preparedIUs.put(profile, preparedProfileIUs);
    }
    preparedProfileIUs.put(iu, iu);
  }
  
  private static synchronized boolean hasPreparedIUs(IProfile profile)
  {
    return preparedIUs.get(profile) != null;
  }
  
  private static synchronized void clearProfileState(IProfile profile)
  {
    manipulators.remove(profile);
    wrappers.remove(profile);
    sourceManipulators.remove(profile);
    preparedIUs.remove(profile);
  }
  
  public IStatus prepare(IProfile profile)
  {
    try
    {
      if (hasPreparedIUs(profile)) {
        return validateProfile(profile);
      }
    }
    catch (RuntimeException e)
    {
      return Util.createError(NLS.bind(Messages.error_validating_profile, profile.getProfileId()), e);
    }
    return Status.OK_STATUS;
  }
  
  public IStatus commit(IProfile profile)
  {
    MultiStatus status = new MultiStatus("org.eclipse.equinox.p2.touchpoint.eclipse", 0, null, null);
    try
    {
      saveManipulator(profile);
    }
    catch (RuntimeException e)
    {
      status.add(Util.createError(Messages.error_saving_manipulator, e));
    }
    catch (IOException e)
    {
      status.add(Util.createError(Messages.error_saving_manipulator, e));
    }
    try
    {
      savePlatformConfigurationWrapper(profile);
    }
    catch (RuntimeException e)
    {
      status.add(Util.createError(Messages.error_saving_platform_configuration, e));
    }
    catch (ProvisionException pe)
    {
      status.add(Util.createError(Messages.error_saving_platform_configuration, pe));
    }
    try
    {
      saveSourceManipulator(profile);
    }
    catch (RuntimeException e)
    {
      status.add(Util.createError(Messages.error_saving_source_bundles_list, e));
    }
    catch (IOException e)
    {
      status.add(Util.createError(Messages.error_saving_source_bundles_list, e));
    }
    return status;
  }
  
  public IStatus rollback(IProfile profile)
  {
    clearProfileState(profile);
    return Status.OK_STATUS;
  }
  
  public String qualifyAction(String actionId)
  {
    String touchpointQualifier = NATIVE_ACTIONS.contains(actionId) ? "org.eclipse.equinox.p2.touchpoint.natives" : "org.eclipse.equinox.p2.touchpoint.eclipse";
    return touchpointQualifier + "." + actionId;
  }
  
  public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map<String, Object> touchpointParameters)
  {
    IProvisioningAgent agent = (IProvisioningAgent)touchpointParameters.get(PARM_AGENT);
    LazyManipulator manipulator = getManipulator(agent, profile);
    touchpointParameters.put("manipulator", manipulator);
    touchpointParameters.put("sourceBundles", getSourceManipulator(profile));
    touchpointParameters.put("platformConfiguration", getPlatformConfigurationWrapper(agent, profile, manipulator));
    return null;
  }
  
  public IStatus initializeOperand(IProfile profile, Map<String, Object> parameters)
  {
    IInstallableUnit iu = (IInstallableUnit)parameters.get("iu");
    IArtifactKey artifactKey = (IArtifactKey)parameters.get("artifact");
    IProvisioningAgent agent = (IProvisioningAgent)parameters.get(PARM_AGENT);
    if ((iu != null) && (Boolean.valueOf(iu.getProperty("org.eclipse.equinox.p2.partial.iu")).booleanValue()))
    {
      IInstallableUnit preparedIU = prepareIU(agent, profile, iu, artifactKey);
      if (preparedIU == null) {
        return Util.createError(NLS.bind(Messages.failed_prepareIU, iu));
      }
      parameters.put("iu", preparedIU);
    }
    if ((!parameters.containsKey("artifact.location")) && (artifactKey != null))
    {
      File fileLocation = Util.getArtifactFile(agent, artifactKey, profile);
      if ((fileLocation != null) && (fileLocation.exists())) {
        parameters.put("artifact.location", fileLocation.getAbsolutePath());
      }
    }
    return Status.OK_STATUS;
  }
  
  public IInstallableUnit prepareIU(IProvisioningAgent agent, IProfile profile, IInstallableUnit iu, IArtifactKey artifactKey)
  {
    IInstallableUnit preparedIU = getPreparedIU(profile, iu);
    if (preparedIU != null) {
      return preparedIU;
    }
    Class<?> c = null;
    try
    {
      c = Class.forName("org.eclipse.equinox.p2.publisher.eclipse.BundlesAction");
      if (c != null) {
        c = Class.forName("org.eclipse.osgi.service.resolver.PlatformAdmin");
      }
    }
    catch (ClassNotFoundException e)
    {
      LogHelper.log(Util.createError(NLS.bind(Messages.publisher_not_available, e.getMessage())));
      return null;
    }
    if (c != null)
    {
      if (artifactKey == null) {
        return iu;
      }
      File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
      if (bundleFile == null)
      {
        LogHelper.log(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey.toString())));
        return null;
      }
      preparedIU = PublisherUtil.createBundleIU(artifactKey, bundleFile);
      if (preparedIU == null)
      {
        LogHelper.log(Util.createError("The bundle manifest could not be read: " + bundleFile.toString()));
        return null;
      }
      savePreparedIU(profile, preparedIU);
      return preparedIU;
    }
    throw new IllegalStateException(Messages.unexpected_prepareiu_error);
  }
  
  private IStatus validateProfile(IProfile profile)
  {
    if (Boolean.FALSE.toString().equals(profile.getProperty("org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile"))) {
      return Status.OK_STATUS;
    }
    Class<?> c = null;
    try
    {
      c = Class.forName("org.eclipse.equinox.p2.planner.IPlanner");
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      return null;
    }
    if (c != null) {
      return DirectorUtil.validateProfile(profile);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.io.IOException;
import java.net.URI;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundlesState;
import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdmin;
import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.util.tracker.ServiceTracker;

public class LazyManipulator
  implements Manipulator
{
  private static final String FILTER_OBJECTCLASS = "(objectClass=" + FrameworkAdmin.class.getName() + ')';
  private static final String filterFwName = "(org.eclipse.equinox.frameworkhandler.framework.name=Equinox)";
  private static final String filterLauncherName = "(org.eclipse.equinox.frameworkhandler.launcher.name=Eclipse.exe)";
  private static final String filterFwAdmin = "(&" + FILTER_OBJECTCLASS + "(org.eclipse.equinox.frameworkhandler.framework.name=Equinox)" + "(org.eclipse.equinox.frameworkhandler.launcher.name=Eclipse.exe)" + ')';
  private Manipulator manipulator;
  private final IProfile profile;
  private final IProvisioningAgent agent;
  
  public LazyManipulator(IProvisioningAgent agent, IProfile profile)
  {
    this.profile = profile;
    this.agent = agent;
  }
  
  private void loadDelegate()
  {
    if (manipulator != null) {
      return;
    }
    manipulator = getFrameworkManipulator();
    if (manipulator == null) {
      throw new IllegalStateException(Messages.failed_acquire_framework_manipulator);
    }
    LauncherData launcherData = manipulator.getLauncherData();
    launcherData.setFwConfigLocation(Util.getConfigurationFolder(profile));
    launcherData.setLauncher(Util.getLauncherPath(profile));
    launcherData.setLauncherConfigLocation(Util.getLauncherConfigLocation(profile));
    launcherData.setOS(Util.isMacOSBundled(profile) ? "macosx-bundled" : Util.getOSFromProfile(profile));
    launcherData.setHome(Util.getInstallFolder(profile));
    try
    {
      manipulator.load();
    }
    catch (IllegalStateException e)
    {
      LogHelper.log(Util.createError(Messages.error_loading_manipulator, e));
      throw new IllegalStateException(Messages.error_loading_manipulator);
    }
    catch (FrameworkAdminRuntimeException e)
    {
      LogHelper.log(Util.createError(Messages.error_loading_manipulator, e));
    }
    catch (IOException e)
    {
      LogHelper.log(Util.createError(Messages.error_loading_manipulator, e));
      throw new IllegalStateException(Messages.error_loading_manipulator);
    }
    manipulator.getConfigData().setProperty("eclipse.p2.profile", profile.getProfileId());
    manipulator.getConfigData().setProperty("eclipse.p2.data.area", Util.getAgentLocation(agent).getRootLocation().toString());
  }
  
  public static FrameworkAdmin getFrameworkAdmin()
  {
    ServiceTracker<FrameworkAdmin, FrameworkAdmin> fwAdminTracker = null;
    try
    {
      Filter filter = Activator.getContext().createFilter(filterFwAdmin);
      fwAdminTracker = new ServiceTracker(Activator.getContext(), filter, null);
      fwAdminTracker.open();
      FrameworkAdmin fwAdmin = (FrameworkAdmin)fwAdminTracker.getService();
      return fwAdmin;
    }
    catch (InvalidSyntaxException localInvalidSyntaxException)
    {
      return null;
    }
    finally
    {
      if (fwAdminTracker != null) {
        fwAdminTracker.close();
      }
    }
  }
  
  private Manipulator getFrameworkManipulator()
  {
    FrameworkAdmin fwAdmin = getFrameworkAdmin();
    if (fwAdmin != null) {
      return fwAdmin.getManipulator();
    }
    return null;
  }
  
  public void save(boolean backup)
    throws IOException, FrameworkAdminRuntimeException
  {
    if (manipulator != null) {
      manipulator.save(backup);
    }
  }
  
  public BundlesState getBundlesState()
    throws FrameworkAdminRuntimeException
  {
    loadDelegate();
    return manipulator.getBundlesState();
  }
  
  public ConfigData getConfigData()
    throws FrameworkAdminRuntimeException
  {
    loadDelegate();
    return manipulator.getConfigData();
  }
  
  public BundleInfo[] getExpectedState()
    throws IllegalStateException, IOException, FrameworkAdminRuntimeException
  {
    loadDelegate();
    return manipulator.getExpectedState();
  }
  
  public LauncherData getLauncherData()
    throws FrameworkAdminRuntimeException
  {
    loadDelegate();
    return manipulator.getLauncherData();
  }
  
  public long getTimeStamp()
  {
    loadDelegate();
    return manipulator.getTimeStamp();
  }
  
  public void initialize()
  {
    loadDelegate();
    manipulator.initialize();
  }
  
  public void load()
    throws IllegalStateException, FrameworkAdminRuntimeException
  {
    loadDelegate();
  }
  
  public void setConfigData(ConfigData configData)
  {
    loadDelegate();
    manipulator.setConfigData(configData);
  }
  
  public void setLauncherData(LauncherData launcherData)
  {
    loadDelegate();
    manipulator.setLauncherData(launcherData);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.LazyManipulator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.messages";
  public static String error_loading_manipulator;
  public static String BundlePool;
  public static String failed_acquire_framework_manipulator;
  public static String failed_prepareIU;
  public static String error_saving_manipulator;
  public static String error_saving_platform_configuration;
  public static String error_saving_source_bundles_list;
  public static String error_parsing_configuration;
  public static String publisher_not_available;
  public static String artifact_write_unsupported;
  public static String iu_contains_no_arifacts;
  public static String artifact_file_not_found;
  public static String artifact_retrieval_unsupported;
  public static String bundle_pool_not_writeable;
  public static String cannot_calculate_extension_location;
  public static String parent_dir_features;
  public static String platform_config_unavailable;
  public static String unexpected_prepareiu_error;
  public static String error_validating_profile;
  public static String invalid_macox_bundled_setup;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.touchpoint.eclipse.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.touchpoint.eclipse.Messages
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.update.Configuration;
import org.eclipse.equinox.internal.p2.update.Feature;
import org.eclipse.equinox.internal.p2.update.Site;
import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.osgi.util.NLS;

public class PlatformConfigurationWrapper
{
  private Configuration configuration = null;
  private Site poolSite = null;
  private File configFile;
  private URI poolURI;
  private Manipulator manipulator;
  private static String FEATURES = "features/";
  
  private static URL getOSGiInstallArea(Manipulator manipulator)
  {
    LauncherData launcherData = manipulator.getLauncherData();
    File home = launcherData.getHome();
    if (home != null) {
      try
      {
        return home.toURI().toURL();
      }
      catch (MalformedURLException localMalformedURLException1) {}
    }
    File fwkJar = launcherData.getFwJar();
    if (fwkJar != null) {
      try
      {
        return fromOSGiJarToOSGiInstallArea(fwkJar.getAbsolutePath()).toURI().toURL();
      }
      catch (MalformedURLException localMalformedURLException2) {}
    }
    File launcherFile = launcherData.getLauncher();
    if (launcherFile != null)
    {
      if ("macosx".equals(launcherData.getOS()))
      {
        IPath launcherPath = new Path(launcherFile.getAbsolutePath());
        if (launcherPath.segmentCount() > 4)
        {
          launcherPath = launcherPath.removeLastSegments(4);
          try
          {
            return launcherPath.toFile().toURI().toURL();
          }
          catch (MalformedURLException localMalformedURLException3) {}
        }
      }
      if ("macosx-bundled".equals(launcherData.getOS())) {
        LogHelper.log(Util.createError(Messages.invalid_macox_bundled_setup));
      }
      try
      {
        return launcherFile.getParentFile().toURI().toURL();
      }
      catch (MalformedURLException localMalformedURLException4) {}
    }
    BundleInfo[] bis = manipulator.getConfigData().getBundles();
    String searchFor = "org.eclipse.equinox.launcher";
    for (int i = 0; i < bis.length; i++) {
      if (bis[i].getSymbolicName().equals(searchFor))
      {
        if (bis[i].getLocation() != null) {
          try
          {
            if (bis[i].getLocation().getScheme().equals("file")) {
              return fromOSGiJarToOSGiInstallArea(bis[i].getLocation().getPath()).toURI().toURL();
            }
          }
          catch (MalformedURLException localMalformedURLException5) {}
        }
        if (searchFor.equals("org.eclipse.osgi")) {
          return null;
        }
        searchFor = "org.eclipse.osgi";
        i = -1;
      }
    }
    return null;
  }
  
  private static File fromOSGiJarToOSGiInstallArea(String path)
  {
    IPath parentFolder = new Path(path).removeLastSegments(1);
    if (parentFolder.lastSegment().equals("plugins")) {
      return parentFolder.removeLastSegments(1).toFile();
    }
    return parentFolder.toFile();
  }
  
  public PlatformConfigurationWrapper(File configDir, URI featurePool, Manipulator manipulator)
  {
    configuration = null;
    configFile = new File(configDir, "/org.eclipse.update/platform.xml");
    poolURI = featurePool;
    this.manipulator = manipulator;
  }
  
  private void loadDelegate()
  {
    if (configuration != null) {
      return;
    }
    try
    {
      if (configFile.exists()) {
        configuration = Configuration.load(configFile, getOSGiInstallArea(manipulator));
      } else {
        configuration = new Configuration();
      }
    }
    catch (ProvisionException localProvisionException)
    {
      throw new IllegalStateException(Messages.error_parsing_configuration);
    }
    if (poolURI == null) {
      throw new IllegalStateException("Error creating platform configuration. No bundle pool defined.");
    }
    poolSite = getSite(poolURI);
    if (poolSite == null)
    {
      poolSite = createSite(poolURI, getDefaultPolicy());
      configuration.add(poolSite);
    }
  }
  
  private String getDefaultPolicy()
  {
    for (Iterator localIterator = configuration.getSites().iterator(); localIterator.hasNext();)
    {
      Site site = (Site)localIterator.next();
      if ("MANAGED-ONLY".equals(site.getPolicy())) {
        return "MANAGED-ONLY";
      }
    }
    return "USER-EXCLUDE";
  }
  
  private Site createSite(URI location, String policy)
  {
    Site result = new Site();
    result.setUrl(location.toString());
    result.setPolicy(policy);
    result.setEnabled(true);
    return result;
  }
  
  private Site getSite(URI url)
  {
    List<Site> sites = configuration.getSites();
    File file = URIUtil.toFile(url);
    for (Iterator localIterator = sites.iterator(); localIterator.hasNext();)
    {
      Site nextSite = (Site)localIterator.next();
      try
      {
        File nextFile = URIUtil.toFile(new URI(nextSite.getUrl()));
        if (nextFile != null) {
          if (nextFile.equals(file)) {
            return nextSite;
          }
        }
      }
      catch (URISyntaxException localURISyntaxException) {}
    }
    return null;
  }
  
  private Site getSite(String id, String version)
  {
    List<Site> sites = configuration.getSites();
    Feature[] features;
    int i;
    for (Iterator localIterator = sites.iterator(); localIterator.hasNext(); i < features.length)
    {
      Site site = (Site)localIterator.next();
      features = site.getFeatures();
      i = 0; continue;
      if ((id.equals(features[i].getId())) && (version.equals(features[i].getVersion()))) {
        return site;
      }
      i++;
    }
    return null;
  }
  
  public IStatus addFeatureEntry(File file, String id, String version, String pluginIdentifier, String pluginVersion, boolean primary, String application, URL[] root, String linkFile)
  {
    loadDelegate();
    if (configuration == null) {
      return new Status(2, "org.eclipse.equinox.p2.touchpoint.eclipse", Messages.platform_config_unavailable, null);
    }
    URI fileURL = null;
    File featureDir = file.getParentFile();
    if ((featureDir == null) || (!featureDir.getName().equals("features"))) {
      return new Status(4, "org.eclipse.equinox.p2.touchpoint.eclipse", NLS.bind(Messages.parent_dir_features, file.getAbsolutePath()), null);
    }
    File locationDir = featureDir.getParentFile();
    if (locationDir == null) {
      return new Status(4, "org.eclipse.equinox.p2.touchpoint.eclipse", NLS.bind(Messages.cannot_calculate_extension_location, file.getAbsolutePath()), null);
    }
    fileURL = locationDir.toURI();
    Site site = getSite(fileURL);
    if (site == null)
    {
      site = createSite(fileURL, getDefaultPolicy());
      if (linkFile != null) {
        site.setLinkFile(linkFile);
      }
      configuration.add(site);
    }
    else if (site.getFeature(id, version) != null)
    {
      return Status.OK_STATUS;
    }
    Feature addedFeature = new Feature(site);
    addedFeature.setId(id);
    addedFeature.setVersion(version);
    addedFeature.setUrl(makeFeatureURL(id, version));
    addedFeature.setApplication(application);
    addedFeature.setPluginIdentifier(pluginIdentifier);
    addedFeature.setPluginVersion(pluginVersion);
    addedFeature.setRoots(root);
    addedFeature.setPrimary(primary);
    site.addFeature(addedFeature);
    return Status.OK_STATUS;
  }
  
  public IStatus removeFeatureEntry(String id, String version)
  {
    loadDelegate();
    if (configuration == null) {
      return new Status(2, "org.eclipse.equinox.p2.touchpoint.eclipse", Messages.platform_config_unavailable, null);
    }
    Site site = getSite(id, version);
    if (site == null) {
      site = poolSite;
    }
    site.removeFeature(makeFeatureURL(id, version));
    
    return Status.OK_STATUS;
  }
  
  public boolean containsFeature(URI siteURI, String featureId, St
1 2 3 4 5 6

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd