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:com.treasuredata.jdbc.TDResultSet.java
private void initColumnNamesAndTypes(String resultSchema) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("resultSchema: " + resultSchema); }// ww w . ja v a 2 s . c om if (resultSchema == null) { LOG.warning("Illegal resultSchema: null"); return; } @SuppressWarnings("unchecked") List<List<String>> cols = (List<List<String>>) JSONValue.parse(resultSchema); if (cols == null) { LOG.warning("Illegal resultSchema: " + resultSchema); return; } columnNames = new ArrayList<String>(cols.size()); columnTypes = new ArrayList<String>(cols.size()); for (List<String> col : cols) { columnNames.add(col.get(0)); columnTypes.add(col.get(1)); } }
From source file:com.google.android.gcm.demo.sender.Sender.java
/** * Sends a message without retrying in case of service unavailability. See * {@link #send(Message, String, int)} for more info. * * @return result of the post, or {@literal null} if the GCM service was * unavailable or any network exception caused the request to fail. * * @throws InvalidRequestException// www . ja v a 2s . c o m * if GCM didn't returned a 200 or 5xx status. * @throws IllegalArgumentException * if registrationId is {@literal null}. */ public Result sendNoRetry(Message message, String registrationId) throws IOException { StringBuilder body = newBody(PARAM_REGISTRATION_ID, registrationId); Boolean delayWhileIdle = message.isDelayWhileIdle(); if (delayWhileIdle != null) { addParameter(body, PARAM_DELAY_WHILE_IDLE, delayWhileIdle ? "1" : "0"); } Boolean dryRun = message.isDryRun(); if (dryRun != null) { addParameter(body, PARAM_DRY_RUN, dryRun ? "1" : "0"); } String collapseKey = message.getCollapseKey(); if (collapseKey != null) { addParameter(body, PARAM_COLLAPSE_KEY, collapseKey); } String restrictedPackageName = message.getRestrictedPackageName(); if (restrictedPackageName != null) { addParameter(body, PARAM_RESTRICTED_PACKAGE_NAME, restrictedPackageName); } Integer timeToLive = message.getTimeToLive(); if (timeToLive != null) { addParameter(body, PARAM_TIME_TO_LIVE, Integer.toString(timeToLive)); } for (Entry<String, String> entry : message.getData().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key == null || value == null) { logger.warning("Ignoring payload entry thas has null: " + entry); } else { key = PARAM_PAYLOAD_PREFIX + key; addParameter(body, key, URLEncoder.encode(value, UTF8)); } } String requestBody = body.toString(); logger.finest("Request body: " + requestBody); HttpURLConnection conn; int status; try { conn = post(GCM_SEND_ENDPOINT, requestBody); status = conn.getResponseCode(); } catch (IOException e) { logger.log(Level.FINE, "IOException posting to GCM", e); return null; } if (status / 100 == 5) { logger.fine("GCM service is unavailable (status " + status + ")"); return null; } String responseBody; if (status != 200) { try { responseBody = getAndClose(conn.getErrorStream()); logger.finest("Plain post error response: " + responseBody); } catch (IOException e) { // ignore the exception since it will thrown an // InvalidRequestException // anyways responseBody = "N/A"; logger.log(Level.FINE, "Exception reading response: ", e); } throw new InvalidRequestException(status, responseBody); } else { try { responseBody = getAndClose(conn.getInputStream()); } catch (IOException e) { logger.log(Level.WARNING, "Exception reading response: ", e); // return null so it can retry return null; } } String[] lines = responseBody.split("\n"); if (lines.length == 0 || lines[0].equals("")) { throw new IOException("Received empty response from GCM service."); } String firstLine = lines[0]; String[] responseParts = split(firstLine); String token = responseParts[0]; String value = responseParts[1]; if (token.equals(TOKEN_MESSAGE_ID)) { Builder builder = new Result.Builder().messageId(value); // check for canonical registration id if (lines.length > 1) { String secondLine = lines[1]; responseParts = split(secondLine); token = responseParts[0]; value = responseParts[1]; if (token.equals(TOKEN_CANONICAL_REG_ID)) { builder.canonicalRegistrationId(value); } else { logger.warning("Invalid response from GCM: " + responseBody); } } Result result = builder.build(); if (logger.isLoggable(Level.FINE)) { logger.fine("Message created succesfully (" + result + ")"); } return result; } else if (token.equals(TOKEN_ERROR)) { return new Result.Builder().errorCode(value).build(); } else { throw new IOException("Invalid response from GCM: " + responseBody); } }
From source file:com.dynamobi.db.conn.couchdb.CouchUdx.java
/** * Helper function gets the rows from the foreign CouchDB server and returns * them as a JSONArray./*from w w w. j a v a 2 s. co m*/ */ private static InputStreamReader getViewStream(String user, String pw, String url, String view, String limit, boolean reduce, String groupLevel, boolean hasReducer) throws SQLException { String full_url = ""; try { // TODO: stringbuffer this for efficiency full_url = makeUrl(url, view); String sep = (view.indexOf("?") == -1) ? "?" : "&"; if (limit != null && limit.length() > 0) { full_url += sep + "limit=" + limit; sep = "&"; } // These options only apply if a reducer function is present. if (hasReducer) { if (!reduce) { full_url += sep + "reduce=false"; if (sep.equals("?")) sep = "&"; } if (groupLevel.toUpperCase().equals("EXACT")) full_url += sep + "group=true"; else if (groupLevel.toUpperCase().equals("NONE")) full_url += sep + "group=false"; else full_url += sep + "group_level=" + groupLevel; } logger.log(Level.FINE, "Attempting CouchDB request with URL: " + full_url); URL u = new URL(full_url); HttpURLConnection uc = (HttpURLConnection) u.openConnection(); if (user != null && user.length() > 0) { uc.setRequestProperty("Authorization", "Basic " + buildAuthHeader(user, pw)); } uc.connect(); return new InputStreamReader(uc.getInputStream()); } catch (MalformedURLException e) { throw new SQLException("Bad URL: " + full_url); } catch (IOException e) { if (hasReducer) { // try again but without the reduce args.. try { return getViewStream(user, pw, url, view, limit, reduce, groupLevel, false); } catch (SQLException e2) { // No good. } } throw new SQLException("Could not read data from URL: " + full_url); } }
From source file:cz.incad.Kramerius.audio.AudioHttpRequestForwarder.java
private void forwardResponseCode(HttpResponse repositoryResponse, HttpServletResponse clientResponse) { int repositoryResponseCode = repositoryResponse.getStatusLine().getStatusCode(); LOGGER.log(Level.FINE, "forwarding status code {0}", repositoryResponseCode); clientResponse.setStatus(repositoryResponseCode); }
From source file:com.globallogic.push_service_poc.demo.sender.Sender.java
/** * Sends a message without retrying in case of service unavailability. See * {@link #send(Message, String, int)} for more info. * * @return result of the post, or {@literal null} if the GCM service was * unavailable or any network exception caused the request to fail. * * @throws InvalidRequestException/*from www . ja v a2s . c om*/ * if GCM didn't returned a 200 or 5xx status. * @throws IllegalArgumentException * if registrationId is {@literal null}. */ public Result sendNoRetry(Message message, String registrationId) throws IOException { StringBuilder body = newBody(PARAM_REGISTRATION_ID, registrationId); Boolean delayWhileIdle = message.isDelayWhileIdle(); if (delayWhileIdle != null) { addParameter(body, PARAM_DELAY_WHILE_IDLE, delayWhileIdle ? "1" : "0"); } Boolean dryRun = message.isDryRun(); if (dryRun != null) { addParameter(body, PARAM_DRY_RUN, dryRun ? "1" : "0"); } String collapseKey = message.getCollapseKey(); if (collapseKey != null) { addParameter(body, PARAM_COLLAPSE_KEY, collapseKey); } String restrictedPackageName = message.getRestrictedPackageName(); if (restrictedPackageName != null) { addParameter(body, PARAM_RESTRICTED_PACKAGE_NAME, restrictedPackageName); } Integer timeToLive = message.getTimeToLive(); if (timeToLive != null) { addParameter(body, PARAM_TIME_TO_LIVE, Integer.toString(timeToLive)); } for (Entry<String, String> entry : message.getData().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key == null || value == null) { logger.warning("Ignoring payload entry thas has null: " + entry); } else { key = PARAM_PAYLOAD_PREFIX + key; addParameter(body, key, URLEncoder.encode(value, UTF8)); } } String requestBody = body.toString(); logger.finest("Request body: " + requestBody); HttpURLConnection conn; int status; try { conn = post(GCM_SEND_ENDPOINT, requestBody); status = conn.getResponseCode(); } catch (IOException e) { logger.log(Level.FINE, "IOException posting to GCM", e); return null; } if (status / 100 == 5) { logger.fine("GCM service is unavailable (status " + status + ")"); return null; } String responseBody; if (status != 200) { try { responseBody = getAndClose(conn.getErrorStream()); logger.finest("Plain post error response: " + responseBody); } catch (IOException e) { // ignore the exception since it will thrown an // InvalidRequestException // anyways responseBody = "N/A"; logger.log(Level.FINE, "Exception reading response: ", e); } throw new InvalidRequestException(status, responseBody); } else { try { responseBody = getAndClose(conn.getInputStream()); } catch (IOException e) { logger.log(Level.WARNING, "Exception reading response: ", e); // return null so it can retry return null; } } String[] lines = responseBody.split("\n"); if (lines.length == 0 || lines[0].equals("")) { throw new IOException("Received empty response from GCM service."); } String firstLine = lines[0]; String[] responseParts = split(firstLine); String token = responseParts[0]; String value = responseParts[1]; if (token.equals(TOKEN_MESSAGE_ID)) { Builder builder = new Builder().messageId(value); // check for canonical registration id if (lines.length > 1) { String secondLine = lines[1]; responseParts = split(secondLine); token = responseParts[0]; value = responseParts[1]; if (token.equals(TOKEN_CANONICAL_REG_ID)) { builder.canonicalRegistrationId(value); } else { logger.warning("Invalid response from GCM: " + responseBody); } } Result result = builder.build(); if (logger.isLoggable(Level.FINE)) { logger.fine("Message created succesfully (" + result + ")"); } return result; } else if (token.equals(TOKEN_ERROR)) { return new Builder().errorCode(value).build(); } else { throw new IOException("Invalid response from GCM: " + responseBody); } }
From source file:core.feature.userfeatureprofile.UserFeatureProfile.java
/** * Metrics updated:/*from w w w. ja v a2 s. c o m*/ * setLastCheckToPerformOn - set to 'nowUtc' on entry * setLastPerformedOn - set to 'nowUtc' if returning true * * Rules: * 1) check the minimum interval, e.g. 1x per day * 2) check the schedule * - uses schedule set on the userFeatureProfile, defaulting to FeatureProfile, defaulting to WideOpen * - consider the last run time when evaluating the schedule, so it is not run twice for the same scheduled time * 3) all Calendars for evaluating the schedules use the users time zone * * @return true if it is time to run the feature **/ public boolean isTimeToRun() { setLastCheckToPerformOn(new Date()); logger.log(Level.FINE, "User time zone is {0}", getUser().getTimeZone()); Calendar userLocalTime = Calendar.getInstance(getUser().getTimeZone()); Calendar userLocalTimeLastPerformedOn = null; CalendarRange intervalRange = null; if (getLastPerformedOn() != null) { userLocalTimeLastPerformedOn = Calendar.getInstance(getUser().getTimeZone()); userLocalTimeLastPerformedOn.setTime(getLastPerformedOn()); intervalRange = new CalendarRange(userLocalTimeLastPerformedOn, userLocalTime); } logger.log(Level.FINE, "userLocalTimeLastPerformedOn={0},userLocalTime={1}", new Object[] { userLocalTimeLastPerformedOn, userLocalTime }); boolean isMinimumIntervalMet = getMinimumIntervalDays() == 0 || userLocalTimeLastPerformedOn == null || DateHelper.calculateIntervalInDays(intervalRange) >= getMinimumIntervalDays(); boolean isTimeToRun = false; if (isMinimumIntervalMet) { isTimeToRun = getSchedule().isRunnable(userLocalTimeLastPerformedOn, userLocalTime); if (isTimeToRun) { setLastPerformedOn(new Date()); } } logger.log(Level.FINE, "isMinimumIntervalMet={0},isTimeToRun={1}", new Object[] { isMinimumIntervalMet, isTimeToRun }); return isTimeToRun; }
From source file:com.googlecode.jsonrpc4j.JsonRpcServer.java
/** * Handles a portlet request./*from w ww. jav a 2 s . c om*/ * * @param request the {@link ResourceRequest} * @param response the {@link ResourceResponse} * @throws IOException on error */ public void handle(ResourceRequest request, ResourceResponse response) throws IOException { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Handing ResourceRequest " + request.getMethod()); } // set response type response.setContentType(JSONRPC_RESPONSE_CONTENT_TYPE); // setup streams InputStream input = null; OutputStream output = response.getPortletOutputStream(); // POST if (request.getMethod().equals("POST")) { input = request.getPortletInputStream(); // GET } else if (request.getMethod().equals("GET")) { input = createInputStream(request.getParameter("method"), request.getParameter("id"), request.getParameter("params")); // invalid request } else { throw new IOException("Invalid request method, only POST and GET is supported"); } // service the request handle(input, output); }
From source file:com.ibm.ws.lars.rest.RepositoryRESTResourceLoggingTest.java
@Test public void testGetAttachments(@Mocked final Logger logger, @Mocked final SecurityContext sc) throws Exception { new Expectations() { {/*w w w . j a v a 2s .c o m*/ logger.isLoggable(Level.FINE); result = true; logger.fine("getAttachments called for assetId: " + NON_EXISTENT_ID); sc.isUserInRole("Administrator"); result = true; } }; getRestResource().getAttachments(NON_EXISTENT_ID, dummyUriInfo, sc); }
From source file:mendeley2kindle.KindleDAO.java
public void removeFile(String collection, KFile file) { log.log(Level.FINER, "Removing a document:" + file.getName() + " from the collection: " + collection); String path = toKindlePath(file); String khash = toKindleHash(path); String key = collection + KINDLE_LOCALE; try {//from www . j av a2 s . c om JSONArray items = collections.getJSONObject(key).getJSONArray("items"); for (int i = 0; i < items.length(); i++) { if (khash.equals(items.get(i))) { items.remove(i); } } log.log(Level.FINE, "Removed a document:" + file.getName() + " to the collection: " + collection); } catch (JSONException e) { e.printStackTrace(); } }