Example usage for java.util.logging Level FINER

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

Introduction

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

Prototype

Level FINER

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

Click Source Link

Document

FINER indicates a fairly detailed tracing message.

Usage

From source file:com.ibm.jaggr.core.impl.transport.AbstractHttpTransport.java

/**
 * Returns a map containing the has-condition/value pairs specified in the request
 *
 * @param request/*from  ww  w  . j  av a  2 s  .  com*/
 *            The http request object
 * @return The map containing the has-condition/value pairs.
 * @throws IOException
 */
protected Features getFeaturesFromRequest(HttpServletRequest request) throws IOException {
    final String sourceMethod = "getFeaturesFromRequest"; //$NON-NLS-1$
    boolean isTraceLogging = log.isLoggable(Level.FINER);
    if (isTraceLogging) {
        log.entering(AbstractHttpTransport.class.getName(), sourceMethod, new Object[] { request });
    }
    Features features = getFeaturesFromRequestEncoded(request);
    if (features == null) {
        features = new Features();
        String has = getHasConditionsFromRequest(request);
        if (has != null) {
            for (String s : has.split("[;*]")) { //$NON-NLS-1$
                boolean value = true;
                if (s.startsWith("!")) { //$NON-NLS-1$
                    s = s.substring(1);
                    value = false;
                }
                features.put(s, value);
            }
        }
    }
    if (isTraceLogging) {
        log.exiting(AbstractHttpTransport.class.getName(), sourceMethod, features);
    }
    return features.unmodifiableFeatures();
}

From source file:com.cedarsoft.couchdb.CouchDatabase.java

@Override
@Nonnull/*  w  w w .j a  v a 2  s .  co m*/
public InputStream get(@Nonnull WebResource resource) throws ActionFailedException {
    long start = System.currentTimeMillis();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("GET " + resource.toString());
    }
    ClientResponse response = resource.get(ClientResponse.class);
    long end = System.currentTimeMillis();
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Took: " + (end - start) + " ms");
    }

    ActionResponseSerializer.verifyNoError(response);

    if (LOG.isLoggable(Level.FINER)) {
        try {
            byte[] content = ByteStreams.toByteArray(response.getEntityInputStream());
            if (content.length > DEBUG_MAX_LENGTH) {
                LOG.finer("Showing first " + DEBUG_MAX_LENGTH + " bytes:\n"
                        + new String(content).substring(0, DEBUG_MAX_LENGTH) + "...");
            } else {
                LOG.finer(new String(content));
            }
            return new ByteArrayInputStream(content);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    return response.getEntityInputStream();
}

From source file:org.b3log.latke.repository.gae.GAERepository.java

/**
 * Updates.//from  ww  w .java  2s. co m
 * 
 * @param id the specified id
 * @param jsonObject the specified json object
 * @param parentKeyKind the specified parent key kind
 * @param parentKeyName the specified parent key name
 * @throws RepositoryException repository exception
 */
private void update(final String id, final JSONObject jsonObject, final String parentKeyKind,
        final String parentKeyName) throws RepositoryException {
    try {
        jsonObject.put(Keys.OBJECT_ID, id);

        final Key parentKey = KeyFactory.createKey(parentKeyKind, parentKeyName);
        final Entity entity = new Entity(getName(), id, parentKey);

        setProperties(entity, jsonObject);

        datastoreService.put(entity);
    } catch (final Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        throw new RepositoryException(e);
    }

    LOGGER.log(Level.FINER, "Updated an object[oId={0}] in repository[name={1}]",
            new Object[] { id, getName() });
}

From source file:fungus.HyphaLink.java

public void absorbHypha(MycoNode target) {

    HyphaData myData = (HyphaData) myNode.getProtocol(hyphaDataPid);
    HyphaLink tl = (HyphaLink) target.getProtocol(hyphaLinkPid);
    HyphaData targetData = (HyphaData) target.getProtocol(hyphaDataPid);

    log.log(Level.FINER,
            myNode + " (" + myData.getState() + ") ABSORBS " + target + " (" + targetData.getState() + ")",
            new Object[] { myNode, target });

    if (targetData.isBiomass()) {
        log.log(Level.FINE, myNode.getID() + " TRIED TO ABSORB BIOMASS NODE " + target.getID(),
                new Object[] { myNode, target });
        return;/*w w  w.java2s  .c o m*/
    }

    // Move all target's hyphae to self
    MycoList hyphae = tl.getHyphae();
    for (MycoNode n : hyphae) {
        tl.transferNeighbor(n, myNode);
    }

    // Move all target's biomass to self
    MycoList biomass = tl.getBiomass();
    for (MycoNode n : biomass) {
        tl.transferNeighbor(n, myNode);
    }

    // Demote absorbed target to biomass
    targetData.becomeBiomass(target);
    //System.out.println("DEMOTED absorbed target " + target);
    //System.out.println("NEW NODE " + myNode);
}

From source file:com.ibm.datapower.amt.clientAPI.Blob.java

/**
 * Get the contents of the blob as an InputStream.
 * <p>//w w w  .j  a  v a  2s . c o m
 * If the Blob was initially constructed via a File, this will open the file
 * and return the InputStream pointing at the beginning of the file. It is
 * up to the caller to close the InputStream.
 * <p>
 * If the Blob was initially constructed via a byte array, this will wrap
 * the byte array with an InputStream. No file is actually created, and the
 * byte array is not copied. For good measure, the caller should close the
 * InputStream.
 * <p>
 * This method needs to be public so it can be invoked by the dataAPI.
 * 
 * @return an InputStream representation of the binary data
 * @throws IOException
 *             there was a problem reading the file from the disk.
 */
public InputStream getInputStream() throws IOException {
    final String METHOD_NAME = "getInputStream"; //$NON-NLS-1$
    InputStream result = null;
    if (this.file != null) {
        result = new FileInputStream(this.file);
    } else if (this.url != null) {
        CustomURLConnection customURLConn = new CustomURLConnection(this.url);
        logger.logp(Level.FINER, CLASS_NAME, METHOD_NAME,
                "Connect timeout is set to " + customURLConn.getConnectLimit());
        URLConnection connection = customURLConn.openConnection();
        if (connection == null) {
            String message = Messages.getString("wamt.clientAPI.Blob.connectionErr", this.url.getHost());
            IOException e = new IOException(message);
            logger.throwing(CLASS_NAME, METHOD_NAME, e);
            throw e;
        }

        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            result = url.openStream();
        } else {
            // fix for 13324: Firmware images reported as not real, when using URL behind some form of authentication              
            throw (new IOException(Integer.toString(httpConnection.getResponseCode()) + " - "
                    + httpConnection.getResponseMessage()));
        }
    } else if (this.bytes != null) {
        result = new ByteArrayInputStream(this.bytes);
    } else {
        // this should not happen
        logger.logp(Level.INFO, CLASS_NAME, METHOD_NAME,
                Messages.getString("wamt.clientAPI.Blob.internalErr", this.toString())); //$NON-NLS-1$
    }
    return (result);
}

From source file:dk.hippogrif.prettyxml.PrettyPrint.java

/**
 * Do the prettyprint according to properties.
 *
 * @param input holds xml document as text if present
 * @return prettyprinted document as text if input param present
 * @throws Exception if something goes wrong
 *//*from   w w  w . ja  v a  2s .co m*/
public static String execute(Properties prop, String input) throws Exception {
    try {
        checkProperties(prop, true);
        logger.log(Level.FINEST, "input=" + input + " properties=" + prop);
        Format format = initFormat(prop);
        PrettyXMLOutputter outp = new PrettyXMLOutputter(format);
        outp.setSortAttributes(prop.containsKey(SORT_ATTRIBUTES));
        outp.setIndentAttributes(prop.containsKey(INDENT_ATTRIBUTES));
        SAXBuilder builder = new SAXBuilder();
        Document doc;
        if (input != null) {
            doc = builder.build(new StringReader(input));
        } else if (prop.containsKey(INPUT)) {
            doc = builder.build(new File(prop.getProperty(INPUT)));
        } else if (prop.containsKey(URL)) {
            doc = builder.build(new URL(prop.getProperty(URL)));
        } else {
            doc = builder.build(System.in);
        }
        if (prop.containsKey(TRANSFORM)) {
            String[] sa = prop.getProperty(TRANSFORM).split(";");
            for (int i = 0; i < sa.length; i++) {
                XSLTransformer transformer = mkTransformer(sa[i].trim());
                doc = transformer.transform(doc);
            }
        }
        if (prop.containsKey(OUTPUT)) {
            FileOutputStream fos = null;
            try {
                fos = new FileOutputStream(new File(prop.getProperty(OUTPUT)));
                outp.output(doc, fos);
            } finally {
                IOUtils.closeQuietly(fos);
            }
        } else if (input != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            outp.output(doc, baos);
            return baos.toString(prop.getProperty(ENCODING, "UTF-8"));
        } else {
            outp.output(doc, System.out);
        }
        return null;
    } catch (Exception e) {
        logger.log(Level.FINER, "properties=" + prop, e);
        throw e;
    }
}

From source file:edu.umass.cs.reconfiguration.ActiveReplica.java

private SenderAndRequest sendResponse(Request request, SenderAndRequest senderAndRequest,
        boolean isCoordinated) {
    if (senderAndRequest == null)
        return null;
    // else//w ww  .  j  a  va 2  s .co  m
    // send demand report
    this.updateDemandStats(request, senderAndRequest.csa.getAddress());
    instrumentNanoApp(isCoordinated ? Instrument.replicable : Instrument.local, senderAndRequest.recvTime);

    ClientRequest response = null;
    // send response to originating client
    if (request instanceof ClientRequest
            && (response = makeClientResponse(((ClientRequest) request).getResponse(),
                    ((ClientRequest) request).getRequestID())) != null) {
        try {
            log.log(Level.FINER, "{0} sending response {1} back to requesting client {2} for {3} request {4}",
                    new Object[] { this, ((ClientRequest) request).getResponse().getSummary(),
                            senderAndRequest.csa, isCoordinated ? "coordinated" : "", request.getSummary() });
            int written = ((JSONMessenger<?>) this.messenger).sendClient(senderAndRequest.csa,
                    response instanceof Byteable ? ((Byteable) response).toBytes() : response,
                    senderAndRequest.mysa);
            if (written > 0)
                if (isCoordinated)
                    AppInstrumenter.sentResponseCoordinated(request);
                else
                    AppInstrumenter.sentResponseLocal(request);
        } catch (IOException | JSONException e) {
            e.printStackTrace();
        }
    }
    return senderAndRequest;
}

From source file:com.kenai.redminenb.repository.RedmineRepository.java

private void fireQueryListChanged() {
    Redmine.LOG.log(Level.FINER, "firing query list changed for repository {0}",
            new Object[] { getDisplayName() }); // NOI18N
    propertyChangeSupport.firePropertyChange(RepositoryProvider.EVENT_QUERY_LIST_CHANGED, null, null);
}

From source file:com.vaadin.server.communication.PushHandler.java

private void disconnect(AtmosphereResourceEvent event) {
    // We don't want to use callWithUi here, as it assumes there's a client
    // request active and does requestStart and requestEnd among other
    // things.//from   w w  w.  j  a v  a 2s.  c  om

    AtmosphereResource resource = event.getResource();
    VaadinServletRequest vaadinRequest = new VaadinServletRequest(resource.getRequest(), service);
    VaadinSession session = null;

    try {
        session = service.findVaadinSession(vaadinRequest);
    } catch (ServiceException e) {
        getLogger().log(Level.SEVERE, "Could not get session. This should never happen", e);
        return;
    } catch (SessionExpiredException e) {
        getLogger().log(Level.SEVERE, "Session expired before push was disconnected. This should never happen",
                e);
        return;
    }

    UI ui = null;
    session.lock();
    try {
        VaadinSession.setCurrent(session);
        // Sets UI.currentInstance
        ui = service.findUI(vaadinRequest);
        if (ui == null) {
            /*
             * UI not found, could be because FF has asynchronously closed
             * the websocket connection and Atmosphere has already done
             * cleanup of the request attributes.
             * 
             * In that case, we still have a chance of finding the right UI
             * by iterating through the UIs in the session looking for one
             * using the same AtmosphereResource.
             */
            ui = findUiUsingResource(resource, session.getUIs());

            if (ui == null) {
                getLogger().log(Level.SEVERE, "Could not get UI. This should never happen,"
                        + " except when reloading in Firefox -" + " see http://dev.vaadin.com/ticket/14251.");
                return;
            } else {
                getLogger().log(Level.INFO,
                        "No UI was found based on data in the request,"
                                + " but a slower lookup based on the AtmosphereResource succeeded."
                                + " See http://dev.vaadin.com/ticket/14251 for more details.");
            }
        }

        PushMode pushMode = ui.getPushConfiguration().getPushMode();
        AtmospherePushConnection pushConnection = getConnectionForUI(ui);

        String id = resource.uuid();

        if (pushConnection == null) {
            getLogger().log(Level.WARNING, "Could not find push connection to close: {0} with transport {1}",
                    new Object[] { id, resource.transport() });
        } else {
            if (!pushMode.isEnabled()) {
                /*
                 * The client is expected to close the connection after push
                 * mode has been set to disabled.
                 */
                getLogger().log(Level.FINER, "Connection closed for resource {0}", id);
            } else {
                /*
                 * Unexpected cancel, e.g. if the user closes the browser
                 * tab.
                 */
                getLogger().log(Level.FINER,
                        "Connection unexpectedly closed for resource {0} with transport {1}",
                        new Object[] { id, resource.transport() });
            }
            if (pushConnection.isConnected()) {
                // disconnect() assumes the push connection is connected but
                // this method can currently be called more than once during
                // disconnect, depending on the situation
                pushConnection.disconnect();
            }
        }

    } catch (final Exception e) {
        callErrorHandler(session, e);
    } finally {
        try {
            session.unlock();
        } catch (Exception e) {
            getLogger().log(Level.WARNING, "Error while unlocking session", e);
            // can't call ErrorHandler, we (hopefully) don't have a lock
        }
    }
}

From source file:de.duenndns.ssl.MemorizingTrustManager.java

public void checkCertTrusted(X509Certificate[] chain, String authType, String domain, boolean isServer,
        boolean interactive) throws CertificateException {
    LOGGER.log(Level.FINE, "checkCertTrusted(" + chain + ", " + authType + ", " + isServer + ")");
    try {//from  w ww  .  ja v a 2 s. c  om
        LOGGER.log(Level.FINE, "checkCertTrusted: trying appTrustManager");
        if (isServer)
            appTrustManager.checkServerTrusted(chain, authType);
        else
            appTrustManager.checkClientTrusted(chain, authType);
    } catch (CertificateException ae) {
        LOGGER.log(Level.FINER, "checkCertTrusted: appTrustManager failed", ae);
        // if the cert is stored in our appTrustManager, we ignore expiredness
        if (isExpiredException(ae)) {
            LOGGER.log(Level.INFO, "checkCertTrusted: accepting expired certificate from keystore");
            return;
        }
        if (isCertKnown(chain[0])) {
            LOGGER.log(Level.INFO, "checkCertTrusted: accepting cert already stored in keystore");
            return;
        }
        try {
            if (defaultTrustManager == null)
                throw ae;
            LOGGER.log(Level.FINE, "checkCertTrusted: trying defaultTrustManager");
            if (isServer)
                defaultTrustManager.checkServerTrusted(chain, authType);
            else
                defaultTrustManager.checkClientTrusted(chain, authType);
        } catch (CertificateException e) {
            boolean trustSystemCAs = !PreferenceManager.getDefaultSharedPreferences(master)
                    .getBoolean("dont_trust_system_cas", false);
            if (domain != null && isServer && trustSystemCAs && !isIp(domain)) {
                String hash = getBase64Hash(chain[0], "SHA-256");
                List<String> fingerprints = getPoshFingerprints(domain);
                if (hash != null && fingerprints.contains(hash)) {
                    Log.d("mtm", "trusted cert fingerprint of " + domain + " via posh");
                    return;
                }
            }
            e.printStackTrace();
            if (interactive) {
                interactCert(chain, authType, e);
            } else {
                throw e;
            }
        }
    }
}