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

ocation.indexOf(';');
      HashMap hmOptions = new HashMap();
      String methodName;
      if (start == 0)
      {
        int end = location.indexOf(':', start + 1);
        if (optionStart != -1)
        {
          String methodName = location.substring(start + 1, optionStart);
          
          StringTokenizer stOpt = new StringTokenizer(
            location.substring(optionStart + 1, end), 
            "=;");
          while (stOpt.hasMoreTokens()) {
            hmOptions.put(stOpt.nextToken(), stOpt.nextToken());
          }
          start = end + 1;
        }
        else
        {
          String methodName = location.substring(start + 1, end);
          start = end + 1;
        }
      }
      else
      {
        methodName = "ext";
        start = 0;
      }
      IConnectionMethod method = getPluggedInConnectionMethod(methodName);
      if (method == null) {
        throw new CVSException(new CVSStatus(4, NLS.bind(CVSMessages.CVSRepositoryLocation_methods, new Object[] { getPluggedInConnectionMethodNames() })));
      }
      errorMessage = CVSMessages.CVSRepositoryLocation_parsingUser;
      
      int end = location.indexOf('@', start);
      String user = null;
      String password = null;
      if (end != -1)
      {
        user = location.substring(start, end);
        
        start = user.indexOf(':');
        if (start != -1)
        {
          errorMessage = CVSMessages.CVSRepositoryLocation_parsingPassword;
          password = user.substring(start + 1);
          user = user.substring(0, start);
        }
        start = end + 1;
      }
      else if (optionStart != -1)
      {
        if (hmOptions.containsKey("username")) {
          user = hmOptions.get("username").toString();
        }
        if (hmOptions.containsKey("password")) {
          password = hmOptions.get("password").toString();
        }
      }
      errorMessage = CVSMessages.CVSRepositoryLocation_parsingHost;
      end = location.indexOf(':', start);
      int hostEnd = end;
      if (end == -1)
      {
        end = location.indexOf('/', start);
        hostEnd = end;
        if (end != -1) {
          end--;
        }
      }
      String host = hmOptions.containsKey("hostname") ? hmOptions.get("hostname").toString() : location.substring(start, hostEnd);
      int port = 0;
      boolean havePort = false;
      if (hmOptions.containsKey("port"))
      {
        port = Integer.parseInt(hmOptions.get("port").toString());
        havePort = true;
      }
      start = host.indexOf('#');
      if (start != -1) {
        try
        {
          errorMessage = CVSMessages.CVSRepositoryLocation_parsingPort;
          port = Integer.parseInt(host.substring(start + 1));
          host = host.substring(0, start);
          havePort = true;
        }
        catch (NumberFormatException localNumberFormatException1) {}
      }
      if (!havePort)
      {
        errorMessage = CVSMessages.CVSRepositoryLocation_parsingPort;
        int index = end;
        char c = location.charAt(++index);
        String portString = new String();
        while (Character.isDigit(c))
        {
          portString = portString + c;
          c = location.charAt(++index);
        }
        if (portString.length() > 0)
        {
          end = index - 1;
          port = Integer.parseInt(portString);
        }
      }
      errorMessage = CVSMessages.CVSRepositoryLocation_parsingRoot;
      start = end + 1;
      String root = location.substring(start);
      if (validateOnly) {
        throw new CVSException(new CVSStatus(0, CVSMessages.ok));
      }
      return new CVSRepositoryLocation(method, user, password, host, port, root, null, user != null, password != null);
    }
    catch (IndexOutOfBoundsException localIndexOutOfBoundsException)
    {
      IStatus status = new CVSStatus(4, errorMessage);
      throw new CVSException(status);
    }
    catch (NumberFormatException localNumberFormatException2)
    {
      IStatus status = new CVSStatus(4, errorMessage);
      
      throw new CVSException(status);
    }
  }
  
  public static IUserAuthenticator getAuthenticator()
  {
    if (authenticator == null) {
      authenticator = getPluggedInAuthenticator();
    }
    return authenticator;
  }
  
  public static IConnectionMethod[] getPluggedInConnectionMethods()
  {
    if (pluggedInConnectionMethods == null)
    {
      List connectionMethods = new ArrayList();
      if (STANDALONE_MODE)
      {
        connectionMethods.add(new PServerConnectionMethod());
      }
      else
      {
        IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.team.cvs.core", "connectionmethods").getExtensions();
        for (int i = 0; i < extensions.length; i++)
        {
          IExtension extension = extensions[i];
          IConfigurationElement[] configs = extension.getConfigurationElements();
          if (configs.length == 0) {
            CVSProviderPlugin.log(4, NLS.bind("Connection method {0} is missing required fields", new Object[] { extension.getUniqueIdentifier() }), null);
          } else {
            try
            {
              IConfigurationElement config = configs[0];
              connectionMethods.add(config.createExecutableExtension("run"));
            }
            catch (CoreException ex)
            {
              CVSProviderPlugin.log(4, NLS.bind("Could not instantiate connection method for  {0}", new Object[] { extension.getUniqueIdentifier() }), ex);
            }
          }
        }
      }
      IConnectionMethod[] methods = (IConnectionMethod[])connectionMethods.toArray(new IConnectionMethod[0]);
      Arrays.sort(methods, new Comparator()
      {
        public int compare(Object o1, Object o2)
        {
          if (((o1 instanceof IConnectionMethod)) && ((o2 instanceof IConnectionMethod)))
          {
            IConnectionMethod cm1 = (IConnectionMethod)o1;
            IConnectionMethod cm2 = (IConnectionMethod)o2;
            return cm1.getName().compareTo(cm2.getName());
          }
          return 0;
        }
      });
      pluggedInConnectionMethods = methods;
    }
    return pluggedInConnectionMethods;
  }
  
  private static IConnectionMethod getPluggedInConnectionMethod(String methodName)
  {
    Assert.isNotNull(methodName);
    IConnectionMethod[] methods = getPluggedInConnectionMethods();
    for (int i = 0; i < methods.length; i++) {
      if (methodName.equals(methods[i].getName())) {
        return methods[i];
      }
    }
    return null;
  }
  
  private static String getPluggedInConnectionMethodNames()
  {
    IConnectionMethod[] methods = getPluggedInConnectionMethods();
    StringBuffer methodNames = new StringBuffer();
    for (int i = 0; i < methods.length; i++)
    {
      String name = methods[i].getName();
      if (i > 0) {
        methodNames.append(", ");
      }
      methodNames.append(name);
    }
    return methodNames.toString();
  }
  
  private static IUserAuthenticator getPluggedInAuthenticator()
  {
    IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.team.cvs.core", "authenticator").getExtensions();
    if (extensions.length == 0) {
      return null;
    }
    IExtension extension = extensions[0];
    IConfigurationElement[] configs = extension.getConfigurationElements();
    if (configs.length == 0)
    {
      CVSProviderPlugin.log(4, NLS.bind("User autheticator {0} is missing required fields", new Object[] { extension.getUniqueIdentifier() }), null);
      return null;
    }
    try
    {
      IConfigurationElement config = configs[0];
      return (IUserAuthenticator)config.createExecutableExtension("run");
    }
    catch (CoreException ex)
    {
      CVSProviderPlugin.log(4, NLS.bind("Unable to instantiate user authenticator {0}", new Object[] { extension.getUniqueIdentifier() }), ex);
    }
    return null;
  }
  
  private CVSRepositoryLocation(IConnectionMethod method, String user, String password, String host, int port, String root, String encoding, boolean userFixed, boolean passwordFixed)
  {
    this.method = method;
    this.user = user;
    this.password = password;
    this.host = host;
    this.port = port;
    this.root = root;
    if ((userFixed) && (user != null)) {
      this.userFixed = true;
    }
    if ((userFixed) && (passwordFixed) && (password != null)) {
      this.passwordFixed = true;
    }
    if (encoding != null) {
      setEncoding(encoding);
    }
  }
  
  private Connection createConnection(String password, IProgressMonitor monitor)
    throws CVSException
  {
    IConnectionMethod methodToUse = method;
    if ((method.getName().equals("ext")) && (extProxy != null) && (!extProxy.equals(method.getName()))) {
      methodToUse = getPluggedInConnectionMethod(extProxy);
    }
    Connection connection = new Connection(this, methodToUse.createConnection(this, password));
    connection.open(monitor);
    return connection;
  }
  
  public void dispose()
  {
    removeNode();
    try
    {
      if (hasPreferences())
      {
        internalGetPreferences().removeNode();
        getParentPreferences().flush();
      }
    }
    catch (BackingStoreException e)
    {
      CVSProviderPlugin.log(4, NLS.bind(CVSMessages.CVSRepositoryLocation_73, new String[] { getLocation(true) }), e);
    }
  }
  
  private void removeNode()
  {
    ISecurePreferences node = getCVSNode();
    if (node == null) {
      return;
    }
    try
    {
      node.clear();
      node.flush();
    }
    catch (IllegalStateException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
    }
    catch (IOException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
    }
  }
  
  public String getHost()
  {
    return host;
  }
  
  public String getLocation()
  {
    return getLocation(false);
  }
  
  public String getLocation(boolean forDisplay)
  {
    return 
    
      ':' + method.getName() + ':' + (userFixed ? user + ((passwordFixed) && (!forDisplay) ? ':' + password : "") + '@' : "") + host + ':' + (port == 0 ? "" : new Integer(port).toString()) + root;
  }
  
  public IConnectionMethod getMethod()
  {
    return method;
  }
  
  public int getPort()
  {
    return port;
  }
  
  public String getEncoding()
  {
    if (hasPreferences()) {
      return internalGetPreferences().get("encoding", getDefaultEncoding());
    }
    return getDefaultEncoding();
  }
  
  public void setEncoding(String encoding)
  {
    if ((encoding == null) || (encoding == getDefaultEncoding()))
    {
      if (hasPreferences()) {
        internalGetPreferences().remove("encoding");
      }
    }
    else
    {
      ensurePreferencesStored();
      internalGetPreferences().put("encoding", encoding);
      flushPreferences();
    }
  }
  
  public ICVSRemoteResource[] members(CVSTag tag, boolean modules, IProgressMonitor progress)
    throws CVSException
  {
    try
    {
      if (modules) {
        return RemoteModule.getRemoteModules(this, tag, progress);
      }
      RemoteFolder root = new RemoteFolder(null, this, "", tag);
      ICVSRemoteResource[] resources = root.members(progress);
      
      List folders = new ArrayList(resources.length);
      for (int i = 0; i < resources.length; i++)
      {
        ICVSRemoteResource remoteResource = resources[i];
        if (remoteResource.isContainer()) {
          folders.add(remoteResource);
        }
      }
      return (ICVSRemoteResource[])folders.toArray(new ICVSRemoteResource[folders.size()]);
    }
    catch (CVSException e)
    {
      throw e;
    }
    catch (TeamException e1)
    {
      throw new CVSException(e1.getStatus());
    }
  }
  
  public ICVSRemoteFolder getRemoteFolder(String remotePath, CVSTag tag)
  {
    return new RemoteFolder(null, this, remotePath, tag);
  }
  
  public ICVSRemoteFile getRemoteFile(String remotePath, CVSTag tag)
  {
    IPath path = new Path(null, remotePath);
    RemoteFolderTree remoteFolder = new RemoteFolderTree(null, this, path.removeLastSegments(1).toString(), tag);
    RemoteFile remoteFile = new RemoteFile(remoteFolder, 1, path.lastSegment(), null, null, tag);
    remoteFolder.setChildren(new ICVSRemoteResource[] { remoteFile });
    return remoteFile;
  }
  
  public String getRootDirectory()
  {
    return root;
  }
  
  public int getTimeout()
  {
    return CVSProviderPlugin.getPlugin().getTimeout();
  }
  
  public IUserInfo getUserInfo(boolean makeUsernameMutable)
  {
    return new UserInfo(getUsername(), password, makeUsernameMutable ? true : isUsernameMutable());
  }
  
  public String getUsername()
  {
    if ((user == null) && (isUsernameMutable())) {
      retrieveUsername();
    }
    return user == null ? "" : user;
  }
  
  public boolean isUsernameMutable()
  {
    return !userFixed;
  }
  
  /* Error */
  public Connection openConnection(IProgressMonitor monitor)
    throws CVSException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokestatic 963	org/eclipse/team/internal/ccvs/core/Policy:checkCanceled	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   4: getstatic 885	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:hostLocks	Ljava/util/Map;
    //   7: dup
    //   8: astore_3
    //   9: monitorenter
    //   10: getstatic 885	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:hostLocks	Ljava/util/Map;
    //   13: aload_0
    //   14: invokevirtual 988	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:getHost	()Ljava/lang/String;
    //   17: invokeinterface 1031 2 0
    //   22: checkcast 498	org/eclipse/core/runtime/jobs/ILock
    //   25: astore_2
    //   26: aload_2
    //   27: ifnonnull +26 -> 53
    //   30: invokestatic 942	org/eclipse/core/runtime/jobs/Job:getJobManager	()Lorg/eclipse/core/runtime/jobs/IJobManager;
    //   33: invokeinterface 1045 1 0
    //   38: astore_2
    //   39: getstatic 885	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:hostLocks	Ljava/util/Map;
    //   42: aload_0
    //   43: invokevirtual 988	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:getHost	()Ljava/lang/String;
    //   46: aload_2
    //   47: invokeinterface 1032 3 0
    //   52: pop
    //   53: aload_3
    //   54: monitorexit
    //   55: goto +6 -> 61
    //   58: aload_3
    //   59: monitorexit
    //   60: athrow
    //   61: iconst_0
    //   62: istore_3
    //   63: iconst_0
    //   64: istore 4
    //   66: invokestatic 959	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:getPlugin	()Lorg/eclipse/team/internal/ccvs/core/CVSProviderPlugin;
    //   69: invokevirtual 953	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:getTimeout	()I
    //   72: istore 5
    //   74: goto +54 -> 128
    //   77: aload_2
    //   78: ldc2_w 436
    //   81: invokeinterface 1047 3 0
    //   86: istore_3
    //   87: goto +4 -> 91
    //   90: pop
    //   91: iload 5
    //   93: ifle +28 -> 121
    //   96: iload 4
    //   98: iload 5
    //   100: if_icmple +21 -> 121
    //   103: new 523	org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException
    //   106: dup
    //   107: getstatic 851	org/eclipse/team/internal/ccvs/core/CVSMessages:CVSRepositoryLocation_72	Ljava/lang/String;
    //   110: aload_0
    //   111: invokevirtual 988	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:getHost	()Ljava/lang/String;
    //   114: invokestatic 948	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   117: invokespecial 974	org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException:<init>	(Ljava/lang/String;)V
    //   120: athrow
    //   121: iinc 4 1
    //   124: aload_1
    //   125: invokestatic 963	org/eclipse/team/internal/ccvs/core/Policy:checkCanceled	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   128: iload_3
    //   129: ifeq -52 -> 77
    //   132: aload_1
    //   133: getstatic 860	org/eclipse/team/internal/ccvs/core/CVSMessages:CVSRepositoryLocation_openingConnection	Ljava/lang/String;
    //   136: iconst_1
    //   137: anewarray 470	java/lang/String
    //   140: dup
    //   141: iconst_0
    //   142: aload_0
    //   143: invokevirtual 988	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:getHost	()Ljava/lang/String;
    //   146: aastore
    //   147: invokestatic 949	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   150: iconst_2
    //   151: invokeinterface 1043 3 0
    //   156: aload_0
    //   157: invokespecial 976	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:ensureLocationCached	()V
    //   160: iconst_0
    //   161: istore 6
    //   163: aload_0
    //   164: getfield 878	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:previousAuthenticationFailed	Z
    //   167: ifeq +11 -> 178
    //   170: aload_0
    //   171: aconst_null
    //   172: invokespecial 995	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:promptForUserInfo	(Ljava/lang/String;)V
    //   175: iconst_1
    //   176: istore 6
    //   178: aload_0
    //   179: getfield 882	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:password	Ljava/lang/String;
    //   182: astore 7
    //   184: aload 7
    //   186: ifnonnull +9 -> 195
    //   189: aload_0
    //   190: invokespecial 993	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:retrievePassword	()Ljava/lang/String;
    //   193: astore 7
    //   195: aload_0
    //   196: getfield 884	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:user	Ljava/lang/String;
    //   199: ifnonnull +17 -> 216
    //   202: new 522	org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException
    //   205: dup
    //   206: getstatic 868	org/eclipse/team/internal/ccvs/core/CVSMessages:CVSRepositoryLocation_usernameRequired	Ljava/lang/String;
    //   209: iconst_1
    //   210: aload_0
    //   211: aconst_null
    //   212: invokespecial 973	org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException:<init>	(Ljava/lang/String;ILorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;Ljava/lang/Exception;)V
    //   215: athrow
    //   216: aload_0
    //   217: aload 7
    //   219: aload_1
    //   220: invokespecial 1009	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:createConnection	(Ljava/lang/String;Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/team/internal/ccvs/core/connection/Connection;
    //   223: astore 8
    //   225: iload 6
    //   227: ifeq +7 -> 234
    //   230: aload_0
    //   231: invokespecial 982	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:updateCachedLocation	()V
    //   234: aload_0
    //   235: iconst_0
    //   236: putfield 878	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:previousAuthenticationFailed	Z
    //   239: aload 8
    //   241: astore 10
    //   243: aload_2
    //   244: invokeinterface 1046 1 0
    //   249: aload_1
    //   250: invokeinterface 1042 1 0
    //   255: aload 10
    //   257: areturn
    //   258: astore 7
    //   260: aload_0
    //   261: iconst_1
    //   262: putfield 878	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:previousAuthenticationFailed	Z
    //   265: aload 7
    //   267: invokevirtual 970	org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException:getRetryStatus	()I
    //   270: iconst_1
    //   271: if_icmpne +22 -> 293
    //   274: aload 7
    //   276: invokevirtual 971	org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException:getMessage	()Ljava/lang/String;
    //   279: astore 8
    //   281: aload_0
    //   282: aload 8
    //   284: invokespecial 995	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:promptForUserInfo	(Ljava/lang/String;)V
    //   287: iconst_1
    //   288: istore 6
    //   290: goto -112 -> 178
    //   293: aload 7
    //   295: athrow
    //   296: astore 9
    //   298: aload_2
    //   299: invokeinterface 1046 1 0
    //   304: aload_1
    //   305: invokeinterface 1042 1 0
    //   310: aload 9
    //   312: athrow
    // Line number table:
    //   Java source line #757	-> byte code offset #0
    //   Java source line #759	-> byte code offset #4
    //   Java source line #760	-> byte code offset #10
    //   Java source line #761	-> byte code offset #26
    //   Java source line #762	-> byte code offset #30
    //   Java source line #763	-> byte code offset #39
    //   Java source line #759	-> byte code offset #53
    //   Java source line #767	-> byte code offset #61
    //   Java source line #768	-> byte code offset #63
    //   Java source line #769	-> byte code offset #66
    //   Java source line #770	-> byte code offset #74
    //   Java source line #772	-> byte code offset #77
    //   Java source line #773	-> byte code offset #90
    //   Java source line #776	-> byte code offset #91
    //   Java source line #777	-> byte code offset #103
    //   Java source line #779	-> byte code offset #121
    //   Java source line #780	-> byte code offset #124
    //   Java source line #770	-> byte code offset #128
    //   Java source line #783	-> byte code offset #132
    //   Java source line #784	-> byte code offset #156
    //   Java source line #785	-> byte code offset #160
    //   Java source line #787	-> byte code offset #163
    //   Java source line #788	-> byte code offset #170
    //   Java source line #790	-> byte code offset #175
    //   Java source line #795	-> byte code offset #178
    //   Java source line #796	-> byte code offset #184
    //   Java source line #798	-> byte code offset #189
    //   Java source line #800	-> byte code offset #195
    //   Java source line #802	-> byte code offset #202
    //   Java source line #806	-> byte code offset #216
    //   Java source line #807	-> byte code offset #225
    //   Java source line #808	-> byte code offset #230
    //   Java source line #809	-> byte code offset #234
    //   Java source line #810	-> byte code offset #239
    //   Java source line #824	-> byte code offset #243
    //   Java source line #825	-> byte code offset #249
    //   Java source line #810	-> byte code offset #255
    //   Java source line #811	-> byte code offset #258
    //   Java source line #812	-> byte code offset #260
    //   Java source line #813	-> byte code offset #265
    //   Java source line #814	-> byte code offset #274
    //   Java source line #815	-> byte code offset #281
    //   Java source line #817	-> byte code offset #287
    //   Java source line #819	-> byte code offset #293
    //   Java source line #823	-> byte code offset #296
    //   Java source line #824	-> byte code offset #298
    //   Java source line #825	-> byte code offset #304
    //   Java source line #826	-> byte code offset #310
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	313	0	this	CVSRepositoryLocation
    //   0	313	1	monitor	IProgressMonitor
    //   25	22	2	hostLock	org.eclipse.core.runtime.jobs.ILock
    //   61	238	2	hostLock	org.eclipse.core.runtime.jobs.ILock
    //   8	51	3	Ljava/lang/Object;	Object
    //   62	67	3	acquired	boolean
    //   64	58	4	count	int
    //   72	27	5	timeout	int
    //   161	128	6	cacheNeedsUpdate	boolean
    //   182	36	7	password	String
    //   258	36	7	ex	CVSAuthenticationException
    //   223	17	8	connection	Connection
    //   279	4	8	message	String
    //   296	15	9	localObject1	Object
    //   241	15	10	localConnection1	Connection
    //   90	1	15	localInterruptedException	InterruptedException
    // Exception table:
    //   from	to	target	type
    //   10	55	58	finally
    //   58	60	58	finally
    //   77	87	90	java/lang/InterruptedException
    //   178	243	258	org/eclipse/team/internal/ccvs/core/connection/CVSAuthenticationException
    //   61	243	296	finally
    //   258	296	296	finally
  }
  
  private void promptForUserInfo(String message)
    throws CVSException
  {
    IUserAuthenticator authenticator = getAuthenticator();
    if (authenticator == null) {
      throw new CVSAuthenticationException(CVSMessages.CVSRepositoryLocation_noAuthenticator, 2, this);
    }
    authenticator.promptForUserInfo(this, this, message);
  }
  
  private void ensureLocationCached()
  {
    String location = getLocation();
    KnownRepositories repositories = KnownRepositories.getInstance();
    if (repositories.isKnownRepository(location)) {
      try
      {
        setAuthenticationInformation((CVSRepositoryLocation)repositories.getRepository(location));
      }
      catch (CVSException e)
      {
        CVSProviderPlugin.log(e);
      }
    } else {
      repositories.addRepository(this, true);
    }
  }
  
  private void setAuthenticationInformation(CVSRepositoryLocation other)
  {
    if (other != this) {
      if (other.getUserInfoCached())
      {
        allowCaching = true;
        if (!userFixed) {
          user = null;
        }
        if (!passwordFixed) {
          password = null;
        }
      }
      else
      {
        setAllowCaching(false);
        if (!userFixed) {
          user = user;
        }
        if (!passwordFixed) {
          password = password;
        }
      }
    }
  }
  
  private void updateCachedLocation()
  {
    try
    {
      CVSRepositoryLocation known = (CVSRepositoryLocation)KnownRepositories.getInstance().getRepository(getLocation());
      known.setAuthenticationInformation(this);
    }
    catch (CVSException e)
    {
      CVSProviderPlugin.log(e);
    }
  }
  
  public String toString()
  {
    return getLocation(true);
  }
  
  public boolean equals(Object o)
  {
    if (this == o) {
      return true;
    }
    if (!(o instanceof CVSRepositoryLocation)) {
      return false;
    }
    return getLocation().equals(((CVSRepositoryLocation)o).getLocation());
  }
  
  public int hashCode()
  {
    return getLocation().hashCode();
  }
  
  private String retrieveUsername()
  {
    ISecurePreferences node = getCVSNode();
    if (node == null) {
      return null;
    }
    try
    {
      String username = node.get("login", null);
      if ((username != null) && (isUsernameMutable())) {
        setUsername(username);
      }
      return username;
    }
    catch (StorageException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
    }
    return null;
  }
  
  private String retrievePassword()
  {
    ISecurePreferences node = getCVSNode();
    if (node == null) {
      return null;
    }
    try
    {
      retrieveUsername();
      return node.get("password", null);
    }
    catch (StorageException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
    }
    return null;
  }
  
  public void setPassword(String password)
  {
    if (passwordFixed) {
      throw new UnsupportedOperationException();
    }
    this.password = password;
    
    previousAuthenticationFailed = false;
  }
  
  public void setUsername(String user)
  {
    if (userFixed) {
      throw new UnsupportedOperationException();
    }
    this.user = user;
  }
  
  public void setUserMuteable(boolean muteable)
  {
    userFixed = (!muteable);
  }
  
  public void setAllowCaching(boolean value)
  {
    allowCaching = value;
    if (allowCaching)
    {
      updateCache();
    }
    else
    {
      if (password == null) {
        password = retrievePassword();
      }
      removeNode();
    }
  }
  
  public void updateCache()
  {
    if ((passwordFixed) || (!allowCaching)) {
      return;
    }
    if ((password == null) && (userFixed)) {
      return;
    }
    if (updateCache(user, password)) {
      password = null;
    }
    ensurePreferencesStored();
  }
  
  private boolean updateCache(String username, String password)
  {
    ISecurePreferences node = getCVSNode();
    if (node == null) {
      return false;
    }
    try
    {
      node.put("login", username, false);
      node.put("password", password, true);
      node.flush();
    }
    catch (StorageException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
      return false;
    }
    catch (IOException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
      return false;
    }
    return true;
  }
  
  /* Error */
  public void validateConnection(IProgressMonitor monitor)
    throws CVSException
  {
    // Byte code:
    //   0: aload_1
    //   1: invokestatic 964	org/eclipse/team/internal/ccvs/core/Policy:monitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   4: astore_1
    //   5: aload_1
    //   6: aconst_null
    //   7: bipush 100
    //   9: invokeinterface 1043 3 0
    //   14: invokestatic 934	org/eclipse/core/resources/ResourcesPlugin:getWorkspace	()Lorg/eclipse/core/resources/IWorkspace;
    //   17: invokeinterface 1033 1 0
    //   22: invokestatic 1017	org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot:getCVSFolderFor	(Lorg/eclipse/core/resources/IContainer;)Lorg/eclipse/team/internal/ccvs/core/ICVSFolder;
    //   25: astore_2
    //   26: new 520	org/eclipse/team/internal/ccvs/core/client/Session
    //   29: dup
    //   30: aload_0
    //   31: aload_2
    //   32: iconst_0
    //   33: invokespecial 968	org/eclipse/team/internal/ccvs/core/client/Session:<init>	(Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;Lorg/eclipse/team/internal/ccvs/core/ICVSFolder;Z)V
    //   36: astore_3
    //   37: aload_3
    //   38: aload_1
    //   39: bipush 50
    //   41: invokestatic 965	org/eclipse/team/internal/ccvs/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   44: iconst_0
    //   45: invokevirtual 967	org/eclipse/team/internal/ccvs/core/client/Session:open	(Lorg/eclipse/core/runtime/IProgressMonitor;Z)V
    //   48: getstatic 872	org/eclipse/team/internal/ccvs/core/client/Command:VERSION	Lorg/eclipse/team/internal/ccvs/core/client/Version;
    //   51: aload_3
    //   52: aload_0
    //   53: aload_1
    //   54: bipush 50
    //   56: invokestatic 965	org/eclipse/team/internal/ccvs/core/Policy:subMonitorFor	(Lorg/eclipse/core/runtime/IProgressMonitor;I)Lorg/eclipse/core/runtime/IProgressMonitor;
    //   59: invokevirtual 969	org/eclipse/team/internal/ccvs/core/client/Version:execute	(Lorg/eclipse/team/internal/ccvs/core/client/Session;Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/eclipse/core/runtime/IStatus;
    //   62: astore 4
    //   64: aload 4
    //   66: invokeinterface 1044 1 0
    //   71: ifne +26 -> 97
    //   74: aload 4
    //   76: invokestatic 958	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   79: goto +18 -> 97
    //   82: astore 5
    //   84: aload_3
    //   85: invokevirtual 966	org/eclipse/team/internal/ccvs/core/client/Session:close	()V
    //   88: aload_1
    //   89: invokeinterface 1042 1 0
    //   94: aload 5
    //   96: athrow
    //   97: aload_3
    //   98: invokevirtual 966	org/eclipse/team/internal/ccvs/core/client/Session:close	()V
    //   101: aload_1
    //   102: invokeinterface 1042 1 0
    //   107: goto +10 -> 117
    //   110: astore_2
    //   111: aload_0
    //   112: invokevirtual 975	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:dispose	()V
    //   115: aload_2
    //   116: athrow
    //   117: return
    // Line number table:
    //   Java source line #1041	-> byte code offset #0
    //   Java source line #1042	-> byte code offset #5
    //   Java source line #1043	-> byte code offset #14
    //   Java source line #1044	-> byte code offset #26
    //   Java source line #1045	-> byte code offset #37
    //   Java source line #1047	-> byte code offset #48
    //   Java source line #1049	-> byte code offset #64
    //   Java source line #1050	-> byte code offset #74
    //   Java source line #1052	-> byte code offset #82
    //   Java source line #1053	-> byte code offset #84
    //   Java source line #1054	-> byte code offset #88
    //   Java source line #1055	-> byte code offset #94
    //   Java source line #1053	-> byte code offset #97
    //   Java source line #1054	-> byte code offset #101
    //   Java source line #1056	-> byte code offset #110
    //   Java source line #1058	-> byte code offset #111
    //   Java source line #1059	-> byte code offset #115
    //   Java source line #1061	-> byte code offset #117
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	118	0	this	CVSRepositoryLocation
    //   0	118	1	monitor	IProgressMonitor
    //   25	7	2	root	org.eclipse.team.internal.ccvs.core.ICVSFolder
    //   110	6	2	e	CVSException
    //   36	62	3	session	org.eclipse.team.internal.ccvs.core.client.Session
    //   62	13	4	status	IStatus
    //   82	13	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   48	82	82	finally
    //   0	107	110	org/eclipse/team/internal/ccvs/core/CVSException
  }
  
  public int getServerPlatform()
  {
    return serverPlatform;
  }
  
  public void setServerPlaform(int serverType)
  {
    switch (serverType)
    {
    case 1: 
    case 2: 
    case 3: 
    case 4: 
      serverPlatform = serverType;
      break;
    default: 
      serverPlatform = 0;
    }
  }
  
  public void flushUserInfo()
  {
    removeNode();
  }
  
  String[] getExtCommand(String password)
    throws IOException
  {
    String CVS_RSH = CVSProviderPlugin.getPlugin().getCvsRshCommand();
    String CVS_RSH_PARAMETERS = CVSProviderPlugin.getPlugin().getCvsRshParameters();
    String CVS_SERVER = CVSProviderPlugin.getPlugin().getCvsServer();
    if ((CVS_RSH == null) || (CVS_SERVER == null)) {
      throw new IOException(CVSMessages.EXTServerConnection_varsNotSet);
    }
    if ((CVS_RSH_PARAMETERS == null) || (CVS_RSH_PARAMETERS.length() == 0))
    {
      if (port != 0) {
        throw new IOException(CVSMessages.EXTServerConnection_invalidPort);
      }
      return new String[] { CVS_RSH, host, "-l", user, CVS_SERVER, "server" };
    }
    CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, "{user}", user);
    CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, "{password}", password);
    CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, "{host}", host);
    CVS_RSH_PARAMETERS = stringReplace(CVS_RSH_PARAMETERS, "{port}", new Integer(port).toString());
    
    List commands = new ArrayList();
    commands.add(CVS_RSH);
    StringTokenizer tokenizer = new StringTokenizer(CVS_RSH_PARAMETERS);
    while (tokenizer.hasMoreTokens())
    {
      String next = tokenizer.nextToken();
      commands.add(next);
    }
    commands.add(CVS_SERVER);
    commands.add("server");
    return (String[])commands.toArray(new String[commands.size()]);
  }
  
  private String stringReplace(String string, String oldString, String newString)
  {
    int index = string.toLowerCase().indexOf(oldString);
    if (index == -1) {
      return string;
    }
    return stringReplace(
      string.substring(0, index) + newString + string.substring(index + oldString.length()), 
      oldString, newString);
  }
  
  public String getServerMessageWithoutPrefix(String errorLine, String prefix)
  {
    String message = errorLine;
    int firstSpace = message.indexOf(' ');
    if (firstSpace != -1)
    {
      message = message.substring(firstSpace + 1);
      if (prefix.startsWith("["))
      {
        int closingBracket = message.indexOf("]: ");
        if (closingBracket == -1) {
          return null;
        }
        String realPrefix = message.substring(1, closingBracket);
        
        int space = realPrefix.indexOf(' ');
        if (space == -1) {
          return null;
        }
        if (realPrefix.indexOf(' ', space + 1) != -1) {
          return null;
        }
        if (!realPrefix.substring(space + 1).equals("aborted")) {
          return null;
        }
        message = message.substring(closingBracket + 2);
        if (message.charAt(0) == ' ') {
          message = message.substring(1);
        }
        return message;
      }
      int colon = message.indexOf(": ");
      if (colon == -1) {
        return null;
      }
      String realPrefix = message.substring(0, colon);
      if (realPrefix.indexOf(' ') != -1) {
        return null;
      }
      message = message.substring(colon + 1);
      if (message.charAt(0) == ' ') {
        message = message.substring(1);
      }
      return message;
    }
    return null;
  }
  
  public IUserAuthenticator getUserAuthenticator()
  {
    return getAuthenticator();
  }
  
  public void setUserAuthenticator(IUserAuthenticator authenticator)
  {
    authenticator = authenticator;
  }
  
  public Preferences getPreferences()
  {
    if (!hasPreferences()) {
      ensurePreferencesStored();
    }
    return internalGetPreferences();
  }
  
  private Preferences internalGetPreferences()
  {
    return getParentPreferences().node(getPreferenceName());
  }
  
  private boolean hasPreferences()
  {
    try
    {
      return getParentPreferences().nodeExists(getPreferenceName());
    }
    catch (BackingStoreException e)
    {
      CVSProviderPlugin.log(4, NLS.bind(CVSMessages.CVSRepositoryLocation_74, new String[] { getLocation(true) }), e);
    }
    return false;
  }
  
  private String getPreferenceName()
  {
    return getLocation().replace('/', '%').replace(':', '%');
  }
  
  public void storePreferences()
  {
    Preferences prefs = internalGetPreferences();
    
    prefs.put("location", getLocation());
    flushPreferences();
  }
  
  private void flushPreferences()
  {
    try
    {
      internalGetPreferences().flush();
    }
    catch (BackingStoreException e)
    {
      CVSProviderPlugin.log(4, NLS.bind(CVSMessages.CVSRepositoryLocation_75, new String[] { getLocation(true) }), e);
    }
  }
  
  private void ensurePreferencesStored()
  {
    if (!hasPreferences()) {
      storePreferences();
    }
  }
  
  public boolean getUserInfoCached()
  {
    ISecurePreferences node = getCVSNode();
    if (node == null) {
      return false;
    }
    try
    {
      String password = node.get("password", null);
      return password != null;
    }
    catch (StorageException e)
    {
      CVSProviderPlugin.log(4, e.getMessage(), e);
    }
    return false;
  }
  
  private ISecurePreferences getCVSNode()
  {
    ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
    if (preferences == null) {
      return null;
    }
    String accountName = EncodingUtils.encodeSlashes(getLocation(true));
    String path = "/CVS/" + accountName;
    try
    {
      return preferences.node(path);
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
    return null;
  }
}

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

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;

public class CVSServerException
  extends CVSException
{
  private static final long serialVersionUID = 1L;
  
  public boolean isNoTagException()
  {
    IStatus status = getStatus();
    if (!status.isMultiStatus()) {
      return false;
    }
    IStatus[] children = ((MultiStatus)status).getChildren();
    for (int i = 0; i < children.length; i++) {
      if (children[i].getCode() == -11) {
        return true;
      }
    }
    return false;
  }
  
  public boolean containsErrors()
  {
    IStatus status = getStatus();
    if (!status.isMultiStatus()) {
      return status.getSeverity() == 4;
    }
    IStatus[] children = ((MultiStatus)status).getChildren();
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