org.eclipse.equinox.p2.reconciler.dropins_1.1.200.v20120301-2145

  }
}

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

import java.util.Properties;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

public class Application
  implements IApplication
{
  public Object start(IApplicationContext context)
    throws Exception
  {
    Object obj = System.getProperties().get("org.eclipse.equinox.p2.reconciler.application.status");
    if ((obj != null) && ((obj instanceof IStatus)) && (!((IStatus)obj).isOK())) {
      return new Integer(13);
    }
    return IApplication.EXIT_OK;
  }
  
  public void stop() {}
}

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

import java.io.File;

class DropinsRepositoryListener$LinkedRepository
{
  private File location;
  
  DropinsRepositoryListener$LinkedRepository(File location)
  {
    if (location == null) {
      throw new IllegalArgumentException("Repository location cannot be null.");
    }
    this.location = location;
  }
  
  boolean exists()
  {
    return location.exists();
  }
  
  File getLocation()
  {
    return location;
  }
  
  boolean isOptional()
  {
    return optional;
  }
  
  void setOptional(boolean optional)
  {
    this.optional = optional;
  }
  
  private boolean optional = false;
}

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

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationArtifactRepository;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepository;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;

public class DropinsRepositoryListener
  extends RepositoryListener
{
  private static final String PREFIX = "[reconciler] [dropins] ";
  private static final String PLUGINS = "plugins";
  private static final String FEATURES = "features";
  private static final String JAR = ".jar";
  private static final String LINK = ".link";
  private static final String ZIP = ".zip";
  private static final String LINKS_PATH = "path";
  private static final String LINK_IS_OPTIONAL = "optional";
  private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories";
  private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories";
  private static final String PIPE = "|";
  private final IProvisioningAgent agent;
  private List<IMetadataRepository> metadataRepositories = new ArrayList();
  private List<IArtifactRepository> artifactRepositories = new ArrayList();
  
  static class LinkedRepository
  {
    private File location;
    
    LinkedRepository(File location)
    {
      if (location == null) {
        throw new IllegalArgumentException("Repository location cannot be null.");
      }
      this.location = location;
    }
    
    boolean exists()
    {
      return location.exists();
    }
    
    File getLocation()
    {
      return location;
    }
    
    boolean isOptional()
    {
      return optional;
    }
    
    void setOptional(boolean optional)
    {
      this.optional = optional;
    }
    
    private boolean optional = false;
  }
  
  public DropinsRepositoryListener(IProvisioningAgent agent, String repositoryName, Map<String, String> properties)
  {
    super(repositoryName, properties);
    this.agent = agent;
  }
  
  public boolean isInterested(File file)
  {
    return true;
  }
  
  public boolean added(File file)
  {
    if (super.added(file))
    {
      if (Tracing.DEBUG_RECONCILER) {
        Tracing.debug("[reconciler] [dropins] Interesting feature or bundle added: " + file);
      }
      return true;
    }
    addRepository(file);
    return true;
  }
  
  public boolean changed(File file)
  {
    if (super.changed(file))
    {
      if (Tracing.DEBUG_RECONCILER) {
        Tracing.debug("[reconciler] [dropins] Interesting feature or bundle changed: " + file);
      }
      return true;
    }
    addRepository(file);
    return true;
  }
  
  private void addRepository(File file)
  {
    URI repoLocation = createRepositoryLocation(file);
    if (repoLocation == null) {
      return;
    }
    Map<String, String> properties = new HashMap();
    if ((file.isFile()) && (file.getName().endsWith(".link")))
    {
      URI linkLocation = getLinkRepository(file, false);
      if (linkLocation != null) {
        properties.put("org.eclipse.update.site.linkFile", file.getAbsolutePath());
      }
    }
    getMetadataRepository(repoLocation, properties);
    getArtifactRepository(repoLocation, properties);
  }
  
  /* Error */
  static LinkedRepository getLinkedRepository(File file)
  {
    // Byte code:
    //   0: new 234	java/util/Properties
    //   3: dup
    //   4: invokespecial 477	java/util/Properties:<init>	()V
    //   7: astore_1
    //   8: new 218	java/io/BufferedInputStream
    //   11: dup
    //   12: new 220	java/io/FileInputStream
    //   15: dup
    //   16: aload_0
    //   17: invokespecial 456	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   20: invokespecial 445	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   23: astore_2
    //   24: aload_1
    //   25: aload_2
    //   26: invokevirtual 478	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   29: goto +10 -> 39
    //   32: astore_3
    //   33: aload_2
    //   34: invokevirtual 457	java/io/InputStream:close	()V
    //   37: aload_3
    //   38: athrow
    //   39: aload_2
    //   40: invokevirtual 457	java/io/InputStream:close	()V
    //   43: goto +30 -> 73
    //   46: astore_2
    //   47: new 237	org/eclipse/core/runtime/Status
    //   50: dup
    //   51: iconst_4
    //   52: ldc 10
    //   54: getstatic 440	org/eclipse/equinox/internal/p2/reconciler/dropins/Messages:error_reading_link	Ljava/lang/String;
    //   57: aload_0
    //   58: invokevirtual 451	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   61: invokestatic 522	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   64: aload_2
    //   65: invokespecial 485	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   68: invokestatic 486	org/eclipse/equinox/internal/p2/core/helpers/LogHelper:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   71: aconst_null
    //   72: areturn
    //   73: aload_1
    //   74: ldc 12
    //   76: invokevirtual 479	java/util/Properties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   79: astore_2
    //   80: aload_2
    //   81: ifnonnull +5 -> 86
    //   84: aconst_null
    //   85: areturn
    //   86: aload_2
    //   87: ldc 14
    //   89: invokevirtual 465	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   92: ifeq +15 -> 107
    //   95: aload_2
    //   96: iconst_2
    //   97: invokevirtual 463	java/lang/String:substring	(I)Ljava/lang/String;
    //   100: invokevirtual 462	java/lang/String:trim	()Ljava/lang/String;
    //   103: astore_2
    //   104: goto +29 -> 133
    //   107: aload_2
    //   108: ldc 15
    //   110: invokevirtual 465	java/lang/String:startsWith	(Ljava/lang/String;)Z
    //   113: ifeq +15 -> 128
    //   116: aload_2
    //   117: iconst_3
    //   118: invokevirtual 463	java/lang/String:substring	(I)Ljava/lang/String;
    //   121: invokevirtual 462	java/lang/String:trim	()Ljava/lang/String;
    //   124: astore_2
    //   125: goto +8 -> 133
    //   128: aload_2
    //   129: invokevirtual 462	java/lang/String:trim	()Ljava/lang/String;
    //   132: astore_2
    //   133: aload_2
    //   134: invokestatic 492	org/eclipse/equinox/internal/p2/reconciler/dropins/Activator:substituteVariables	(Ljava/lang/String;)Ljava/lang/String;
    //   137: astore_2
    //   138: new 219	java/io/File
    //   141: dup
    //   142: aload_2
    //   143: invokespecial 453	java/io/File:<init>	(Ljava/lang/String;)V
    //   146: astore_3
    //   147: aload_3
    //   148: invokevirtual 446	java/io/File:isAbsolute	()Z
    //   151: ifne +24 -> 175
    //   154: invokestatic 491	org/eclipse/equinox/internal/p2/reconciler/dropins/Activator:getEclipseHome	()Ljava/io/File;
    //   157: astore 4
    //   159: aload 4
    //   161: ifnull +14 -> 175
    //   164: new 219	java/io/File
    //   167: dup
    //   168: aload 4
    //   170: aload_2
    //   171: invokespecial 455	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   174: astore_3
    //   175: new 244	org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener$LinkedRepository
    //   178: dup
    //   179: aload_3
    //   180: invokevirtual 449	java/io/File:getCanonicalFile	()Ljava/io/File;
    //   183: invokespecial 516	org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener$LinkedRepository:<init>	(Ljava/io/File;)V
    //   186: astore 4
    //   188: aload_1
    //   189: ldc 9
    //   191: invokevirtual 479	java/util/Properties:getProperty	(Ljava/lang/String;)Ljava/lang/String;
    //   194: astore 5
    //   196: aload 4
    //   198: aload 5
    //   200: invokestatic 459	java/lang/Boolean:valueOf	(Ljava/lang/String;)Ljava/lang/Boolean;
    //   203: invokevirtual 458	java/lang/Boolean:booleanValue	()Z
    //   206: invokevirtual 514	org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener$LinkedRepository:setOptional	(Z)V
    //   209: aload 4
    //   211: areturn
    //   212: astore 4
    //   214: new 237	org/eclipse/core/runtime/Status
    //   217: dup
    //   218: iconst_4
    //   219: ldc 10
    //   221: getstatic 441	org/eclipse/equinox/internal/p2/reconciler/dropins/Messages:error_resolving_link	Ljava/lang/String;
    //   224: aload_3
    //   225: invokevirtual 451	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   228: aload_0
    //   229: invokevirtual 451	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   232: invokestatic 523	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/String;
    //   235: aload 4
    //   237: invokespecial 485	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   240: invokestatic 486	org/eclipse/equinox/internal/p2/core/helpers/LogHelper:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   243: aconst_null
    //   244: areturn
    // Line number table:
    //   Java source line #131	-> byte code offset #0
    //   Java source line #133	-> byte code offset #8
    //   Java source line #135	-> byte code offset #24
    //   Java source line #136	-> byte code offset #32
    //   Java source line #137	-> byte code offset #33
    //   Java source line #138	-> byte code offset #37
    //   Java source line #137	-> byte code offset #39
    //   Java source line #139	-> byte code offset #46
    //   Java source line #140	-> byte code offset #47
    //   Java source line #141	-> byte code offset #71
    //   Java source line #143	-> byte code offset #73
    //   Java source line #144	-> byte code offset #80
    //   Java source line #145	-> byte code offset #84
    //   Java source line #149	-> byte code offset #86
    //   Java source line #150	-> byte code offset #95
    //   Java source line #151	-> byte code offset #107
    //   Java source line #152	-> byte code offset #116
    //   Java source line #154	-> byte code offset #128
    //   Java source line #156	-> byte code offset #133
    //   Java source line #157	-> byte code offset #138
    //   Java source line #158	-> byte code offset #147
    //   Java source line #160	-> byte code offset #154
    //   Java source line #161	-> byte code offset #159
    //   Java source line #162	-> byte code offset #164
    //   Java source line #165	-> byte code offset #175
    //   Java source line #169	-> byte code offset #188
    //   Java source line #170	-> byte code offset #196
    //   Java source line #171	-> byte code offset #209
    //   Java source line #172	-> byte code offset #212
    //   Java source line #173	-> byte code offset #214
    //   Java source line #174	-> byte code offset #243
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	245	0	file	File
    //   7	182	1	links	java.util.Properties
    //   23	17	2	input	java.io.InputStream
    //   46	19	2	e	IOException
    //   79	92	2	path	String
    //   32	6	3	localObject	Object
    //   146	79	3	linkedFile	File
    //   157	12	4	root	File
    //   186	24	4	result	LinkedRepository
    //   212	24	4	e	IOException
    //   194	5	5	optional	String
    // Exception table:
    //   from	to	target	type
    //   24	32	32	finally
    //   8	43	46	java/io/IOException
    //   175	211	212	java/io/IOException
  }
  
  private URI createRepositoryLocation(File file)
  {
    try
    {
      file = file.getCanonicalFile();
      String fileName = file.getName();
      if (fileName.endsWith(".link")) {
        return getLinkRepository(file, true);
      }
      if (file.isDirectory())
      {
        if (file.getName().equals("plugins"))
        {
          File parentFile = file.getParentFile();
          return parentFile != null ? parentFile.toURI() : null;
        }
        if (file.getName().equals("features"))
        {
          File parentFile = file.getParentFile();
          if ((parentFile == null) || (new File(parentFile, "plugins").isDirectory())) {
            return null;
          }
          return parentFile.toURI();
        }
        return file.toURI();
      }
      if ((fileName.endsWith(".zip")) || (fileName.endsWith(".jar"))) {
        return new URI("jar:" + file.toURI() + "!/");
      }
      return getLinkRepository(file, false);
    }
    catch (URISyntaxException e)
    {
      LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while building repository location from file: " + file.getAbsolutePath(), e));
    }
    catch (IOException e)
    {
      LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while building repository location from file: " + file.getAbsolutePath(), e));
    }
    return null;
  }
  
  private URI getLinkRepository(File file, boolean logMissingLink)
  {
    LinkedRepository repo = getLinkedRepository(file);
    if (repo == null)
    {
      if (logMissingLink) {
        LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Unable to determine link location from file: " + file.getAbsolutePath()));
      }
      return null;
    }
    return (repo.isOptional()) && (!repo.exists()) ? null : repo.getLocation().toURI();
  }
  
  public void getMetadataRepository(URI repoURL, Map<String, String> properties)
  {
    try
    {
      IMetadataRepository repository = null;
      try
      {
        ExtensionLocationMetadataRepository.validate(repoURL, null);
        repository = Activator.createExtensionLocationMetadataRepository(repoURL, "dropins metadata repo: " + repoURL, properties);
      }
      catch (ProvisionException localProvisionException1)
      {
        repository = Activator.loadMetadataRepository(repoURL, null);
      }
      metadataRepositories.add(repository);
      debugRepository(repository);
    }
    catch (ProvisionException ex)
    {
      LogHelper.log(ex);
    }
  }
  
  private void debugRepository(IMetadataRepository repository)
  {
    if (!Tracing.DEBUG_RECONCILER) {
      return;
    }
    Tracing.debug("[reconciler] [dropins] Repository created " + repository.getLocation());
    
    IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
    for (Iterator<IInstallableUnit> iter = result.iterator(); iter.hasNext();) {
      Tracing.debug("[reconciler] [dropins] \t" + iter.next());
    }
  }
  
  public void getArtifactRepository(URI repoURL, Map<String, String> properties)
  {
    try
    {
      IArtifactRepository repository = null;
      try
      {
        ExtensionLocationArtifactRepository.validate(repoURL, null);
        repository = Activator.createExtensionLocationArtifactRepository(repoURL, "dropins artifact repo: " + repoURL, properties);
      }
      catch (ProvisionException localProvisionException1)
      {
        repository = Activator.loadArtifactRepository(repoURL, null);
      }
      artifactRepositories.add(repository);
    }
    catch (ProvisionException ex)
    {
      LogHelper.log(ex);
    }
  }
  
  public void stopPoll()
  {
    synchronizeDropinMetadataRepositories();
    synchronizeDropinArtifactRepositories();
    super.stopPoll();
  }
  
  private void synchronizeDropinMetadataRepositories()
  {
    List<String> currentRepositories = new ArrayList();
    for (Iterator<IMetadataRepository> it = metadataRepositories.iterator(); it.hasNext();)
    {
      IMetadataRepository repository = (IMetadataRepository)it.next();
      currentRepositories.add(repository.getLocation().toString());
    }
    List<String> previousRepositories = getListRepositoryProperty(getMetadataRepository(), "dropin.metadataRepositories");
    for (Iterator<String> iterator = previousRepositories.iterator(); iterator.hasNext();)
    {
      String repository = (String)iterator.next();
      if (!currentRepositories.contains(repository)) {
        removeMetadataRepository(repository);
      }
    }
    setListRepositoryProperty(getMetadataRepository(), "dropin.metadataRepositories", currentRepositories);
  }
  
  private void removeMetadataRepository(String urlString)
  {
    IMetadataRepositoryManager manager = (IMetadataRepositoryManager)agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
    if (manager == null) {
      throw new IllegalStateException(Messages.metadata_repo_manager_not_registered);
    }
    try
    {
      manager.removeRepository(new URI(urlString));
    }
    catch (URISyntaxException e)
    {
      LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while creating URL from: " + urlString, e));
    }
  }
  
  private void synchronizeDropinArtifactRepositories()
  {
    List<String> currentRepositories = new ArrayList();
    for (Iterator<IArtifactRepository> it = artifactRepositories.iterator(); it.hasNext();)
    {
      IArtifactRepository repository = (IArtifactRepository)it.next();
      currentRepositories.add(repository.getLocation().toString());
    }
    List<String> previousRepositories = getListRepositoryProperty(getArtifactRepository(), "dropin.artifactRepositories");
    for (Iterator<String> iterator = previousRepositories.iterator(); iterator.hasNext();)
    {
      String repository = (String)iterator.next();
      if (!currentRepositories.contains(repository)) {
        removeArtifactRepository(repository);
      }
    }
    setListRepositoryProperty(getArtifactRepository(), "dropin.artifactRepositories", currentRepositories);
  }
  
  public void removeArtifactRepository(String urlString)
  {
    IArtifactRepositoryManager manager = (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
    if (manager == null) {
      throw new IllegalStateException(Messages.artifact_repo_manager_not_registered);
    }
    try
    {
      manager.removeRepository(new URI(urlString));
    }
    catch (URISyntaxException e)
    {
      LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while creating URL from: " + urlString, e));
    }
  }
  
  private List<String> getListRepositoryProperty(IRepository<?> repository, String key)
  {
    List<String> listProperty = new ArrayList();
    String dropinRepositories = (String)repository.getProperties().get(key);
    if (dropinRepositories != null)
    {
      StringTokenizer tokenizer = new StringTokenizer(dropinRepositories, "|");
      while (tokenizer.hasMoreTokens()) {
        listProperty.add(tokenizer.nextToken());
      }
    }
    return listProperty;
  }
  
  private void setListRepositoryProperty(IRepository<?> repository, String key, List<String> listProperty)
  {
    StringBuffer buffer = new StringBuffer();
    for (Iterator<String> it = listProperty.iterator(); it.hasNext();)
    {
      String repositoryString = (String)it.next();
      buffer.append(repositoryString);
      if (it.hasNext()) {
        buffer.append("|");
      }
    }
    String value = buffer.length() == 0 ? null : buffer.toString();
    repository.setProperty(key, value);
  }
  
  public Collection<IMetadataRepository> getMetadataRepositories()
  {
    List<IMetadataRepository> result = new ArrayList(metadataRepositories);
    result.add(getMetadataRepository());
    return result;
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.reconciler.dropins.messages";
  public static String artifact_repo_manager_not_registered;
  public static String errorLoadingRepository;
  public static String errorProcessingConfg;
  public static String metadata_repo_manager_not_registered;
  public static String error_reading_link;
  public static String error_resolving_link;
  public static String remove_root;
  public static String remove_all_roots;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.reconciler.dropins.messages", Messages.class);
  }
}

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

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
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.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepository;
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.p2.directorywatcher.DirectoryChangeListener;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.util.NLS;

public class PlatformXmlListener
  extends DirectoryChangeListener
{
  private static final String PLATFORM_XML = "platform.xml";
  private boolean changed = false;
  private File root;
  private long lastModified = -1L;
  private Set<IMetadataRepository> configRepositories;
  
  private String toString(Feature[] features, String[] list)
  {
    StringBuffer buffer = new StringBuffer();
    if (features != null) {
      for (int i = 0; i < features.length; i++)
      {
        String featureURL = features[i].getUrl();
        if (featureURL != null)
        {
          buffer.append(featureURL).append(',');
        }
        else
        {
          String id = features[i].getId();
          String version = features[i].getVersion();
          if ((id != null) && (version != null)) {
            buffer.append("features/" + id + "_" + version + "/,");
          }
        }
      }
    }
    if (list != null) {
      for (int i = 0; i < list.length; i++) {
        buffer.append(list[i]).append(',');
      }
    }
    if (buffer.length() == 0) {
      return "";
    }
    return buffer.substring(0, buffer.length() - 1);
  }
  
  public PlatformXmlListener(File file)
  {
    if (!"platform.xml".equals(file.getName())) {
      throw new IllegalArgumentException();
    }
    root = file;
  }
  
  public boolean added(File file)
  {
    changed = ((changed) || ("platform.xml".equals(file.getName())));
    return false;
  }
  
  public boolean changed(File file)
  {
    changed = ((changed) || ("platform.xml".equals(file.getName())));
    return false;
  }
  
  public Long getSeenFile(File file)
  {
    return new Long(0L);
  }
  
  public boolean isInterested(File file)
  {
    return (file.getName().equals("platform.xml")) && (lastModified != file.lastModified());
  }
  
  public boolean removed(File file)
  {
    changed = ((changed) || ("platform.xml".equals(file.getName())));
    return false;
  }
  
  public void startPoll()
  {
    changed = false;
  }
  
  public void stopPoll()
  {
    if (changed)
    {
      lastModified = root.lastModified();
      try
      {
        Configuration configuration = Configuration.load(root, Activator.getOSGiInstallArea());
        synchronizeConfiguration(configuration);
      }
      catch (ProvisionException e)
      {
        LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", Messages.errorProcessingConfg, e));
      }
    }
    changed = false;
  }
  
  public Collection<IMetadataRepository> getMetadataRepositories()
  {
    if (configRepositories == null) {
      return CollectionUtils.emptySet();
    }
    return configRepositories;
  }
  
  private IMetadataRepository getMatchingRepo(Collection<IMetadataRepository> repositoryList, String urlString)
  {
    if (repositoryList == null) {
      return null;
    }
    IPath urlPath = new Path(urlString).makeAbsolute();
    for (Iterator localIterator = repositoryList.iterator(); localIterator.hasNext();)
    {
      IMetadataRepository repo = (IMetadataRepository)localIterator.next();
      File file = URIUtil.toFile(repo.getLocation());
      if (file != null)
      {
        Path repoPath = new Path(file.getAbsolutePath());
        if (repoPath.makeAbsolute().equals(urlPath)) {
          return repo;
        }
        if ((repo instanceof ExtensionLocationMetadataRepository)) {
          try
          {
            File one = ExtensionLocationMetadataRepository.getBaseDirectory(repo.getLocation());
            File two = ExtensionLocationMetadataRepository.getBaseDirectory(new URI(urlString));
            if (one.equals(two)) {
              return repo;
            }
          }
          catch (ProvisionException e)
          {
            if (e.getStatus().getCode() != 1000) {
              LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while comparing repository locations.", e));
            }
          }
          catch (URISyntaxException e)
          {
            LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while comparing repository locations.", e));
          }
        }
      }
    }
    return null;
  }
  
  protected void synchronizeConfiguration(Configuration config)
  {
    List<Site> sites = config.getSites();
    Set<IMetadataRepository> newRepos = new LinkedHashSet();
    Set<Site> toBeRemoved = new HashSet();
    for (Iterator localIterator = sites.iterator(); localIterator.hasNext();)
    {
      Site site = (Site)localIterator.next();
      String siteURL = site.getUrl();
      IMetadataRepository match = getMatchingRepo(Activator.getRepositories(), siteURL);
      if (match == null) {
        try
        {
          String linkFile = site.getLinkFile();
          if ((linkFile != null) && (linkFile.length() > 0))
          {
            File link = new File(linkFile);
            if (!link.exists())
            {
              toBeRemoved.add(site);
              continue;
            }
          }
          if (!site.isEnabled())
          {
            toBeRemoved.add(site);
          }
          else
          {
            String eclipseExtensionURL = siteURL + ".eclipseextension";
            
            URI location = new URI(eclipseExtensionURL);
            Map<String, String> properties = new HashMap();
            properties.put("org.eclipse.update.site.policy", site.getPolicy());
            
            Feature[] listFeatures = site.getPolicy().equals("USER-INCLUDE") ? site.getFeatures() : null;
            
            properties.put("org.eclipse.update.site.list", toString(listFeatures, site.getList()));
            
            IMetadataRepository metadataRepository = null;
            URI fileURI;
            try
            {
              metadataRepository = Activator.createExtensionLocationMetadataRepository(location, "extension location metadata repository: " + location.toString(), properties);
            }
            catch (ProvisionException localProvisionException1)
            {
              try
              {
                metadataRepository = Activator.loadMetadataRepository(location, null);
              }
              catch (ProvisionException inner)
              {
                fileURI = new URI(siteURL);
                File file = URIUtil.toFile(fileURI);
                if ((file != null) && (!file.exists()))
                {
                  toBeRemoved.add(site);
                  continue;
                }
                throw inner;
              }
              fileURI = properties.entrySet().iterator();
            }
            while (fileURI.hasNext())
            {
              Map.Entry<String, String> entry = (Map.Entry)fileURI.next();
              metadataRepository.setProperty((String)entry.getKey(), (String)entry.getValue());
            }
            newRepos.add(metadataRepository);
            try
            {
              Activator.createExtensionLocationArtifactRepository(location, "extension location artifact repository: " + location, properties);
            }
            catch (ProvisionException localProvisionException2)
            {
              IArtifactRepository artifactRepository = Activator.loadArtifactRepository(location, null);
              for (Iterator<String> inner = properties.keySet().iterator(); inner.hasNext();)
              {
                String key = (String)inner.next();
                String value = (String)properties.get(key);
                artifactRepository.setProperty(key, value);
              }
            }
            LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", NLS.bind(Messages.errorLoadingRepository, siteURL), e));
          }
        }
        catch (URISyntaxException e)
        {
          LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", NLS.bind(Messages.errorLoadingRepository, siteURL), e));
        }
        catch (ProvisionException e)
        {
          if (e.getStatus().getCode() == 1000) {
            continue;
          }
        }
      } else {
        newRepos.add(match);
      }
    }
    if (!toBeRemoved.isEmpty())
    {
      for (Iterator<Site> iter = toBeRemoved.iterator(); iter.hasNext();) {
        config.removeSite((Site)iter.next());
      }
      try
      {
        config.save(root, Activator.getOSGiInstallArea());
      }
      catch (ProvisionException e)
      {
        LogHelper.log(new Status(4, "org.eclipse.equinox.p2.reconciler.dropins", "Error occurred while saving configuration at: " + root, e));
      }
    }
    configRepositories = newRepos;
  }
}

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

import java.util.Comparator;

class ProfileSynchronizer$1
  implements Comparator<String>
{
  final ProfileSynchronizer this$0;
  
  ProfileSynchronizer$1(ProfileSynchronizer paramProfileSynchronizer, String paramString) {}
  
  public int compare(String left, String right)
  {
    if (val$OSGiInstallArea.equals(left)) {
      return -1;
    }
    if (val$OSGiInstallArea.equals(right)) {
      return 1;
    }
    return left.compareTo(right);
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;

class ProfileSynchronizer$ReconcilerProfileChangeRequest
  extends ProfileChangeRequest
{
  List<IInstallableUnit> toMove = new ArrayList();
  
  public ProfileSynchronizer$ReconcilerProfileChangeRequest(IProfile profile)
  {
    super(profile);
  }
  
  void moveAll(Collection<IInstallableUnit> list)
  {
    toMove.addAll(list);
  }
  
  Collection<IInstallableUnit> getMoves()
  {
    return toMove;
  }
}

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

import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IEngine;
import org.eclipse.equinox.p2.engine.IPhaseSet;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.PhaseSetFactory;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
import org.eclipse.equinox.p2.query.Collector;
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.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;

public class ProfileSynchronizer
{
  private static final String RECONCILER_APPLICATION_ID = "org.eclipse.equinox.p2.reconciler.application";
  private static final String TIMESTAMPS_FILE_PREFIX = "timestamps";
  private static final String PROFILE_TIMESTAMP = "PROFILE";
  private static final String NO_TIMESTAMP = "-1";
  private static final String PROP_FROM_DROPINS = "org.eclipse.equinox.p2.reconciler.dropins";
  private static final String INCLUSION_RULES = "org.eclipse.equinox.p2.internal.inclusion.rules";
  private static final String INCLUSION_OPTIONAL = "OPTIONAL";
  private static final String INCLUSION_STRICT = "STRICT";
  private static final String CACHE_EXTENSIONS = "org.eclipse.equinox.p2.cache.extensions";
  private static final String PIPE = "|";
  private static final String EXPLANATION = "org.eclipse.equinox.p2.director.explain";
  final IProfile profile;
  final Map<String, IMetadataRepository> repositoryMap;
  private Map<String, String> timestamps;
  private final IProvisioningAgent agent;
  static Class class$0;
  
  static class ReconcilerProfileChangeRequest
    extends ProfileChangeRequest
  {
    List<IInstallableUnit> toMove = new ArrayList();
    
    public ReconcilerProfileChangeRequest(IProfile profile)
    {
      super();
    }
    
    void moveAll(Collection<IInstallableUnit> list)
    {
      toMove.addAll(list);
    }
    
    Collection<IInstallableUnit> getMoves()
    {
      return toMove;
    }
  }
  
  public ProfileSynchronizer(IProvisioningAgent agent, IProfile profile, Collection<IMetadataRepository> repositories)
  {
    this.agent = agent;
    this.profile = profile;
    repositoryMap = new HashMap();
    for (Iterator localIterator = repositories.iterator(); localIterator.hasNext();)
    {
      IMetadataRepository repository = (IMetadataRepository)localIterator.next();
      repositoryMap.put(repository.getLocation().toString(), repository);
    }
  }
  
  public IStatus synchronize(IProgressMonitor monitor)
  {
    readTimestamps();
    if (isUpToDate()) {
      return Status.OK_STATUS;
    }
    ProvisioningContext context = getContext();
    context.setProperty("org.eclipse.equinox.p2.director.explain", new Boolean(Tracing.DEBUG_RECONCILER).toString());
    
    String updatedCacheExtensions = synchronizeCacheExtensions();
    
    ReconcilerProfileChangeRequest request = createProfileChangeRequest(context);
    if (request == null)
    {
      if (updatedCacheExtensions == null) {
        return Status.OK_STATUS;
      }
      IStatus engineResult = setProperty("org.eclipse.equino
1 2 3 4

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-2019. Infinite Loop Ltd