Example usage for java.util.logging Level CONFIG

List of usage examples for java.util.logging Level CONFIG

Introduction

In this page you can find the example usage for java.util.logging Level CONFIG.

Prototype

Level CONFIG

To view the source code for java.util.logging Level CONFIG.

Click Source Link

Document

CONFIG is a message level for static configuration messages.

Usage

From source file:com.google.enterprise.connector.otex.LivelinkConnectorType.java

/**
 * {@inheritDoc}//from  ww w.j a va  2 s. co  m
 * <p>
 * This method will use the provided configuration
 * information to attempt to instantiate a LivelinkConnector
 * and call its <code>login</code> method. This allows this
 * method to determine whether the configuration information
 * provided is sufficient to connect to Livelink for
 * traversal. It does not attempt to validate the separate
 * authentication configuration, if any, since no separate
 * user information can be provided, and it's possible that
 * the traversal username isn't one that can be authenticated
 * using the authentication properties. For example,
 * traversal might be done as a Livelink admin user using the
 * Livelink server port, while authentication is done using a
 * web server. The Livelink admin user may not be a defined
 * user in the web server's authentication scheme.
 */
/*
 * TODO: Add init method and parameter validation to
 * LivelinkConnector.
 */
@Override
public ConfigureResponse validateConfig(Map<String, String> configData, Locale locale,
        ConnectorFactory connectorFactory) {
    if (LOGGER.isLoggable(Level.CONFIG)) {
        LOGGER.config("validateConfig data: " + getMaskedMap(configData));
        LOGGER.config("validateConfig locale: " + locale);
    }

    try {
        ResourceBundle bundle = getResources(locale);
        FormContext formContext = new FormContext(configData);

        // We want to change the passed in properties, but avoid
        // changing the original configData parameter.
        HashMap<String, String> config = new HashMap<String, String>(configData);
        config.put(VERSION_PROPERTY, VERSION_NUMBER);

        // If the user supplied a URL as the server, pull out the host name.
        smartConfig(config);

        // Update the properties to copy the enabler properties to
        // the uses.
        Boolean changeHttp = changeFormDisplay(config, "useHttpTunneling", "enableHttpTunneling");
        Boolean changeAuth = changeFormDisplay(config, "useSeparateAuthentication",
                "enableSeparateAuthentication");

        // Skip validation if one of the groups has been enabled.
        // The configuration is probably incomplete in this case,
        // and at least one more call to validateConfig will be
        // made, so we will eventually validate any of the other
        // changes that have been made this time.
        if (changeHttp == Boolean.TRUE || changeAuth == Boolean.TRUE) {
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.finest(
                        "SKIPPING VALIDATION: changeHttp = " + changeHttp + "; changeAuth = " + changeAuth);
            }
            return getResponse(null, bundle, config, formContext);
        }

        // Instantiate a LivelinkConnector to check connectivity.
        LivelinkConnector conn = null;
        try {
            conn = (LivelinkConnector) connectorFactory.makeConnector(config);
        } catch (Throwable t) {
            LOGGER.log(Level.WARNING, "Failed to create connector", t);
            t = t.getCause();
            while (t != null) {
                if (t instanceof PropertyBatchUpdateException) {
                    PropertyAccessException[] pae = ((PropertyBatchUpdateException) t)
                            .getPropertyAccessExceptions();
                    for (int i = 0; i < pae.length; i++)
                        LOGGER.warning(pae[i].getMessage());
                } else
                    LOGGER.warning(t.toString());
                t = t.getCause();
            }
            return getResponse(failedInstantiation(bundle), bundle, config, formContext);
        }

        if (!ignoreDisplayUrlErrors(config)) {
            try {
                String url = config.get("displayUrl");
                LOGGER.finer("Validating display URL " + url);
                validateUrl(url, bundle);
                url = conn.getPublicContentDisplayUrl();
                LOGGER.finer("Validating public content display URL " + url);
                validateUrl(url, bundle);
            } catch (UrlConfigurationException e) {
                LOGGER.log(Level.WARNING, "Error in configuration", e);
                formContext.setHideIgnoreDisplayUrlErrors(false);
                return getResponse(errorInConfiguration(bundle, e.getLocalizedMessage()), bundle, config,
                        formContext);
            }
        }

        try {
            conn.login();
        } catch (LivelinkException e) {
            // XXX: Should this be an errorInConfiguration error?
            return getResponse(e.getLocalizedMessage(bundle), bundle, config, formContext);
        } catch (ConfigurationException c) {
            LOGGER.log(Level.WARNING, "Error in configuration", c);
            return getResponse(errorInConfiguration(bundle, c.getLocalizedMessage(bundle)), bundle, config,
                    formContext);
        } catch (Throwable t) {
            LOGGER.log(Level.WARNING, "Error in configuration", t);
            return getResponse(errorInConfiguration(bundle, t.getLocalizedMessage()), bundle, config,
                    formContext);
        }

        // Return the OK configuration.
        return getResponse(null, null, config, null);
    } catch (Throwable t) {
        // One last catch to be sure we return a message.
        LOGGER.log(Level.SEVERE, "Failed to create config form", t);
        return getErrorResponse(getExceptionMessages(null, t));
    }
}

From source file:org.eclipse.birt.report.engine.api.ReportRunner.java

/**
 * new a EngineConfig and config it with user's setting
 * //w ww  . ja v  a2 s  . c om
 */
protected EngineConfig createEngineConfig() {
    EngineConfig config = new EngineConfig();

    String resourcePath = (String) params.get("resourceDir");
    if (resourcePath != null)
        config.setResourcePath(resourcePath.trim());

    String tempDir = (String) params.get("tempDir");
    if (tempDir != null)
        config.setTempDir(tempDir.trim());

    String logDir = (String) params.get("logDir");
    String logLevel = (String) params.get("logLevel");
    Level level = null;
    if (logLevel != null) {
        logLevel = logLevel.trim();
        if ("all".equalsIgnoreCase(logLevel)) {
            level = Level.ALL;
        } else if ("config".equalsIgnoreCase(logLevel)) {
            level = Level.CONFIG;
        } else if ("fine".equalsIgnoreCase(logLevel)) {
            level = Level.FINE;
        } else if ("finer".equalsIgnoreCase(logLevel)) {
            level = Level.FINER;
        } else if ("finest".equalsIgnoreCase(logLevel)) {
            level = Level.FINEST;
        } else if ("info".equalsIgnoreCase(logLevel)) {
            level = Level.INFO;
        } else if ("off".equalsIgnoreCase(logLevel)) {
            level = Level.OFF;
        } else if ("severe".equalsIgnoreCase(logLevel)) {
            level = Level.SEVERE;
        } else if ("warning".equalsIgnoreCase(logLevel)) {
            level = Level.WARNING;
        }
    }
    String logD = (logDir == null) ? config.getLogDirectory() : logDir;
    Level logL = (level == null) ? config.getLogLevel() : level;
    config.setLogConfig(logD, logL);

    String logFile = (String) params.get("logFile");
    if (logFile != null)
        config.setLogFile(logFile.trim());

    String scripts = (String) params.get("scriptPath");
    HashMap map = new HashMap();
    map.put(EngineConstants.PROJECT_CLASSPATH_KEY, scripts);
    config.setAppContext(map);

    return config;
}

From source file:com.delcyon.capo.Configuration.java

@SuppressWarnings({ "unchecked", "static-access" })
public Configuration(String... programArgs) throws Exception {

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    documentBuilder = documentBuilderFactory.newDocumentBuilder();

    options = new Options();
    // the enum this is a little complicated, but it gives us a nice
    // centralized place to put all of the system parameters
    // and lets us iterate of the list of options and preferences
    PREFERENCE[] preferences = PREFERENCE.values();
    for (PREFERENCE preference : preferences) {
        // not the most elegant, but there is no default constructor, but
        // the has arguments value is always there
        OptionBuilder optionBuilder = OptionBuilder.hasArg(preference.hasArgument);
        if (preference.hasArgument == true) {
            String[] argNames = preference.arguments;
            for (String argName : argNames) {
                optionBuilder = optionBuilder.withArgName(argName);
            }//  www  .  j  a  v  a  2  s .c o  m
        }

        optionBuilder = optionBuilder.withDescription(preference.getDescription());
        optionBuilder = optionBuilder.withLongOpt(preference.getLongOption());
        options.addOption(optionBuilder.create(preference.getOption()));

        preferenceHashMap.put(preference.toString(), preference);
    }

    //add dynamic options

    Set<String> preferenceProvidersSet = CapoApplication.getAnnotationMap()
            .get(PreferenceProvider.class.getCanonicalName());
    if (preferenceProvidersSet != null) {
        for (String className : preferenceProvidersSet) {
            Class preferenceClass = Class.forName(className).getAnnotation(PreferenceProvider.class)
                    .preferences();
            if (preferenceClass.isEnum()) {
                Object[] enumObjects = preferenceClass.getEnumConstants();
                for (Object enumObject : enumObjects) {

                    Preference preference = (Preference) enumObject;
                    //filter out any preferences that don't belong on this server or client.
                    if (preference.getLocation() != Location.BOTH) {
                        if (CapoApplication.isServer() == true && preference.getLocation() == Location.CLIENT) {
                            continue;
                        } else if (CapoApplication.isServer() == false
                                && preference.getLocation() == Location.SERVER) {
                            continue;
                        }
                    }
                    preferenceHashMap.put(preference.toString(), preference);
                    boolean hasArgument = false;
                    if (preference.getArguments() == null || preference.getArguments().length == 0) {
                        hasArgument = false;
                    } else {
                        hasArgument = true;
                    }

                    OptionBuilder optionBuilder = OptionBuilder.hasArg(hasArgument);
                    if (hasArgument == true) {
                        String[] argNames = preference.getArguments();
                        for (String argName : argNames) {
                            optionBuilder = optionBuilder.withArgName(argName);
                        }
                    }

                    optionBuilder = optionBuilder.withDescription(preference.getDescription());
                    optionBuilder = optionBuilder.withLongOpt(preference.getLongOption());
                    options.addOption(optionBuilder.create(preference.getOption()));
                }

            }
        }
    }

    // create parser
    CommandLineParser commandLineParser = new GnuParser();
    this.commandLine = commandLineParser.parse(options, programArgs);

    Preferences systemPreferences = Preferences
            .systemNodeForPackage(CapoApplication.getApplication().getClass());
    String capoDirString = null;
    while (true) {
        capoDirString = systemPreferences.get(PREFERENCE.CAPO_DIR.longOption, null);
        if (capoDirString == null) {

            systemPreferences.put(PREFERENCE.CAPO_DIR.longOption, PREFERENCE.CAPO_DIR.defaultValue);
            capoDirString = PREFERENCE.CAPO_DIR.defaultValue;
            try {
                systemPreferences.sync();
            } catch (BackingStoreException e) {
                //e.printStackTrace();            
                if (systemPreferences.isUserNode() == false) {
                    System.err.println("Problem with System preferences, trying user's");
                    systemPreferences = Preferences
                            .userNodeForPackage(CapoApplication.getApplication().getClass());
                    continue;
                } else //just bail out
                {
                    throw e;
                }

            }
        }
        break;
    }

    disableAutoSync = hasOption(PREFERENCE.DISABLE_CONFIG_AUTOSYNC);

    File capoDirFile = new File(capoDirString);
    if (capoDirFile.exists() == false) {
        if (disableAutoSync == false) {
            capoDirFile.mkdirs();
        }
    }
    File configDir = new File(capoDirFile, PREFERENCE.CONFIG_DIR.defaultValue);
    if (configDir.exists() == false) {
        if (disableAutoSync == false) {
            configDir.mkdirs();
        }
    }

    if (disableAutoSync == false) {
        capoConfigFile = new File(configDir, CONFIG_FILENAME);
        if (capoConfigFile.exists() == false) {

            Document configDocument = CapoApplication.getDefaultDocument("config.xml");

            FileOutputStream configFileOutputStream = new FileOutputStream(capoConfigFile);
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.transform(new DOMSource(configDocument), new StreamResult(configFileOutputStream));
            configFileOutputStream.close();
        }

        configDocument = documentBuilder.parse(capoConfigFile);
    } else //going memory only, because of disabled auto sync
    {
        configDocument = CapoApplication.getDefaultDocument("config.xml");
    }
    if (configDocument instanceof CDocument) {
        ((CDocument) configDocument).setSilenceEvents(true);
    }
    loadPreferences();
    preferenceValueHashMap.put(PREFERENCE.CAPO_DIR.longOption, capoDirString);
    //print out preferences
    //this also has the effect of persisting all of the default values if a values doesn't already exist
    for (PREFERENCE preference : preferences) {
        if (getValue(preference) != null) {
            CapoApplication.logger.log(Level.CONFIG, preference.longOption + "='" + getValue(preference) + "'");
        }
    }

    CapoApplication.logger.setLevel(Level.parse(getValue(PREFERENCE.LOGGING_LEVEL)));
}

From source file:org.schemaspy.Config.java

/**
 * Set the level of logging to perform.<p/>
 * The levels in descending order are:/*  w  w  w  .j av  a  2 s. c  o  m*/
 * <ul>
 * <li><code>severe</code> (highest - least detail)
 * <li><code>warning</code> (default)
 * <li><code>info</code>
 * <li><code>config</code>
 * <li><code>fine</code>
 * <li><code>finer</code>
 * <li><code>finest</code>  (lowest - most detail)
 * </ul>
 *
 * @param logLevel
 */
public void setLogLevel(String logLevel) {
    if (logLevel == null) {
        this.logLevel = Level.WARNING;
        return;
    }

    Map<String, Level> levels = new LinkedHashMap<>();
    levels.put("severe", Level.SEVERE);
    levels.put("warning", Level.WARNING);
    levels.put("info", Level.INFO);
    levels.put("config", Level.CONFIG);
    levels.put("fine", Level.FINE);
    levels.put("finer", Level.FINER);
    levels.put("finest", Level.FINEST);

    this.logLevel = levels.get(logLevel.toLowerCase());
    if (this.logLevel == null) {
        throw new InvalidConfigurationException(
                "Invalid logLevel: '" + logLevel + "'. Must be one of: " + levels.keySet());
    }
}

From source file:org.quickserver.net.qsadmin.CommandHandler.java

public void handleCommand(ClientHandler handler, String command) throws SocketTimeoutException, IOException {
    if (command == null || command.trim().equals("")) {
        handler.sendClientMsg("-ERR No command");
        return;/*from   w  ww  .  j a v  a2 s. co m*/
    }

    //v1.2 - plugin
    if (plugin != null && plugin.handleCommand(handler, command)) {
        logger.fine("Handled by plugin.");
        return;
    }
    QSAdminServer adminServer = (QSAdminServer) handler.getServer().getStoreObjects()[2];

    StringTokenizer st = new StringTokenizer(command, " ");
    String cmd = null;
    cmd = st.nextToken().toLowerCase();
    String param[] = new String[st.countTokens()];

    QuickServer target = null;
    for (int i = 0; st.hasMoreTokens(); i++) {
        param[i] = st.nextToken();
    }

    if (command.equals("start console")) { /*v1.4.5*/
        QSAdminShell.getInstance((QuickServer) handler.getServer().getStoreObjects()[0], null);
        handler.sendClientMsg("+OK QSAdminShell is started.");
        return;
    } else if (command.equals("stop console")) { /*v1.4.5*/
        QSAdminShell shell = QSAdminShell.getInstance(null, null);
        if (shell != null) {
            try {
                shell.stopShell();
            } catch (Exception err) {
                handler.sendClientMsg("-ERR Error stopping QSAdminShell: " + err);
            }
            handler.sendClientMsg("+OK QSAdminShell is stopped.");
        } else {
            handler.sendClientMsg("-ERR QSAdminShell is not running.");
        }
        return;
    } else if (cmd.equals("jvm")) {/*2.0.0*/
        /*
           jvm dumpHeap
           jvm dumpJmapHisto file
           jvm dumpJmapHisto log
           jvm threadDump file
           jvm threadDump log
           jvm dumpJStack file
           jvm dumpJStack log
         */

        if (param.length == 0) {
            handler.sendClientMsg("-ERR " + "Use jvm help");
            return;
        }

        if (param[0].equals("dumpHeap")) {
            File file = getFile("dumpHeap", ".bin");
            JvmUtil.dumpHeap(file.getAbsolutePath(), true);
            handler.sendClientMsg("+OK File " + file.getAbsolutePath());
        } else if (param[0].equals("dumpJmapHisto")) {
            if (param.length < 2)/*dumpJmapHisto file*/ {
                handler.sendClientMsg("-ERR " + "insufficient param");
                return;
            }

            if (param[1].equals("file")) {
                File file = getFile("dumpJmapHisto", ".txt");

                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.dumpJmapHisto(file.getAbsolutePath());

                handler.sendClientMsg("Done - File " + file.getAbsolutePath());
                handler.sendClientMsg(".");
            } else if (param[1].equals("log")) {
                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.dumpJmapHistoToLog();

                handler.sendClientMsg("Done - Dumped to jdk log file");
                handler.sendClientMsg(".");
            } else {
                handler.sendClientMsg("-ERR " + "bad param");
                return;
            }
        } else if (param[0].equals("threadDump")) {
            if (param.length < 2)/*threadDump file*/ {
                handler.sendClientMsg("-ERR " + "insufficient param");
                return;
            }

            if (param[1].equals("file")) {
                File file = getFile("threadDump", ".txt");

                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.threadDump(file.getAbsolutePath());

                handler.sendClientMsg("Done - File " + file.getAbsolutePath());
                handler.sendClientMsg(".");
            } else if (param[1].equals("log")) {
                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.threadDumpToLog();

                handler.sendClientMsg("Done - Dumped to jdk log file");
                handler.sendClientMsg(".");
            } else {
                handler.sendClientMsg("-ERR " + "bad param");
                return;
            }
        } else if (param[0].equals("dumpJStack")) {
            if (param.length < 2)/*dumpJStack file*/ {
                handler.sendClientMsg("-ERR " + "insufficient param");
                return;
            }

            if (param[1].equals("file")) {
                File file = getFile("dumpJStack", ".txt");

                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.dumpJStack(file.getAbsolutePath());

                handler.sendClientMsg("Done - File " + file.getAbsolutePath());
                handler.sendClientMsg(".");
            } else if (param[1].equals("log")) {
                handler.sendClientMsg("+OK info follows");
                handler.sendClientMsg("Starting.. ");

                JvmUtil.dumpJStackToLog();

                handler.sendClientMsg("Done - Dumped to jdk log file");
                handler.sendClientMsg(".");
            } else {
                handler.sendClientMsg("-ERR " + "bad param");
                return;
            }
        } else if (param[0].equals("help")) {
            handler.sendClientMsg("+OK info follows");

            handler.sendClientMsg("jvm dumpJmapHisto file");
            handler.sendClientMsg("jvm dumpJStack file");

            handler.sendClientMsg(" ");

            handler.sendClientMsg("jvm threadDump file");
            handler.sendClientMsg("jvm dumpHeap");

            handler.sendClientMsg(" ");

            handler.sendClientMsg("jvm threadDump log");
            handler.sendClientMsg("jvm dumpJmapHisto log");
            handler.sendClientMsg("jvm dumpJStack log");

            handler.sendClientMsg(".");
            return;
        } else {
            handler.sendClientMsg("-ERR " + "bad param use jvm help");
        }
        return;
    }

    if (param.length > 0) {
        if (param[0].equals("server"))
            target = (QuickServer) handler.getServer().getStoreObjects()[0];
        else if (param[0].equals("self"))
            target = handler.getServer();
        else {
            handler.sendClientMsg("-ERR Bad <<target>> : " + param[0]);
            return;
        }
    }

    if (cmd.equals("help")) {
        handler.sendClientMsg(
                "+OK info follows" + "\r\n" + "Refer Api Docs for org.quickserver.net.qsadmin.CommandHandler");
        handler.sendClientMsg(".");
        return;
    } else if (cmd.equals("quit")) {
        handler.sendClientMsg("+OK Bye ;-)");
        handler.closeConnection();
        return;
    } else if (cmd.equals("shutdown")) {
        try {
            QuickServer controlServer = (QuickServer) handler.getServer().getStoreObjects()[0];
            if (controlServer != null && controlServer.isClosed() == false) {
                controlServer.stopServer();
            }
            if (handler.getServer() != null && handler.getServer().isClosed() == false) {
                handler.getServer().stopServer();
            }

            QSAdminShell shell = QSAdminShell.getInstance(null, null);
            if (shell != null) {
                try {
                    shell.stopShell();
                } catch (Exception err) {
                    logger.warning("Error stoping shell: " + err);
                }
            }

            handler.sendClientMsg("+OK Done");
        } catch (AppException e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("version")) {
        handler.sendClientMsg("+OK " + QuickServer.getVersion());
        return;
    } else if (cmd.equals("kill") || cmd.equals("exit")) /*v1.3,v1.3.2*/ {
        StringBuilder errBuf = new StringBuilder();
        QuickServer controlServer = (QuickServer) handler.getServer().getStoreObjects()[0];
        int exitCode = 0;

        if (param.length != 0) {
            try {
                exitCode = Integer.parseInt(param[0]);
            } catch (Exception nfe) {
                /*ignore*/}
        }

        try {
            if (controlServer != null && controlServer.isClosed() == false) {
                try {
                    controlServer.stopServer();
                } catch (AppException ae) {
                    errBuf.append(ae.toString());
                }
            }
            if (handler.getServer() != null && handler.getServer().isClosed() == false) {
                try {
                    handler.getServer().stopServer();
                } catch (AppException ae) {
                    errBuf.append(ae.toString());
                }
            }

            QSAdminShell shell = QSAdminShell.getInstance(null, null);
            if (shell != null) {
                try {
                    shell.stopShell();
                } catch (Exception err) {
                    errBuf.append(err.toString());
                }
            }

            if (errBuf.length() == 0)
                handler.sendClientMsg("+OK Done");
            else
                handler.sendClientMsg("+OK Done, Errors: " + errBuf.toString());
        } catch (Exception e) {
            handler.sendClientMsg("-ERR Exception : " + e + "\r\n" + errBuf.toString());
            if (exitCode == 0)
                exitCode = 1;
        } finally {
            try {
                if (controlServer != null)
                    controlServer.closeAllPools();
                if (handler.getServer() != null)
                    handler.getServer().closeAllPools();
            } catch (Exception er) {
                logger.warning("Error closing pools: " + er);
            }
            System.exit(exitCode);
        }
        return;
    } else if (cmd.equals("memoryinfo")) { /*v1.3.2*/
        //Padding : Total:Used:Max
        float totalMemory = (float) runtime.totalMemory();
        float usedMemory = totalMemory - (float) runtime.freeMemory();
        float maxMemory = (float) runtime.maxMemory();
        handler.sendClientMsg("+OK " + totalMemory + ":" + usedMemory + ":" + maxMemory);
        return;
    } else if (cmd.equals("systeminfo")) { /*v1.4.5*/
        handler.sendClientMsg("+OK info follows");
        handler.sendClientMsg(MyString.getSystemInfo(target.getVersion()));
        handler.sendClientMsg(".");
        return;
    } else if (param.length == 0) {
        handler.sendClientMsg("-ERR Bad Command or No Param : ->" + cmd + "<-");
        return;
    }

    if (cmd.equals("start")) {
        try {
            target.startServer();
            handler.sendClientMsg("+OK Server Started");
        } catch (AppException e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("stop")) {
        try {
            target.stopServer();
            handler.sendClientMsg("+OK Server Stopped");
        } catch (AppException e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("restart")) {
        try {
            target.stopServer();
            target.startServer();
            handler.sendClientMsg("+OK Server Restarted");
        } catch (AppException e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("info")) {
        handler.sendClientMsg("+OK info follows");
        handler.sendClientMsg("" + target);
        handler.sendClientMsg("Running : " + !target.isClosed());
        handler.sendClientMsg("PID : " + QuickServer.getPID());
        handler.sendClientMsg("Max Client Allowed  : " + target.getMaxConnection());
        handler.sendClientMsg("No Client Connected : " + target.getClientCount());
        if (target.isRunningSecure() == true) {
            handler.sendClientMsg("Running in secure mode : " + target.getSecure().getProtocol());
        } else {
            handler.sendClientMsg("Running in non-secure mode");
        }
        handler.sendClientMsg("Server Mode : " + target.getBasicConfig().getServerMode());
        handler.sendClientMsg("QuickServer v : " + QuickServer.getVersion());
        handler.sendClientMsg("Uptime : " + target.getUptime());
        handler.sendClientMsg(".");
        return;
    } else if (cmd.equals("noclient")) {
        handler.sendClientMsg("+OK " + target.getClientCount());
        return;
    } else if (cmd.equals("running")) {
        handler.sendClientMsg("+OK " + !target.isClosed());
        return;
    } else if (cmd.equals("suspendservice")) {
        handler.sendClientMsg("+OK " + target.suspendService());
        return;
    } else if (cmd.equals("resumeservice")) {
        handler.sendClientMsg("+OK " + target.resumeService());
        return;
    } else if (cmd.equals("client-thread-pool-info")) /*v1.3.2*/ {
        temp.setLength(0);//used:idle
        if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) {
            temp.append(target.getClientPool().getNumActive());
            temp.append(':');
            temp.append(target.getClientPool().getNumIdle());
        } else {
            temp.append("0:0");
        }
        handler.sendClientMsg("+OK " + temp.toString());
        return;
    } else if (cmd.equals("client-thread-pool-dump")) /*v1.4.5*/ {
        if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) {
            handler.sendClientMsg("+OK info follows");
            ClientThread ct = null;
            synchronized (target.getClientPool().getObjectToSynchronize()) {
                Iterator iterator = target.getClientPool().getAllClientThread();
                while (iterator.hasNext()) {
                    ct = (ClientThread) iterator.next();
                    handler.sendClientMsg(ct.toString());
                }
            }
            handler.sendClientMsg(".");
        } else {
            handler.sendClientMsg("-ERR Pool Closed");
        }
        return;
    } else if (cmd.equals("client-handler-pool-dump")) /*v1.4.6*/ {

        ObjectPool objectPool = target.getClientHandlerPool();

        if (PoolHelper.isPoolOpen(objectPool) == true) {
            if (QSObjectPool.class.isInstance(objectPool) == false) {
                handler.sendClientMsg("-ERR System Error!");
            }

            ClientIdentifier clientIdentifier = target.getClientIdentifier();
            ClientHandler foundClientHandler = null;
            synchronized (clientIdentifier.getObjectToSynchronize()) {
                Iterator iterator = clientIdentifier.findAllClient();
                handler.sendClientMsg("+OK info follows");
                while (iterator.hasNext()) {
                    foundClientHandler = (ClientHandler) iterator.next();
                    handler.sendClientMsg(foundClientHandler.info());
                }
            }
            handler.sendClientMsg(".");
        } else {
            handler.sendClientMsg("-ERR Pool Closed");
        }
        return;
    } else if (cmd.equals("client-data-pool-info")) /*v1.3.2*/ {
        temp.setLength(0);//used:idle
        if (target.getClientDataPool() != null) {
            if (PoolHelper.isPoolOpen(target.getClientDataPool()) == true) {
                temp.append(target.getClientDataPool().getNumActive());
                temp.append(':');
                temp.append(target.getClientDataPool().getNumIdle());
                handler.sendClientMsg("+OK " + temp.toString());
            } else {
                handler.sendClientMsg("-ERR Client Data Pool Closed");
            }
        } else {
            handler.sendClientMsg("-ERR No Client Data Pool");
        }
        return;
    } else if (cmd.equals("byte-buffer-pool-info")) /*v1.4.6*/ {
        temp.setLength(0);//used:idle
        if (target.getByteBufferPool() != null) {
            if (PoolHelper.isPoolOpen(target.getByteBufferPool()) == true) {
                temp.append(target.getByteBufferPool().getNumActive());
                temp.append(':');
                temp.append(target.getByteBufferPool().getNumIdle());
                handler.sendClientMsg("+OK " + temp.toString());
            } else {
                handler.sendClientMsg("-ERR ByteBuffer Pool Closed");
            }
        } else {
            handler.sendClientMsg("-ERR No ByteBuffer Pool");
        }
        return;
    } else if (cmd.equals("all-pool-info")) /*v1.4.5*/ {
        handler.sendClientMsg("+OK info follows");
        temp.setLength(0);//used:idle

        if (PoolHelper.isPoolOpen(target.getClientPool().getObjectPool()) == true) {
            temp.append("Client Thread Pool - ");
            temp.append("Num Active: ");
            temp.append(target.getClientPool().getNumActive());
            temp.append(", Num Idle: ");
            temp.append(target.getClientPool().getNumIdle());
            temp.append(", Max Idle: ");
            temp.append(target.getClientPool().getPoolConfig().getMaxIdle());
            temp.append(", Max Active: ");
            temp.append(target.getClientPool().getPoolConfig().getMaxActive());
        } else {
            temp.append("Byte Buffer Pool - Closed");
        }
        handler.sendClientMsg(temp.toString());
        temp.setLength(0);

        if (PoolHelper.isPoolOpen(target.getClientHandlerPool()) == true) {
            temp.append("Client Handler Pool - ");
            temp.append("Num Active: ");
            temp.append(target.getClientHandlerPool().getNumActive());
            temp.append(", Num Idle: ");
            temp.append(target.getClientHandlerPool().getNumIdle());
            temp.append(", Max Idle: ");
            temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig()
                    .getMaxIdle());
            temp.append(", Max Active: ");
            temp.append(target.getBasicConfig().getObjectPoolConfig().getClientHandlerObjectPoolConfig()
                    .getMaxActive());
        } else {
            temp.append("Client Handler Pool - Closed");
        }
        handler.sendClientMsg(temp.toString());
        temp.setLength(0);

        if (target.getByteBufferPool() != null) {
            if (PoolHelper.isPoolOpen(target.getByteBufferPool()) == true) {
                temp.append("ByteBuffer Pool - ");
                temp.append("Num Active: ");
                temp.append(target.getByteBufferPool().getNumActive());
                temp.append(", Num Idle: ");
                temp.append(target.getByteBufferPool().getNumIdle());
                temp.append(", Max Idle: ");
                temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig()
                        .getMaxIdle());
                temp.append(", Max Active: ");
                temp.append(target.getBasicConfig().getObjectPoolConfig().getByteBufferObjectPoolConfig()
                        .getMaxActive());
            } else {
                temp.append("Byte Buffer Pool - Closed");
            }
        } else {
            temp.append("Byte Buffer Pool - Not Used");
        }
        handler.sendClientMsg(temp.toString());
        temp.setLength(0);

        if (target.getClientDataPool() != null) {
            if (PoolHelper.isPoolOpen(target.getClientDataPool()) == true) {
                temp.append("Client Data Pool - ");
                temp.append("Num Active: ");
                temp.append(target.getClientDataPool().getNumActive());
                temp.append(", Num Idle: ");
                temp.append(target.getClientDataPool().getNumIdle());
                temp.append(", Max Idle: ");
                temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig()
                        .getMaxIdle());
                temp.append(", Max Active: ");
                temp.append(target.getBasicConfig().getObjectPoolConfig().getClientDataObjectPoolConfig()
                        .getMaxActive());
            } else {
                temp.append("Client Data Pool - Closed");
            }
        } else {
            temp.append("Client Data Pool - Not Used");
        }
        handler.sendClientMsg(temp.toString());
        temp.setLength(0);

        handler.sendClientMsg(".");
        return;
    } else if (cmd.equals("set")) {
        if (param.length < 3)/*target,key,value*/ {
            handler.sendClientMsg("-ERR " + "insufficient param");
            return;
        }
        if (param[2].equals("null"))
            param[2] = null;
        try {
            if (param[1].equals("maxClient")) {
                long no = Long.parseLong(param[2]);
                target.setMaxConnection(no);
            } else if (param[1].equals("maxClientMsg")) {
                target.setMaxConnectionMsg(param[2]);
            } else if (param[1].equals("port")) {
                long no = Long.parseLong(param[2]);
                target.setPort((int) no);
            } else if (param[1].equals("port")) {
                long no = Long.parseLong(param[2]);
                target.setPort((int) no);
            } else if (param[1].equals("maxAuthTry")) {
                int no = Integer.parseInt(param[2]);
                target.setMaxAuthTry(no);
            } else if (param[1].equals("maxAuthTryMsg")) {
                target.setMaxAuthTryMsg(param[2]);
            } else if (param[1].equals("clientEventHandler")) { /*v1.4.6*/
                target.setClientEventHandler(param[2]);
            } else if (param[1].equals("clientCommandHandler")) {
                target.setClientCommandHandler(param[2]);
            } else if (param[1].equals("clientWriteHandler")) { /*v1.4.6*/
                target.setClientWriteHandler(param[2]);
            } else if (param[1].equals("clientObjectHandler")) {
                target.setClientObjectHandler(param[2]); /*v1.3*/
            } else if (param[1].equals("clientAuthenticationHandler")) {
                target.setClientAuthenticationHandler(param[2]);
            } else if (param[1].equals("clientData")) {
                target.setClientData(param[2]);
            } else if (param[1].equals("clientExtendedEventHandler")) { /*v1.4.6*/
                target.setClientExtendedEventHandler(param[2]);
            } else if (param[1].equals("timeout")) {
                long no = Long.parseLong(param[2]);
                target.setTimeout((int) no);
            } else if (param[1].equals("timeoutMsg")) {
                target.setTimeoutMsg(param[2]); /* v1.3 */
            } else if (param[1].equals("plugin")) /* v1.2*/ {
                if (param[0].equals("self")) {
                    try {
                        adminServer.setCommandPlugin(param[2]);
                    } catch (Exception e) {
                        handler.sendClientMsg("-ERR not set : " + e);
                        return;
                    }
                } else {
                    handler.sendClientMsg("-ERR Bad target : " + param[0] + " self is only allowed.");
                    return;
                }
            } else if (param[1].equals("consoleLoggingFormatter")) {
                target.setConsoleLoggingFormatter(param[2]); /* v1.3 */
            } else if (param[1].equals("consoleLoggingLevel")) { /* v1.3 */
                if (param[2].endsWith("SEVERE"))
                    target.setConsoleLoggingLevel(Level.SEVERE);
                else if (param[2].endsWith("WARNING"))
                    target.setConsoleLoggingLevel(Level.WARNING);
                else if (param[2].endsWith("INFO"))
                    target.setConsoleLoggingLevel(Level.INFO);
                else if (param[2].endsWith("CONFIG"))
                    target.setConsoleLoggingLevel(Level.CONFIG);
                else if (param[2].endsWith("FINE"))
                    target.setConsoleLoggingLevel(Level.FINE);
                else if (param[2].endsWith("FINER"))
                    target.setConsoleLoggingLevel(Level.FINER);
                else if (param[2].endsWith("FINEST"))
                    target.setConsoleLoggingLevel(Level.FINEST);
                else if (param[2].endsWith("ALL"))
                    target.setConsoleLoggingLevel(Level.ALL);
                else if (param[2].endsWith("OFF"))
                    target.setConsoleLoggingLevel(Level.OFF);
                else {
                    handler.sendClientMsg("-ERR Bad Level " + param[2]);
                    return;
                }
            } else if (param[1].equals("loggingLevel")) { /* v1.3.1 */
                if (param[2].endsWith("SEVERE"))
                    target.setLoggingLevel(Level.SEVERE);
                else if (param[2].endsWith("WARNING"))
                    target.setLoggingLevel(Level.WARNING);
                else if (param[2].endsWith("INFO"))
                    target.setLoggingLevel(Level.INFO);
                else if (param[2].endsWith("CONFIG"))
                    target.setLoggingLevel(Level.CONFIG);
                else if (param[2].endsWith("FINE"))
                    target.setLoggingLevel(Level.FINE);
                else if (param[2].endsWith("FINER"))
                    target.setLoggingLevel(Level.FINER);
                else if (param[2].endsWith("FINEST"))
                    target.setLoggingLevel(Level.FINEST);
                else if (param[2].endsWith("ALL"))
                    target.setLoggingLevel(Level.ALL);
                else if (param[2].endsWith("OFF"))
                    target.setLoggingLevel(Level.OFF);
                else {
                    handler.sendClientMsg("-ERR Bad Level " + param[2]);
                    return;
                }
            } else if (param[1].equals("communicationLogging")) {
                if (param[2].equals("true"))/* v1.3.2 */
                    target.setCommunicationLogging(true);
                else
                    target.setCommunicationLogging(false);
            } else if (param[1].equals("objectPoolConfig-maxActive")) {
                int no = Integer.parseInt(param[2]);
                target.getConfig().getObjectPoolConfig().setMaxActive(no);
            } else if (param[1].equals("objectPoolConfig-maxIdle")) {
                int no = Integer.parseInt(param[2]);
                target.getConfig().getObjectPoolConfig().setMaxIdle(no);
            } else if (param[1].equals("objectPoolConfig-initSize")) {
                int no = Integer.parseInt(param[2]);
                target.getConfig().getObjectPoolConfig().setInitSize(no);
            } else {
                handler.sendClientMsg("-ERR Bad Set Key : " + param[1]);
                return;
            }
            handler.sendClientMsg("+OK Set");
        } catch (Exception e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("get")) {
        if (param.length < 2)/*target,key*/ {
            handler.sendClientMsg("-ERR " + "insufficient param");
            return;
        }
        try {
            if (param[1].equals("maxClient")) {
                long no = target.getMaxConnection();
                handler.sendClientMsg("+OK " + no);
            } else if (param[1].equals("maxClientMsg")) {
                String msg = target.getMaxConnectionMsg();
                msg = MyString.replaceAll(msg, "\n", "\\n");
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("port")) {
                long no = target.getPort();
                handler.sendClientMsg("+OK " + no);
            } else if (param[1].equals("maxAuthTry")) {
                int no = target.getMaxAuthTry();
                handler.sendClientMsg("+OK " + no);
            } else if (param[1].equals("maxAuthTryMsg")) {
                String msg = target.getMaxAuthTryMsg();
                msg = MyString.replaceAll(msg, "\n", "\\n");
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientEventHandler")) { /*v1.4.6*/
                String msg = target.getClientEventHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientCommandHandler")) {
                String msg = target.getClientCommandHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientWriteHandler")) { /*v1.4.6*/
                String msg = target.getClientWriteHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientObjectHandler")) {
                String msg = target.getClientObjectHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientAuthenticationHandler")) {
                String msg = target.getClientAuthenticationHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientData")) {
                String msg = target.getClientData();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("clientExtendedEventHandler")) { /*v1.4.6*/
                String msg = target.getClientExtendedEventHandler();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("timeout")) {
                String msg = "" + target.getTimeout();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("timeoutMsg")) {
                String msg = "" + target.getTimeoutMsg();
                msg = MyString.replaceAll(msg, "\n", "\\n");
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("plugin")) /* v1.2*/ {
                if (param[0].equals("self")) {
                    String msg = adminServer.getCommandPlugin();
                    handler.sendClientMsg("+OK " + msg);
                } else {
                    handler.sendClientMsg("-ERR Bad target : " + param[0] + " self is only allowed.");
                }
            } else if (param[1].equals("consoleLoggingFormatter")) {
                String msg = "" + target.getConsoleLoggingFormatter(); /* v1.3 */
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("consoleLoggingLevel")) { /* v1.3 */
                String msg = "" + target.getConsoleLoggingLevel();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("serviceState")) {
                int state = target.getServiceState(); /*v1.3*/
                if (state == org.quickserver.net.Service.INIT)
                    handler.sendClientMsg("+OK INIT");
                else if (state == org.quickserver.net.Service.RUNNING)
                    handler.sendClientMsg("+OK RUNNING");
                else if (state == org.quickserver.net.Service.STOPPED)
                    handler.sendClientMsg("+OK STOPPED");
                else if (state == org.quickserver.net.Service.SUSPENDED)
                    handler.sendClientMsg("+OK SUSPENDED");
                else
                    handler.sendClientMsg("+OK UNKNOWN");
            } else if (param[1].equals("communicationLogging")) {
                String msg = "" + target.getCommunicationLogging();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("objectPoolConfig-maxActive")) {
                String msg = "" + target.getConfig().getObjectPoolConfig().getMaxActive();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("objectPoolConfig-maxIdle")) {
                String msg = "" + target.getConfig().getObjectPoolConfig().getMaxIdle();
                handler.sendClientMsg("+OK " + msg);
            } else if (param[1].equals("objectPoolConfig-initSize")) {
                String msg = "" + target.getConfig().getObjectPoolConfig().getInitSize();
                handler.sendClientMsg("+OK " + msg);
            } else {
                handler.sendClientMsg("-ERR Bad Get Key : " + param[1]);
            }
        } catch (Exception e) {
            handler.sendClientMsg("-ERR " + e);
        }
        return;
    } else if (cmd.equals("kill-clients-all")) /*v2.0.0*/ {

        ObjectPool objectPool = target.getClientHandlerPool();

        if (PoolHelper.isPoolOpen(objectPool) == true) {
            if (QSObjectPool.class.isInstance(objectPool) == false) {
                handler.sendClientMsg("-ERR System Error!");
            }

            ClientIdentifier clientIdentifier = target.getClientIdentifier();
            ClientHandler foundClientHandler = null;
            synchronized (clientIdentifier.getObjectToSynchronize()) {
                Iterator iterator = clientIdentifier.findAllClient();
                handler.sendClientMsg("+OK closing");
                int count = 0;
                int found = 0;
                while (iterator.hasNext()) {
                    foundClientHandler = (ClientHandler) iterator.next();
                    found++;
                    if (foundClientHandler.isClosed() == false) {
                        foundClientHandler.closeConnection();
                        count++;
                    }
                }
                handler.sendClientMsg("Count Found: " + found);
                handler.sendClientMsg("Count Closed: " + count);
            }
            handler.sendClientMsg(".");
        } else {
            handler.sendClientMsg("-ERR Closing");
        }
        return;
    } else if (cmd.equals("kill-client-with")) /*v2.0.0*/ {

        if (param.length < 2)/*target,search*/ {
            handler.sendClientMsg("-ERR " + "insufficient param");
            return;
        }
        String search = param[1];

        ObjectPool objectPool = target.getClientHandlerPool();

        if (PoolHelper.isPoolOpen(objectPool) == true) {
            if (QSObjectPool.class.isInstance(objectPool) == false) {
                handler.sendClientMsg("-ERR System Error!");
            }

            ClientIdentifier clientIdentifier = target.getClientIdentifier();
            ClientHandler foundClientHandler = null;
            synchronized (clientIdentifier.getObjectToSynchronize()) {
                Iterator iterator = clientIdentifier.findAllClient();
                handler.sendClientMsg("+OK closing");
                int count = 0;
                int found = 0;
                while (iterator.hasNext()) {
                    foundClientHandler = (ClientHandler) iterator.next();
                    if (foundClientHandler.toString().indexOf(search) != -1) {
                        found++;
                        if (foundClientHandler.isClosed() == false) {
                            foundClientHandler.closeConnection();
                            count++;
                        }
                    }
                }
                handler.sendClientMsg("Count Found: " + found);
                handler.sendClientMsg("Count Closed: " + count);
            }
            handler.sendClientMsg(".");
        } else {
            handler.sendClientMsg("-ERR Closing");
        }
        return;
    } else {
        handler.sendClientMsg("-ERR Bad Command : " + cmd);
    }
    return;
}

From source file:org.quickserver.net.server.QuickServer.java

/**
 * Sets the console log handler level./*from ww  w .  j  a v  a  2  s  .  com*/
 * @since 1.2
 */
public void setConsoleLoggingLevel(Level level) {
    Logger rlogger = Logger.getLogger("");
    Handler[] handlers = rlogger.getHandlers();

    boolean isConsole = true;
    try {
        if (System.console() == null) {
            isConsole = false;
        }
    } catch (Throwable e) {
        //ignore
    }

    for (int index = 0; index < handlers.length; index++) {
        if (ConsoleHandler.class.isInstance(handlers[index])) {
            if (isConsole == false && level != Level.OFF) {
                System.out.println("QuickServer: You do not have a console.. so turning console logger off..");
                level = Level.OFF;
            }

            if (level == Level.OFF) {
                logger.info("QuickServer: Removing console handler.. ");
                rlogger.removeHandler(handlers[index]);

                handlers[index].setLevel(level);
                handlers[index].close();
            } else {
                handlers[index].setLevel(level);
            }
        }
    }
    if (level == Level.SEVERE)
        consoleLoggingLevel = "SEVERE";
    else if (level == Level.WARNING)
        consoleLoggingLevel = "WARNING";
    else if (level == Level.INFO)
        consoleLoggingLevel = "INFO";
    else if (level == Level.CONFIG)
        consoleLoggingLevel = "CONFIG";
    else if (level == Level.FINE)
        consoleLoggingLevel = "FINE";
    else if (level == Level.FINER)
        consoleLoggingLevel = "FINER";
    else if (level == Level.FINEST)
        consoleLoggingLevel = "FINEST";
    else if (level == Level.OFF)
        consoleLoggingLevel = "OFF";
    else
        consoleLoggingLevel = "UNKNOWN";

    logger.log(Level.FINE, "Set to {0}", level);
}

From source file:org.quickserver.net.server.QuickServer.java

/**
 * Sets the level for all log handlers.//from   w w w.  j  av a 2s  . co  m
 * @since 1.3.1
 */
public void setLoggingLevel(Level level) {
    Logger rlogger = Logger.getLogger("");
    Handler[] handlers = rlogger.getHandlers();
    for (int index = 0; index < handlers.length; index++) {
        handlers[index].setLevel(level);
    }

    if (level == Level.SEVERE)
        loggingLevel = "SEVERE";
    else if (level == Level.WARNING)
        loggingLevel = "WARNING";
    else if (level == Level.INFO)
        loggingLevel = "INFO";
    else if (level == Level.CONFIG)
        loggingLevel = "CONFIG";
    else if (level == Level.FINE)
        loggingLevel = "FINE";
    else if (level == Level.FINER)
        loggingLevel = "FINER";
    else if (level == Level.FINEST)
        loggingLevel = "FINEST";
    else if (level == Level.OFF)
        loggingLevel = "OFF";
    else
        loggingLevel = "UNKNOWN";

    consoleLoggingLevel = loggingLevel;

    logger.log(Level.FINE, "Set to {0}", level);
}

From source file:org.quickserver.net.server.QuickServer.java

private void configConsoleLoggingLevel(QuickServer qs, String temp) {
    if (temp.equals("SEVERE"))
        qs.setConsoleLoggingLevel(Level.SEVERE);
    else if (temp.equals("WARNING"))
        qs.setConsoleLoggingLevel(Level.WARNING);
    else if (temp.equals("INFO"))
        qs.setConsoleLoggingLevel(Level.INFO);
    else if (temp.equals("CONFIG"))
        qs.setConsoleLoggingLevel(Level.CONFIG);
    else if (temp.equals("FINE"))
        qs.setConsoleLoggingLevel(Level.FINE);
    else if (temp.equals("FINER"))
        qs.setConsoleLoggingLevel(Level.FINER);
    else if (temp.equals("FINEST"))
        qs.setConsoleLoggingLevel(Level.FINEST);
    else if (temp.equals("OFF"))
        qs.setConsoleLoggingLevel(Level.OFF);
    else//from  w w  w  .  j  a  va2  s.c om
        logger.log(Level.WARNING, "unknown level {0}", temp);
}

From source file:com.google.enterprise.connector.sharepoint.spiimpl.SharepointConnectorType.java

/**
 * Validating feed ACLs related HTML controls against blank, specific formats
 * and for valid LDAP context.//from  w  w w. j  av a2  s .  co  m
 *
 * @return true if feed ACLs is not selected by the connector administrator
 *         during setting of connector configuration at GSA and false in case
 *         if any of its fields are blank, wrong user name format or couldn't
 *         get valid initial LDAP context.
 */
private boolean validateFeedAclsRelatedHtmlControls(final ErrorDignostics ed) {
    if (null != pushAcls && this.pushAcls.equalsIgnoreCase(SPConstants.ON)) {
        LOGGER.config("Selected Feed ACLs option.");
        if (!Strings.isNullOrEmpty(usernameFormatInAce) && !Strings.isNullOrEmpty(groupnameFormatInAce)) {
            if (!checkForSpecialCharacters(usernameFormatInAce)) {
                ed.set(SPConstants.USERNAME_FORMAT_IN_ACE,
                        rb.getString(SPConstants.SPECIAL_CHARACTERS_IN_USERNAME_FORMAT));
                return false;
            }
            if (!checkForSpecialCharacters(groupnameFormatInAce)) {
                ed.set(SPConstants.GROUPNAME_FORMAT_IN_ACE,
                        rb.getString(SPConstants.SPECIAL_CHARACTERS_IN_GROUPNAME_FORMAT));
                return false;
            }
            if (!Strings.isNullOrEmpty(ldapServerHostAddress) && !Strings.isNullOrEmpty(portNumber)
                    && !Strings.isNullOrEmpty(domain)) {

                LOGGER.config("Checking for a valid port number.");
                if (!checkForInteger(portNumber)) {
                    ed.set(SPConstants.PORT_NUMBER,
                            MessageFormat.format(rb.getString(SPConstants.INVALID_PORT_NUMBER), portNumber));
                    return false;
                }
                Method method;
                if (Method.SSL.toString().equalsIgnoreCase(this.connectMethod.toString())) {
                    method = Method.SSL;
                } else {
                    method = Method.STANDARD;
                }

                AuthType authType;
                if (AuthType.ANONYMOUS.toString().equalsIgnoreCase(this.authenticationType.toString())) {
                    authType = AuthType.ANONYMOUS;
                } else {
                    authType = AuthType.SIMPLE;
                }
                LdapConnectionSettings settings = new LdapConnectionSettings(method, this.ldapServerHostAddress,
                        Integer.parseInt(this.portNumber), this.searchBase, authType, this.username,
                        this.password, this.domain);
                LOGGER.config("Created LDAP connection settings object to obtain LDAP context "
                        + ldapConnectionSettings);
                LdapConnection ldapConnection = new LdapConnection(settings);
                if (ldapConnection.getLdapContext() == null) {
                    Map<LdapConnectionError, String> errors = ldapConnection.getErrors();
                    Iterator<Entry<LdapConnectionError, String>> iterator = errors.entrySet().iterator();
                    StringBuffer errorMessage = new StringBuffer();
                    errorMessage.append(rb.getString(SPConstants.LDAP_CONNECTVITY_ERROR));
                    while (iterator.hasNext()) {
                        Map.Entry<LdapConnectionError, String> entry = iterator.next();
                        errorMessage.append(SPConstants.SPACE + entry.getValue());
                    }
                    ed.set(SPConstants.LDAP_SERVER_HOST_ADDRESS, errorMessage.toString());
                    return false;
                }

                if (ldapConnection.getLdapContext() == null) {
                    LOGGER.log(Level.WARNING,
                            "Couldn't obtain context object to query LDAP (AD) directory server.");
                    ed.set(SPConstants.LDAP_SERVER_HOST_ADDRESS,
                            rb.getString(SPConstants.LDAP_CONNECTVITY_ERROR));
                    return false;
                }

                if (!checkForSearchBase(ldapConnection.getLdapContext(), searchBase, ed)) {
                    return false;
                }
                LOGGER.log(Level.CONFIG,
                        "Sucessfully created initial LDAP context to query LDAP directory server.");
            } else {
                if (Strings.isNullOrEmpty(ldapServerHostAddress)) {
                    ed.set(SPConstants.LDAP_SERVER_HOST_ADDRESS,
                            rb.getString(SPConstants.LDAP_SERVER_HOST_ADDRESS_BLANK));
                    return false;
                } else if (Strings.isNullOrEmpty(portNumber)) {
                    ed.set(SPConstants.PORT_NUMBER, rb.getString(SPConstants.PORT_NUMBER_BLANK));
                    return false;
                } else if (Strings.isNullOrEmpty(searchBase)) {
                    ed.set(SPConstants.SEARCH_BASE, rb.getString(SPConstants.SEARCH_BASE_BLANK));
                    return false;
                } else if (Strings.isNullOrEmpty(domain)) {
                    ed.set(SPConstants.DOMAIN, rb.getString(SPConstants.BLANK_DOMAIN_NAME_LDAP));
                    return false;
                }
            }
            if (!Strings.isNullOrEmpty(useCacheToStoreLdapUserGroupsMembership)) {
                if (null != useCacheToStoreLdapUserGroupsMembership
                        && this.useCacheToStoreLdapUserGroupsMembership.equalsIgnoreCase(SPConstants.ON)) {
                    if (!Strings.isNullOrEmpty(initialCacheSize)
                            && !Strings.isNullOrEmpty(cacheRefreshInterval)) {
                        if (!checkForInteger(this.initialCacheSize)) {
                            ed.set(SPConstants.INITAL_CACHE_SIZE, MessageFormat.format(
                                    rb.getString(SPConstants.INVALID_INITIAL_CACHE_SIZE), initialCacheSize));
                            return false;
                        }
                        if (!checkForInteger(this.cacheRefreshInterval)) {
                            ed.set(SPConstants.CACHE_REFRESH_INTERVAL,
                                    MessageFormat.format(
                                            rb.getString(SPConstants.INVALID_CACHE_REFRESH_INTERVAL),
                                            cacheRefreshInterval));
                            return false;
                        }
                    } else {
                        if (Strings.isNullOrEmpty(initialCacheSize)) {
                            ed.set(SPConstants.INITAL_CACHE_SIZE,
                                    rb.getString(SPConstants.BLANK_INITIAL_CACHE_SIZE));
                            return false;
                        }
                        if (Strings.isNullOrEmpty(cacheRefreshInterval)) {
                            ed.set(SPConstants.CACHE_REFRESH_INTERVAL,
                                    rb.getString(SPConstants.BLANK_CACHE_REFRESH_INTERVAL));
                            return false;
                        }
                    }
                }
            }
        } else {
            if (Strings.isNullOrEmpty(groupnameFormatInAce)) {
                ed.set(SPConstants.GROUPNAME_FORMAT_IN_ACE, MessageFormat
                        .format(rb.getString(SPConstants.BLANK_GROUPNAME_FORMAT), groupnameFormatInAce));
                return false;
            }
            if (Strings.isNullOrEmpty(usernameFormatInAce)) {
                ed.set(SPConstants.USERNAME_FORMAT_IN_ACE, MessageFormat
                        .format(rb.getString(SPConstants.BLANK_USERNAME_FORMAT), usernameFormatInAce));
                return false;
            }
        }
    }
    return true;
}