org.eclipse.team.cvs.core_3.3.400.I20110510-0800

arAt(0) == '-')
        {
          switch (next.charAt(1))
          {
          case 'a': 
            localOptionsList.add(Checkout.ALIAS);
            break;
          case 'l': 
            localOptionsList.add(Command.DO_NOT_RECURSE);
            break;
          case 'd': 
            localOptionsList.add(Checkout.makeDirectoryNameOption(tokenizer.nextToken()));
            break;
          case 'e': 
          case 'i': 
          case 'o': 
          case 't': 
          case 'u': 
            tokenizer.nextToken();
            break;
          case 's': 
            localOptionsList.add(Checkout.makeStatusOption(tokenizer.nextToken()));
          }
          next = tokenizer.nextToken();
        }
      }
      catch (NoSuchElementException localNoSuchElementException)
      {
        CVSProviderPlugin.log(2, NLS.bind(CVSMessages.RemoteModule_invalidDefinition, new String[] { moduleDefinitionStrings[i], repository.getLocation(true) }), null);
        continue;
      }
      String next;
      List localOptionsList;
      Command.LocalOption[] localOptions = (Command.LocalOption[])localOptionsList.toArray(new Command.LocalOption[localOptionsList.size()]);
      if (Checkout.ALIAS.isElementOf(localOptions))
      {
        localOptions.length;
        
        List expansions = new ArrayList(10);
        expansions.add(next);
        while (tokenizer.hasMoreTokens()) {
          expansions.add(tokenizer.nextToken());
        }
        moduleAliases.put(moduleName, expansions.toArray(new String[expansions.size()]));
        modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
      }
      else
      {
        if (next.charAt(0) != '&')
        {
          String directory = next;
          List files = new ArrayList();
          while ((tokenizer.hasMoreTokens()) && (next.charAt(0) != '&'))
          {
            next = tokenizer.nextToken();
            if (next.charAt(0) != '&') {
              files.add(next);
            }
          }
          RemoteModule remoteModule = new RemoteModule(moduleName, null, repository, directory, localOptions, tag, !files.isEmpty());
          modules.put(moduleName, remoteModule);
          if (!files.isEmpty())
          {
            ICVSRemoteResource[] children = new ICVSRemoteResource[files.size()];
            for (int j = 0; j < children.length; j++)
            {
              children[j] = new RemoteFile(remoteModule, 0, (String)files.get(j), null, null, tag);
              remoteModule.setChildren(children);
            }
          }
        }
        else
        {
          modules.put(moduleName, new RemoteModule(moduleName, null, repository, null, localOptions, tag, true));
        }
        if (next.charAt(0) == '&')
        {
          List children = new ArrayList(10);
          children.add(next);
          while (tokenizer.hasMoreTokens()) {
            children.add(tokenizer.nextToken());
          }
          referencedModulesTable.put(moduleName, children.toArray(new String[children.size()]));
        }
      }
    }
    Iterator iter = moduleAliases.keySet().iterator();
    while (iter.hasNext())
    {
      String moduleName = (String)iter.next();
      RemoteModule module = (RemoteModule)modules.get(moduleName);
      String[] expansion = (String[])moduleAliases.get(moduleName);
      List referencedFolders = new ArrayList();
      boolean expandable = true;
      for (int i = 0; i < expansion.length; i++) {
        if (expansion[i].charAt(0) == '!')
        {
          expandable = false;
        }
        else
        {
          IPath path = new Path(null, expansion[i]);
          if (path.segmentCount() > 1)
          {
            expandable = false;
          }
          else
          {
            RemoteModule child = (RemoteModule)modules.get(expansion[i]);
            if (child == null) {
              referencedFolders.add(new RemoteFolder(null, repository, path.toString(), tag));
            } else if (child.isAlias()) {
              expandable = false;
            } else {
              referencedFolders.add(child);
            }
          }
        }
      }
      if (expandable) {
        module.setChildren((ICVSRemoteResource[])referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
      } else {
        module.setExpandable(false);
      }
    }
    iter = modules.keySet().iterator();
    while (iter.hasNext())
    {
      String moduleName = (String)iter.next();
      String[] children = (String[])referencedModulesTable.get(moduleName);
      if (children != null)
      {
        RemoteModule module = (RemoteModule)modules.get(moduleName);
        List referencedFolders = new ArrayList();
        boolean expandable = true;
        for (int i = 0; i < children.length; i++)
        {
          RemoteModule child = (RemoteModule)modules.get(children[i].substring(1));
          if (child == null) {
            expandable = false;
          } else if (child.isAlias()) {
            expandable = false;
          } else if (Command.findOption(child.getLocalOptions(), "-d") != null) {
            expandable = false;
          } else {
            referencedFolders.add(child);
          }
        }
        if (expandable) {
          module.setReferencedModules((ICVSRemoteResource[])referencedFolders.toArray(new ICVSRemoteResource[referencedFolders.size()]));
        } else {
          module.setExpandable(false);
        }
      }
    }
    return (RemoteModule[])modules.values().toArray(new RemoteModule[modules.size()]);
  }
  
  public RemoteModule(String label, RemoteFolder parent, ICVSRepositoryLocation repository, String repositoryRelativePath, Command.LocalOption[] localOptions, CVSTag tag, boolean isStatic)
  {
    super(parent, label, repository, repositoryRelativePath == null ? "CVSROOT/Emptydir" : repositoryRelativePath, tag, isStatic);
    this.localOptions = localOptions;
    this.label = label;
    expandable = true;
  }
  
  public Command.LocalOption[] getLocalOptions()
  {
    return localOptions;
  }
  
  public ICVSRemoteResource[] getMembers(CVSTag tagName, IProgressMonitor monitor)
    throws CVSException
  {
    if (!expandable) {
      return new ICVSRemoteResource[0];
    }
    ICVSRemoteResource[] physicalChildren;
    ICVSRemoteResource[] physicalChildren;
    if (folderInfo.getIsStatic()) {
      physicalChildren = getChildren();
    } else {
      physicalChildren = super.getMembers(tagName, monitor);
    }
    ICVSRemoteResource[] allChildren;
    if ((referencedModules != null) && (referencedModules.length > 0))
    {
      ICVSRemoteResource[] allChildren;
      if (physicalChildren == null)
      {
        allChildren = referencedModules;
      }
      else
      {
        ICVSRemoteResource[] allChildren = new ICVSRemoteResource[physicalChildren.length + referencedModules.length];
        for (int i = 0; i < physicalChildren.length; i++) {
          allChildren[i] = physicalChildren[i];
        }
        for (int i = 0; i < referencedModules.length; i++) {
          allChildren[(i + physicalChildren.length)] = referencedModules[i];
        }
      }
    }
    else
    {
      ICVSRemoteResource[] allChildren;
      if (physicalChildren != null) {
        allChildren = physicalChildren;
      } else {
        allChildren = new ICVSRemoteResource[0];
      }
    }
    return allChildren;
  }
  
  private void setReferencedModules(ICVSRemoteResource[] referencedModules)
  {
    this.referencedModules = referencedModules;
  }
  
  public boolean isAlias()
  {
    return Checkout.ALIAS.isElementOf(localOptions);
  }
  
  public boolean isExpandable()
  {
    return expandable;
  }
  
  private void setExpandable(boolean expandable)
  {
    this.expandable = expandable;
  }
  
  public ICVSRemoteResource forTag(ICVSRemoteFolder parent, CVSTag tagName)
  {
    RemoteModule r = new RemoteModule(label, (RemoteFolder)parent, getRepository(), folderInfo.getRepository(), localOptions, tagName, folderInfo.getIsStatic());
    r.setExpandable(expandable);
    if (folderInfo.getIsStatic())
    {
      ICVSRemoteResource[] children = getChildren();
      if (children != null)
      {
        List taggedChildren = new ArrayList(children.length);
        for (int i = 0; i < children.length; i++)
        {
          ICVSRemoteResource resource = children[i];
          taggedChildren.add(((RemoteResource)resource).forTag(r, tagName));
        }
        r.setChildren((ICVSRemoteResource[])taggedChildren.toArray(new ICVSRemoteResource[taggedChildren.size()]));
      }
    }
    if (referencedModules != null)
    {
      List taggedModules = new ArrayList(referencedModules.length);
      for (int i = 0; i < referencedModules.length; i++)
      {
        RemoteModule module = (RemoteModule)referencedModules[i];
        taggedModules.add(module.forTag(r, tagName));
      }
      r.setReferencedModules((ICVSRemoteResource[])taggedModules.toArray(new ICVSRemoteResource[taggedModules.size()]));
    }
    return r;
  }
  
  public boolean isDefinedModule()
  {
    return true;
  }
  
  public boolean equals(Object arg0)
  {
    if ((arg0 instanceof RemoteModule))
    {
      RemoteModule module = (RemoteModule)arg0;
      return (getName().equals(module.getName())) && (super.equals(module));
    }
    return false;
  }
  
  public int hashCode()
  {
    return super.hashCode() | getName().hashCode();
  }
  
  public ICVSResource getChild(String path)
    throws CVSException
  {
    if ((path.equals(".")) || (path.length() == 0)) {
      return this;
    }
    if ((referencedModules != null) && 
      (path.indexOf("/") == -1)) {
      for (int i = 0; i < referencedModules.length; i++) {
        if (referencedModules[i].getName().equals(path)) {
          return referencedModules[i];
        }
      }
    }
    return super.getChild(path);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.resources.RemoteModule
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.resources;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.variants.CachedResourceVariant;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;

public abstract class RemoteResource
  extends CachedResourceVariant
  implements ICVSRemoteResource
{
  protected RemoteFolder parent;
  protected String name;
  private int workspaceSyncState = 0;
  
  public RemoteResource(RemoteFolder parent, String name)
  {
    this.parent = parent;
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public String getRelativePath(ICVSFolder ancestor)
    throws CVSException
  {
    return Util.appendPath(parent.getRelativePath(ancestor), getName());
  }
  
  public ICVSRemoteResource getRemoteParent()
  {
    return parent;
  }
  
  public abstract String getRepositoryRelativePath();
  
  public abstract ICVSRepositoryLocation getRepository();
  
  public int getWorkspaceSyncState()
  {
    return workspaceSyncState;
  }
  
  public void setWorkspaceSyncState(int workspaceSyncState)
  {
    this.workspaceSyncState = workspaceSyncState;
  }
  
  public void delete() {}
  
  public boolean exists()
  {
    return true;
  }
  
  public boolean exists(IProgressMonitor monitor)
    throws TeamException
  {
    return parent.exists(this, monitor);
  }
  
  public ICVSFolder getParent()
  {
    return parent;
  }
  
  public boolean isIgnored()
  {
    return false;
  }
  
  public boolean isManaged()
  {
    return parent != null;
  }
  
  public boolean isModified(IProgressMonitor monitor)
    throws CVSException
  {
    return true;
  }
  
  public void unmanage(IProgressMonitor monitor)
    throws CVSException
  {}
  
  public abstract ResourceSyncInfo getSyncInfo();
  
  public boolean equals(Object target)
  {
    if (this == target) {
      return true;
    }
    if (!(target instanceof RemoteResource)) {
      return false;
    }
    RemoteResource remote = (RemoteResource)target;
    
    return (remote.isContainer() == isContainer()) && (remote.getRepository().equals(getRepository())) && (remote.getRepositoryRelativePath().equals(getRepositoryRelativePath()));
  }
  
  public void setIgnoredAs(String pattern)
    throws CVSException
  {
    Assert.isTrue(false);
  }
  
  public IResource getIResource()
  {
    return null;
  }
  
  public abstract ICVSRemoteResource forTag(ICVSRemoteFolder paramICVSRemoteFolder, CVSTag paramCVSTag);
  
  public int hashCode()
  {
    return getRepositoryRelativePath().hashCode();
  }
  
  public abstract byte[] getSyncBytes();
  
  public String toString()
  {
    return "Remote " + (isContainer() ? "Folder: " : "File: ") + getName();
  }
  
  public String getCachePath()
  {
    ICVSRepositoryLocation location = getRepository();
    IPath path = new Path(null, location.getHost());
    path = path.append(location.getRootDirectory());
    path = path.append(parent.getRepositoryRelativePath());
    path = path.append(getName() + ' ' + getContentIdentifier());
    return path.toString();
  }
  
  protected String getCacheId()
  {
    return "org.eclipse.team.cvs.core";
  }
  
  public byte[] asBytes()
  {
    return getSyncBytes();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.resources.RemoteResource
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.resources;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ISynchronizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;

class SessionPropertySyncInfoCache$1
  implements IResourceVisitor
{
  final SessionPropertySyncInfoCache this$0;
  private final ISynchronizer val$synchronizer;
  
  SessionPropertySyncInfoCache$1(SessionPropertySyncInfoCache paramSessionPropertySyncInfoCache, ISynchronizer paramISynchronizer)
  {
    this$0 = paramSessionPropertySyncInfoCache;val$synchronizer = paramISynchronizer;
  }
  
  public boolean visit(IResource resource)
    throws CoreException
  {
    if (resource.getType() != 1)
    {
      String di = null;
      try
      {
        di = this$0.getDirtyIndicator(resource, true);
      }
      catch (CVSException e)
      {
        CVSProviderPlugin.log(e);
      }
      if (di != null) {
        val$synchronizer.setSyncInfo(SessionPropertySyncInfoCache.access$0(this$0), resource, di.getBytes());
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.resources.SessionPropertySyncInfoCache.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.resources;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.ISynchronizer;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.FileNameMatcher;
import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;

class SessionPropertySyncInfoCache
  extends SyncInfoCache
  implements ISaveParticipant
{
  private static final QualifiedName RESOURCE_SYNC_CACHED_KEY = new QualifiedName("org.eclipse.team.cvs.core", "resource-sync-cached");
  private static final Object RESOURCE_SYNC_CACHED = new Object();
  static final FileNameMatcher NULL_IGNORES = new FileNameMatcher();
  private static final FolderSyncInfo NULL_FOLDER_SYNC_INFO = new FolderSyncInfo("dummy-repo", "dummy-root", null, false);
  private QualifiedName FOLDER_DIRTY_STATE_KEY = new QualifiedName("org.eclipse.team.cvs.core", "folder-dirty-state-cached");
  private SynchronizerSyncInfoCache synchronizerCache;
  
  SessionPropertySyncInfoCache(SynchronizerSyncInfoCache synchronizerCache)
  {
    this.synchronizerCache = synchronizerCache;
    try
    {
      ResourcesPlugin.getWorkspace().addSaveParticipant(CVSProviderPlugin.getPlugin(), this);
      ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
      synchronizer.add(FOLDER_DIRTY_STATE_KEY);
    }
    catch (CoreException e)
    {
      CVSProviderPlugin.log(e);
    }
  }
  
  FileNameMatcher getFolderIgnores(IContainer container, boolean threadSafeAccess)
    throws CVSException
  {
    FileNameMatcher matcher = (FileNameMatcher)safeGetSessionProperty(container, IGNORE_SYNC_KEY);
    if ((threadSafeAccess) && (matcher == null))
    {
      String[] ignores = SyncFileWriter.readCVSIgnoreEntries(container);
      if (ignores == null) {
        matcher = NULL_IGNORES;
      } else {
        matcher = new FileNameMatcher(ignores);
      }
      safeSetSessionProperty(container, IGNORE_SYNC_KEY, matcher);
    }
    return matcher;
  }
  
  boolean isIgnoresCached(IContainer container)
    throws CVSException
  {
    return safeGetSessionProperty(container, IGNORE_SYNC_KEY) != null;
  }
  
  boolean isFolderSyncInfoCached(IContainer container)
    throws CVSException
  {
    Object info = safeGetSessionProperty(container, FOLDER_SYNC_KEY);
    if (info == null) {
      info = synchronizerCache.getCachedFolderSync(container, true);
    }
    return info != null;
  }
  
  boolean isResourceSyncInfoCached(IContainer container)
    throws CVSException
  {
    return safeGetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY) != null;
  }
  
  void setResourceSyncInfoCached(IContainer container)
    throws CVSException
  {
    safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, RESOURCE_SYNC_CACHED);
  }
  
  FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess)
    throws CVSException
  {
    FolderSyncInfo info = (FolderSyncInfo)safeGetSessionProperty(container, FOLDER_SYNC_KEY);
    if (!threadSafeAccess) {
      return info == NULL_FOLDER_SYNC_INFO ? null : info;
    }
    if (info == null)
    {
      info = synchronizerCache.getCachedFolderSync(container, true);
      if (info != null) {
        safeSetSessionProperty(container, FOLDER_SYNC_KEY, info);
      }
    }
    if (info == null) {
      if ((container.exists()) && (!container.isDerived()))
      {
        IStatus status = new CVSStatus(4, 4, NLS.bind(CVSMessages.EclipseSynchronizer_folderSyncInfoMissing, new String[] { container.getFullPath().toString() }), container);
        throw new CVSException(status);
      }
    }
    if (info == NULL_FOLDER_SYNC_INFO) {
      return null;
    }
    return info;
  }
  
  IResource[] purgeCache(IContainer container, boolean deep)
    throws CVSException
  {
    if (!container.exists()) {
      return new IResource[0];
    }
    try
    {
      Set flushed = new HashSet();
      if (container.getType() != 8)
      {
        safeSetSessionProperty(container, IGNORE_SYNC_KEY, null);
        safeSetSessionProperty(container, FOLDER_SYNC_KEY, null);
        safeSetSessionProperty(container, RESOURCE_SYNC_CACHED_KEY, null);
        flushed.add(container);
        EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(container, "r");
      }
      IResource[] members = container.members();
      for (int i = 0; i < members.length; i++)
      {
        IResource resource = members[i];
        purgeResourceSyncCache(resource);
        flushed.add(resource);
        if ((deep) && (resource.getType() != 1))
        {
          IResource[] flushedChildren = purgeCache((IContainer)resource, deep);
          flushed.addAll(Arrays.asList(flushedChildren));
        }
      }
      return (IResource[])flushed.toArray(new IResource[flushed.size()]);
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  void purgeResourceSyncCache(IResource resource)
    throws CVSException
  {
    safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, null);
    EclipseSynchronizer.getInstance().adjustDirtyStateRecursively(resource, "r");
  }
  
  void setCachedFolderIgnores(IContainer container, String[] ignores)
    throws CVSException
  {
    safeSetSessionProperty(container, IGNORE_SYNC_KEY, new FileNameMatcher(ignores));
  }
  
  void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace)
    throws CVSException
  {
    if (!container.exists()) {
      return;
    }
    if (info == null) {
      info = NULL_FOLDER_SYNC_INFO;
    }
    safeSetSessionProperty(container, FOLDER_SYNC_KEY, info);
    if ((canModifyWorkspace) && (synchronizerCache.getCachedFolderSync(container, true) != null)) {
      synchronizerCache.setCachedFolderSync(container, null, true);
    }
  }
  
  void setDirtyIndicator(IResource resource, String indicator)
    throws CVSException
  {
    if (resource.getType() == 1) {
      internalSetDirtyIndicator((IFile)resource, indicator);
    } else {
      internalSetDirtyIndicator((IContainer)resource, indicator);
    }
  }
  
  String getDirtyIndicator(IResource resource, boolean threadSafeAccess)
    throws CVSException
  {
    if (resource.getType() == 1) {
      return internalGetDirtyIndicator((IFile)resource, threadSafeAccess);
    }
    return internalGetDirtyIndicator((IContainer)resource, threadSafeAccess);
  }
  
  private void internalSetDirtyIndicator(IFile file, String indicator)
    throws CVSException
  {
    safeSetSessionProperty(file, IS_DIRTY, indicator);
  }
  
  private String internalGetDirtyIndicator(IFile file, boolean threadSafeAccess)
    throws CVSException
  {
    String di = (String)safeGetSessionProperty(file, IS_DIRTY);
    if (di == null) {
      di = "r";
    }
    return di;
  }
  
  private void internalSetDirtyIndicator(IContainer container, String indicator)
    throws CVSException
  {
    safeSetSessionProperty(container, IS_DIRTY, indicator);
  }
  
  private String internalGetDirtyIndicator(IContainer container, boolean threadSafeAccess)
    throws CVSException
  {
    try
    {
      String di = (String)safeGetSessionProperty(container, IS_DIRTY);
      if (di == null)
      {
        byte[] diBytes = ResourcesPlugin.getWorkspace().getSynchronizer().getSyncInfo(FOLDER_DIRTY_STATE_KEY, container);
        if ((diBytes != null) && (!CVSProviderPlugin.getPlugin().crashOnLastRun()))
        {
          di = new String(diBytes);
          if (di.equals("c")) {
            di = "c";
          } else if (di.equals("d")) {
            di = "d";
          } else {
            di = "r";
          }
        }
        else
        {
          di = "r";
        }
        if (threadSafeAccess) {
          setDirtyIndicator(container, di);
        }
      }
      return di;
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  void flushDirtyCache(IResource resource)
    throws CVSException
  {
    if (resource.exists()) {
      if (resource.getType() == 1)
      {
        safeSetSessionProperty(resource, IS_DIRTY, null);
      }
      else
      {
        safeSetSessionProperty(resource, IS_DIRTY, null);
        flushDirtyStateFromDisk((IContainer)resource);
      }
    }
  }
  
  boolean isSyncInfoLoaded(IContainer parent)
    throws CVSException
  {
    if (parent.getFolder(new Path("CVS")).exists())
    {
      if (safeGetSessionProperty(parent, RESOURCE_SYNC_CACHED_KEY) == null) {
        return false;
      }
      if (safeGetSessionProperty(parent, FOLDER_SYNC_KEY) == null) {
        return false;
      }
    }
    return true;
  }
  
  byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess)
    throws CVSException
  {
    byte[] bytes = (byte[])safeGetSessionProperty(resource, RESOURCE_SYNC_KEY);
    if (!threadSafeAccess) {
      return bytes;
    }
    if (bytes == null)
    {
      bytes = synchronizerCache.getCachedSyncBytes(resource, true);
      if (bytes != null)
      {
        boolean genderChange = false;
        if (resource.getType() == 1)
        {
          if (ResourceSyncInfo.isFolder(bytes)) {
            genderChange = true;
          }
        }
        else if (!ResourceSyncInfo.isFolder(bytes)) {
          genderChange = true;
        }
        if (genderChange) {
          bytes = (byte[])null;
        } else {
          safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, ResourceSyncInfo.convertFromDeletion(bytes));
        }
      }
    }
    return bytes;
  }
  
  Object safeGetSessionProperty(IResource resource, QualifiedName key)
    throws CVSException
  {
    try
    {
      return resource.getSessionProperty(key);
    }
    catch (CoreException e)
    {
      IStatus status = e.getStatus();
      if (status != null)
      {
        int code = e.getStatus().getCode();
        if ((code != 369) || 
          (code != 368)) {
          return null;
        }
      }
      throw CVSException.wrapException(e);
    }
  }
  
  void safeSetSessionProperty(IResource resource, QualifiedName key, Object value)
    throws CVSException
  {
    try
    {
      resource.setSessionProperty(key, value);
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace)
    throws CVSException
  {
    if ((syncBytes != null) && (ResourceSyncInfo.isDeletion(syncBytes))) {
      syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
    }
    safeSetSessionProperty(resource, RESOURCE_SYNC_KEY, syncBytes);
    if ((canModifyWorkspace) && (synchronizerCache.getCachedSyncBytes(resource, true) != null)) {
      synchronizerCache.setCachedSyncBytes(resource, null, canModifyWorkspace);
    }
  }
  
  public void doneSaving(ISaveContext context) {}
  
  public void prepareToSave(ISaveContext context)
    throws CoreException
  {}
  
  public void rollback(ISaveContext context) {}
  
  public void saving(ISaveContext context)
    throws CoreException
  {
    boolean fullSave = context.getKind() == 1;
    boolean projectSave = context.getKind() == 3;
    if ((projectSave) || (fullSave))
    {
      ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
      IProject[] projects;
      if (projectSave)
      {
        IProject[] projects = new IProject[1];
        projects[0] = context.getProject();
      }
      else
      {
        projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      }
      for (int i = 0; i < projects.length; i++)
      {
        IProject project = projects[i];
        RepositoryProvider provider = RepositoryProvider.getProvider(
          project, 
          CVSProviderPlugin.getTypeId());
        if (provider != null) {
          project.accept(new IResourceVisitor()
          {
            private final ISynchronizer val$synchronizer;
            
            public boolean visit(IResource resource)
              throws CoreException
            {
              if (resource.getType() != 1)
              {
                String di = null;
                try
                {
                  di = getDirtyIndicator(resource, true);
                }
                catch (CVSException e)
                {
                  CVSProviderPlugin.log(e);
                }
                if (di != null) {
                  val$synchronizer.setSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, di.getBytes());
                }
              }
              return true;
            }
          });
        }
      }
    }
  }
  
  private void flushDirtyStateFromDisk(IContainer container)
  {
    ISynchronizer synchronizer = ResourcesPlugin.getWorkspace().getSynchronizer();
    try
    {
      synchronizer.flushSyncInfo(FOLDER_DIRTY_STATE_KEY, container, 2);
    }
    catch (CoreException e)
    {
      CVSProviderPlugin.log(e);
    }
  }
  
  void purgeDirtyCache(IResource resource)
    throws CVSException
  {
    if (!resource.exists()) {
      return;
    }
    try
    {
      if (resource.getType() != 8) {
        safeSetSessionProperty(resource, IS_DIRTY, null);
      }
      if (resource.getType() != 1)
      {
        ResourcesPlugin.getWorkspace().getSynchronizer().flushSyncInfo(FOLDER_DIRTY_STATE_KEY, resource, 2);
        IResource[] members = ((IContainer)resource).members();
        for (int i = 0; i < members.length; i++) {
          purgeDirtyCache(members[i]);
        }
      }
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  public boolean cachesDirtyState()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.resources.SessionPropertySyncInfoCache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.resources;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;

abstract class SyncInfoCache
{
  static final QualifiedName FOLDER_SYNC_KEY = new QualifiedName("org.eclipse.team.cvs.core", "folder-sync");
  static final QualifiedName RESOURCE_SYNC_KEY = new QualifiedName("org.eclipse.team.cvs.core", "resource-sync");
  static final QualifiedName IGNORE_SYNC_KEY = new QualifiedName("org.eclipse.team.cvs.core", "folder-ignore");
  static final byte[][] EMPTY_RESOURCE_SYNC_INFOS = new byte[0][0];
  static final QualifiedName IS_DIRTY = new QualifiedName("org.eclipse.team.cvs.core", "is-dirty");
  static final String IS_DIRTY_INDICATOR = "d";
  static final String NOT_DIRTY_INDICATOR = "c";
  static final String RECOMPUTE_INDICATOR = "r";
  static final IStatus STATUS_OK = new Status(0, "org.eclipse.team.cvs.core", 0, CVSMessages.ok, null);
  
  abstract FolderSyncInfo getCachedFolderSync(IContainer paramIContainer, boolean paramBoolean)
    throws CVSException;
  
  abstract void setCachedFolderSync(IContainer paramIContainer, FolderSyncInfo paramFolderSyncInfo, boolean paramBoolean)
    throws CVSException;
  
  abstract byte[] getCachedSyncBytes(IResource paramIResource, boolean paramBoolean)
    throws CVSException;
  
  abstract void setCachedSyncBytes(IResource paramIResource, byte[] paramArrayOfByte, boolean paramBoolean)
    throws CVSException;
  
  abstract String getDirtyIndicator(IResource paramIResource, boolean paramBoolean)
    throws CVSException;
  
  abstract void setDirtyIndicator(IResource paramIResource, String paramString)
    throws CVSException;
  
  abstract void flushDirtyCache(IResource paramIResource)
    throws CVSException;
  
  abstract boolean isSyncInfoLoaded(IContainer paramIContainer)
    throws CVSException;
  
  abstract boolean isFolderSyncInfoCached(IContainer paramIContainer)
    throws CVSException;
  
  abstract boolean isResourceSyncInfoCached(IContainer paramIContainer)
    throws CVSException;
  
  abstract void setResourceSyncInfoCached(IContainer paramIContainer)
    throws CVSException;
  
  public abstract boolean cachesDirtyState();
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.resources.SyncInfoCache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.resources;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ISynchronizer;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;

class SynchronizerSyncInfoCache
  extends SyncInfoCache
{
  Map pendingCacheWrites = new HashMap();
  private static final Object BYTES_REMOVED = new byte[0];
  
  public SynchronizerSyncInfoCache()
  {
    getWorkspaceSynchronizer().add(FOLDER_SYNC_KEY);
    getWorkspaceSynchronizer().add(RESOURCE_SYNC_KEY);
  }
  
  private ISynchronizer getWorkspaceSynchronizer()
  {
    return ResourcesPlugin.getWorkspace().getSynchronizer();
  }
  
  void flush(IProject project)
    throws CVSException
  {
    purgeCache(project, true);
  }
  
  void flush(IFolder folder)
    throws CVSException
  {
    purgeCache(folder, false);
  }
  
  FolderSyncInfo getCachedFolderSync(IContainer container, boolean threadSafeAccess)
    throws CVSException
  {
    byte[] bytes = internalGetCachedSyncBytes(container);
    if (bytes == null) {
      return null;
    }
    return FolderSyncInfo.getFolderSyncInfo(bytes);
  }
  
  boolean hasCachedFolderSync(IContainer container)
    throws CVSException
  {
    return internalGetCachedSyncBytes(container) != null;
  }
  
  private byte[] internalGetCachedSyncBytes(IContainer container)
    throws CVSException
  {
    try
    {
      return getWorkspaceSynchronizer().getSyncInfo(FOLDER_SYNC_KEY, container);
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  void setCachedFolderSync(IContainer container, FolderSyncInfo info, boolean canModifyWorkspace)
    throws CVSException
  {
    try
    {
      if (info == null)
      {
        if ((container.exists()) || (container.isPhantom())) {
          getWorkspaceSynchronizer().flushSyncInfo(FOLDER_SYNC_KEY, container, 0);
        }
      }
      else {
        getWorkspaceSynchronizer().setSyncInfo(FOLDER_SYNC_KEY, container, info.getBytes());
      }
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  byte[] getCachedSyncBytes(IResource resource, boolean threadSafeAccess)
    throws CVSException
  {
    try
    {
      byte[] bytes = (byte[])null;
      if (!hasPendingCacheRemoval(resource))
      {
        bytes = getPendingCacheWrite(resource);
        if (bytes == null) {
          bytes = getWorkspaceSynchronizer().getSyncInfo(RESOURCE_SYNC_KEY, resource);
        }
      }
      if ((bytes != null) && (resource.getType() == 1)) {
        if (ResourceSyncInfo.isAddition(bytes)) {
          bytes = (byte[])null;
        } else if (ResourceSyncInfo.isDeletion(bytes)) {}
      }
      return ResourceSyncInfo.convertToDeletion(bytes);
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  void setCachedSyncBytes(IResource resource, byte[] syncBytes, boolean canModifyWorkspace)
    throws CVSException
  {
    byte[] oldBytes = getCachedSyncBytes(resource, true);
    try
    {
      if (syncBytes == null)
      {
        if (oldBytes != null) {
          if (canModifyWorkspace)
          {
            if ((resource.exists()) || (resource.isPhantom())) {
              getWorkspaceSynchronizer().flushSyncInfo(RESOURCE_SYNC_KEY, resource, 0);
            }
            removePendingCacheWrite(resource);
          }
          else if ((resource.exists()) || (resource.isPhantom()))
          {
            setPendingCacheWriteToDelete(resource);
          }
        }
      }
      else if ((oldBytes == null) || (!equals(syncBytes, oldBytes))) {
        if (canModifyWorkspace)
        {
          getWorkspaceSynchronizer().setSyncInfo(RESOURCE_SYNC_KEY, resource, syncBytes);
          removePendingCacheWrite(resource);
        }
        else
        {
          setPendingCacheWrite(resource, syncBytes);
        }
      }
    }
    catch (CoreException e)
    {
      throw CVSException.wrapException(e);
    }
  }
  
  private boolean equals(byte[] syncBytes, byte[] oldBytes)
    throws CVSException
  {
    if (!ResourceSyncInfo.isFolder(syncBytes)) {
      syncBytes = ResourceSyncInfo.convertToDeletion(syncBytes);
    }
    if (!ResourceSyncInfo.isFolder(oldBytes)) {
      try
      {
        oldBytes = ResourceSyncInfo.convertToDeletion(oldBytes);
      }
      catch (CVSException e)
      {
        CVSProviderPlugin.log(e);
        return false;
      }
    }
    return Util.equals(syncBytes, oldBytes);
  }
  
  String getDirtyIndicator(IResource resource, boolean threadSafeAccess)
    throws CVSException
  {
    if (resource.getType() == 1) {
      return getCachedSyncBytes(resource, threadSafeAccess) != null ? 
        "d" : 
        "c";
    }
    return calculateDirtyCountForPhantomFolder((IContainer)resource);
  }
  
  void setDirtyIndicator(IResource resource, String indicator)
    throws CVSException
  {}
  
  public boolean cachesDirtyState()
  {
    return false;
  }
  
  void flushDirtyCache(IResource container)
    throws CVSException
  {}
  
  boolean isSyncInfoLoaded(IContainer parent)
    throws CVSException
  {
    return true;
  }
  
  boolean isResourceSyncInfoCached(IContainer container)
    throws CVSException
  {
    return true;
  }
  
  void setResourceSyncInfoCached(IContainer container)
    throws CVSException
  {}
  
  boolean isFolderSyncInfoCached(IContainer container)
    throws CVSException
  {
    return true;
  }
  
  private String calculateDirtyCountForPhantomFolder(IContainer parent)
    throws CVSException
  {
    ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(parent);
    if (getCachedFolderSync(parent, true) == null) {
      return "c";
    }
    String indicator = "c";
    ICVSResource[] children = cvsFolder.members(80);
    for (int i = 0; i < children.length; i++)
    {
      ICVSResource resource = children[i];
      if (resource.isFolder())
      {
        indicator = calculateDirtyCountForPhantomFolder((IContainer)resource.getIResource());
      }
      else
      {
  
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

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