Example usage for java.util.logging Level WARNING

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

Introduction

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

Prototype

Level WARNING

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

Click Source Link

Document

WARNING is a message level indicating a potential problem.

Usage

From source file:com.neophob.sematrix.core.generator.Image.java

/**
 * load a new file.//from  ww  w .  j ava2  s .c o  m
 *
 * @param filename the filename
 */
public synchronized void loadFile(String filename) {
    if (StringUtils.isBlank(filename)) {
        LOG.log(Level.INFO, "Empty filename provided, call ignored!");
        return;
    }

    //only load if needed
    if (StringUtils.equals(filename, this.filename)) {
        LOG.log(Level.INFO, "new filename does not differ from old: " + filename);
        return;
    }

    try {
        String fileToLoad = fileUtils.getImageDir() + File.separator + filename;

        LOG.log(Level.INFO, "load image " + fileToLoad);
        BufferedImage img = ImageIO.read(new File(fileToLoad));
        if (img == null || img.getHeight() < 2) {
            LOG.log(Level.WARNING, "Invalid image, image height is < 2!");
            return;
        }

        //convert to RGB colorspace
        int w = img.getWidth();
        int h = img.getHeight();
        int[] dataBuffInt = img.getRGB(0, 0, w, h, null, 0, w);

        LOG.log(Level.INFO, "resize to img " + filename + " " + internalBufferXSize + ", " + internalBufferYSize
                + " using " + resize.getName());
        this.internalBuffer = resize.getBuffer(dataBuffInt, internalBufferXSize, internalBufferYSize, w, h);
        this.filename = filename;

        short r, g, b;
        int rgbColor;

        //greyscale it
        for (int i = 0; i < internalBuffer.length; i++) {
            rgbColor = internalBuffer[i];
            r = (short) ((rgbColor >> 16) & 255);
            g = (short) ((rgbColor >> 8) & 255);
            b = (short) (rgbColor & 255);
            int val = (int) (r * 0.3f + g * 0.59f + b * 0.11f);
            internalBuffer[i] = val;
        }

    } catch (Exception e) {
        LOG.log(Level.WARNING, "Failed to load image " + filename, e);
    }
}

From source file:com.codelanx.codelanxlib.listener.ListenerManager.java

/**
 * Returns {@code true} if the passed {@link Listener} has another Listener
 * of the same class type already registered for bukkit. This should not be
 * used with any listeners that are from an anonymous class, as this will
 * return {@code true} for any other anonymous classes as well
 * //ww  w.  j  ava 2s  . c o  m
 * @since 0.1.0
 * @version 0.1.0
 * 
 * @param p The {@link Plugin} that registers this {@link Listener}
 * @param l The {@link Listener} to check
 * @return {@code true} if registered to bukkit
 */
public static boolean isRegisteredToBukkit(Plugin p, Listener l) {
    if (l.getClass().isAnonymousClass()) {
        StackTraceElement t = Reflections.getCaller();
        Logging.simple().here().print(Level.WARNING, "Passed an anonymous class from %s:%d",
                t.getClass().getName(), t.getLineNumber());
    }
    return HandlerList.getRegisteredListeners(p).stream()
            .anyMatch(r -> r.getListener().getClass() == l.getClass());
}

From source file:com.symbian.driver.remoting.master.TDIWrapper.java

/**
 * Standard Constructor/*from   ww w .j  a v a2  s.c om*/
 * 
 * @param aTestPackage
 *            A test pacakage path.
 * @param aResultsPath
 *            A path where to collect the results.
 * @throws ArrayIndexOutOfBoundsException
 * @throws ParseException
 * @throws IOException
 * @throws TimeLimitExceededException
 */
public TDIWrapper(final File aTestPackage, final File aResultsPath)
        throws ArrayIndexOutOfBoundsException, ParseException, IOException, TimeLimitExceededException {

    // Setup Autmation Folder
    URL lSource = TDIWrapper.class.getProtectionDomain().getCodeSource().getLocation();
    File lInstallationFolder = new File(lSource.getPath()).getParentFile().getParentFile();

    iAutomationFolder = new File(lInstallationFolder, "automation");

    LOGGER.info("Automation folder has been set as: " + iAutomationFolder);

    // Initialise Package
    final Task lStartTask = initialize(aTestPackage, aResultsPath);

    //  for timeout set the root node of SymbianVisitor to xxyy
    //  do some kind of stopping!
    lSymbianThread = new Thread(new Runnable() {
        public void run() {
            Thread lCurrentThread = Thread.currentThread();
            if (lSymbianThread == lCurrentThread) {
                SymbianVisitor lSymbianVisitor = new SymbianVisitor();
                try {
                    TDConfig.getInstance().printConfig(true);
                } catch (IOException lE) {
                    LOGGER.log(Level.WARNING, "Could not print the config..." + lE.getMessage(), lE);
                }
                // execute the test
                SecurityManager lSec = null;
                try {
                    lSec = System.getSecurityManager();
                    //set security manager to disable system.exit() called by Test Driver
                    System.setSecurityManager(new NoExitSecurityManager());
                    lSymbianVisitor.start(lStartTask);
                } catch (SecurityException lSecurityException) {
                    // ignore
                } finally {
                    // reset security manager so that the server can exit in case of problems.
                    try {
                        System.setSecurityManager(lSec);
                    } catch (SecurityException lSecurityException) {
                        // ignore
                    }
                }
                //  cleanup all data except testresults

            }
        }
    });
}

From source file:com.titankingdoms.dev.titanchat.addon.AddonManager.java

/**
 * Registers the {@link ChatAddon}s/*from  w  ww  .  jav a2s. co m*/
 * 
 * @param addons The {@link ChatAddon}s to register
 */
public void registerAddons(ChatAddon... addons) {
    if (addons == null)
        return;

    for (ChatAddon addon : addons) {
        if (addon == null || addon.getName().isEmpty())
            continue;

        if (hasAddon(addon)) {
            plugin.log(Level.WARNING, "Duplicate addon: " + addon.getName());
            continue;
        }

        this.addons.put(addon.getName().toLowerCase(), addon);
        db.debug(Level.INFO, "Registered addon: " + addon.getName());
    }
}

From source file:com.opera.core.systems.scope.AbstractService.java

/**
 * Query a collection JXPath and return a pointer FIXME: This does not belong
 * here!/*from   w w w .  ja  va  2  s.  c om*/
 *
 * @param collection
 * @param query
 * @return Pointer to node
 */
public Pointer xpathPointer(Collection<?> collection, String query) {
    JXPathContext pathContext = JXPathContext.newContext(collection);
    Pointer result = null;
    try {
        result = pathContext.getPointer(query);
    } catch (JXPathNotFoundException e) {
        logger.log(Level.WARNING, "JXPath exception: {0}", e.getMessage());
    }
    return result;
}

From source file:com.bitplan.vzjava.resources.PowerPlotResource.java

/**
 * http://stackoverflow.com/a/10257341/1497139
 * Sends the file if modified and "not modified" if not modified
 * future work may put each file with a unique id in a separate folder in
 * tomcat/*  w  w  w  .j a va 2 s . c om*/
 * * use that static URL for each file
 * * if file is modified, URL of file changes
 * * -> client always fetches correct file
 * 
 * method header for calling method public Response
 * getXY(@HeaderParam("If-Modified-Since") String modified) {
 * 
 * @param file
 *          to send
 * @param modified
 *          - HeaderField "If-Modified-Since" - may be "null"
 * @return Response to be sent to the client
 */
public static Response returnFile(File file, String modified) {
    if (!file.exists()) {
        return Response.status(Status.NOT_FOUND).build();
    }

    // do we really need to send the file or can send "not modified"?
    if (modified != null) {
        Date modifiedDate = null;

        // we have to switch the locale to ENGLISH as parseDate parses in the
        // default locale
        Locale old = Locale.getDefault();
        Locale.setDefault(Locale.ENGLISH);
        try {
            modifiedDate = DateUtils.parseDate(modified, DEFAULT_PATTERNS);
        } catch (ParseException e) {
            LOGGER.log(Level.WARNING, e.getMessage());
        }
        Locale.setDefault(old);

        if (modifiedDate != null) {
            // modifiedDate does not carry milliseconds, but fileDate does
            // therefore we have to do a range-based comparison
            // 1000 milliseconds = 1 second
            if (file.lastModified() - modifiedDate.getTime() < DateUtils.MILLIS_PER_SECOND) {
                return Response.status(Status.NOT_MODIFIED).build();
            }
        }
    }
    // we really need to send the file

    try {
        Date fileDate = new Date(file.lastModified());
        return Response.ok(new FileInputStream(file)).lastModified(fileDate).build();
    } catch (FileNotFoundException e) {
        return Response.status(Status.NOT_FOUND).build();
    }
}

From source file:com.novartis.pcs.ontology.service.graph.DOTProcessImpl.java

@PreDestroy
protected void destroy() {
    OutputStream stdin = process.getOutputStream();
    InputStream stdout = process.getInputStream();
    InputStream stderr = process.getErrorStream();
    try {/*from w w  w  .j  a v  a2s  . com*/
        // Closing stdin (which sends EOF) causes the dot process to exit
        logger.info("Closing stdin on dot process");
        stdin.close();

        // On some OSs (e.g. OSX) closing the input stream
        // (incorrectly) seems to re-send the stream's internal
        // buffer contents. The causes the dot process to
        // generate output on stdout which needs to be read
        // so the process can exit cleanly. Otherwise, the
        // process.waitFor() call below blocks indefinitely. 
        logger.info("Reading dot process stdout stream");
        while (stdout.read(buffer) != -1)
            ;

        logger.info("Reading dot process stderr stream");
        while (stderr.read(buffer) != -1)
            ;

        logger.info("Waiting for dot process to terminate");
        if (process.waitFor() != 0) {
            String msg = "dot process exited unsuccuessfully: " + process.exitValue();
            logger.warning(msg);
        }
        buffer = null;
        skip = null;
    } catch (Exception e) {
        String msg = "Failed to shutdown dot process cleanly";
        logger.log(Level.WARNING, msg, e);
        process.destroy();
    } finally {
        logger.info("Closing dot process stdout stderr streams");
        IOUtils.closeQuietly(stdout);
        IOUtils.closeQuietly(stderr);
    }
}

From source file:it.txt.ens.namespace.osgi.test.Activator.java

@Override
public void start(BundleContext context) throws Exception {
    //retrieve the configuration admin service
    configAdminSR = context.getServiceReference(ConfigurationAdmin.class);
    if (configAdminSR == null)
        throw new Exception("No " + ConfigurationAdmin.class.getName() + " available");
    ConfigurationAdmin configAdmin = context.getService(configAdminSR);
    config = configAdmin.createFactoryConfiguration(NamespaceInquirerMSF.PID, null);

    //load the configuration for this bundle
    File configFile = new File(DEFAULT_CONFIG_DIR + CONFIG_FILE);
    Dictionary<String, Object> properties = null;

    try {//from www . j  a  v  a 2 s.  c om
        properties = Utils.loadConfiguration(DEFAULT_CONFIG_DIR + CONFIG_FILE);
        //add owner id
        String ownerID = String.valueOf(context.getBundle().getBundleId());
        properties.put(NamespaceInquirerMSF.OWNER_ID, ownerID);
        config.update(properties);
        EqualsFilter ownerIDFilter = new EqualsFilter(NamespaceInquirerMSF.OWNER_ID, ownerID);

        Filter filter = context.createFilter(ownerIDFilter.encode());
        NamespaceInquirerTracker tracker = new NamespaceInquirerTracker(context, filter);
        new Thread(tracker, "Namespace Inquirer Tracker").start();
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, MessageFormat.format(
                LOGGING_MESSAGES.getString("errorWhileReadingConfigFile"), configFile.getAbsolutePath()), e);
    }
}

From source file:com.github.shynixn.blockball.bukkit.logic.persistence.context.SqlDbContextImpl.java

private void connectInternal(Plugin plugin) {
    if (!plugin.getConfig().getBoolean("sql.enabled")) {
        try {/*from w w w  .  j av a 2s  .co m*/
            if (!plugin.getDataFolder().exists())
                plugin.getDataFolder().mkdir();
            final File file = new File(plugin.getDataFolder(), "BlockBall.db");
            if (!file.exists())
                file.createNewFile();
            this.enableData(SqlDbContextImpl.SQLITE_DRIVER, "jdbc:sqlite:" + file.getAbsolutePath(), null, null,
                    this.retriever);
            try (final Connection connection = this.getConnection()) {
                this.execute("PRAGMA foreign_keys=ON", connection);
            }
        } catch (final SQLException e) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot execute statement.", e);
        } catch (final IOException e) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot read file.", e);
        }
        try (final Connection connection = this.getConnection()) {
            for (final String data : this.getStringFromFile("create-sqlite").split(Pattern.quote(";"))) {
                this.executeUpdate(data, connection);
            }
        } catch (final Exception e) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot execute creation.", e);
        }
    } else {
        final FileConfiguration c = plugin.getConfig();
        try {
            this.enableData(SqlDbContextImpl.MYSQL_DRIVER, "jdbc:mysql://", c.getString("sql.host"),
                    c.getInt("sql.port"), c.getString("sql.database"), c.getString("sql.username"),
                    c.getString("sql.password"), this.retriever);
        } catch (final IOException e) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot connect to MySQL database!", e);
            Bukkit.getLogger().log(Level.WARNING, "Trying to connect to SQLite database....", e);
            plugin.getConfig().set("sql.enabled", false);
            this.connectInternal(plugin);
            return;
        }
        try (final Connection connection = this.getConnection()) {
            for (final String data : this.getStringFromFile("create-mysql").split(Pattern.quote(";"))) {
                this.executeUpdate(data, connection);
            }
        } catch (final Exception e) {
            Bukkit.getLogger().log(Level.WARNING, "Cannot execute creation.", e);
            Bukkit.getLogger().log(Level.WARNING, "Trying to connect to SQLite database....", e);
            plugin.getConfig().set("sql.enabled", false);
            this.connectInternal(plugin);
        }
    }
}

From source file:com.socrata.ApiBase.java

/**
 * Empty out the batchQueue, sending stored data back to Socrata servers
 * @return success or failure/*  ww  w .  j a  va 2s.c o m*/
 */
public boolean sendBatchRequest() {
    if (batchQueue == null || batchQueue.size() == 0) {
        log(Level.WARNING, "No batch requests in queue, ignoring call to sendBatchRequest", null);
        return false;
    }
    Collection batches = new ArrayList<Map>();
    for (BatchRequest b : batchQueue) {
        batches.add(b.data());
    }

    JSONObject bodyObject = new JSONObject();
    try {
        bodyObject.put("requests", batches);
    } catch (JSONException ex) {
        log(Level.SEVERE, "Could not convert array of batch requests to JSON", ex);
        return false;
    }

    HttpPost request = new HttpPost(httpBase() + "/batches");
    try {
        request.setEntity(new StringEntity(bodyObject.toString()));
        log(Level.INFO, bodyObject.toString());
    } catch (UnsupportedEncodingException ex) {
        log(Level.SEVERE, "Could not encode JSON data into HTTP entity", ex);
        return false;
    }

    JsonPayload response = performRequest(request);
    if (!isErroneous(response)) {
        log(Level.INFO, "Completed batch request, clearing out queue of " + batchQueue.size() + " entries.");
        batchQueue.clear();
        return true;
    }

    return false;
}