Example usage for java.util.logging Level FINE

List of usage examples for java.util.logging Level FINE

Introduction

In this page you can find the example usage for java.util.logging Level FINE.

Prototype

Level FINE

To view the source code for java.util.logging Level FINE.

Click Source Link

Document

FINE is a message level providing tracing information.

Usage

From source file:hudson.plugins.script_realm.ScriptSecurityRealm.java

protected GrantedAuthority[] loadGroups(String username) throws AuthenticationException {
    try {// w  w w .  j  a  v a2 s  .c o  m
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(AUTHENTICATED_AUTHORITY);
        if (!StringUtils.isBlank(groupsCommandLine)) {
            StringWriter out = new StringWriter();
            LocalLauncher launcher = new LoginScriptLauncher(new StreamTaskListener(out));
            Map<String, String> overrides = new HashMap<String, String>();
            overrides.put("U", username);
            if (isWindows()) {
                overrides.put("SystemRoot", System.getenv("SystemRoot"));
            }
            OutputStream scriptOut = new ByteArrayOutputStream();
            if (launcher.launch().cmds(QuotedStringTokenizer.tokenize(groupsCommandLine)).stdout(scriptOut)
                    .envs(overrides).join() == 0) {
                StringTokenizer tokenizer = new StringTokenizer(scriptOut.toString().trim(), groupsDelimiter);
                while (tokenizer.hasMoreTokens()) {
                    final String token = tokenizer.nextToken().trim();
                    String[] args = new String[] { token, username };
                    LOGGER.log(Level.FINE, "granting: {0} to {1}", args);
                    authorities.add(new GrantedAuthorityImpl(token));
                }

            } else {
                throw new BadCredentialsException(out.toString());
            }
        }
        return authorities.toArray(new GrantedAuthority[0]);
    } catch (InterruptedException e) {
        throw new AuthenticationServiceException("Interrupted", e);
    } catch (IOException e) {
        throw new AuthenticationServiceException("Failed", e);
    }
}

From source file:com.ovea.facebook.client.DefaultFacebookClient.java

@Override
public JSONArray friends(FacebookToken accessToken) throws FacebookException {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair(ACCESS_TOKEN, accessToken.value()));
    JSONType result = get("https", "graph.facebook.com", "/me/friends", qparams);
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("friends for token " + accessToken + " : " + result);
    }/* w w w.j  a va 2s.  c om*/
    checkErrorOn(result);
    return result.asObject().getArray("data");
}

From source file:com.commsen.jwebthumb.WebThumbService.java

/**
 * Fetches single file form webthumb site. Depending on what image format was requested
 * (jpg|png|png8) and what file size is set in {@link WebThumbFetchRequest} returned byte array
 * will be the content of the jpg, png, png8 or zip file.
 * /*from ww w .java2s. c o  m*/
 * @param webThumbFetchRequest fetch request containing the job and size to be fetched
 * @return the content of the jpg, png, png8 or zip file.
 * @throws WebThumbException if the file can not be fetched for whatever reason
 */
public byte[] fetch(WebThumbFetchRequest webThumbFetchRequest) throws WebThumbException {
    HttpURLConnection connection = getFetchConnection(webThumbFetchRequest);
    int contentLength = connection.getContentLength();
    if (contentLength != -1) {
        byte[] data;
        try {
            data = IOUtils.toByteArray(connection.getInputStream());
        } catch (IOException e) {
            throw new WebThumbException("failed to read response", e);
        }
        if (data.length != contentLength) {
            throw new WebThumbException("Read " + data.length + " bytes; Expected " + contentLength + " bytes");
        }
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Response processed! Returning: " + data.length + " bytes of data");
        }
        return data;
    } else {
        throw new WebThumbException("Failed to fetch image! Missing content length!");
    }
}

From source file:com.nimbits.server.gcm.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 if GCM didn't returned a 200 or 5xx status.
 * @throws IllegalArgumentException if registrationId is {@literal null}.
 *//* ww  w . jav  a 2s .  co m*/
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)) {
        Result.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.pivotal.gemfire.tools.pulse.internal.log.PulseLogWriter.java

@Override
public void fine(Throwable ex) {
    logger.logp(Level.FINE, "", "", "", ex);
}

From source file:org.openspaces.rest.space.SpaceAPIController.java

/**
 * REST GET for introducing type to space
 *
 * @deprecated Use {@link #introduceTypeAdvanced(String, String)} instead
 * @param type type name/*from w  w  w.  j  ava 2  s  .  co m*/
 * @return
 */
@Deprecated
@RequestMapping(value = "/{type}/_introduce_type", method = RequestMethod.GET, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody Map<String, Object> introduceType(@PathVariable String type,
        @RequestParam(value = SPACEID_PARAM, defaultValue = "id") String spaceID) {
    if (logger.isLoggable(Level.FINE))
        logger.fine("introducing type: " + type);
    Map<String, Object> result = new Hashtable<String, Object>();
    try {
        GigaSpace gigaSpace = ControllerUtils.xapCache.get();
        SpaceTypeDescriptor typeDescriptor = gigaSpace.getTypeManager().getTypeDescriptor(type);
        if (typeDescriptor != null) {
            throw new TypeAlreadyRegisteredException(type);
        }

        SpaceTypeDescriptor spaceTypeDescriptor = new SpaceTypeDescriptorBuilder(type).idProperty(spaceID)
                .routingProperty(spaceID).supportsDynamicProperties(true).create();
        gigaSpace.getTypeManager().registerTypeDescriptor(spaceTypeDescriptor);
        result.put("status", "success");
    } catch (IllegalStateException e) {
        throw new RestException(e.getMessage());
    }

    return result;
}

From source file:edu.wpi.cs.wpisuitetng.modules.core.entitymanagers.ProjectManager.java

@Override
public void save(Session s, Project model) throws WPISuiteException {
    if (s == null) {
        throw new WPISuiteException("Null Session.");
    }//from w  w  w.  ja va2s  .  c o  m
    //permissions checking happens in update, create, and delete methods only
    /*User theUser = s.getUser();
    if(Role.ADMIN.equals(theUser.getRole()) || 
    Permission.WRITE.equals(model.getPermission(theUser))){*/
    if (data.save(model)) {
        logger.log(Level.FINE, "Project Saved :" + model);
        return;
    }
    /*else
    {
       logger.log(Level.WARNING, "Project Save Failure!");
       throw new DatabaseException("Save failure for Project."); // Session User: " + s.getUsername() + " Project: " + model.getName());
    }
    /*}
    else
    {
       logger.log(Level.WARNING, "ProjectManager Save attempted by user with insufficient permission");
       throw new UnauthorizedException("You do not have the requred permissions to perform this action.");
    }*/

}