List of usage examples for java.util.logging Level FINE
Level FINE
To view the source code for java.util.logging Level FINE.
Click Source Link
From source file:org.tomitribe.tribestream.registryng.repository.Repository.java
public Endpoint findEndpointFromHumanReadableMeta(final String humanReadableApplicationName, final String verb, final String humanReadableEndpointPath, final String version) { try {//from w ww. j a v a2 s .co m final List<Endpoint> endpoints = ofNullable(version).filter(v -> !v.trim().isEmpty()) .map(v -> em.createNamedQuery(Endpoint.Queries.FIND_BY_HUMAN_REDABLE_PATH, Endpoint.class) .setParameter("applicationVersion", version)) .orElseGet(() -> em.createNamedQuery(Endpoint.Queries.FIND_BY_HUMAN_REDABLE_PATH_NO_VERSION, Endpoint.class)) .setParameter("applicationName", humanReadableApplicationName).setParameter("verb", verb) .setParameter("endpointPath", humanReadableEndpointPath).setMaxResults(2).getResultList(); if (endpoints.size() > 1) { throw new IllegalArgumentException("Conflicting endpoints: " + endpoints); } if (endpoints.isEmpty()) { return null; } return endpoints.get(0); } catch (final NoResultException e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Could not find endpoint by {0}/{1}/{2}", new Object[] { humanReadableApplicationName, verb, humanReadableEndpointPath }); } return null; } }
From source file:com.match_tracker.twitter.TwitterSearch.java
protected Integer search(String queryString, TweetCallbackListener callback) throws UnirestException { Integer offset = 0;/*from w w w.j a v a 2s . c o m*/ Integer currentResultsSize = 0; do { log.log(Level.FINE, "Sending Twitter search query: {0} @ {1}", new Object[] { queryString, offset }); JsonObject results = this.retrieveSearchResults(queryString, offset); results.get("tweets").asArray().forEach(tweet -> callback.onTweet(tweet.asObject())); currentResultsSize = results.get("search").asObject().get("current").asInt(); offset += currentResultsSize; log.log(Level.FINE, "Twitter search ({0}) results: {1}", new Object[] { queryString, offset }); } while (currentResultsSize > 0); return offset; }
From source file:net.consulion.jeotag.PhotoLoader.java
private static Boolean photoHasGeotag(final TiffImageMetadata exif, final File file) { Boolean hasGeoTag = false;/*w w w . j av a2s . co m*/ try { final TiffImageMetadata.GPSInfo gps = exif.getGPS(); if (gps != null && gps.getLatitudeAsDegreesNorth() != 0 && gps.getLongitudeAsDegreesEast() != 0) { hasGeoTag = Boolean.TRUE; } } catch (ImageReadException ex) { Logger.getLogger(PhotoLoader.class.getName()).log(Level.FINE, null, String.format("File: %s couldn't be read. Cause: %s", file.getPath(), ex.getMessage())); } return hasGeoTag; }
From source file:ste.web.http.beanshell.BeanShellHandler.java
@Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { String uri = request.getRequestLine().getUri(); int pos = uri.indexOf('?'); if (pos >= 0) { uri = uri.substring(0, pos);/*from www . java 2 s .c o m*/ } if (log.isLoggable(Level.FINE)) { log.fine(String.format("serving %s", uri)); } if (controllersFolder == null) { controllersFolder = DEFAULT_CONTROLLERS_PREFIX; } else { // // let's fix a common mistake :) // if (!controllersFolder.startsWith("/")) { setControllersFolder('/' + getControllersFolder()); } } File scriptFile = new File(appsRoot, uri); String controllerPath = scriptFile.getParent() + getControllersFolder(); scriptFile = new File(controllerPath, scriptFile.getName()); if (log.isLoggable(Level.FINE)) { log.fine(String.format("script path: %s", scriptFile.getAbsolutePath())); } try { Interpreter bsh = new Interpreter(); BeanShellUtils.setup(bsh, request, response, (HttpSessionContext) context); bsh.set(VAR_SOURCE, scriptFile.getAbsolutePath()); bsh.eval(BeanShellUtils.getScript(scriptFile)); String view = (String) bsh.get(ATTR_VIEW); if (view == null) { throw new HttpException( "view not defined. Set the variable 'view' to the name of the view to show (including .v)."); } if (log.isLoggable(Level.FINE)) { log.fine("view: " + view); } BeanShellUtils.cleanup(bsh, request); BeanShellUtils.setVariablesAttributes(bsh, context); } catch (FileNotFoundException e) { response.setStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, "Script " + scriptFile + " not found."); } catch (EvalError x) { String msg = x.getMessage(); if (log.isLoggable(Level.SEVERE)) { log.severe(String.format("error evaluating: %s: %s", uri, msg)); log.throwing(getClass().getName(), "handleError", x); } throw new HttpException("error evaluating " + uri + ": " + msg, x); } }
From source file:org.apache.cxf.transport.jms.JMSConduit.java
/** * Send the JMS Request out and if not oneWay receive the response * //from w w w . jav a 2s . co m * @param outMessage * @param request * @return inMessage */ public void sendExchange(final Exchange exchange, final Object request) { LOG.log(Level.FINE, "JMSConduit send message"); final Message outMessage = exchange.getOutMessage(); if (outMessage == null) { throw new RuntimeException("Exchange to be sent has no outMessage"); } JMSMessageHeadersType headers = (JMSMessageHeadersType) outMessage .get(JMSConstants.JMS_CLIENT_REQUEST_HEADERS); JmsTemplate jmsTemplate = JMSFactory.createJmsTemplate(jmsConfig, headers); if (!exchange.isOneWay() && jmsListener == null) { jmsListener = JMSFactory.createJmsListener(jmsConfig, this, jmsConfig.getReplyDestination(), conduitId); } final javax.jms.Destination replyTo = exchange.isOneWay() ? null : jmsListener.getDestination(); final String correlationId = (headers != null && headers.isSetJMSCorrelationID()) ? headers.getJMSCorrelationID() : JMSUtils.createCorrelationId(jmsConfig.getConduitSelectorPrefix() + conduitId, messageCount.incrementAndGet()); MessageCreator messageCreator = new MessageCreator() { public javax.jms.Message createMessage(Session session) throws JMSException { String messageType = jmsConfig.getMessageType(); final javax.jms.Message jmsMessage; jmsMessage = JMSUtils.buildJMSMessageFromCXFMessage(outMessage, request, messageType, session, replyTo, correlationId); LOG.log(Level.FINE, "client sending request: ", jmsMessage); return jmsMessage; } }; /** * If the message is not oneWay we will expect to receive a reply on the listener. To receive this * reply we add the correlationId and an empty CXF Message to the correlationMap. The listener will * fill to Message and notify this thread */ if (!exchange.isOneWay()) { synchronized (exchange) { correlationMap.put(correlationId, exchange); jmsTemplate.send(jmsConfig.getTargetDestination(), messageCreator); if (exchange.isSynchronous()) { try { exchange.wait(jmsTemplate.getReceiveTimeout()); } catch (InterruptedException e) { correlationMap.remove(correlationId); throw new RuntimeException(e); } correlationMap.remove(correlationId); if (exchange.get(CORRELATED) == null) { throw new RuntimeException("Timeout receiving message with correlationId " + correlationId); } } } } else { jmsTemplate.send(jmsConfig.getTargetDestination(), messageCreator); } }
From source file:edu.usu.sdl.openstorefront.service.OrganizationServiceImpl.java
private void extractOrg(Class organizationClass) { log.log(Level.FINE, MessageFormat.format("Extracting Orgs from {0}", organizationClass.getSimpleName())); List<ODocument> documents = persistenceService.query( "Select DISTINCT(organization) as organization from " + organizationClass.getSimpleName(), new HashMap<>()); log.log(Level.FINE, MessageFormat.format("Found: {0}", documents.size())); documents.forEach(document -> {/*from w w w . j a v a 2 s.c o m*/ String org = document.field("organization"); addOrganization(org); }); }
From source file:fitnesse.FitNesseExpediter.java
private Response makeResponse(final Request request) throws Exception { Response response;//from w w w.ja v a2s. com try { executorService.submit(new Callable<Request>() { @Override public Request call() throws Exception { request.parse(); return request; } }).get(requestParsingTimeLimit, TimeUnit.MILLISECONDS); if (request.hasBeenParsed()) { if (context.contextRoot.equals(request.getRequestUri() + "/")) { response = new SimpleResponse(); response.redirect(context.contextRoot, ""); } else { response = createGoodResponse(request); } } else { response = reportError(request, 400, "The request could not be parsed."); } } catch (SocketException se) { throw se; } catch (TimeoutException e) { String message = "The client request has been unproductive for too long. It has timed out and will no longer be processed."; LOG.log(Level.FINE, message, e); response = reportError(request, 408, message); } catch (HttpException e) { LOG.log(Level.FINE, "An error occured while fulfilling user request", e); response = reportError(request, 400, e.getMessage()); } catch (Exception e) { LOG.log(Level.WARNING, "An error occured while fulfilling user request", e); response = reportError(request, e); } // Add those as default headers? response.addHeader("Server", "FitNesse-" + context.version); response.addHeader("Connection", "close"); return response; }
From source file:com.matthewcasperson.validation.filter.ParameterValidationFilter.java
/** * This filter implements multiple chains of validation rules. Each chain is executed against each parameter until * alll validation rules have been executed, or until one of the validation rules stops the execution of the chain. *//*from www . j a v a 2s . c om*/ @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { //LOGGER.log(Level.INFO, "Parameter Validation Filter processing request"); ServletRequest requestWrapper = request; try { if (parameterValidationDefinitions != null && parameterValidationDefinitions.getParameterValidationDefinitions() != null) { LOGGER.log(Level.FINE, "Parameter Validation Filter has loaded the config file"); if (requestWrapper instanceof HttpServletRequest) { //LOGGER.log(Level.INFO, "Parameter Validation Filter is filtering a HttpServletRequest"); final HttpServletRequest httpServletRequest = (HttpServletRequest) requestWrapper; /* * Loop over each param. Note that while the validation rules may well * create wrappers that return different values for the params (i.e. requestWrapper is * updated to reference a new wrapper), we use this original copy for the list of * param keys to loop over. */ final Enumeration<String> iter = httpServletRequest.getParameterNames(); paramaterNameLoop: while (iter.hasMoreElements()) { /* * Get the param name and move the enumerator along */ final String paramName = iter.nextElement(); boolean paramValidated = false; LOGGER.log(Level.FINE, "Parameter Validation Filter processing " + paramName); /* * Loop over each validation rule in the chain */ final List<ParameterValidationChain> validationChains = parameterValidationDefinitions .getParameterValidationDefinitions(); for (final ParameterValidationChain validationChain : validationChains) { checkState(validationChain != null, "A validation rule should never be null"); /* * Test this validation rule against the param name */ final boolean paramMatches = validationChain.getParamNamePattern().matcher(paramName) .find(); final boolean uriMatches = validationChain.getRequestURIPattern() .matcher(httpServletRequest.getRequestURI()).find(); final boolean paramMatchesAfterNegation = paramMatches ^ validationChain.isParamNamePatternNegated(); final boolean uriMatchesAfterNegation = uriMatches ^ validationChain.isRequestURIPatternNegated(); if (paramMatchesAfterNegation && uriMatchesAfterNegation) { LOGGER.log(Level.FINE, "Parameter Validation Filter found matching chain"); /* * Make a note that this parameter has been validated by at least one rule */ paramValidated = true; /* * Loop over each rule in the chain */ for (final ParameterValidationDefinitionImpl validationRule : validationChain .getList()) { LOGGER.log(Level.FINE, "Processing " + paramName + " with " + validationRule.getValidationRuleName()); /* * Get the object that will actually do the validation */ final ParameterValidationRule rule = validationRule.getRule(); /* * It is possible that a bad configuration will result in rule being null */ checkState(rule != null, "A validation rule should never be null. Check the class name defined in the configuration xml file."); try { /* Process the parameter */ final ServletRequest processRequest = rule.processParameter(requestWrapper, paramName); checkState(processRequest != null, "A validation rule should never return null when processing a paramemter"); /* * The validation rule is expected to return a valid request regardless of the * processing that should or should not be done. */ requestWrapper = processRequest; } catch (final ValidationFailedException ex) { /* * Log this as a warning as we are probably interested in knowing when our apps * are getting hit with invalid data. */ LOGGER.log(Level.WARNING, ex.toString()); if (parameterValidationDefinitions.getEnforcingMode()) { /* If we are enforcing, rethrow so the outer catch block can block the request */ throw ex; } else { /* Otherwise move to the next parameter name. This allows us to be notified of every param that will fail instead of just bailing with the first one that fails. */ continue paramaterNameLoop; } } } } } if (!paramValidated) { /* * This might be intentional, so log it as an INFO */ LOGGER.log(Level.INFO, "PVF-INFO-0001: " + paramName + " has not been validated."); } } } } } catch (final ValidationFailedException ex) { /* * Stop processing and return a HTTP error code if we are enforcing the rules */ if (parameterValidationDefinitions.getEnforcingMode()) { respondWithBadRequest(response); return; } } catch (final Exception ex) { /* * We probably reach this because of some invalid state due to rules returning null * or throwing unchecked exceptions during their own processing. This is logged as * severe as it is most likely a bug in the code. */ LOGGER.log(Level.SEVERE, ExceptionUtils.getFullStackTrace(ex)); /* * Don't allow apps to process raw parameters if this filter has failed and we are * enforcing the rules */ if (parameterValidationDefinitions.getEnforcingMode()) { respondWithBadRequest(response); return; } } /* * Continue to the next filter */ if (parameterValidationDefinitions.getEnforcingMode()) { /* In enforcing mode we pass the wrapper onto the next filter */ chain.doFilter(requestWrapper, response); } else { /* If enforcing mode is not enabled, we pass through the original request */ chain.doFilter(request, response); } }
From source file:com.symbian.driver.plugins.comms.stat.StatProcess.java
/** * @see com.symbian.driver.core.extension.ISymbianProcessBuilder.ISymbianProcess#join() * //from ww w . j a v a 2 s.c om * Uses STAT to poll the executable by doing the following: * <nl> * <li> Poll for PID and sleep * <li> Check if process has completed normally * <li> Stop if polling failed 3 times, if the stop() method is called, or * if process timedout. * </nl> * */ public boolean join() { LOGGER.entering("StatProcess", "join"); int lRetry = 0; try { while (true) { LOGGER.info("Polling PID: " + iPid); JStatResult lPollResult = null; // 1. Poll + Sleep try { Thread.sleep(POLL_SLEEP); } catch (InterruptedException lInterruptedException) { // ignore interruption LOGGER.fine("Polling sleep interrupted."); } try { lPollResult = iStatProxy.getStat().poll(iPid); } catch (JStatException lJStatException) { int lRet = lJStatException.getResult().getReturnedValue(); // if 155/131 try again. if ((lRet == 155 || lRet == 131) && lRetry < 3) { LOGGER.log(Level.FINE, "JStat returned with an internal 155/131 when polling. Trying again: ", lJStatException); lRetry++; LOGGER.log(Level.SEVERE, "Failed to poll pid :" + iPid + " after 3 tries."); continue; } else { // try to kill the process before returning. LOGGER.info("Could not poll process, Trying to kill it - PID=" + iPid); try { iStatProxy.getStat().kill(iPid); } catch (JStatException lJException) { LOGGER.log(Level.SEVERE, "Could not kill process: " + iPid, lJException); } throw lJStatException; } } // reset lRetry. lRetry = 0; // 2. pid completed if (lPollResult != null && (lPollResult.getReturnedValue() == 0 || lPollResult.getReceivedData().equals("0"))) { LOGGER.info("Process with PID: " + iPid + " finished."); break; } // 3. check if timeout reached. if (STOP) { LOGGER.info("Timeout reached, Trying to kill it PID=" + iPid); try { iStatProxy.getStat().kill(iPid); } catch (JStatException lJException) { LOGGER.log(Level.SEVERE, "Could not kill process: " + iPid, lJException); } throw new TimeLimitExceededException("Command timed out."); } } return true; } catch (TimeLimitExceededException lTimeLimitExceededException) { LOGGER.log(Level.SEVERE, "Time limit exeeded", lTimeLimitExceededException); } catch (JStatException lJStatException) { LOGGER.log(Level.SEVERE, "STAT exception", lJStatException); } finally { LOGGER.exiting("StatProcess", "join"); stopTimer(); } return false; }
From source file:es.tor.push.android.Sender.java
/** * Sends a message to one device, retrying in case of unavailability. * /* w w w. j av a2 s .co m*/ * <p> * <strong>Note: </strong> this method uses exponential back-off to retry in * case of service unavailability and hence could block the calling thread * for many seconds. * * @param message * message to be sent, including the device's registration id. * @param registrationId * device where the message will be sent. * @param retries * number of retries in case of service unavailability errors. * * @return result of the request (see its javadoc for more details) * * @throws IllegalArgumentException * if registrationId is {@literal null}. * @throws InvalidRequestException * if GCM didn't returned a 200 or 503 status. * @throws IOException * if message could not be sent. */ public Result send(Message message, String registrationId, int retries) throws IOException { int attempt = 0; Result result = null; int backoff = BACKOFF_INITIAL_DELAY; boolean tryAgain; do { attempt++; if (logger.isLoggable(Level.FINE)) { logger.fine("Attempt #" + attempt + " to send message " + message + " to regIds " + registrationId); } result = sendNoRetry(message, registrationId); tryAgain = result == null && attempt <= retries; if (tryAgain) { int sleepTime = backoff / 2 + random.nextInt(backoff); sleep(sleepTime); if (2 * backoff < MAX_BACKOFF_DELAY) { backoff *= 2; } } } while (tryAgain); if (result == null) { throw new IOException("Could not send message after " + attempt + " attempts"); } return result; }