List of usage examples for java.util.logging Logger getAnonymousLogger
public static Logger getAnonymousLogger()
From source file:org.fiware.cybercaptor.server.api.IDMEFManagement.java
/** * Load the IDMEF from an XML file (containing the alerts in IDMEF format) * cf https://www.ietf.org/rfc/rfc4765.txt. * Serialize this list of alerts in a file, in order to send them to the client when it * makes the proper request./*w ww . j a v a 2 s .c o m*/ * * @param idmefXMLString the XML string of the alerts * @throws JDOMException * @throws IOException */ public static void loadIDMEFAlertsFromXML(String idmefXMLString) throws JDOMException, IOException, ClassNotFoundException { String alertsTemporaryPath = ProjectProperties.getProperty("alerts-temporary-path"); if (alertsTemporaryPath == null || alertsTemporaryPath.isEmpty()) { alertsTemporaryPath = ProjectProperties.getProperty("output-path") + "/alerts.bin"; } if (alertsTemporaryPath == null || alertsTemporaryPath.isEmpty()) { throw new IllegalStateException("The path where the alerts should be saved is invalid."); } //Load the alerts history File alertsFile = new File(alertsTemporaryPath); List<Alert> alerts; if (alertsFile.exists()) { ObjectInputStream ois = new ObjectInputStream(new FileInputStream(alertsTemporaryPath)); try { alerts = (List<Alert>) ois.readObject(); } catch (InvalidClassException exception) { // The sources have been changed since the alerts where saved, reinitialize the database alerts = new ArrayList<Alert>(); } } else { alerts = new ArrayList<Alert>(); } //Load the alerts from the XML SAXBuilder sxb = new SAXBuilder(); Document document = sxb.build(new StringReader(idmefXMLString)); Namespace idmefNamespace = Namespace.getNamespace("http://iana.org/idmef"); Element root = document.getRootElement(); for (Element alertElement : root.getChildren("Alert", idmefNamespace)) { Alert alert = new Alert(alertElement); alerts.add(alert); } //Save to the alerts in temporary file ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(alertsFile)); oos.writeObject(alerts); Logger.getAnonymousLogger().log(Level.INFO, alerts.size() + " alerts are now stored in temporary file."); }
From source file:org.kalypso.model.hydrology.internal.preprocessing.writer.BodentypWriter.java
private void reportInvalidParameters(final String soilType, final ValidSoilParametersVisitor<? extends SoilLayerParameter> visitor) { final SoilLayerParameter[] invalidParameters = visitor.getInvalidParameters(); for (final SoilLayerParameter parameter : invalidParameters) { Logger.getAnonymousLogger().log(Level.WARNING, Messages.getString( "org.kalypso.convert.namodel.manager.BodentypManager.29", soilType, parameter.getName())); //$NON-NLS-1$ }/* w w w.j a v a 2 s . com*/ }
From source file:spout.mddb.MddbFeatureExtractorSpout.java
/** * Called when a task for this component is initialized within a worker on the cluster. * It provides the spout with the environment in which the spout executes. * <p/>// w w w .j a v a2 s . c o m * <p>This includes the:</p> * * @param conf The Storm configuration for this spout. This is the configuration provided to the topology merged in with cluster configuration on this machine. * @param context This object can be used to pythonDictToJava information about this task's place within the topology, including the task id and component id of this task, input and output information, etc. * @param collector The collector is used to emit tuples from this spout. Tuples can be emitted at any time, including the open and close methods. The collector is thread-safe and should be saved as an instance variable of this spout object. */ @Override public void open(final Map conf, final TopologyContext context, final SpoutOutputCollector collector) { Logger.getAnonymousLogger().log(Level.INFO, MessageFormat.format("Opening {0}", getClass().getCanonicalName())); this.collector = collector; this.taskId = context.getThisTaskId(); this.featureFiles = new ArrayDeque<String>(); SpoutUtils.listFilesForFolder(new File(folder), featureFiles); try { this.peekableScanner = moveSpoutForward(); updateMlStormFieldTemplate(fieldTemplate, peekableScanner.peek().split(FIELD_SEPARATOR).length); } catch (FileNotFoundException e) { throw new IllegalStateException(e); } }
From source file:org.silverpeas.core.viewer.service.ViewServiceNoCacheDemonstrationAfter.java
@Test public void demonstrateNoCache() throws Exception { if (canPerformViewConversionTest()) { long conversionDurationFromBefore = readAndRemoveFromTemporaryPathAsLong( ViewServiceNoCacheDemonstrationITSuite.CONVERSION_DURATION_FILE_NAME); DocumentView documentViewFromBefore = SerializationUtil.deserializeFromString( readAndRemoveFromTemporaryPath(ViewServiceNoCacheDemonstrationITSuite.DOCUMENT_VIEW_FILE_NAME)); Thread.sleep(1001);/*from www .j av a2 s . c o m*/ SimpleDocument document = getSimpleDocumentNamed("file.odt"); long start = System.currentTimeMillis(); final DocumentView view = viewService.getDocumentView(ViewerContext.from(document)); assertDocumentView(view); long end = System.currentTimeMillis(); long fromCacheDuration = end - start; Logger.getAnonymousLogger().info("(Again) Conversion duration without cache in " + DurationFormatUtils.formatDurationHMS(fromCacheDuration)); assertThat(fromCacheDuration, greaterThan(250l)); assertThat((fromCacheDuration * 2), greaterThan(conversionDurationFromBefore)); assertThat(view, not(sameInstance(documentViewFromBefore))); assertThat(view.getPhysicalFile().getParentFile().getName(), not(is(documentViewFromBefore.getPhysicalFile().getParentFile().getName()))); assertThat(view.getPhysicalFile().getParentFile().lastModified(), greaterThan(documentViewFromBefore.getPhysicalFile().getParentFile().lastModified())); assertThat(view.getPhysicalFile().lastModified(), greaterThan(documentViewFromBefore.getPhysicalFile().lastModified())); } }
From source file:org.silverpeas.core.viewer.service.ViewServiceCacheDemonstrationAfter.java
@Test public void demonstrateCache() throws Exception { if (canPerformViewConversionTest()) { long conversionDurationFromBefore = readAndRemoveFromTemporaryPathAsLong( ViewServiceCacheDemonstrationITSuite.CONVERSION_DURATION_FILE_NAME); DocumentView documentViewFromBefore = SerializationUtil.deserializeFromString( readAndRemoveFromTemporaryPath(ViewServiceCacheDemonstrationITSuite.DOCUMENT_VIEW_FILE_NAME)); Thread.sleep(1001);//from w w w .j a v a 2 s. com SimpleDocument document = getSimpleDocumentNamed("file.odt"); long start = System.currentTimeMillis(); final DocumentView view = viewService.getDocumentView(ViewerContext.from(document)); assertDocumentView(view); long end = System.currentTimeMillis(); long fromCacheDuration = end - start; Logger.getAnonymousLogger() .info("From cache in " + DurationFormatUtils.formatDurationHMS(fromCacheDuration)); assertThat(fromCacheDuration, lessThan(250l)); assertThat((fromCacheDuration * 5), lessThan(conversionDurationFromBefore)); assertThat(view, not(sameInstance(documentViewFromBefore))); assertThat(view.getPhysicalFile().getParentFile().getName(), is(documentViewFromBefore.getPhysicalFile().getParentFile().getName())); assertThat(view.getPhysicalFile().getParentFile().lastModified(), is(documentViewFromBefore.getPhysicalFile().getParentFile().lastModified())); assertThat(view.getPhysicalFile().lastModified(), is(documentViewFromBefore.getPhysicalFile().lastModified())); } }
From source file:org.silverpeas.core.viewer.service.ViewServiceCacheDemonstrationTestAfter.java
@Test public void demonstrateCache() throws Exception { if (canPerformViewConversionTest()) { long conversionDurationFromBefore = readAndRemoveFromTemporaryPathAsLong( ViewServiceCacheDemonstrationTestSuite.CONVERSION_DURATION_FILE_NAME); DocumentView documentViewFromBefore = SerializationUtil.deserializeFromString( readAndRemoveFromTemporaryPath(ViewServiceCacheDemonstrationTestSuite.DOCUMENT_VIEW_FILE_NAME)); Thread.sleep(1001);//from w w w . j av a2 s . c om SimpleDocument document = getSimpleDocumentNamed("file.odt"); long start = System.currentTimeMillis(); final DocumentView view = viewService.getDocumentView(ViewerContext.from(document)); assertDocumentView(view); long end = System.currentTimeMillis(); long fromCacheDuration = end - start; Logger.getAnonymousLogger() .info("From cache in " + DurationFormatUtils.formatDurationHMS(fromCacheDuration)); assertThat(fromCacheDuration, lessThan(250l)); assertThat((fromCacheDuration * 5), lessThan(conversionDurationFromBefore)); assertThat(view, not(sameInstance(documentViewFromBefore))); assertThat(view.getPhysicalFile().getParentFile().getName(), is(documentViewFromBefore.getPhysicalFile().getParentFile().getName())); assertThat(view.getPhysicalFile().getParentFile().lastModified(), is(documentViewFromBefore.getPhysicalFile().getParentFile().lastModified())); assertThat(view.getPhysicalFile().lastModified(), is(documentViewFromBefore.getPhysicalFile().lastModified())); } }
From source file:org.silverpeas.core.viewer.service.ViewServiceNoCacheDemonstrationTestAfter.java
@Test public void demonstrateNoCache() throws Exception { if (canPerformViewConversionTest()) { long conversionDurationFromBefore = readAndRemoveFromTemporaryPathAsLong( ViewServiceNoCacheDemonstrationTestSuite.CONVERSION_DURATION_FILE_NAME); DocumentView documentViewFromBefore = SerializationUtil .deserializeFromString(readAndRemoveFromTemporaryPath( ViewServiceNoCacheDemonstrationTestSuite.DOCUMENT_VIEW_FILE_NAME)); Thread.sleep(1001);/*from w w w . j a v a 2 s . c o m*/ SimpleDocument document = getSimpleDocumentNamed("file.odt"); long start = System.currentTimeMillis(); final DocumentView view = viewService.getDocumentView(ViewerContext.from(document)); assertDocumentView(view); long end = System.currentTimeMillis(); long fromCacheDuration = end - start; Logger.getAnonymousLogger().info("(Again) Conversion duration without cache in " + DurationFormatUtils.formatDurationHMS(fromCacheDuration)); assertThat(fromCacheDuration, greaterThan(250l)); assertThat((fromCacheDuration * 2), greaterThan(conversionDurationFromBefore)); assertThat(view, not(sameInstance(documentViewFromBefore))); assertThat(view.getPhysicalFile().getParentFile().getName(), not(is(documentViewFromBefore.getPhysicalFile().getParentFile().getName()))); assertThat(view.getPhysicalFile().getParentFile().lastModified(), greaterThan(documentViewFromBefore.getPhysicalFile().getParentFile().lastModified())); assertThat(view.getPhysicalFile().lastModified(), greaterThan(documentViewFromBefore.getPhysicalFile().lastModified())); } }
From source file:org.silverpeas.core.admin.AssignRightIT.java
@Before public void setUp() throws Exception { try {/* ww w . j ava 2 s . c o m*/ verifyCurrentDirectRights("test-assign-rights-expected-initial.txt"); } catch (Throwable t) { Logger.getAnonymousLogger().severe("FAILED ON INITIAL DATA VERIFICATION"); throw new RuntimeException(t); } }
From source file:org.silverpeas.core.viewer.service.AbstractViewerTest.java
protected boolean canPerformViewConversionTest() { if (SwfToolManager.isActivated()) { return true; }//from w w w . j a v a2s. c o m Logger.getAnonymousLogger().severe("SwfTools are not available, test is skipped."); Logger.getAnonymousLogger().severe("Please install pdf2swf and swfrender tools."); return false; }
From source file:org.silverpeas.core.io.temp.TestLastModifiedDateFileTask.java
@SuppressWarnings("ConstantConditions") @Test/*from w w w . j a va 2 s.c o m*/ public void verifyLastModifiedDate() throws Exception { List<File> files = new ArrayList<File>(); File fileTest = new File(tempPath, "file.txt"); FileUtils.touch(fileTest); files.add(fileTest); fileTest = new File(tempPath, "folder"); fileTest.mkdirs(); files.add(fileTest); fileTest = new File(fileTest, "file1.txt"); FileUtils.touch(fileTest); files.add(fileTest); fileTest = new File(fileTest.getParentFile(), "file2.txt"); FileUtils.touch(fileTest); files.add(fileTest); fileTest = new File(fileTest.getParentFile(), "otherFolder"); fileTest.mkdirs(); files.add(fileTest); fileTest = new File(fileTest, "otherFile1.txt"); FileUtils.touch(fileTest); files.add(fileTest); fileTest = new File(fileTest.getParentFile(), "otherFile2.txt"); FileUtils.touch(fileTest); files.add(fileTest); Thread.sleep(200); long oneSecondAfterFileCreation = System.currentTimeMillis(); List<Pair<File, Long>> fileLastModifiedDate = new ArrayList<Pair<File, Long>>(); for (File file : files) { fileLastModifiedDate.add(Pair.of(file, file.lastModified())); } for (Pair<File, Long> fileOrFolder : fileLastModifiedDate) { assertThat(fileOrFolder.getKey().getName(), fileOrFolder.getKey().lastModified(), is(fileOrFolder.getValue())); assertThat(fileOrFolder.getKey().getName(), fileOrFolder.getKey().lastModified(), lessThan(oneSecondAfterFileCreation)); } Thread.sleep(1001); File[] tempRootFiles = tempPath.listFiles(); assertThat(tempRootFiles, arrayWithSize(2)); for (File tempRootFile : tempRootFiles) { LastModifiedDateFileTask.addFile(tempRootFile); } long l = 0; while (LastModifiedDateFileTask.isRunning()) { l++; } assertThat("This assertion shows that the thread stops after all the files are performed", l, greaterThan(0l)); Logger.getAnonymousLogger().info(MessageFormat .format("Calling LastModifiedDateFileThread.isRunning() {0} times", String.valueOf(l))); for (Pair<File, Long> fileOrFolder : fileLastModifiedDate) { assertThat(fileOrFolder.getKey().getName(), fileOrFolder.getKey().lastModified(), greaterThan(fileOrFolder.getValue())); assertThat(fileOrFolder.getKey().getName(), fileOrFolder.getKey().lastModified(), greaterThan(oneSecondAfterFileCreation)); } }