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:tools.datasync.db2db.util.Md5HashGenerator.java

public String generate(byte[] data) {
    try {/*from  w  w w  .j a  va  2s  .co m*/
        messageDigest.update(data);
        byte[] digest = messageDigest.digest();
        String checksum = toHexString1(digest);
        return checksum;
    } catch (Exception e) {
        exceptionHandler.handle(e, Level.WARNING, "Error while generating checksum", data);
        return null;
    }
}

From source file:photosharing.api.oauth.PollingDefinition.java

/**
 * processes the polling /*w  w  w.  j av  a2  s .  c o  m*/
 * 
 * @param request
 *            the http request object
 * @param request
 *            the http response object
 */
public void run(HttpServletRequest request, HttpServletResponse response) {

    HttpSession session = request.getSession(false);
    if (session != null) {

        Object oData = session.getAttribute(OAuth20Handler.CREDENTIALS);

        if (oData != null) {

            String oName = oData.getClass().getSimpleName();
            if (oName.contains("OAuth20Data")) {
                response.setStatus(HttpStatus.SC_OK);
            } else {
                logger.log(Level.WARNING, "Error on getting credentials - bad value for odata");
                response.setStatus(HttpStatus.SC_BAD_REQUEST);
            }

        } else {
            logger.log(Level.WARNING, "No OAuth2.0 Credentials Found during Polling");
            response.setStatus(HttpStatus.SC_NO_CONTENT);
        }

    } else {
        // When there is no session, set SC_BAD_REQUEST
        logger.log(Level.WARNING, "Invalid Session - Cookie found/exists - " + request.getHeader("Cookie"));
        response.setStatus(HttpStatus.SC_BAD_REQUEST);
    }

}

From source file:com.almende.eve.test.TestCall.java

/**
 * Test proxy./* w  ww .j  a  va2 s . co  m*/
 * 
 * @throws Exception
 *             the exception
 */
@Test
public void testCall() throws Exception {
    // Create TestAgent according to TestInterface
    final AgentHost host = AgentHost.getInstance();
    final FileStateFactory stateFactory = new FileStateFactory(".eveagents");
    host.setStateFactory(stateFactory);
    host.setSchedulerFactory(new ClockSchedulerFactory(host, new HashMap<String, Object>()));
    if (host.hasAgent("TestAgent")) {
        host.deleteAgent("TestAgent");
    }
    final TestAgent agent = host.createAgent(TestAgent.class, "TestAgent");
    final AsyncCallback<JSONResponse> callback = new AsyncCallback<JSONResponse>() {

        @Override
        public void onSuccess(JSONResponse result) {
            LOG.info("received result:" + result);
        }

        @Override
        public void onFailure(Exception exception) {
            LOG.log(Level.WARNING, "Failure:", exception);
            fail("Failure:" + exception.getLocalizedMessage());
        }
    };

    agent.send(
            new JSONRequest("helloWorld", (ObjectNode) JOM.getInstance().readTree("{\"msg\":\"hi there!\"}")),
            URI.create("local:TestAgent"), callback, null);

    agent.send(
            new JSONRequest("helloWorld2",
                    (ObjectNode) JOM.getInstance().readTree("{\"msg1\":\"hi there!\",\"msg2\":\"Bye!\"}")),
            URI.create("local:TestAgent"), callback, null);

    agent.send(new JSONRequest("scheduler.getTasks", JOM.createObjectNode()), URI.create("local:TestAgent"),
            callback, null);

    agent.send(new JSONRequest("testVoid", JOM.createObjectNode()), URI.create("local:TestAgent"), callback,
            null);

    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
    }
}

From source file:com.qwazr.server.InFileSessionPersistenceManager.java

@Override
public void persistSessions(final String deploymentName, final Map<String, PersistentSession> sessionData) {
    if (sessionData == null)
        return;//  w  ww  .  j  a  va  2  s. c  o m
    final Path deploymentDir = sessionDir.resolve(deploymentName);
    try {
        if (!Files.exists(deploymentDir))
            Files.createDirectory(deploymentDir);
    } catch (IOException e) {
        LOGGER.log(Level.WARNING, e,
                () -> "Cannot create the session directory " + deploymentDir + ": persistence aborted.");
        return;
    }
    sessionData.forEach(
            (sessionId, persistentSession) -> writeSession(deploymentDir, sessionId, persistentSession));
}

From source file:net.chrissearle.flickrvote.web.admin.SendTweetAction.java

@Override
public String execute() throws Exception {
    try {// ww  w .ja  v  a 2s .co  m
        if (!isDm()) {
            tweetService.tweet(tweet);

            addActionMessage("Tweeted");
        } else {
            directMessageService.dm(twitterId, tweet);

            addActionMessage("Sent");

            return "dmsuccess";
        }
    } catch (TwitterServiceException tse) {
        if (logger.isLoggable(Level.WARNING)) {
            logger.warning("Unable to tweet: " + tse.getMessage());
        }
        addActionError("Unable to tweet: " + tse.getMessage());
    }

    return SUCCESS;
}

From source file:application.ReviewDocumentIndexer.java

/**
 * @param args//w  w  w .j  ava 2s. c o m
 */
@SuppressWarnings("deprecation")
public static void main(String[] args) {
    // Parse command line arguments. Exit program is provided arguments are insufficient
    ReviewDocumentIndexer indexer = new ReviewDocumentIndexer(args);
    if (indexer == null)
        return;

    // Open a new index
    IndexWriter index = null;
    try {
        index = new IndexWriter(new SimpleFSDirectory(new File(Paths.luceneIndex)),
                new ReviewTextAnalyzer(indexer), indexer.new_index ? true : false, MaxFieldLength.UNLIMITED);
        if (indexer.pause_every > 2) {
            index.setMaxBufferedDocs(indexer.pause_every);
        }
        index.setMaxMergeDocs(Config.maxMergeDocs);
        index.setMergeFactor(Config.mergeFactor);
    } catch (CorruptIndexException e) {
        AppLogger.error.log(Level.SEVERE,
                "Lucene detected an inconsistency upon opening the index located at " + Paths.luceneIndex);
        throw new RuntimeException("Exiting application", e);
    } catch (LockObtainFailedException e) {
        AppLogger.error.log(Level.SEVERE,
                "Index located at " + Paths.luceneIndex + " is already open by another Lucene process");
        throw new RuntimeException("Exiting application", e);
    } catch (IOException e) {
        AppLogger.error.log(Level.SEVERE, "Could not access location " + Paths.luceneIndex);
        throw new RuntimeException("Exiting application", e);
    }

    // Load a number of reviews from database
    NumberFormat docIdFormat = TokenListsCollector.defaultDocIdFormat();
    try {
        DatabaseReviewCollection reviews = new DatabaseReviewCollection(indexer.pause_every);
        reviews.setLimits(indexer.min_reviewid, indexer.stop_after);
        int indexed_counter = 0;

        while (reviews.hasNextSegment()) {

            System.out.print(Calendar.getInstance().getTime().toGMTString());

            System.out.print(" Loading from DB... ");
            reviews.loadNextSegment();
            Iterator<Review> reviewsIterator = reviews.getIterator();

            System.out.print(" Indexing... ");
            while (reviewsIterator.hasNext()) {
                DatabaseReview dbr = (DatabaseReview) reviewsIterator.next();
                int dbr_id = dbr.getReviewid();
                int dbr_rating = dbr.getRating();

                try {
                    indexer.theReviewId.set(dbr_id);
                    indexer.theStats.setCurrent(dbr_id, dbr_rating);

                    index.addDocument(dbr.getDocumentForIndexing());
                    indexed_counter++;

                    // Also, keep track of the rating and length of this review
                    indexer.theStats.storeCurrent();

                } catch (CorruptIndexException e) {
                    AppLogger.error.log(Level.SEVERE,
                            "Lucene detected an inconsistency upon saving review #"
                                    + Integer.toString(dbr.getReviewid()) + "to the index located at "
                                    + Paths.luceneIndex);
                    return;
                } catch (IOException e) {
                    AppLogger.error.log(Level.WARNING,
                            "Review #" + Integer.toString(dbr.getReviewid()) + " could not be indexed");
                }
            }

            // Backup everything
            System.out.print("Indexed " + indexed_counter + " reviews total. ");
            if (indexer.pause_every > 0) {
                System.out.print("Saving tokenlists... ");
                indexer.theTokenLists.writeNextFile(docIdFormat);

                System.out.print("Saving state... ");
                try {
                    index.commit();
                    indexer.saveState();
                } catch (CorruptIndexException e) {
                    AppLogger.error.log(Level.SEVERE, "Committing index changes failed on review #"
                            + indexer.theReviewId.get() + "due to CorruptIndexException");
                    return;
                } catch (IOException e) {
                    AppLogger.error.log(Level.WARNING, "Committing index changes failed on review #"
                            + indexer.theReviewId.get() + "due to IOException");
                }
            }
            System.out.print("DONE\n");

            reviews.reset();
        }
    } catch (SQLException e) {
        AppLogger.error.log(Level.SEVERE,
                "An exception occured while trying to access the database.\n" + e.getMessage());
        return;
    }

    try {
        index.close();
        indexer.backupIndex();
    } catch (CorruptIndexException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.err.println("Indexing successfully completed!");
    return;
}

From source file:Emporium.Controle.ContrVpne.java

public static boolean inserirVpne(String sql, String nomeBD) {
    Connection conn = Conexao.conectar(nomeBD);
    try {//from  w  ww  .  j a  v a  2 s.c om
        PreparedStatement valores = conn.prepareStatement(sql);
        valores.executeUpdate();
        valores.close();
        return true;
    } catch (SQLException e) {
        Logger.getLogger(ContrPreVendaImporta.class.getName()).log(Level.WARNING, e.getMessage(), e);
        return false;
    } finally {
        Conexao.desconectar(conn);
    }
}

From source file:com.nebel_tv.content.wrapper.builders.MediaItemBuilder.java

private void executeQuery() {
    item = MediaItemCache.getItem(id);//from  w ww .java 2 s  .  c om
    if (item == null) {
        try {
            String source = ConnectionUtils.getResponseAsString(ConnectionHelper.fixURL(queryUrl));
            JSONObject root = new JSONObject(source);
            item = (JSONObject) root.get("d");
        } catch (Exception ex) {
            Logger.getLogger(MediaItemBuilder.class.getName()).log(Level.WARNING, null, ex);
        }
    }
}

From source file:com.almende.eve.transport.http.HttpTransportBuilder.java

/**
 * Gets the instance by params./* w ww . jav a  2  s  .c o m*/
 * 
 * @param params
 *            the params
 * @return the instance by params
 */
public HttpService getInstanceByParams(final ObjectNode params) {
    HttpService service = null;
    final HttpTransportConfig config = HttpTransportConfig.decorate(params);
    final String servletUrl = config.getServletUrl();
    if (servletUrl != null) {
        try {
            final URI servletUri = URIUtil.parse(servletUrl);
            if (services.containsKey(servletUri)) {
                // Shortcut, it already exists and is launched.
                return services.get(servletUri);
            }
            service = new HttpService(servletUri, params);
            services.put(servletUri, service);

        } catch (final URISyntaxException e) {
            LOG.log(Level.WARNING, "Couldn't parse 'servletUrl'", e);
        }
    } else {
        LOG.warning("Parameter 'servletUrl' is required.");
    }
    return service;
}

From source file:fr.gouv.vitam.utils.logging.CommonsLoggerFactory.java

@Override
protected void seLevelSpecific(final VitamLogLevel level) {
    // XXX FIXME does not work for Apache Commons Logger
    switch (level) {
    case TRACE://w w  w . ja  v  a2 s. co  m
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.FINEST);
        break;
    case DEBUG:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.FINE);
        break;
    case INFO:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.INFO);
        break;
    case WARN:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.WARNING);
        break;
    case ERROR:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.SEVERE);
        break;
    default:
        LogFactory.getFactory().setAttribute(LogFactory.PRIORITY_KEY, Level.WARNING);
        break;
    }
}