Package org.nasutekds.guitools.controlpanel.util

Examples of org.nasutekds.guitools.controlpanel.util.ConfigReader


      if (lastRemoteHostName != null)
      {
        desc.setHostname(lastRemoteHostName);
      }
    }
    ConfigReader reader;

    ServerDescriptor.ServerStatus status = null;
    for (Task task : getTasks())
    {
      if ((task.getType() == Task.Type.START_SERVER) &&
          (task.getState() == Task.State.RUNNING) &&
          isRunningOnServer(desc, task))
      {
        status = ServerDescriptor.ServerStatus.STARTING;
      }
      else if ((task.getType() == Task.Type.STOP_SERVER) &&
          (task.getState() == Task.State.RUNNING) &&
          isRunningOnServer(desc, task))
      {
        status = ServerDescriptor.ServerStatus.STOPPING;
      }
    }
    if (status != null)
    {
      desc.setStatus(status);
      if (status == ServerDescriptor.ServerStatus.STOPPING)
      {
        if (ctx != null)
        {
          try
          {
            ctx.close();
          }
          catch (Throwable t)
          {
          }
          this.ctx = null;
        }
        if (userDataCtx != null)
        {
          if (connectionPool.isConnectionRegistered(userDataCtx))
          {
            try
            {
              connectionPool.unregisterConnection(userDataCtx);
            }
            catch (Throwable t)
            {
            }
          }
          try
          {
            userDataCtx.close();
          }
          catch (Throwable t)
          {
          }
          userDataCtx = null;
        }
      }
      if (isLocal)
      {
        reader = createNewConfigFromFileReader();
        ((ConfigFromFile)reader).readConfiguration();
      }
      else
      {
        reader = null;
      }
      desc.setAuthenticated(false);
    }
    else if (!isLocal ||
        Utilities.isServerRunning(new File(desc.getInstancePath())))
    {
      desc.setStatus(ServerDescriptor.ServerStatus.STARTED);

      if ((ctx == null) && (lastWorkingBindDN != null))
      {
        // Try with previous credentials.
        try
        {
          if (isLocal)
          {
            ctx = Utilities.getAdminDirContext(this, lastWorkingBindDN,
              lastWorkingBindPwd);
          }
          else if (lastRemoteAdministrationURL != null)
          {
            ctx = Utils.createLdapsContext(lastRemoteAdministrationURL,
                lastWorkingBindDN,
                lastWorkingBindPwd,
                getConnectTimeout(), null,
                getTrustManager());
          }
        }
        catch (ConfigReadException cre)
        {
//        Ignore: we will ask the user for credentials.
        }
        catch (NamingException ne)
        {
          // Ignore: we will ask the user for credentials.
        }
        if (ctx != null)
        {
          this.ctx = ctx;
        }
      }

      if (isLocal && (ctx == null))
      {
        reader = createNewConfigFromFileReader();
        ((ConfigFromFile)reader).readConfiguration();
      }
      else
      {
        if (!isLocal && (ctx == null))
        {
          desc.setStatus(ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
          reader = null;
        }
        else
        {
          reader = createNewConfigFromDirContextReader();
          ((ConfigFromDirContext)reader).readConfiguration(ctx);

          boolean connectionWorks = checkConnections(ctx, userDataCtx);
          if (!connectionWorks)
          {
            if (isLocal)
            {
              // Try with off-line info
              reader = createNewConfigFromFileReader();
              ((ConfigFromFile)reader).readConfiguration();
            }
            else
            {
              desc.setStatus(
                  ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
              reader = null;
            }
            try
            {
              ctx.close();
            }
            catch (Throwable t)
            {
            }
            this.ctx = null;
            if (connectionPool.isConnectionRegistered(userDataCtx))
            {
              try
              {
                connectionPool.unregisterConnection(userDataCtx);
              }
              catch (Throwable t)
              {
              }
            }
            try
            {
              userDataCtx.close();
            }
            catch (Throwable t)
            {
            }
            userDataCtx = null;
          }
        }
      }
      if (reader != null)
      {
        desc.setAuthenticated(reader instanceof ConfigFromDirContext);
        desc.setJavaVersion(reader.getJavaVersion());
        desc.setOpenConnections(reader.getOpenConnections());
        desc.setTaskEntries(reader.getTaskEntries());
        if (reader instanceof ConfigFromDirContext)
        {
          ConfigFromDirContext rCtx = (ConfigFromDirContext)reader;
          desc.setRootMonitor(rCtx.getRootMonitor());
          desc.setEntryCachesMonitor(rCtx.getEntryCaches());
View Full Code Here

TOP

Related Classes of org.nasutekds.guitools.controlpanel.util.ConfigReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.