org.eclipse.equinox.p2.publisher_1.2.0.v20110815-1419

16:44:20.797 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.publisher_1.2.0.v20110815-1419.jar
package org.eclipse.equinox.internal.p2.publisher;

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

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

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

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;

public class FileSetDescriptor
{
  private final String key;
  private String configSpec = null;
  private HashSet<File> fileset = new HashSet();
  private final ArrayList<String[]> permissions = new ArrayList();
  private String links = "";
  
  public FileSetDescriptor(String key, String configSpec)
  {
    this.key = key;
    this.configSpec = configSpec;
  }
  
  public void addFiles(File[] files)
  {
    fileset.addAll(Arrays.asList(files));
  }
  
  public void addPermissions(String[] property)
  {
    permissions.add(property);
  }
  
  public void setLinks(String property)
  {
    links = property;
  }
  
  public String getConfigSpec()
  {
    return configSpec;
  }
  
  public String getKey()
  {
    return key;
  }
  
  public String getLinks()
  {
    return links;
  }
  
  public String[][] getPermissions()
  {
    return (String[][])permissions.toArray(new String[permissions.size()][]);
  }
  
  public File[] getFiles()
  {
    return (File[])fileset.toArray(new File[fileset.size()]);
  }
  
  public int size()
  {
    return fileset.size();
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.publisher.messages";
  public static String exception_errorConverting;
  public static String exception_stateAddition;
  public static String exception_errorReadingManifest;
  public static String exception_errorLoadingManifest;
  public static String exception_errorLoadingProductFile;
  public static String exception_noPluginConverter;
  public static String exception_noArtifactRepo;
  public static String exception_noMetadataRepo;
  public static String exception_noBundlesOrLocations;
  public static String exception_noFeaturesOrLocations;
  public static String exception_invalidSiteReference;
  public static String exception_invalidSiteReferenceInFeature;
  public static String exception_repoMustBeURL;
  public static String exception_sourcePath;
  public static String message_generatingMetadata;
  public static String message_generationCompleted;
  public static String message_noSimpleconfigurator;
  public static String message_resultException;
  public static String message_publisherArguments;
  public static String exception_artifactRepoNoAppendDestroysInput;
  public static String error_rootIU_generation;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.publisher.messages", Messages.class);
  }
}

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

import java.io.IOException;
import java.io.StreamTokenizer;
import java.io.StringReader;
import java.util.Enumeration;
import java.util.NoSuchElementException;

public class QuotedTokenizer
  implements Enumeration<String>
{
  private StreamTokenizer tokenizer = null;
  
  public QuotedTokenizer(String str)
  {
    this(str, null);
  }
  
  public QuotedTokenizer(String str, String delim)
  {
    if ((delim != null) && (delim.indexOf('"') > -1)) {
      throw new IllegalArgumentException();
    }
    StringReader reader = new StringReader(str);
    tokenizer = new StreamTokenizer(reader);
    
    tokenizer.resetSyntax();
    if (delim == null) {
      tokenizer.ordinaryChars(0, 32);
    } else {
      tokenizer.wordChars(0, 32);
    }
    tokenizer.wordChars(33, 255);
    tokenizer.quoteChar(34);
    if (delim != null) {
      for (int i = 0; i < delim.length(); i++) {
        tokenizer.ordinaryChar(delim.charAt(i));
      }
    }
  }
  
  public boolean hasMoreTokens()
  {
    return token(null) != -1;
  }
  
  public String nextToken()
  {
    StringBuffer buffer = new StringBuffer(10);
    int tokenType = token(buffer);
    if (tokenType == -1) {
      throw new NoSuchElementException();
    }
    return buffer.toString();
  }
  
  private int token(StringBuffer buffer)
  {
    int tokenType = 0;
    int next = 0;
    do
    {
      for (;;)
      {
        try
        {
          tokenType = tokenizer.nextToken();
        }
        catch (IOException localIOException1)
        {
          tokenType = -1;
        }
        switch (tokenType)
        {
        case -3: 
        case 34: 
          if (buffer == null)
          {
            tokenizer.pushBack();
            return tokenType;
          }
          buffer.append(tokenizer.sval);
          try
          {
            next = tokenizer.nextToken();
            tokenizer.pushBack();
          }
          catch (IOException localIOException2)
          {
            next = -1;
          }
          if (next != 34) {
            return tokenType;
          }
          break;
        }
      }
      break;
    } while ((buffer == null) || (buffer.length() <= 0));
    return tokenType;
  }
  
  public boolean hasMoreElements()
  {
    return hasMoreTokens();
  }
  
  public String nextElement()
  {
    return nextToken();
  }
}

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

import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;

public class AbstractAdvice
  implements IPublisherAdvice
{
  public boolean isApplicable(String configSpec, boolean includeDefault, String id, Version version)
  {
    return (matchConfig(configSpec, includeDefault)) && (matchId(id)) && (matchVersion(version));
  }
  
  protected boolean matchVersion(Version version)
  {
    if (version == null) {
      return true;
    }
    Version adviceVersion = getVersion();
    if (adviceVersion != null) {
      return version.equals(adviceVersion);
    }
    VersionRange range = getVersionRange();
    if (range != null) {
      return range.isIncluded(version);
    }
    return true;
  }
  
  protected Version getVersion()
  {
    return null;
  }
  
  protected VersionRange getVersionRange()
  {
    return null;
  }
  
  protected boolean matchId(String id)
  {
    if (id == null) {
      return true;
    }
    String adviceId = getId();
    return adviceId == null ? true : adviceId.equals(id);
  }
  
  protected String getId()
  {
    return null;
  }
  
  protected boolean matchConfig(String configSpec, boolean includeDefault)
  {
    String adviceConfigSpec = getConfigSpec();
    if (adviceConfigSpec == null) {
      return includeDefault;
    }
    String[] full = AbstractPublisherAction.parseConfigSpec(configSpec);
    String[] partial = AbstractPublisherAction.parseConfigSpec(adviceConfigSpec);
    for (int i = 0; i < partial.length; i++)
    {
      String string = partial[i];
      if ((string != null) && (!string.equals(full[i]))) {
        return false;
      }
    }
    return true;
  }
  
  protected String getConfigSpec()
  {
    return null;
  }
}

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

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
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.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils.IPathComputer;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.publisher.Activator;
import org.eclipse.equinox.internal.p2.publisher.QuotedTokenizer;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.ITouchpointData;
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.publisher.actions.IAdditionalInstallableUnitAdvice;
import org.eclipse.equinox.p2.publisher.actions.ICapabilityAdvice;
import org.eclipse.equinox.p2.publisher.actions.IFilterAdvice;
import org.eclipse.equinox.p2.publisher.actions.IPropertyAdvice;
import org.eclipse.equinox.p2.publisher.actions.ITouchpointAdvice;
import org.eclipse.equinox.p2.publisher.actions.IUpdateDescriptorAdvice;
import org.eclipse.equinox.p2.query.Collector;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;

public abstract class AbstractPublisherAction
  implements IPublisherAction
{
  public static final String CONFIG_ANY = "ANY";
  public static final String CONFIG_SEGMENT_SEPARATOR = ".";
  protected IPublisherInfo info;
  
  public static String[] getArrayFromString(String list, String separator)
  {
    if ((list == null) || (list.trim().equals(""))) {
      return new String[0];
    }
    List<String> result = new ArrayList();
    for (QuotedTokenizer tokens = new QuotedTokenizer(list, separator); tokens.hasMoreTokens();)
    {
      String token = tokens.nextToken().trim();
      if (!token.equals("")) {
        result.add(token);
      }
    }
    return (String[])result.toArray(new String[result.size()]);
  }
  
  public static String[] parseConfigSpec(String configSpec)
  {
    String[] result = getArrayFromString(configSpec, ".");
    for (int i = 0; i < result.length; i++) {
      if (result[i].equals("*")) {
        result[i] = "ANY";
      }
    }
    if (result.length < 3)
    {
      String[] temp = new String[3];
      System.arraycopy(result, 0, temp, 0, result.length);
      for (int i = result.length; i < temp.length; i++) {
        temp[i] = "ANY";
      }
      result = temp;
    }
    return result;
  }
  
  public static String createConfigSpec(String ws, String os, String arch)
  {
    return ws + '.' + os + '.' + arch;
  }
  
  protected void addSelfCapability(MetadataFactory.InstallableUnitDescription root)
  {
    root.setCapabilities(new IProvidedCapability[] { createSelfCapability(root.getId(), root.getVersion()) });
  }
  
  protected IMatchExpression<IInstallableUnit> createFilterSpec(String configSpec)
  {
    String[] config = parseConfigSpec(configSpec);
    if ((config[0] != null) || (config[1] != null) || (config[2] != null))
    {
      String filterWs = (config[0] != null) && (config[0] != "ANY") ? "(osgi.ws=" + config[0] + ")" : "";
      String filterOs = (config[1] != null) && (config[1] != "ANY") ? "(osgi.os=" + config[1] + ")" : "";
      String filterArch = (config[2] != null) && (config[2] != "ANY") ? "(osgi.arch=" + config[2] + ")" : "";
      if ((filterWs.length() == 0) && (filterOs.length() == 0) && (filterArch.length() == 0)) {
        return null;
      }
      return InstallableUnit.parseFilter("(& " + filterWs + filterOs + filterArch + ")");
    }
    return null;
  }
  
  protected boolean filterMatches(IMatchExpression<IInstallableUnit> filter, String configSpec)
  {
    if (filter == null) {
      return true;
    }
    String[] config = parseConfigSpec(configSpec);
    return filter.isMatch(InstallableUnit.contextIU(config[0], config[1], config[2]));
  }
  
  protected String createIdString(String configSpec)
  {
    String[] config = parseConfigSpec(configSpec);
    return config[0] + '.' + config[1] + '.' + config[2];
  }
  
  protected String createCUIdString(String id, String type, String flavor, String configSpec)
  {
    return flavor + id + "." + type + "." + createIdString(configSpec);
  }
  
  protected Collection<IRequirement> createIURequirements(Collection<? extends IVersionedId> children)
  {
    ArrayList<IRequirement> result = new ArrayList(children.size());
    for (Iterator localIterator = children.iterator(); localIterator.hasNext();)
    {
      IVersionedId next = (IVersionedId)localIterator.next();
      if ((next instanceof IInstallableUnit))
      {
        IInstallableUnit iu = (IInstallableUnit)next;
        VersionRange range = new VersionRange(iu.getVersion(), true, iu.getVersion(), true);
        result.add(MetadataFactory.createRequirement("org.eclipse.equinox.p2.iu", iu.getId(), range, iu.getFilter() == null ? null : iu.getFilter(), false, false));
      }
      else
      {
        Version version = next.getVersion();
        VersionRange range = (version == null) || (Version.emptyVersion.equals(version)) ? VersionRange.emptyRange : new VersionRange(version, true, version, true);
        IMatchExpression<IInstallableUnit> filter = getFilterAdvice(next);
        result.add(MetadataFactory.createRequirement("org.eclipse.equinox.p2.iu", next.getId(), range, filter, false, false));
      }
    }
    return result;
  }
  
  private IMatchExpression<IInstallableUnit> getFilterAdvice(IVersionedId name)
  {
    if (info == null) {
      return null;
    }
    Collection<IFilterAdvice> filterAdvice = info.getAdvice("ANY", true, name.getId(), name.getVersion(), IFilterAdvice.class);
    for (Iterator localIterator = filterAdvice.iterator(); localIterator.hasNext();)
    {
      IFilterAdvice advice = (IFilterAdvice)localIterator.next();
      IMatchExpression<IInstallableUnit> result = advice.getFilter(name.getId(), name.getVersion(), false);
      if (result != null) {
        return result;
      }
    }
    return null;
  }
  
  protected MetadataFactory.InstallableUnitDescription createIUShell(String id, Version version)
  {
    MetadataFactory.InstallableUnitDescription root = new MetadataFactory.InstallableUnitDescription();
    root.setId(id);
    root.setVersion(version);
    return root;
  }
  
  protected IArtifactDescriptor createPack200ArtifactDescriptor(IArtifactKey key, File pathOnDisk, String installSize)
  {
    ArtifactDescriptor result = new ArtifactDescriptor(key);
    if (pathOnDisk != null)
    {
      result.setProperty("artifact.size", installSize);
      
      result.setProperty("download.size", Long.toString(pathOnDisk.length()));
    }
    IProcessingStepDescriptor[] steps = { new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true) };
    result.setProcessingSteps(steps);
    result.setProperty("format", "packed");
    return result;
  }
  
  protected MetadataFactory.InstallableUnitDescription createParentIU(Collection<? extends IVersionedId> children, String id, Version version)
  {
    MetadataFactory.InstallableUnitDescription root = createIUShell(id, version);
    root.addRequirements(createIURequirements(children));
    addSelfCapability(root);
    return root;
  }
  
  protected FileUtils.IPathComputer createParentPrefixComputer(int segmentsToKeep)
  {
    return FileUtils.createParentPrefixComputer(segmentsToKeep);
  }
  
  protected FileUtils.IPathComputer createRootPrefixComputer(File root)
  {
    return FileUtils.createRootPathComputer(root);
  }
  
  protected IProvidedCapability createSelfCapability(String installableUnitId, Version installableUnitVersion)
  {
    return MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.iu", installableUnitId, installableUnitVersion);
  }
  
  protected static MetadataFactory.InstallableUnitDescription[] processAdditionalInstallableUnitsAdvice(IInstallableUnit iu, IPublisherInfo publisherInfo)
  {
    Collection<IAdditionalInstallableUnitAdvice> advice = publisherInfo.getAdvice(null, false, iu.getId(), iu.getVersion(), IAdditionalInstallableUnitAdvice.class);
    if (advice.isEmpty()) {
      return null;
    }
    List<MetadataFactory.InstallableUnitDescription> ius = new ArrayList();
    for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
    {
      IAdditionalInstallableUnitAdvice entry = (IAdditionalInstallableUnitAdvice)localIterator.next();
      MetadataFactory.InstallableUnitDescription[] others = entry.getAdditionalInstallableUnitDescriptions(iu);
      if (others != null) {
        ius.addAll(Arrays.asList(others));
      }
    }
    return (MetadataFactory.InstallableUnitDescription[])ius.toArray(new MetadataFactory.InstallableUnitDescription[ius.size()]);
  }
  
  protected static void processArtifactPropertiesAdvice(IInstallableUnit iu, IArtifactDescriptor descriptor, IPublisherInfo info)
  {
    if (!(descriptor instanceof SimpleArtifactDescriptor)) {
      return;
    }
    Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class);
    for (Iterator localIterator1 = advice.iterator(); localIterator1.hasNext();)
    {
      IPropertyAdvice entry = (IPropertyAdvice)localIterator1.next();
      Map<String, String> props = entry.getArtifactProperties(iu, descriptor);
      if (props != null) {
        for (Iterator localIterator2 = props.entrySet().iterator(); localIterator2.hasNext();)
        {
          Map.Entry<String, String> pe = (Map.Entry)localIterator2.next();
          ((SimpleArtifactDescriptor)descriptor).setRepositoryProperty((String)pe.getKey(), (String)pe.getValue());
        }
      }
    }
  }
  
  protected static void processInstallableUnitPropertiesAdvice(MetadataFactory.InstallableUnitDescription iu, IPublisherInfo info)
  {
    Collection<IPropertyAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IPropertyAdvice.class);
    for (Iterator localIterator1 = advice.iterator(); localIterator1.hasNext();)
    {
      IPropertyAdvice entry = (IPropertyAdvice)localIterator1.next();
      Map<String, String> props = entry.getInstallableUnitProperties(iu);
      if (props != null) {
        for (Iterator localIterator2 = props.entrySet().iterator(); localIterator2.hasNext();)
        {
          Map.Entry<String, String> pe = (Map.Entry)localIterator2.next();
          iu.setProperty((String)pe.getKey(), (String)pe.getValue());
        }
      }
    }
  }
  
  protected static void processUpdateDescriptorAdvice(MetadataFactory.InstallableUnitDescription iu, IPublisherInfo info)
  {
    Collection<IUpdateDescriptorAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), IUpdateDescriptorAdvice.class);
    if (advice.isEmpty()) {
      return;
    }
    for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
    {
      IUpdateDescriptorAdvice entry = (IUpdateDescriptorAdvice)localIterator.next();
      
      IUpdateDescriptor updateDescriptor = entry.getUpdateDescriptor(iu);
      if (updateDescriptor != null) {
        iu.setUpdateDescriptor(updateDescriptor);
      }
    }
  }
  
  protected static void processCapabilityAdvice(MetadataFactory.InstallableUnitDescription iu, IPublisherInfo info)
  {
    Collection<ICapabilityAdvice> advice = info.getAdvice(null, false, iu.getId(), iu.getVersion(), ICapabilityAdvice.class);
    if (advice.isEmpty()) {
      return;
    }
    for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
    {
      ICapabilityAdvice entry = (ICapabilityAdvice)localIterator.next();
      
      IRequirement[] requiredAdvice = entry.getRequiredCapabilities(iu);
      IRequiredCapability currentRequiredCapability;
      if (requiredAdvice != null)
      {
        List<IRequirement> current = iu.getRequirements();
        Set<IRequirement> resultRequiredCapabilities = new HashSet(current);
        for (int j = 0; j < current.size(); j++)
        {
          IRequirement curr = (IRequirement)current.get(j);
          currentRequiredCapability = null;
          if ((curr instanceof IRequiredCapability))
          {
            currentRequiredCapability = (IRequiredCapability)curr;
            for (int k = 0; k < requiredAdvice.length; k++)
            {
              IRequiredCapability requiredCapability = null;
              if ((requiredAdvice[k] instanceof IRequiredCapability))
              {
                requiredCapability = (IRequiredCapability)requiredAdvice[k];
                if ((requiredCapability.getNamespace().equals(currentRequiredCapability.getNamespace())) && (requiredCapability.getName().equals(currentRequiredCapability.getName())))
                {
                  resultRequiredCapabilities.remove(currentRequiredCapability);
                  break;
                }
              }
            }
          }
        }
        resultRequiredCapabilities.addAll(Arrays.asList(requiredAdvice));
        iu.setRequirements((IRequirement[])resultRequiredCapabilities.toArray(new IRequirement[resultRequiredCapabilities.size()]));
      }
      IRequirement[] metaRequiredAdvice = entry.getMetaRequiredCapabilities(iu);
      IRequiredCapability currentMetaRequiredCapability;
      if (metaRequiredAdvice != null)
      {
        Collection<IRequirement> current = iu.getMetaRequirements();
        Set<IRequirement> resultMetaRequiredCapabilities = new HashSet(current);
        for (currentRequiredCapability = current.iterator(); currentRequiredCapability.hasNext();)
        {
          IRequirement curr = (IRequirement)currentRequiredCapability.next();
          currentMetaRequiredCapability = null;
          if ((curr instanceof IRequiredCapability))
          {
            currentMetaRequiredCapability = (IRequiredCapability)curr;
            for (int k = 0; k < metaRequiredAdvice.length; k++)
            {
              IRequiredCapability metaRequiredCapability = null;
              if ((metaRequiredAdvice[k] instanceof IRequiredCapability))
              {
                metaRequiredCapability = (IRequiredCapability)metaRequiredAdvice[k];
                if ((metaRequiredCapability.getNamespace().equals(currentMetaRequiredCapability.getNamespace())) && (metaRequiredCapability.getName().equals(currentMetaRequiredCapability.getName())))
                {
                  resultMetaRequiredCapabilities.remove(currentMetaRequiredCapability);
                  break;
                }
              }
            }
          }
        }
        resultMetaRequiredCapabilities.addAll(Arrays.asList(metaRequiredAdvice));
        iu.setMetaRequirements((IRequirement[])resultMetaRequiredCapabilities.toArray(new IRequirement[resultMetaRequiredCapabilities.size()]));
      }
      IProvidedCapability[] providedAdvice = entry.getProvidedCapabilities(iu);
      if (providedAdvice != null)
      {
        Collection<IProvidedCapability> current = iu.getProvidedCapabilities();
        Set<IProvidedCapability> resultProvidedCapabilities = new HashSet(current);
        for (currentMetaRequiredCapability = current.iterator(); currentMetaRequiredCapability.hasNext();)
        {
          IProvidedCapability currentProvidedCapability = (IProvidedCapability)currentMetaRequiredCapability.next();
          for (int k = 0; k < providedAdvice.length; k++)
          {
            IProvidedCapability providedCapability = providedAdvice[k];
            if ((providedCapability.getNamespace().equals(currentProvidedCapability.getNamespace())) && (providedCapability.getName().equals(currentProvidedCapability.getName())))
            {
              resultProvidedCapabilities.remove(currentProvidedCapability);
              break;
            }
          }
        }
        resultProvidedCapabilities.addAll(Arrays.asList(providedAdvice));
        iu.setCapabilities((IProvidedCapability[])resultProvidedCapabilities.toArray(new IProvidedCapability[resultProvidedCapabilities.size()]));
      }
    }
  }
  
  protected static void processTouchpointAdvice(MetadataFactory.InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info)
  {
    processTouchpointAdvice(iu, currentInstructions, info, null);
  }
  
  protected static void processTouchpointAdvice(MetadataFactory.InstallableUnitDescription iu, Map<String, ? extends Object> currentInstructions, IPublisherInfo info, String configSpec)
  {
    Collection<ITouchpointAdvice> advice = info.getAdvice(configSpec, false, iu.getId(), iu.getVersion(), ITouchpointAdvice.class);
    if (currentInstructions == null)
    {
      if ((advice == null) || (advice.isEmpty())) {
        return;
      }
      currentInstructions = CollectionUtils.emptyMap();
    }
    ITouchpointData result = MetadataFactory.createTouchpointData(currentInstructions);
    if (advice != null) {
      for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
      {
        ITouchpointAdvice entry = (ITouchpointAdvice)localIterator.next();
        result = entry.getTouchpointData(result);
      }
    }
    iu.addTouchpointData(result);
  }
  
  protected void publishArtifact(IArtifactDescriptor descriptor, File inclusion, IPublisherInfo publisherInfo)
  {
    if (inclusion == null) {
      return;
    }
    IArtifactRepository destination = publisherInfo.getArtifactRepository();
    if ((destination == null) || (destination.contains(descriptor))) {
      return;
    }
    if ((publisherInfo.getArtifactOptions() & 0x2) == 0)
    {
      destination.addDescriptor(descriptor);
      return;
    }
    if ((destination instanceof IFileArtifactRepository))
    {
      File descriptorFile = ((IFileArtifactRepository)destination).getArtifactFile(descriptor);
      if (inclusion.equals(descriptorFile))
      {
        destination.addDescriptor(descriptor);
        return;
      }
    }
    try
    {
      OutputStream output = destination.getOutputStream(descriptor);
      if (output == null) {
        return;
      }
      output = new BufferedOutputStream(output);
      FileUtils.copyStream(new BufferedInputStream(new FileInputStream(inclusion)), true, output, true);
    }
    catch (ProvisionException e)
    {
      LogHelper.log(e.getStatus());
    }
    catch (IOException e)
    {
      LogHelper.log(new Status(4, Activator.ID, "Error publishing artifacts", e));
    }
  }
  
  /* Error */
  protected void publishArtifact(IArtifactDescriptor descriptor, File[] inclusions, File[] exclusions, IPublisherInfo publisherInfo, FileUtils.IPathComputer prefixComputer)
  {
    // Byte code:
    //   0: aload_2
    //   1: ifnull +9 -> 10
    //   4: aload_2
    //   5: arraylength
    //   6: iconst_1
    //   7: if_icmpge +4 -> 11
    //   10: return
    //   11: aload 4
    //   13: invokeinterface 781 1 0
    //   18: astore 6
    //   20: aload 6
    //   22: ifnull +14 -> 36
    //   25: aload 6
    //   27: aload_1
    //   28: invokeinterface 798 2 0
    //   33: ifeq +4 -> 37
    //   36: return
    //   37: aload 4
    //   39: invokeinterface 780 1 0
    //   44: iconst_2
    //   45: iand
    //   46: ifne +12 -> 58
    //   49: aload 6
    //   51: aload_1
    //   52: invokeinterface 797 2 0
    //   57: return
    //   58: aconst_null
    //   59: astore 7
    //   61: aload 6
    //   63: aload_1
    //   64: invokeinterface 799 2 0
    //   69: astore 8
    //   71: aload 8
    //   73: ifnonnull +15 -> 88
    //   76: aload 7
    //   78: ifnull +9 -> 87
    //   81: aload 7
    //   83: invokevirtual 676	java/io/File:delete	()Z
    //   86: pop
    //   87: return
    //   88: new 321	java/io/BufferedOutputStream
    //   91: dup
    //   92: aload 8
    //   94: invokespecial 674	java/io/BufferedOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   97: astore 8
    //   99: ldc_w 314
    //   102: ldc 1
    //   104: invokestatic 678	java/io/File:createTempFile	(Ljava/lang/String;Ljava/lang/String;)Ljava/io/File;
    //   107: astore 7
    //   109: aload_2
    //   110: aload_3
    //   111: aload 7
    //   113: aload 5
    //   115: invokestatic 708	org/eclipse/equinox/internal/p2/core/helpers/FileUtils:zip	([Ljava/io/File;[Ljava/io/File;Ljava/io/File;Lorg/eclipse/equinox/internal/p2/core/helpers/FileUtils$IPathComputer;)V
    //   118: aload 8
    //   120: ifnull +110 -> 230
    //   123: new 320	java/io/BufferedInputStream
    //   126: dup
    //   127: new 323	java/io/FileInputStream
    //   130: dup
    //   131: aload 7
    //   133: invokespecial 679	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   136: invokespecial 673	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   139: iconst_1
    //   140: aload 8
    //   142: iconst_1
    //   143: invokestatic 706	org/eclipse/equinox/internal/p2/core/helpers/FileUtils:copyStream	(Ljava/io/InputStream;ZLjava/io/OutputStream;Z)I
    //   146: pop
    //   147: goto +83 -> 230
    //   150: astore 8
    //   152: aload 8
    //   154: invokevirtual 715	org/eclipse/equinox/p2/core/ProvisionException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   157: invokestatic 709	org/eclipse/equinox/internal/p2/core/helpers/LogHelper:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   160: aload 7
    //   162: ifnull +79 -> 241
    //   165: aload 7
    //   167: invokevirtual 676	java/io/File:delete	()Z
    //   170: pop
    //   171: goto +70 -> 241
    //   174: astore 8
    //   176: new 344	org/eclipse/core/runtime/Status
    //   179: dup
    //   180: iconst_4
    //   181: getstatic 663	org/eclipse/equinox/internal/p2/publisher/Activator:ID	Ljava/lang/String;
    //   184: ldc_w 303
    //   187: aload 8
    //   189: invokespecial 702	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   192: invokestatic 709	org/eclipse/equinox/internal/p2/core/helpers/LogHelper:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   195: aload 8
    //   197: invokevirtual 680	java/io/IOException:printStackTrace	()V
    //   200: aload 7
    //   202: ifnull +39 -> 241
    //   205: aload 7
    //   207: invokevirtual 676	java/io/File:delete	()Z
    //   210: pop
    //   211: goto +30 -> 241
    //   214: astore 9
    //   216: aload 7
    //   218: ifnull +9 -> 227
    //   221: aload 7
    //   223: invokevirtual 676	java/io/File:delete	()Z
    //   226: pop
    //   227: aload 9
    //   229: athrow
    //   230: aload 7
    //   232: ifnull +9 -> 241
    //   235: aload 7
    //   237: invokevirtual 676	java/io/File:delete	()Z
    //   240: pop
    //   241: return
    // Line number table:
    //   Java source line #465	-> byte code offset #0
    //   Java source line #466	-> byte code offset #10
    //   Java source line #468	-> byte code offset #11
    //   Java source line #469	-> byte code offset #20
    //   Java source line #470	-> byte code offset #36
    //   Java source line #472	-> byte code offset #37
    //   Java source line #473	-> byte code offset #49
    //   Java source line #474	-> byte code offset #57
    //   Java source line #481	-> byte code offset #58
    //   Java source line #483	-> byte code offset #61
    //   Java source line #484	-> byte code offset #71
    //   Java source line #497	-> byte code offset #76
    //   Java source line #498	-> byte code offset #81
    //   Java source line #485	-> byte code offset #87
    //   Java source line #486	-> byte code offset #88
    //   Java source line #487	-> byte code offset #99
    //   Java source line #488	-> byte code offset #109
    //   Java source line #489	-> byte code offset #118
    //   Java source line #490	-> byte code offset #123
    //   Java source line #491	-> byte code offset #150
    //   Java source line #492	-> byte code offset #152
    //   Java source line #497	-> byte code offset #160
    //   Java source line #498	-> byte code offset #165
    //   Java source line #493	-> byte code offset #174
    //   Java source line #494	-> byte code offset #176
    //   Java source line #495	-> byte code offset #195
    //   Java source line #497	-> byte code offset #200
    //   Java source line #498	-> byte code offset #205
    //   Java source line #496	-> byte code offset #214
    //   Java source line #497	-> byte code offset #216
    //   Java source line #498	-> byte code offset #221
    //   Java source line #499	-> byte code offset #227
    //   Java source line #497	-> byte code offset #230
    //   Java source line #498	-> byte code offset #235
    //   Java source line #500	-> byte code offset #241
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	242	0	this	AbstractPublisherAction
    //   0	242	1	descriptor	IArtifactDescriptor
    //   0	242	2	inclusions	File[]
    //   0	242	3	exclusions	File[]
    //   0	242	4	publisherInfo	IPublisherInfo
    //   0	242	5	prefixComputer	FileUtils.IPathComputer
    //   18	44	6	destination	IArtifactRepository
    //   59	177	7	tempFile	File
    //   69	3	8	output	OutputStream
    //   88	53	8	output	OutputStream
    //   150	3	8	e	ProvisionException
    //   174	22	8	e	IOException
    //   214	14	9	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   61	76	150	org/eclipse/equinox/p2/core/ProvisionException
    //   88	147	150	org/eclipse/equinox/p2/core/ProvisionException
    //   61	76	174	java/io/IOException
    //   88	147	174	java/io/IOException
    //   61	76	214	finally
    //   88	160	214	finally
    //   174	200	214	finally
  }
  
  protected IInstallableUnit queryForIU(IPublisherResult publisherResult, String iuId, Version version)
  {
    IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(iuId, version);
    if ((version == null) || (Version.emptyVersion.equals(version))) {
      query = QueryUtil.createLatestQuery(query);
    }
    IQueryResult<IInstallableUnit> collector = Collector.emptyCollector();
    NullProgressMonitor progress = new NullProgressMonitor();
    if (publisherResult != null) {
      collector = publisherResult.query(query, progress);
    }
    if ((collector.isEmpty()) && (info.getMetadataRepository() != null)) {
      collector = info.getMetadataRepository().query(query, progress);
    }
    if ((collector.isEmpty()) && (info.getContextMetadataRepository() != null)) {
      collector = info.getContextMetadataRepository().query(query, progress);
    }
    if (!collector.isEmpty()) {
      return (IInstallableUnit)collector.iterator().next();
    }
    return null;
  }
  
  protected IQueryResult<IInstallableUnit> queryForIUs(IPublisherResult publisherResult, String iuId, VersionRange versionRange)
  {
    IQuery<IInstallableUnit> query = null;
    IQueryResult<IInstallableUnit> queryResult = Collector.emptyCollector();
    query = QueryUtil.createIUQuery(iuId, versionRange);
    NullProgressMonitor progress = new NullProgressMonitor();
    if (publisherResult != null) {
      queryResult = publisherResult.query(query, progress);
    }
    if ((queryResult.isEmpty()) && (info.getMetadataRepository() != null)) {
      queryResult = info.getMetadataRepository().query(query, progress);
    }
    if ((queryResult.isEmpty()) && (info.getContextMetadataRepository() != null)) {
      queryResult = info.getContextMetadataRepository().query(query, progress);
    }
    return queryResult;
  }
  
  public abstract IStatus perform(IPublisherInfo paramIPublisherInfo, IPublisherResult paramIPublisherResult, IProgressMonitor paramIProgressMonitor);
  
  public void setPublisherInfo(IPublisherInfo info)
  {
    this.info = info;
  }
}

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

import java.io.File;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.internal.p2.publisher.Activator;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
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;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

public abstract class AbstractPublisherApplication
  implements IApplication
{
  protected static final String[][] INPLACE_MAPPING_RULES = { { "(& (classifier=osgi.bundle) (format=packed)", "${repoUrl}/features/${id}_${version}.jar.pack.gz" }, 
    { "(& (classifier=osgi.bundle))", "${repoUrl}/plugins/${id}_${version}.jar" }, 
    { "(& (classifier=binary))", "${repoUrl}/binary/${id}_${version}" }, 
    { "(& (classifier=org.eclipse.update.feature))", "${repoUrl}/features/${id}_${version}.jar" } };
  public static final String PUBLISH_PACK_FILES_AS_SIBLINGS = "publishPackFilesAsSiblings";
  protected PublisherInfo info;
  protected String source;
 
1 2 3 4 5

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