List of usage examples for java.util.logging Logger getAnonymousLogger
public static Logger getAnonymousLogger()
From source file:org.javascool.compiler.ProgletCodeCompiler.java
/** * Configure le translator pour lui ajouter les Imports necessaires *//*from w w w.j av a 2s . c om*/ private void setUpTranslator() { translator.addDefaultImports(); // On vrifie bien qu'on est dans un monde Java's Cool (Imports, Runnable ...) try { ProgletCodeCompiler.class.getClassLoader() .loadClass("org.javascool.proglets." + this.proglet + ".Functions"); translator.addImport("org.javascool.proglets." + this.proglet + ".Functions.*", true); } catch (ClassNotFoundException e) { Logger.getAnonymousLogger().log(Level.INFO, "Aucun fonction ajouter avec la proglet " + this.proglet); } // Dans ce cas on ne fais rien car il n'y a pas de Functions.java }
From source file:org.objectpocket.viewer.Viewer.java
private void updateTable() { String selectedType = ((DefaultMutableTreeNode) classTree.getSelectionPath().getLastPathComponent()) .toString();/* w ww. j ava 2 s . com*/ String selectedObjectPocket = ((DefaultMutableTreeNode) classTree.getSelectionPath() .getPathComponent(classTree.getSelectionPath().getPathCount() - 2)).toString(); ObjectPocketImpl objectPocket = null; for (ObjectPocketImpl objectPocketImpl : objectPocketList) { if (objectPocketImpl.getSource().equals(selectedObjectPocket)) { objectPocket = objectPocketImpl; } } if (objectPocket != null) { Map<String, Object> objectMap = objectPocket.getMapForType(selectedType); try { Class<?> clazz = Class.forName(selectedType); List<Field> allFields = FieldUtils.getAllFieldsList(clazz); List<Field> fields = new ArrayList<>(); // filter fields for (Field field : allFields) { if (!Modifier.isTransient(field.getModifiers()) && !field.getName().equals("id")) { fields.add(field); } } String[] columnNames = new String[fields.size() + 2]; columnNames[0] = ""; columnNames[1] = "id"; int index = 2; for (Field f : fields) { columnNames[index] = f.getName() + "(" + f.getType().getSimpleName() + ")"; index++; } // filter objects Map<String, Object> filteredObjects = filterObjects(objectMap, fields); String[][] rowData = new String[filteredObjects.size()][columnNames.length]; index = 0; statusLabel.setText("object count: " + filteredObjects.size()); for (String key : filteredObjects.keySet()) { rowData[index][0] = "" + (index + 1); rowData[index][1] = key; for (int i = 0; i < fields.size(); i++) { Field f = fields.get(i); f.setAccessible(true); try { Object object = f.get(filteredObjects.get(key)); if (object != null) { rowData[index][2 + i] = object.toString(); } else { rowData[index][2 + i] = "null"; } } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } } index++; } DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames); objectTable.setModel(tableModel); viewerFrame.revalidate(); } catch (ClassNotFoundException e) { Logger.getAnonymousLogger().warning("Could not load class for type. " + selectedType); e.printStackTrace(); // --- fallback String[] columnNames = { "", "id", "data" }; String[][] rowData = new String[objectMap.size()][3]; int index = 0; for (String key : objectMap.keySet()) { rowData[index][0] = "" + (index + 1); rowData[index][1] = key; rowData[index][2] = objectMap.get(key).toString(); index++; } DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames); objectTable.setModel(tableModel); viewerFrame.revalidate(); } } for (int i = 0; i < objectTable.getColumnModel().getColumnCount(); i++) { if (i == 0) { objectTable.getColumnModel().getColumn(i).setPreferredWidth(50); } else { objectTable.getColumnModel().getColumn(i).setPreferredWidth(200); } } }
From source file:Utilities.java
/** * Returns the usable area of the screen where applications can place its * windows. The method subtracts from the screen the area of taskbars, * system menus and the like.//from w ww. j a v a 2 s .co m * * @param gconf the GraphicsConfiguration of the monitor * @return the rectangle of the screen where one can place windows * * @since 2.5 */ public static Rectangle getUsableScreenBounds(GraphicsConfiguration gconf) { if (gconf == null) { gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); } Rectangle bounds = new Rectangle(gconf.getBounds()); String str; str = System.getProperty("netbeans.screen.insets"); // NOI18N if (str != null) { StringTokenizer st = new StringTokenizer(str, ", "); // NOI18N if (st.countTokens() == 4) { try { bounds.y = Integer.parseInt(st.nextToken()); bounds.x = Integer.parseInt(st.nextToken()); bounds.height -= (bounds.y + Integer.parseInt(st.nextToken())); bounds.width -= (bounds.x + Integer.parseInt(st.nextToken())); } catch (NumberFormatException ex) { Logger.getAnonymousLogger().log(Level.WARNING, null, ex); } } return bounds; } str = System.getProperty("netbeans.taskbar.height"); // NOI18N if (str != null) { bounds.height -= Integer.getInteger(str, 0).intValue(); return bounds; } try { Toolkit toolkit = Toolkit.getDefaultToolkit(); Insets insets = toolkit.getScreenInsets(gconf); bounds.y += insets.top; bounds.x += insets.left; bounds.height -= (insets.top + insets.bottom); bounds.width -= (insets.left + insets.right); } catch (Exception ex) { Logger.getAnonymousLogger().log(Level.WARNING, null, ex); } return bounds; }
From source file:org.objectpocket.storage.blob.MultiZipBlobStore.java
private void scanForBlobContainers() throws IOException { File dir = new File(directory); if (!dir.exists()) { dir.mkdirs();/* w w w .j a v a 2 s . c o m*/ } Collection<File> blobContainers = FileUtils.listFiles(dir, FileFilterUtils.prefixFileFilter(BLOB_STORE_DEFAULT_FILENAME), null); for (File file : blobContainers) { String filenameSuffix = file.getName().substring(file.getName().indexOf('.') + 1); try { int suffixInt = Integer.parseInt(filenameSuffix); if (suffixInt > lastBlobContainerNum) { lastBlobContainer = file; lastBlobContainerNum = suffixInt; lastBlobContainerSize = file.length(); } // this is necessary for index creation getReadFileSystem(file.getName()); } catch (NumberFormatException e) { Logger.getAnonymousLogger().log(Level.WARNING, "There was an error parsing the suffix of binary file " + file.getAbsolutePath(), e); } } }
From source file:org.silverpeas.core.persistence.jdbc.JdbcSqlQueryIT.java
private void info(List<String> logContainer, String message) { logContainer.add(message);/*from ww w. j a va 2s. c o m*/ Logger.getAnonymousLogger().info("[" + Thread.currentThread().getId() + "] " + message); }
From source file:org.javascool.compiler.ProgletCodeCompiler.java
/** * Cherche si la proglet dfinit un Translator. Permet d'acceder aux translators des package du Classpath. * * @param progletName L'identificateur de la proglet * @return Le Translator utiliser pour cette proglet *//* w w w . j a va 2s . c o m*/ protected JVSTranslator getTranslatorForProglet(String progletName) { if (!isDefaultProglet(progletName)) { try { Class<?> translatorClass = ProgletCodeCompiler.class.getClassLoader() .loadClass("org.javascool.proglets." + this.proglet + ".Translator"); translator = (JVSTranslator) translatorClass.getDeclaredConstructor(File.class) .newInstance(jvsFile); } catch (ClassNotFoundException e) { Logger.getAnonymousLogger().log(Level.INFO, "Aucun Translator pour " + progletName); } // Dans ce cas on ne fais rien car il n'y a pas de Functions.java catch (Exception e) { throw new IllegalStateException("Impossible de crer un translator."); } } try { return new DefaultJVSTranslator(jvsFile); } catch (IOException e) { throw new IllegalStateException("Impossible de crer un translator sur le fichier ouvrir"); } }
From source file:ru.codeinside.gses.webui.form.EFormBuilder.java
public Property createProperty(PropertyValue<?> propertyValue, String suffix) { String prefix;/* w ww .j a v a 2 s.com*/ if (suffix.isEmpty()) { prefix = suffix; } else { prefix = suffix.substring(1).replace('_', '.') + ") "; } PropertyNode node = propertyValue.getNode(); Property property = new Property(); property.label = prefix + node.getName(); VariableType type = node.getVariableType(); property.type = type == null ? "string" : type.getName(); property.required = node.isFieldRequired(); property.writable = !formValue.isArchiveMode() & node.isFieldWritable(); if (propertyValue.getAudit() != null) { property.sign = propertyValue.getAudit().isVerified(); if (propertyValue.getAudit().isVerified()) { property.certificate = propertyValue.getAudit().getLogin() + "(" + propertyValue.getAudit().getOrganization() + ")"; } } if (!(propertyValue.getValue() instanceof FileValue)) { Object value = propertyValue.getValue(); if (value instanceof byte[]) { try { property.value = new String((byte[]) value, "UTF-8"); } catch (UnsupportedEncodingException e) { Logger.getAnonymousLogger().info("can't decode model!"); } } else if (value instanceof Date) { String pattern = StringUtils.trimToNull(node.getPattern()) == null ? DateType.PATTERN2 : node.getPattern(); property.value = new SimpleDateFormat(pattern).format(value); } else { property.value = value == null ? null : value.toString(); } } else { FileValue value = (FileValue) propertyValue.getValue(); try { property.updateContent(value.getFileName(), value.getMimeType(), Streams.copyToTempFile( new ByteArrayInputStream(value.getContent()), "efrom-", ".attachment"), false); } catch (IOException e) { Logger.getLogger(getClass().getName()).log(Level.WARNING, "can't create tmpFile", e); } } return property; }
From source file:org.silverpeas.core.test.WarBuilder.java
/** * Builds the final WAR archive. The following stuffs are automatically added : * <ul>/* w w w.j a v a 2 s .c o m*/ * <li>The <b>beans.xml</b> in order to activate CDI,</li> * <li>The <b>META-INF/services/org.silverpeas.core.util.BeanContainer</b> to load the CDI-based bean * container,</li> * <li>The <b>test-ds.xml</b> resource in order to define a data source for tests.</li> * </ul> * @return the built WAR archive. */ @Override public final WebArchive build() { try { if (!jarLibForPersistence.isEmpty()) { String persistenceXmlContent; try (InputStream is = WarBuilder.class.getResourceAsStream("/META-INF/core-test-persistence.xml")) { persistenceXmlContent = IOUtils.toString(is); } File persistenceXml = FileUtils.getFile( classOfTest.getProtectionDomain().getCodeSource().getLocation().getFile(), "META-INF", "dynamic-test-persistence.xml"); logInfo("Setting persistence xml descriptor: " + persistenceXml.getPath()); persistenceXmlContent = persistenceXmlContent.replace("<!-- @JAR_FILES@ -->", String.join("\n", jarLibForPersistence)); FileUtils.writeStringToFile(persistenceXml, persistenceXmlContent); logInfo("Filling '" + persistenceXml.getPath() + "'\nwith content:\n" + persistenceXmlContent); logInfo("Adding completed META-INF/persistence.xml"); addAsResource("META-INF/" + persistenceXml.getName(), "META-INF/persistence.xml"); } else { addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml"); } if (!webParts.isEmpty()) { String webXmlContent; try (InputStream is = WarBuilder.class.getResourceAsStream("/META-INF/core-web-test.xml")) { webXmlContent = IOUtils.toString(is); } File webXml = FileUtils.getFile( classOfTest.getProtectionDomain().getCodeSource().getLocation().getFile(), "META-INF", "dynamic-test-web.xml"); logInfo("Setting web xml descriptor: " + webXml.getPath()); webXmlContent = webXmlContent.replace("<!-- @WEB_PARTS@ -->", String.join("\n", webParts)); FileUtils.writeStringToFile(webXml, webXmlContent); logInfo("Filling '" + webXml.getPath() + "'\nwith content:\n" + webXmlContent); logInfo("Adding completed web.xml"); war.setWebXML(webXml); } File[] libs = Stream.of(Maven.resolver().loadPomFromFile("pom.xml").resolve(mavenDependencies) .withTransitivity().asFile()).filter(onLibsToInclude()).toArray(File[]::new); war.addAsLibraries(libs); war.addAsResource("META-INF/services/test-org.silverpeas.core.util.BeanContainer", "META-INF/services/org.silverpeas.core.util.BeanContainer"); war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); war.addAsWebInfResource("test-ds.xml", "test-ds.xml"); // Resources war.addAsResource("maven.properties"); return war; } catch (Exception e) { Logger.getAnonymousLogger().log(Level.SEVERE, "WAR BUILD PROBLEM...", e); throw new RuntimeException(e); } }
From source file:org.fiware.cybercaptor.server.api.InformationSystemManagement.java
/** * Execute the python script that builds MulVAL inputs * * @return boolean true if the execution was right *///from w ww. j a v a 2s . c o m public static boolean prepareMulVALInputs() { try { //Load python script properties String pythonPath = ProjectProperties.getProperty("python-path"); String mulvalInputScriptFolder = ProjectProperties.getProperty("mulval-input-script-folder"); String mulvalInputScriptPath = mulvalInputScriptFolder + "main.py"; String hostInterfacePath = ProjectProperties.getProperty("host-interfaces-path"); String vlansPath = ProjectProperties.getProperty("vlans-path"); String routingPath = ProjectProperties.getProperty("routing-path"); String flowMatrixPath = ProjectProperties.getProperty("flow-matrix-path"); String vulnerabilityScanPath = ProjectProperties.getProperty("vulnerability-scan-path"); String mulvalInputPath = ProjectProperties.getProperty("mulval-input"); String topologyPath = ProjectProperties.getProperty("topology-path"); File mulvalInputFile = new File(mulvalInputPath); if (mulvalInputFile.exists()) { mulvalInputFile.delete(); } Logger.getAnonymousLogger().log(Level.INFO, "Genering MulVAL inputs"); //TODO: use parameter nessus-files-path rather than vulnerability-scan-path, in order to manage when // mutliple nessus files are provided. ProcessBuilder processBuilder = new ProcessBuilder(pythonPath, mulvalInputScriptPath, "--hosts-interfaces-file", hostInterfacePath, "--vlans-file", vlansPath, "--flow-matrix-file", flowMatrixPath, "--vulnerability-scan", vulnerabilityScanPath, "--routing-file", routingPath, "--mulval-output-file", mulvalInputFile.getAbsolutePath(), "--to-fiware-xml-topology", topologyPath); processBuilder.directory(new File(mulvalInputScriptFolder)); StringBuilder command = new StringBuilder(); for (String str : processBuilder.command()) command.append(str + " "); Logger.getAnonymousLogger().log(Level.INFO, "Launch generation of MulVAL inputs with command : \n" + command.toString()); processBuilder.redirectOutput( new File(ProjectProperties.getProperty("output-path") + "/input-generation.log")); processBuilder.redirectError( new File(ProjectProperties.getProperty("output-path") + "/input-generation.log")); Process process = processBuilder.start(); process.waitFor(); if (!mulvalInputFile.exists()) { Logger.getAnonymousLogger().log(Level.WARNING, "A problem happened in the generation of mulval inputs"); return false; } return true; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:org.silverpeas.core.util.DBUtilIntegrationTest.java
@Test public void nextUniqueIdUpdateForAnExistingTablesShouldWorkAndConcurrency() throws Exception { long startTime = System.currentTimeMillis(); try {//from w w w .ja v a 2 s. c o m final int nbProcesses = 150; final int nbSetOfThreadsPerProcess = 15; final List<Object> count = new ArrayList<>(); final List<Callable<org.apache.commons.lang3.tuple.Pair<String, Integer>>> listsOfGetNextId = new ArrayList<>( nbProcesses); for (int i = 0; i < nbProcesses; i++) { listsOfGetNextId.add(() -> { String tableName; synchronized (count) { count.add(""); tableName = "User_" + count.size() + "_table"; } return org.apache.commons.lang3.tuple.Pair.of(tableName, nextUniqueIdUpdateForAnExistingTableShouldWorkAndConcurrency(tableName, nbSetOfThreadsPerProcess)); }); } ExecutorService executorService = Executors.newFixedThreadPool(10); List<org.apache.commons.lang3.tuple.Pair<String, Integer>> tableNextIdsInError = new ArrayList<>(); try { for (Future<org.apache.commons.lang3.tuple.Pair<String, Integer>> aTreatment : executorService .invokeAll(listsOfGetNextId)) { org.apache.commons.lang3.tuple.Pair<String, Integer> tableIdValue = aTreatment.get(); if (tableIdValue.getRight() != nbSetOfThreadsPerProcess) { if (tableNextIdsInError.isEmpty()) { Logger.getAnonymousLogger().severe("Some errors..."); } tableNextIdsInError.add(tableIdValue); Logger.getAnonymousLogger().severe("Next id value must be " + nbSetOfThreadsPerProcess + " for table " + tableIdValue.getLeft() + ", but was " + tableIdValue.getRight()); } } } finally { executorService.shutdown(); } if (!tableNextIdsInError.isEmpty()) { fail("The next id of " + tableNextIdsInError.size() + " tables is in error."); } } finally { Logger.getAnonymousLogger() .info("Test duration of " + (System.currentTimeMillis() - startTime) + " ms"); } }