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.almende.eve.transport.Router.java

@Override
public void connect() throws IOException {
    final Set<Transport> result = new HashSet<Transport>(transports.size());
    for (final Transport transport : transports.values()) {
        result.add(transport);/*w w w . j a v  a 2 s  .  co  m*/
    }
    for (final Transport transport : result) {
        final long[] sleep = new long[1];
        sleep[0] = 1000L;
        final double rnd = Math.random();
        final ScheduledThreadPoolExecutor STE = ThreadPool.getScheduledPool();
        STE.schedule(new Runnable() {
            @Override
            public void run() {
                try {
                    transport.connect();
                } catch (IOException e) {
                    LOG.log(Level.WARNING, "Failed to reconnect agent on new transport.", e);
                    if (sleep[0] <= 80000) {
                        sleep[0] *= 2;
                        STE.schedule(this, (long) (sleep[0] * rnd), TimeUnit.MILLISECONDS);
                    }
                }
            }

        }, (long) (sleep[0] * rnd), TimeUnit.MILLISECONDS);
    }
}

From source file:com.github.thesmartenergy.cnr.ChargingPlanSubscriber.java

@Override
public void run() {
    LOG.info("Starting worker.");
    while (!Thread.currentThread().isInterrupted()) {
        try {//  ww  w  .  j a v a  2 s  .co m
            ReceiveQueueMessageResult result = service.receiveQueueMessage(queue, opts);
            BrokeredMessage message = result.getValue();
            if (message == null) {
                continue;
            }

            System.out.println(message.getContentType());
            System.out.println(message.getCorrelationId());
            System.out.println(message.getDate());
            System.out.println(message.getDeliveryCount());
            System.out.println(message.getLabel());
            System.out.println(message.getLockLocation());
            System.out.println(message.getLockToken());
            System.out.println(message.getLockedUntilUtc());
            System.out.println(message.getMessageId());
            System.out.println(message.getMessageLocation());
            System.out.println(message.getPartitionKey());
            System.out.println(message.getProperties());
            System.out.println(message.getReplyTo());
            System.out.println(message.getSessionId());

            // SCP response
            String id = message.getMessageId();
            if (id == null) {
                LOG.log(Level.WARNING, "received message with null id. Try to delete:");
                try {
                    service.deleteMessage(message);
                } catch (Exception ex) {
                    LOG.warning("error while trying to delete message: " + ex.getMessage());
                    ex.printStackTrace();
                    LOG.warning("this was the content:");
                    System.out.println(IOUtils.toString(message.getBody(), "UTF-8"));
                }
                continue;
            } else {
                LOG.info("received response " + id);
            }

            byte[] body = IOUtils.toByteArray(message.getBody());
            String bodyAsString = IOUtils.toString(body, "UTF-8");
            LOG.info(bodyAsString);

            // strangely, string starts with "@strin3http://schemas.microsoft.com/2003/10/Serialization/?f<s:Envelope ..." on this side, 
            // although it starts with  "<?xml version="1.0" encoding="UTF-8"?> <s:Envelope ..." on the other side
            // so ... ugly hack
            bodyAsString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                    + bodyAsString.substring(64, bodyAsString.length() - 1);

            ResourceDescription presentation = new ResourceDescription(DEV_BASE + "outputGraph");
            Model output;
            try {
                PresentationUtils presentationUtils = new PresentationUtils();
                SPARQLGenerateHandler lifter = new SPARQLGenerateHandler(BASE, presentationUtils);
                output = lifter.lift(MediaType.APPLICATION_XML_TYPE, presentation,
                        IOUtils.toInputStream(bodyAsString, "UTF-8"));
            } catch (RDFPException ex) {
                throw new PEPException("error while lifting output", ex);
            }

            ProcessExecution processExecution = smartChargingProvider.find(id);
            processExecution = new ProcessExecutionImpl(BASE, processExecution.getContainerPath(),
                    processExecution.getId(), processExecution.getInput(),
                    CompletableFuture.completedFuture(output));
            smartChargingProvider.update(processExecution);

            // Delete message from queue
            service.deleteMessage(message);

        } catch (ServiceException | IOException | PEPException ex) {
            LOG.log(Level.WARNING, "error while processing input ", ex);
        }
        try {
            Thread.sleep(3000);
        } catch (InterruptedException ex) {
            Thread.currentThread().interrupt();
        }
    }
    LOG.info("Stopping worker.");
}

From source file:de.romankreisel.faktotum.FaktotumContextListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    try (InputStream is = sce.getServletContext()
            .getResourceAsStream(FaktotumContextListener.RELATIVE_MANIFEST_PATH)) {
        Manifest manifest = new Manifest(is);
        Attributes attributes = manifest.getMainAttributes();
        String buildTimeString = attributes.getValue("Build-Time");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (StringUtils.isNotBlank(buildTimeString)) {
            FaktotumContextListener.buildTime = simpleDateFormat.parse(buildTimeString);
        }/*  w  ww  .  ja va 2 s  .c o m*/
        FaktotumContextListener.version = attributes.getValue("Implementation-Version");
        this.getLogger().info("Faktotum initialized");
        this.getLogger().info("Version: " + FaktotumContextListener.getVersion());
        this.getLogger().info("Build-Time: " + simpleDateFormat.format(FaktotumContextListener.getBuildTime()));

        this.getLogger().fine("Removing old sessions...");
        this.authenticationBean.removeOldSessions();
    } catch (IOException e) {
        this.getLogger().log(Level.WARNING, "Error reading build time from manifest", e);
    } catch (ParseException e) {
        this.getLogger().log(Level.WARNING, "Error parsing build time from manifest", e);
    } catch (Exception e) {
        this.getLogger().log(Level.SEVERE, "Error reading build time", e);
        throw e;
    }
}

From source file:org.gvnix.dynamic.configuration.roo.addon.Commands.java

@CliCommand(value = "configuration property add", help = "Make a property available for all configurations")
public void propertyAdd(
        @CliOption(key = "name", mandatory = true, help = "Name of property to add", optionContext = DynPropertyConverter.SOURCE_FILES) DynProperty name) {

    // Add the property and show a message
    Boolean added = operations.addProperty(name.getKey());
    if (added == null) {

        logger.log(Level.WARNING, "Property not exists");

    } else if (added == true) {

        logger.log(Level.INFO, "Property available for all configurations");
        logger.log(Level.INFO, "(use 'configuration property value' to set property new values)");
        logger.log(Level.INFO, "(use 'configuration property undefined' to set property with no values)");

    } else {/*w w w  .  jav a2  s.  c  om*/

        logger.log(Level.WARNING, "Property already available for configurations");
        logger.log(Level.WARNING,
                "(use 'configuration property value' to set property new values by configuration)");
    }
}

From source file:org.kontalk.client.DownloadClient.java

/**
 * Downloads to a directory represented by a {@link File} object,
 * determining the file name from the Content-Disposition header.
 * @param url URL of file//from   w  w w .ja v a  2s  . co m
 * @param base base directory in which the download is saved
 * @param listener listener for download progress
 * @return the absolute file path of the downloaded file, or an empty string
 * if the file could not be downloaded
 */
public String download(String url, File base) {
    if (mHTTPClient == null) {
        mHTTPClient = createHTTPClient(mPrivateKey, mCertificate, mValidateCertificate);
        if (mHTTPClient == null)
            return "";
    }

    LOGGER.info("downloading file from URL=" + url + "...");
    mCurrentRequest = new HttpGet(url);

    // execute request
    CloseableHttpResponse response;
    try {
        response = mHTTPClient.execute(mCurrentRequest);
    } catch (IOException ex) {
        LOGGER.log(Level.WARNING, "can't execute request", ex);
        return "";
    }

    try {
        int code = response.getStatusLine().getStatusCode();
        // HTTP/1.1 200 OK -- other codes should throw Exceptions
        if (code != 200) {
            LOGGER.warning("invalid response code: " + code);
            return "";
        }

        // get filename
        Header dispHeader = response.getFirstHeader("Content-Disposition");
        if (dispHeader == null) {
            LOGGER.warning("no content header");
            return "";
        }
        String filename = parseContentDisposition(dispHeader.getValue());
        // never trust incoming data
        filename = filename != null ? new File(filename).getName() : "";
        if (filename.isEmpty()) {
            LOGGER.warning("no filename in content: " + dispHeader.getValue());
            return "";
        }

        // get file size
        long s = -1;
        Header lengthHeader = response.getFirstHeader("Content-Length");
        if (lengthHeader == null) {
            LOGGER.warning("no length header");
        } else {
            try {
                s = Long.parseLong(lengthHeader.getValue());
            } catch (NumberFormatException ex) {
                LOGGER.log(Level.WARNING, "can' parse file size", ex);
            }
        }
        final long fileSize = s;
        mListener.updateProgress(s < 0 ? -2 : 0);

        // TODO should check for content-disposition parsing here
        // and choose another filename if necessary
        HttpEntity entity = response.getEntity();
        if (entity == null) {
            LOGGER.warning("no entity in response");
            return "";
        }

        File destination = new File(base, filename);
        if (destination.exists()) {
            LOGGER.warning("file already exists: " + destination.getAbsolutePath());
            return "";
        }
        try (FileOutputStream out = new FileOutputStream(destination)) {
            CountingOutputStream cOut = new CountingOutputStream(out) {
                @Override
                protected synchronized void afterWrite(int n) {
                    if (fileSize <= 0)
                        return;

                    // inform listener
                    mListener.updateProgress((int) (this.getByteCount() / (fileSize * 1.0) * 100));
                }
            };
            entity.writeTo(cOut);
        } catch (IOException ex) {
            LOGGER.log(Level.WARNING, "can't download file", ex);
            return "";
        }

        LOGGER.info("... download successful!");
        return destination.getAbsolutePath();
    } finally {
        try {
            response.close();
        } catch (IOException ex) {
            LOGGER.log(Level.WARNING, "can't close response", ex);
        }
    }
}

From source file:com.michelin.cio.jenkins.plugin.rrod.RequestRenameOrDeletePlugin.java

public HttpResponse doManageRequests(StaplerRequest request, StaplerResponse response)
        throws IOException, ServletException {
    Hudson.getInstance().checkPermission(Hudson.ADMINISTER);

    errors.clear();/*from w ww  .  j  a v a 2 s. c  om*/

    String[] selectedRequests = request.getParameterValues("selected");

    //Store the request once they have been applied
    List<Request> requestsToRemove = new ArrayList<Request>();

    if (selectedRequests != null && selectedRequests.length > 0) {
        for (String sindex : selectedRequests) {
            if (StringUtils.isNotBlank(sindex)) {
                int index = Integer.parseInt(sindex);
                Request currentRequest = requests.get(index);

                if (StringUtils.isNotBlank(request.getParameter("apply"))) {

                    if (currentRequest.process()) {
                        //Store to remove
                        requestsToRemove.add(currentRequest);
                    } else {
                        errors.add(currentRequest.getErrorMessage());
                        LOGGER.log(Level.WARNING, "The request \"{0}\" can not be processed",
                                currentRequest.getMessage());
                    }
                } else {
                    requestsToRemove.add(currentRequest);
                    LOGGER.log(Level.INFO, "The request \"{0}\" has been discarded",
                            currentRequest.getMessage());
                }

            } else {
                LOGGER.log(Level.WARNING, "The request index is not defined");
            }
        }
    } else {
        LOGGER.log(Level.FINE, "Nothing selected");
    }

    //Once it has done thr work, it removes the applied requests
    if (!requestsToRemove.isEmpty()) {
        removeAllRequests(requestsToRemove);
    }

    return new HttpRedirect(".");
}

From source file:com.subgraph.vega.internal.http.proxy.HttpProxy.java

@Override
public void startProxy() {
    try {/*  w  ww . j  a v  a2  s .c  om*/
        logger.info("Listening on port " + listenPort);
        serverSocket = new ServerSocket(listenPort);
        proxyThread = new Thread(createProxyLoopRunnable());
        proxyThread.start();
    } catch (IOException e) {
        logger.log(Level.WARNING, "IO error creating listening socket: " + e.getMessage(), e);
    }
}

From source file:org.gvnix.dynamic.configuration.roo.addon.config.XpathElementsDynamicConfiguration.java

/**
 * {@inheritDoc}//  w ww  . j a v  a  2  s . c  o  m
 */
@Override
public void write(DynPropertyList dynProps) {

    // Get the XML file path
    MutableFile file = getFile();
    if (file != null) {

        // Obtain the root element of the XML file
        Document doc = getXmlDocument(file);

        // Update the root element property values with dynamic properties
        for (DynProperty dynProp : dynProps) {

            // Obtain the element related to this dynamic property
            String xpath = getXpath() + XPATH_ARRAY_PREFIX + getKey() + XPATH_EQUALS_SYMBOL
                    + XPATH_STRING_DELIMITER + getKeyValue(dynProp.getKey()) + XPATH_STRING_DELIMITER
                    + XPATH_ARRAY_SUFIX;
            Element elem = XmlUtils.findFirstElement(xpath, doc.getDocumentElement());
            if (elem == null) {

                logger.log(Level.WARNING, "Element " + xpath + " to set value not exists on file");
            } else {

                // If target element exists, set new value
                Element value = XmlUtils.findFirstElement(getValue(), elem);
                if (value == null) {

                    logger.log(Level.WARNING, "Element  " + xpath + " to set value not exists on file");
                } else {

                    value.setTextContent(dynProp.getValue());
                }
            }
        }

        // Update the XML file
        XmlUtils.writeXml(file.getOutputStream(), doc);

    } else if (!dynProps.isEmpty()) {

        logger.log(Level.WARNING,
                "File " + getFilePath() + " not exists and there are dynamic properties to set it");
    }
}

From source file:com.marvelution.hudson.plugins.apiv2.resources.impl.ActivityRestResourceImpl.java

/**
 * {@inheritDoc}// ww  w  . ja  v  a 2  s.  co  m
 */
@Override
public Activities getActivities(ActivityType[] types, String[] jobs, String[] userIds, int maxResults) {
    Activities activities = new Activities();
    for (ActivityCache cache : getFilteredActivities(types, jobs, userIds)) {
        try {
            hudson.model.Job<?, ? extends AbstractBuild<?, ?>> job = getHudsonJob(cache.getJob());
            if (job.hasPermission(Project.READ)) {
                if (cache instanceof BuildActivityCache) {
                    activities.add(getBuildActivityFromCache((BuildActivityCache) cache, job));
                } else if (cache instanceof JobActivityCache) {
                    activities.add(getJobActivityFromCache((JobActivityCache) cache, job));
                }
                if (activities.size() == maxResults) {
                    // We have the maximum number of results wanted
                    break;
                }
            }
        } catch (Exception e) {
            LOGGER.log(Level.WARNING,
                    "Failed to add ActivityCache object " + cache.toString() + ". Reason: " + e.getMessage(),
                    e);
        }
    }
    return activities;
}