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.subgraph.vega.internal.crawler.RequestConsumer.java

private void runLoop() throws InterruptedException {
    while (!stop) {
        CrawlerTask task = (CrawlerTask) crawlerRequestQueue.take();

        if (task.isExitTask()) {
            // Put poison pill back in queue so every other RequestConsumer task will see it.
            crawlerRequestQueue.add(task);
            return;
        }//w w w . j a  va2  s .c o m

        logger.info("Retrieving: " + task.getRequest().getRequestLine().getUri());

        if (!sendRequest(task)) {
            if (!stop && !task.causedException()) {
                logger.log(Level.WARNING,
                        "No response was receiven for request to " + task.getRequest().getURI());
            }
        }
        crawlerResponseQueue.put(task);
    }
}

From source file:cz.cas.lib.proarc.common.process.ExternalProcess.java

@Override
public void run() {
    Map<String, String> env = buildEnv(conf);
    List<String> cmdLine = buildCmdLine(conf);
    try {//from w  ww. j a v a2  s. c o m
        int retry = getRetryCount() + 1;
        for (int i = 0; i < retry; i++) {
            runCmdLine(cmdLine, env);
            if (isOk()) {
                return;
            }
            LOG.log(Level.WARNING, "{0}. failure, \n{1}, \nCmd: {2}",
                    new Object[] { i + 1, getFullOutput(), cmdLine });
        }
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    } catch (InterruptedException ex) {
        throw new IllegalStateException(ex);
    }
}

From source file:com.levalo.contacts.view.ContactView.java

public StreamedContent doExportContactToXml(Contact contact) {
    try {//from  w  w  w  .ja  v  a2 s .co  m
        String xmlContactString = contactService.getXmlFromContact(contact);
        InputStream xmlContactStream = new ByteArrayInputStream(xmlContactString.getBytes());
        String title = contact.getFirstname() + "_" + contact.getLastname() + ".xml";
        StreamedContent xmlContact = new DefaultStreamedContent(xmlContactStream, "text/xml", title);
        return xmlContact;
    } catch (Exception ex) {
        logger.log(Level.WARNING, ex.getMessage());
        return null;
    }
}

From source file:cz.incad.kramerius.k5indexer.IndexDocs.java

private void getDocs(int start) throws Exception {

    _init = true;//from  w  ww .  jav a2  s.  c  o  m
    docs.clear();

    String urlStr = host + "/select?wt=" + wt + "&q=" + URLEncoder.encode(query, "UTF-8") + "&rows=" + rows
            + "&start=" + (start + initStart);
    if (fl != null) {
        urlStr += "&fl=" + fl;
    }
    logger.log(Level.INFO, "urlStr: {0}", urlStr);

    java.net.URL url = new java.net.URL(urlStr);
    InputStream is;
    StringWriter resp = new StringWriter();
    try {
        is = url.openStream();
    } catch (Exception ex) {
        logger.log(Level.WARNING, "", ex);
        is = url.openStream();
    }

    if (wt.equals("json")) {
        org.apache.commons.io.IOUtils.copy(is, resp, "UTF-8");
        JSONObject json = new JSONObject(resp.toString());
        JSONObject response = json.getJSONObject("response");
        numFound = response.getInt("numFound");
        JSONArray jdocs = response.getJSONArray("docs");
        numDocs = jdocs.length();
        for (int i = 0; i < jdocs.length(); i++) {
            docs.add(jdocs.getJSONObject(i));
        }
    } else {

        Document respDoc = builder.parse(is);
        numFound = Integer.parseInt(respDoc.getElementsByTagName("result").item(0).getAttributes()
                .getNamedItem("numFound").getNodeValue());
        numDocs = respDoc.getElementsByTagName("doc").getLength();
        docs.add(respDoc);
    }

}

From source file:alfio.config.Initializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);

    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());

    configureSessionCookie(servletContext);

    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);/*from w  w w .  j ava 2  s.c  om*/

    Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", cef);
    characterEncodingFilter.setAsyncSupported(true);
    characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");

    //force log initialization, then disable it
    XRLog.setLevel(XRLog.EXCEPTION, Level.WARNING);
    XRLog.setLoggingEnabled(false);

}

From source file:com.example.getstarted.auth.Oauth2CallbackServlet.java

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {

    // Ensure that this is no request forgery going on, and that the user
    // sending us this connect request is the user that was supposed to.
    if (req.getSession().getAttribute("state") == null
            || !req.getParameter("state").equals((String) req.getSession().getAttribute("state"))) {
        resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        logger.log(Level.WARNING, "Invalid state parameter, expected "
                + (String) req.getSession().getAttribute("state") + " got " + req.getParameter("state"));
        resp.sendRedirect("/books");
        return;/* w  w w  . j  av a 2s  . c  o m*/
    }

    req.getSession().removeAttribute("state"); // Remove one-time use state.

    flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
            getServletContext().getInitParameter("bookshelf.clientID"),
            getServletContext().getInitParameter("bookshelf.clientSecret"), SCOPES).build();

    final TokenResponse tokenResponse = flow.newTokenRequest(req.getParameter("code"))
            .setRedirectUri(getServletContext().getInitParameter("bookshelf.callback")).execute();

    req.getSession().setAttribute("token", tokenResponse.toString()); // Keep track of the token.
    final Credential credential = flow.createAndStoreCredential(tokenResponse, null);
    final HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(credential);

    final GenericUrl url = new GenericUrl(USERINFO_ENDPOINT); // Make an authenticated request.
    final HttpRequest request = requestFactory.buildGetRequest(url);
    request.getHeaders().setContentType("application/json");

    final String jsonIdentity = request.execute().parseAsString();
    @SuppressWarnings("unchecked")
    HashMap<String, String> userIdResult = new ObjectMapper().readValue(jsonIdentity, HashMap.class);
    // From this map, extract the relevant profile info and store it in the session.
    req.getSession().setAttribute("userEmail", userIdResult.get("email"));
    req.getSession().setAttribute("userId", userIdResult.get("sub"));
    req.getSession().setAttribute("userImageUrl", userIdResult.get("picture"));
    logger.log(Level.INFO,
            "Login successful, redirecting to " + (String) req.getSession().getAttribute("loginDestination"));
    resp.sendRedirect((String) req.getSession().getAttribute("loginDestination"));
}

From source file:fr.logfiletoes.Config.java

/**
 * //w  w w .jav a2 s  . co  m
 * @param unitFormJson
 * @return 
 */
protected Unit createUnit(JSONObject unitFormJson) {
    Unit unit = new Unit();

    if (unitFormJson.has("file")) {
        String filepathUnit = unitFormJson.getString("file");
        File file = new File(filepathUnit);
        if (file.exists()) {
            unit.setLogFile(file);
        } else {
            LOG.warning("file error");
            return null;
        }
    } else {
        LOG.warning("file is required");
        return null;
    }

    if (unitFormJson.has("pattern")) {
        String pattern = unitFormJson.getString("pattern");
        try {
            unit.setLogPattern(pattern);
        } catch (PatternSyntaxException exception) {
            LOG.log(Level.WARNING, "pattern error", exception);
            return null;
        }
    } else {
        LOG.warning("Pattern of unit config is required");
        return null;
    }

    if (unitFormJson.has("elasticsearch")) {
        JSONObject elasticSearchJson = unitFormJson.getJSONObject("elasticsearch");
        ElasticSearch createElasticSearch = createElasticSearch(elasticSearchJson);
        if (createElasticSearch == null) {
            LOG.log(Level.WARNING, "elasticsearch error");
        } else {
            unit.setElasticSearch(createElasticSearch);
        }
    } else {
        LOG.warning("elasticsearch is required");
        return null;
    }

    if (unitFormJson.has("fields")) {
        JSONObject mapping = unitFormJson.getJSONObject("fields");
        unit.setGroupToField(extractMappingForUnit(mapping));
    }

    if (unitFormJson.has("concatPreviousLog")) {
        String concatPreviousLog = unitFormJson.getString("concatPreviousLog");
        try {
            unit.setConcatPreviousPattern(concatPreviousLog);
        } catch (PatternSyntaxException exception) {
            LOG.log(Level.WARNING, "concatPreviousLog error", exception);
        }
    } else {
        LOG.info("concatPreviousLog can be used to no matching is concat previous log line");
    }

    if (unitFormJson.has("timestamp")) {
        JSONObject timestampConfig = unitFormJson.getJSONObject("timestamp");
        Integer field = null;
        String format = null;
        String addField = null;
        if (timestampConfig.has("field")) {
            field = timestampConfig.getInt("field");
        } else {
            LOG.warning("Position of field is required for timestamp");
        }
        if (timestampConfig.has("format")) {
            format = timestampConfig.getString("format");
        } else {
            LOG.warning("Format (from SimpleDateFormat) is required for date to timestamp");
        }
        if (timestampConfig.has("addField")) {
            addField = timestampConfig.getString("addField");
        } else {
            LOG.warning("addField is required for add timestamp in new field in elasticsearch format");
        }

        if (field != null && format != null && addField != null) {
            unit.setFieldToTimestamp(field);
            unit.setSdf(new SimpleDateFormat(format));
            unit.setAddFieldToTimestamp(addField);
        }
    }

    return unit;
}

From source file:tools.datasync.db2db.seed.DbSeedProducer.java

public boolean publish(JSON record) throws InterruptedException {

    if (stop) {//from  ww w.  j a va  2 s .c  o  m
        throw new InterruptedException("");
    }
    SeedRecord seed = null;
    try {
        String entityId = Ids.EntityId.get(record.getEntity());
        String recordId = String.valueOf(record.get(Ids.KeyColumn.get(record.getEntity())));
        String recordJson = jsonMapper.writeValueAsString(record);
        String recordHash = hashGenerator.generate(recordJson);
        String origin = me.getPeerId();
        seed = new SeedRecord(entityId, recordId, recordHash, recordJson, origin);
        logger.finest("generated seed record: " + seed);
    } catch (IOException e) {
        exceptionHandler.handle(e, Level.WARNING, "Error while JSON Serialization", record);
    }

    try {
        if (seed != null) {
            logger.finer("Publishing seed record: " + seed);
            dataHandler.seedOut(seed);
            return true;
        }
    } catch (Exception ex) {
        exceptionHandler.handle(ex, Level.WARNING, "Error while sending record to peer", record);
    }

    return false;
}

From source file:daylightchart.gui.util.GuiAction.java

/**
 * {@inheritDoc}//  w  w w  .j  av  a 2  s .c  o  m
 *
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
@Override
public void actionPerformed(final ActionEvent e) {
    try {
        final ActionListener[] actionListeners = listeners.getListeners(ActionListener.class);
        for (final ActionListener actionListener : actionListeners) {
            actionListener.actionPerformed(e);
        }
    } catch (final Exception ex) {
        LOGGER.log(Level.WARNING, "Cannot perform action - " + getValue(SHORT_DESCRIPTION), ex);
    }
}

From source file:com.simplyian.voxelscript.script.JSLoader.java

/**
 * Loads a package provided its directory.
 *
 * @param name/*www . j a  v  a2s  . co  m*/
 * @param dir
 * @return
 * @throws IOException
 */
public Package loadPackage(String name, File dir) throws IOException {
    Scriptable packageScope = cx.newObject(scope);
    packageScope.setPrototype(scope);
    packageScope.setParentScope(scope);
    packageScope.put("include", scope, new IncludeFunction(plugin, dir, this, packageScope));
    packageScope.put("resource", scope, new ResourceFunction(plugin, dir));

    File mainFile = null;
    PackageDescription desc = null;

    File packageJson = new File(dir.getPath(), "package.json");
    if (!packageJson.exists()) {
        plugin.getLogger().log(Level.WARNING, "A package.json was not found for the package '" + name + "'.");
        mainFile = new File(dir.getPath(), "index.js");
        if (!mainFile.exists()) {
            plugin.getLogger().log(Level.WARNING,
                    "An index.js was not found for the package '" + name + "'. This package was not loaded.");
            return null;
        }
        desc = PackageDescription.load(name, null);
    } else {
        // TODO load package.json
    }

    String script = FileUtils.readFileToString(mainFile);
    if (loadingPackages.contains(name.toLowerCase())) {
        plugin.getLogger().log(Level.WARNING,
                "Circular dependency detected for something wanting package '" + name + "'. Stopping...");
        return null;
    }

    loadingPackages.add(name.toLowerCase());
    Scriptable exports = runScript(name, script, packageScope);
    loadingPackages.remove(name.toLowerCase());
    if (exports == null) {
        return null;
    }
    return new Package(desc, exports);
}