List of usage examples for java.util.logging Level FINER
Level FINER
To view the source code for java.util.logging Level FINER.
Click Source Link
From source file:com.granule.json.utils.XML.java
/** * Method to take an input stream to an JSON document and return a String of the XML format. Note that the JSONStream is not closed when read is complete. This is left up to the caller, who may wish to do more with it. * @param xmlStream The InputStream to an JSON document to transform to XML. * @param verbose Boolean flag denoting whther or not to write the XML in verbose (formatted), or compact form (no whitespace) * @return A string of the JSON representation of the XML file * /*from w w w. j av a2 s. c o m*/ * @throws IOException Thrown if an IOError occurs. */ public static String toXml(InputStream JSONStream, boolean verbose) throws IOException { if (logger.isLoggable(Level.FINER)) { logger.exiting(className, "toXml(InputStream, boolean)"); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); String result = null; try { toXml(JSONStream, baos, verbose); result = baos.toString("UTF-8"); baos.close(); } catch (UnsupportedEncodingException uec) { IOException iox = new IOException(uec.toString()); iox.initCause(uec); throw iox; } if (logger.isLoggable(Level.FINER)) { logger.exiting(className, "toXml(InputStream, boolean)"); } return result; }
From source file:org.b3log.latke.repository.gae.GAERepository.java
@Override @SuppressWarnings("unchecked") public Map<String, JSONObject> get(final Iterable<String> ids) throws RepositoryException { LOGGER.log(Level.FINEST, "Getting with ids[{0}]", ids); final GAETransaction currentTransaction = TX.get(); if (null == currentTransaction || !currentTransaction.hasUncommitted(ids)) { Map<String, JSONObject> ret; if (cacheEnabled) { final String cacheKey = CACHE_KEY_PREFIX + ids.hashCode(); ret = (Map<String, JSONObject>) CACHE.get(cacheKey); if (null != ret) { LOGGER.log(Level.FINER, "Got objects[cacheKey={0}] from repository cache[name={1}]", new Object[] { cacheKey, getName() }); return ret; }//from w ww. j av a 2 s . com } final Set<Key> keys = new HashSet<Key>(); for (final String id : ids) { final Key key = KeyFactory.createKey(DEFAULT_PARENT_KEY, getName(), id); keys.add(key); } ret = new HashMap<String, JSONObject>(); final Map<Key, Entity> map = datastoreService.get(keys); for (final Entry<Key, Entity> entry : map.entrySet()) { ret.put(entry.getKey().getName(), entity2JSONObject(entry.getValue())); } LOGGER.log(Level.FINER, "Got objects[oIds={0}] from repository[name={1}]", new Object[] { ids, getName() }); if (cacheEnabled) { final String cacheKey = CACHE_KEY_PREFIX + ids.hashCode(); CACHE.putAsync(cacheKey, (Serializable) ret); LOGGER.log(Level.FINER, "Added objects[cacheKey={0}] in repository cache[{1}]", new Object[] { cacheKey, getName() }); } return ret; } // The returned value may be null if it has been set to null in the // current transaction return currentTransaction.getUncommitted(ids); }
From source file:org.b3log.latke.servlet.RequestProcessors.java
/** * Scans classpath (lib directory) to discover request processor classes. *//*from w w w . j a v a2 s . c o m*/ private static void discoverFromLibDir() { final String webRoot = AbstractServletListener.getWebRoot(); final File libDir = new File( webRoot + File.separator + "WEB-INF" + File.separator + "lib" + File.separator); @SuppressWarnings("unchecked") final Collection<File> files = FileUtils.listFiles(libDir, new String[] { "jar" }, true); final ClassLoader classLoader = RequestProcessors.class.getClassLoader(); try { for (final File file : files) { if (file.getName().contains("appengine-api") || file.getName().startsWith("freemarker") || file.getName().startsWith("javassist") || file.getName().startsWith("commons") || file.getName().startsWith("mail") || file.getName().startsWith("activation") || file.getName().startsWith("slf4j") || file.getName().startsWith("bonecp") || file.getName().startsWith("jsoup") || file.getName().startsWith("guava") || file.getName().startsWith("markdown") || file.getName().startsWith("mysql") || file.getName().startsWith("c3p0")) { // Just skips some known dependencies hardly.... LOGGER.log(Level.INFO, "Skipped request processing discovery[jarName={0}]", file.getName()); continue; } final JarFile jarFile = new JarFile(file.getPath()); final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { final JarEntry jarEntry = entries.nextElement(); final String classFileName = jarEntry.getName(); if (classFileName.contains("$") // Skips inner class || !classFileName.endsWith(".class")) { continue; } final DataInputStream classInputStream = new DataInputStream(jarFile.getInputStream(jarEntry)); final ClassFile classFile = new ClassFile(classInputStream); final AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) classFile .getAttribute(AnnotationsAttribute.visibleTag); if (null == annotationsAttribute) { continue; } for (Annotation annotation : annotationsAttribute.getAnnotations()) { if ((annotation.getTypeName()).equals(RequestProcessor.class.getName())) { // Found a request processor class, loads it final String className = classFile.getName(); final Class<?> clz = classLoader.loadClass(className); LOGGER.log(Level.FINER, "Found a request processor[className={0}]", className); final Method[] declaredMethods = clz.getDeclaredMethods(); for (int i = 0; i < declaredMethods.length; i++) { final Method mthd = declaredMethods[i]; final RequestProcessing requestProcessingMethodAnn = mthd .getAnnotation(RequestProcessing.class); if (null == requestProcessingMethodAnn) { continue; } addProcessorMethod(requestProcessingMethodAnn, clz, mthd); } } } } } } catch (final Exception e) { LOGGER.log(Level.SEVERE, "Scans classpath (lib directory) failed", e); } }
From source file:org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.java
@Override public BoundingBox getBounds(final String typeName) { final Lock lock = rwLock.readLock(); ReferencedEnvelope bound = null;/*w w w . j a v a 2s .c o m*/ try { lock.lock(); checkStore(); if (bounds.containsKey(typeName)) { bound = bounds.get(typeName); } else { bound = this.tileIndexStore.getFeatureSource(typeName).getBounds(); bounds.put(typeName, bound); } } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); bounds.remove(typeName); } finally { lock.unlock(); } // return bounds; return bound; }
From source file:org.jenkinsci.plugins.vsphere.tools.VSphere.java
/** * @param name - Name of VM to start//from w ww.j a v a 2 s.c o m * @param timeoutInSeconds How long to wait for the VM to be running. * @throws VSphereException If an error occurred. */ public void startVm(String name, int timeoutInSeconds) throws VSphereException { try { VirtualMachine vm = getVmByName(name); if (vm == null) { throw new VSphereNotFoundException("VM", name); } if (isPoweredOn(vm)) return; if (vm.getConfig().template) throw new VSphereException("VM represents a template!"); Task task = vm.powerOnVM_Task(null); int timesToCheck = timeoutInSeconds / 5; // add one extra time for remainder timesToCheck++; LOGGER.log(Level.FINER, "Checking " + timesToCheck + " times for vm to be powered on"); for (int i = 0; i < timesToCheck; i++) { if (task.getTaskInfo().getState() == TaskInfoState.success) { LOGGER.log(Level.FINER, "VM was powered up successfully."); return; } if (task.getTaskInfo().getState() == TaskInfoState.running || task.getTaskInfo().getState() == TaskInfoState.queued) { Thread.sleep(5000); } //Check for copied/moved question VirtualMachineQuestionInfo q = vm.getRuntime().getQuestion(); if (q != null && q.getId().equals("_vmx1")) { vm.answerVM(q.getId(), q.getChoice().getDefaultIndex().toString()); return; } } } catch (InterruptedException e) { // build aborted Thread.currentThread().interrupt(); // pass interrupt upwards throw new VSphereException("VM cannot be started: " + e.getMessage(), e); } catch (Exception e) { throw new VSphereException("VM cannot be started: " + e.getMessage(), e); } throw new VSphereException("VM cannot be started"); }
From source file:net.sourceforge.pmd.PMD.java
/** * Parses the command line arguments and executes PMD. * * @param args// w ww . j a v a2 s . c o m * command line arguments * @return the exit code, where <code>0</code> means successful execution, * <code>1</code> means error, <code>4</code> means there have been * violations found. */ public static int run(String[] args) { int status = 0; long start = System.nanoTime(); final PMDParameters params = PMDCommandLineInterface.extractParameters(new PMDParameters(), args, "pmd"); final PMDConfiguration configuration = PMDParameters.transformParametersIntoConfiguration(params); final Level logLevel = params.isDebug() ? Level.FINER : Level.INFO; final Handler logHandler = new ConsoleLogHandler(); final ScopedLogHandlersManager logHandlerManager = new ScopedLogHandlersManager(logLevel, logHandler); final Level oldLogLevel = LOG.getLevel(); // Need to do this, since the static logger has already been initialized // at this point LOG.setLevel(logLevel); try { int violations = PMD.doPMD(configuration); if (violations > 0 && configuration.isFailOnViolation()) { status = PMDCommandLineInterface.VIOLATIONS_FOUND; } else { status = 0; } } catch (Exception e) { System.out.println(PMDCommandLineInterface.buildUsageText()); System.out.println(); System.err.println(e.getMessage()); status = PMDCommandLineInterface.ERROR_STATUS; } finally { logHandlerManager.close(); LOG.setLevel(oldLogLevel); if (params.isBenchmark()) { long end = System.nanoTime(); Benchmarker.mark(Benchmark.TotalPMD, end - start, 0); // TODO get specified report format from config TextReport report = new TextReport(); report.generate(Benchmarker.values(), System.err); } } return status; }
From source file:com.ibm.jaggr.core.impl.deps.DepTree.java
/** * Returns the set of non-JavaScript file extensions to include in the scanned dependencies name * list. The values returned are obtained from the following sources: * <ul>//from w w w . j av a 2 s . co m * <li>Default values specified by {@link IDependencies#defaultNonJSExtensions}</li> * <li>Values specified by the {@link IDependencies#nonJSExtensionsCfgPropName} config property</li> * <li>Values specified by the {@link IModuleBuilderExtensionPoint#EXTENSION_ATTRIBUTE} config * property for the registered module builders</li> * </ul> * * @param aggregator * the aggregator instance * @return the set of extension names */ public Set<String> getNonJSExtensions(IAggregator aggregator) { final String sourceMethod = "getNonJSExtensions"; //$NON-NLS-1$ boolean isTraceLogging = log.isLoggable(Level.FINER); if (isTraceLogging) { log.entering(DepTree.class.getName(), sourceMethod, new Object[] { aggregator }); } // Build set of non-js file extensions to include in the dependency names Set<String> result = new HashSet<String>(Arrays.asList(IDependencies.defaultNonJSExtensions)); // Add any extensions specified in the config Object cfgExtensions = aggregator.getConfig().getProperty(IDependencies.nonJSExtensionsCfgPropName, String[].class); if (cfgExtensions != null && cfgExtensions instanceof String[]) { result.addAll(Arrays.asList((String[]) cfgExtensions)); } // Add extensions specified by any module builders Iterable<IAggregatorExtension> aggrExts = aggregator.getExtensions(IModuleBuilderExtensionPoint.ID); if (aggrExts != null) { for (IAggregatorExtension aggrExt : aggrExts) { String ext = aggrExt.getAttribute(IModuleBuilderExtensionPoint.EXTENSION_ATTRIBUTE); if (ext != null && ext.length() > 0 && !ext.equals("js") && !ext.equals("*")) { //$NON-NLS-1$ //$NON-NLS-2$ result.add(ext); } } } log.exiting(DepTree.class.getName(), sourceMethod, result); return result; }
From source file:com.granule.json.utils.internal.JSONObject.java
/** * Method to write an 'empty' XML tag, like <F/> * @param writer The writer object to render the XML to. * @param indentDepth How far to indent. * @param contentOnly Whether or not to write the object name as part of the output * @param compact Flag to denote whether to output in a nice indented format, or in a compact format. * @throws IOException Trhown if an error occurs on write. *//*from w w w. jav a 2 s .co m*/ private void writeEmptyObject(Writer writer, int indentDepth, boolean contentOnly, boolean compact) throws IOException { if (logger.isLoggable(Level.FINER)) logger.entering(className, "writeEmptyObject(Writer, int, boolean, boolean)"); if (!contentOnly) { if (!compact) { writeIndention(writer, indentDepth); writer.write("\"" + this.objectName + "\""); writer.write(" : true"); } else { writer.write("\"" + this.objectName + "\""); writer.write(":true"); } } else { if (!compact) { writeIndention(writer, indentDepth); writer.write("true"); } else { writer.write("true"); } } if (logger.isLoggable(Level.FINER)) logger.exiting(className, "writeEmptyObject(Writer, int, boolean, boolean)"); }
From source file:com.granule.json.utils.XML.java
/** * Method to take a JSON file and return a String of the XML format. * //from ww w. j a v a 2 s . c o m * @param xmlFile The JSON file to transform to XML. * @param verbose Boolean flag denoting whther or not to write the XML in verbose (formatted), or compact form (no whitespace) * @return A string of the XML representation of the JSON file * * @throws IOException Thrown if an IOError occurs. */ public static String toXml(File jsonFile, boolean verbose) throws IOException { if (logger.isLoggable(Level.FINER)) { logger.exiting(className, "toXml(InputStream, boolean)"); } FileInputStream fis = new FileInputStream(jsonFile); String result = null; result = toXml(fis, verbose); fis.close(); if (logger.isLoggable(Level.FINER)) { logger.exiting(className, "toXml(InputStream, boolean)"); } return result; }
From source file:com.mercer.cpsg.swarm.oidc.deployment.OIDCAuthenticationMechanism.java
protected String restoreState(String state, HttpServerExchange exchange) throws Exception { if (oidcProvider.isCheckNonce()) { String previousState = (String) getSession(exchange).getAttribute(LOCATION_KEY); return previousState != null && previousState.equals(state) ? state : null; } else {//from w w w .ja va 2 s . c om byte[] secureReturnURL = Base64.getDecoder().decode(state); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, stateKey); try { secureReturnURL = cipher.doFinal(secureReturnURL); return new String(secureReturnURL); } catch (Exception e) { // non-critical exception LOG.log(Level.FINER, "State decryption failed", e); return null; } } }