List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.acmsl.queryj.api.handlers.AbstractTemplateWritingHandler.java
/** * Writes the templates./*from w w w . j a va 2 s . c o m*/ * @param templates the templates. * @param engineName the engine name. * @param parameters the parameters. * @param charset the file encoding. * @param templateGenerator the template generator. * @param threadCount the number of threads to use. * @param rootDir the root dir. * @return the futures for the concurrent threads. * @throws QueryJBuildException if the templates cannot be written. */ @NotNull @SuppressWarnings("unused") protected List<Future<?>> writeTemplatesMultithread2ndVersion(@Nullable final List<T> templates, @NotNull final String engineName, @NotNull final QueryJCommand parameters, @NotNull final Charset charset, @NotNull final TG templateGenerator, final int threadCount, @NotNull final File rootDir) throws QueryJBuildException { @NotNull final List<Future<?>> result; if (templates != null) { result = new ArrayList<>(templates.size()); @NotNull final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount); @NotNull final CyclicBarrier round = new CyclicBarrier(threadCount); @NotNull AtomicInteger index = new AtomicInteger(0); int intIndex; @Nullable final Log t_Log = UniqueLogFactory.getLog(AbstractTemplateWritingHandler.class); for (@Nullable final T t_Template : templates) { if (t_Template != null) { intIndex = index.incrementAndGet(); if (intIndex <= threadCount) { if (t_Log != null) { t_Log.info("Starting a new thread " + intIndex + "/" + threadCount); } result.add(threadPool.submit((Runnable) buildGeneratorThread(t_Template, templateGenerator, retrieveOutputDir(t_Template.getTemplateContext(), rootDir, parameters), rootDir, charset, intIndex, round, parameters))); } else { if (t_Log != null) { t_Log.info("No threads available " + intIndex + "/" + threadCount); } index = new AtomicInteger(0); try { round.await(); } catch (@NotNull final InterruptedException interrupted) { if (t_Log != null) { t_Log.info("Thread pool interrupted while waiting", interrupted); } } catch (@NotNull final BrokenBarrierException brokenBarrier) { if (t_Log != null) { t_Log.info(BROKEN_BARRIER_LITERAL, brokenBarrier); } } if (t_Log != null) { t_Log.info("Resetting thread pool (shutdown? " + threadPool.isShutdown() + ")"); } round.reset(); } } } } else { result = new ArrayList<>(0); } return result; }
From source file:org.acmsl.queryj.customsql.handlers.customsqlvalidation.RetrieveQueryHandler.java
/** * Retrieves the current {@link Sql query}, and delegates * the flow to given chain.// w w w.j a v a2s.com * @param command the command. * @param chain the chain. * @return {@code false} if everything went fine. * @throws QueryJBuildException if the operation fails. */ protected boolean handle(@NotNull final QueryJCommand command, @NotNull final CustomQueryChain chain) throws QueryJBuildException { int t_iIndex = retrieveCurrentSqlIndex(command); @Nullable final Log t_Log = UniqueLogFactory.getLog(RetrieveQueryHandler.class); @NotNull final List<Sql<String>> t_lSql = retrieveSqlList(command); final int t_iTotalQueries = t_lSql.size(); @Nullable final Chronometer t_Chronometer; if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Chronometer = new Chronometer(); t_Log.info("Validating up to " + t_iTotalQueries + " queries. It can take some time."); } else { t_Chronometer = null; } while ((t_iIndex > -1) && (t_iIndex < t_lSql.size())) { @NotNull final Sql<String> t_Sql = t_lSql.get(t_iIndex); setCurrentSql(t_Sql, command); if ((t_Log != null) && (t_Log.isDebugEnabled())) { t_Log.debug("[" + t_iIndex + "/" + t_iTotalQueries + "] / " + t_Sql.getId()); } setCurrentSqlIndex(t_iIndex++, command); chain.process(command); } if ((t_Log != null) && (t_Chronometer != null)) { t_Log.info("Validation took " + t_Chronometer.now()); } return false; }
From source file:org.acmsl.queryj.metadata.engines.AbstractJdbcMetadataManager.java
/** * {@inheritDoc}/*from w w w . j a va2 s.c o m*/ */ @Override public void eagerlyFetchMetadata() throws SQLException, QueryJException { if (getTables().size() == 0) { @Nullable final Chronometer t_Chronometer; @Nullable final Log t_Log = UniqueLogFactory.getLog(AbstractJdbcMetadataManager.class); if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Chronometer = new Chronometer(); t_Log.info("Starting database crawl"); } else { t_Chronometer = null; } setTables(extractTableMetadata(getTableNames(), getMetaData(), getCatalog(), getSchema(), isCaseSensitive(), getMetadataExtractionListener(), MetaLanguageUtils.getInstance())); if ((t_Log != null) && (t_Log.isInfoEnabled()) && (t_Chronometer != null)) { @NotNull final String t_strMessage = "Finished database crawl: " + t_Chronometer.now(); t_Log.info(t_strMessage); } } }
From source file:org.acmsl.queryj.metadata.engines.oracle.OracleMetadataManager.java
/** * Builds the table structures./*from w w w. j a va 2 s . c om*/ * @param tableMap the table map. * @param columnMap the column map. * @param primaryKeyMap the primary key map. * @param foreignKeyMap the foreign key map. * @param foreignKeyAttributeMap the foreign key attribute map. * @param caseSensitiveness whether it's case sensitive. * @param metaLanguageUtils the {@link MetaLanguageUtils} instance. */ protected void buildUpTables(@NotNull final Map<String, TableIncompleteValueObject> tableMap, @NotNull final Map<String, List<AttributeIncompleteValueObject>> columnMap, @NotNull final Map<String, List<AttributeIncompleteValueObject>> primaryKeyMap, @NotNull final Map<String, List<ForeignKeyIncompleteValueObject>> foreignKeyMap, @NotNull final Map<String, List<AttributeIncompleteValueObject>> foreignKeyAttributeMap, final boolean caseSensitiveness, @NotNull final MetaLanguageUtils metaLanguageUtils) { @Nullable final Log t_Log = UniqueLogFactory.getLog(OracleMetadataManager.class); @Nullable Chronometer t_Chronometer = null; if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Chronometer = new Chronometer(); t_Log.info("Building up " + tableMap.size() + " tables ..."); } for (@Nullable final TableIncompleteValueObject t_Table : tableMap.values()) { if (t_Table != null) { @Nullable final List<AttributeIncompleteValueObject> t_lColumns = columnMap.get(t_Table.getName()); if (t_lColumns != null) { t_Table.setAttributes(toAttributeList(t_lColumns)); } @Nullable final List<AttributeIncompleteValueObject> t_lPrimaryKeys = primaryKeyMap.get(t_Table.getName()); if (t_lPrimaryKeys != null) { t_Table.setPrimaryKey(toAttributeList(t_lPrimaryKeys)); } @Nullable final List<ForeignKeyIncompleteValueObject> t_lForeignKeys = foreignKeyMap.get(t_Table.getName()); if (t_lForeignKeys != null) { for (@Nullable final ForeignKeyIncompleteValueObject t_ForeignKey : t_lForeignKeys) { if (t_ForeignKey != null) { final List<AttributeIncompleteValueObject> t_lForeignKeyAttributes = foreignKeyAttributeMap .get(t_ForeignKey.getFkName()); if (t_lForeignKeyAttributes != null) { t_ForeignKey.setAttributes(toAttributeList(t_lForeignKeyAttributes)); } } } t_Table.setForeignKeys(toForeignKeyList(t_lForeignKeys)); } } } if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Log.info("Table build up phase took " + t_Chronometer.now()); t_Log.info("Processing table comments ..."); t_Chronometer = new Chronometer(); } // second round: fix table properties based on the table comments. processTableComments(tableMap.values(), metaLanguageUtils); if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Log.info("Processing table comments took " + t_Chronometer.now()); t_Log.info("Building hierarchy relationships ..."); t_Chronometer = new Chronometer(); } // third round: parent tables bindParentChildRelationships(tableMap.values(), caseSensitiveness, metaLanguageUtils); if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Log.info("Hierarchy relationships took " + t_Chronometer.now()); t_Log.info("Binding attributes ..."); t_Chronometer = new Chronometer(); } bindAttributes(tableMap.values(), columnMap); if ((t_Log != null) && (t_Log.isInfoEnabled())) { t_Log.info("Attribute binding took " + t_Chronometer.now()); } }
From source file:org.acmsl.queryj.templates.packaging.handlers.FindTemplateDefsHandler.java
/** * Handles given parameters.//from www . j ava 2 s . c o m * @param command the command to handle. * @param log the log. * @return <code>true</code> if the chain should be stopped. * @throws QueryJBuildException if the template defs are unavailable. */ protected boolean handle(@NotNull final QueryJCommand command, @Nullable final Log log) throws QueryJBuildException { @NotNull final Set<File> t_lBaseFolders = expandFolders(retrieveSourceFolders(command)); @NotNull final List<File> t_lTotalDefFiles = new ArrayList<>(); for (@NotNull final File t_BaseFolder : t_lBaseFolders) { @NotNull final List<File> t_lDefFiles = findDefFiles(t_BaseFolder); if (log != null) { if (t_lDefFiles.size() > 0) { log.info("Found " + t_lDefFiles.size() + " template def files in " + t_BaseFolder.getAbsolutePath()); } } t_lTotalDefFiles.addAll(t_lDefFiles); } new QueryJCommandWrapper<List<File>>(command).setSetting(DEF_FILES, t_lTotalDefFiles); return false; }
From source file:org.acmsl.queryj.tools.cli.QueryJCLIHelper.java
/** * Validates the configuration properties specified as command-line * option.//from w ww.j a va2s . c o m * @param configurationFile the file to validate. * @return the <code>Properties</code> instance with the configuration * settings. */ @SuppressWarnings("unused") @Nullable public Properties readConfigurationSettings(@Nullable final String configurationFile) { @Nullable Properties result = null; if (configurationFile != null) { @Nullable InputStream stream = null; try { @NotNull final File t_File = new File(configurationFile); if ((t_File.exists()) && (t_File.canRead())) { stream = new FileInputStream(t_File); result = readConfigurationSettings(stream, false); } if (result == null) { stream = QueryJCLIHelper.class.getResourceAsStream(configurationFile); result = readConfigurationSettings(stream, true); if (result != null) { @Nullable final Log t_Log = UniqueLogFactory.getLog(QueryJCLIHelper.class); if (t_Log != null) { t_Log.info("Configuration properties have been read " + "from classpath"); } } } } catch (@NotNull final IOException ioException) { @Nullable final Log t_Log = UniqueLogFactory.getLog(QueryJCLIHelper.class); if (t_Log != null) { t_Log.info(Literals.CANNOT_READ_THE_CONFIGURATION_PROPERTIES_FILE, ioException); } } finally { if (stream != null) { try { stream.close(); } catch (@NotNull final IOException ioException) { @Nullable final Log t_Log = UniqueLogFactory.getLog(QueryJCLIHelper.class); if (t_Log != null) { t_Log.info("Cannot close the stream opened to read " + "the configuration properties.", ioException); } } } } } return result; }
From source file:org.acmsl.queryj.tools.handlers.ParameterValidationHandler.java
/** * Validates the parameters./* w w w . jav a 2 s. c om*/ * @param driver the JDBC driver. * @param url the url. * @param username the username. * @param schema the schema. * @param repository the repository. * @param packageName the package name. * @param outputDir the output folder. * @param header the header. * @param jndiDataSources the JNDI location for data sources. * @param sqlXmlFile the sql.xml file. * @param grammarFolder the grammar folder. * @param grammarBundleName the grammar bundle name. * @param grammarSuffix the grammar suffix. * @param encoding the file encoding. * @param threadCount the number of threads. * @param command the command, to store processed information. * such as the header contents. * @throws QueryJBuildException if any parameter fails to validate. */ protected void validateParameters(@Nullable final String driver, @Nullable final String url, @Nullable final String username, @Nullable final String schema, @Nullable final String repository, @Nullable final String packageName, @Nullable final File outputDir, @Nullable final File header, @Nullable final String jndiDataSources, @Nullable final File sqlXmlFile, @Nullable final File grammarFolder, @Nullable final String grammarBundleName, @Nullable final String grammarSuffix, @Nullable final String encoding, final int threadCount, @NotNull final QueryJCommand command) throws QueryJBuildException { @Nullable final Log t_Log = UniqueLogFactory.getLog(ParameterValidationHandler.class); if (driver == null) { throw new MissingJdbcDriverException(); } if (url == null) { throw new MissingJdbcUrlException(); } if (username == null) { throw new MissingJdbcUsernameException(); } /* Not mandatory. if (password == null) { throw new QueryJBuildException(PASSWORD_MISSING); } */ /* Not mandatory. if (catalog == null) { throw new QueryJBuildException(CATALOG_MISSING); } */ if (schema == null) { throw new MissingJdbcSchemaException(); } if (repository == null) { throw new MissingRepositoryException(); } if (packageName == null) { throw new MissingPackageException(); } if (outputDir == null) { throw new MissingOutputFolderException(); } if (header == null) { if (t_Log != null) { t_Log.info("No header specified. Using " + "GPLed QueryJ's instead."); } } else { try { command.setSetting(HEADER, readFile(header, Charset.forName(encoding))); } catch (@NotNull final FileNotFoundException fileNotFoundException) { if (t_Log != null) { t_Log.warn("Header file not found.", fileNotFoundException); } throw new CannotReadHeaderFileException(header, fileNotFoundException); } catch (@NotNull final SecurityException securityException) { if (t_Log != null) { t_Log.warn("No permission to read header file.", securityException); } throw new CannotReadHeaderFileException(header, securityException); } catch (@NotNull final IOException ioException) { if (t_Log != null) { t_Log.warn("Could not read header file.", ioException); } throw new CannotReadHeaderFileException(header, ioException); } } if (!outputDir.isDirectory()) { throw new OutputDirIsNotAFolderException(outputDir); } if (jndiDataSources == null) { throw new MissingJndiLocationException(); } if ((jndiDataSources.contains("\"")) || (jndiDataSources.contains("\n"))) { throw new InvalidJndiLocationException(jndiDataSources); } if (sqlXmlFile == null) { throw new MissingCustomSqlXmlFileException(); } if (!sqlXmlFile.exists()) { throw new CannotReadCustomSqlXmlFileException(sqlXmlFile); } if (!sqlXmlFile.canRead()) { throw new MissingCustomSqlXmlFileException(); } // Not mandatory if (grammarFolder != null) { if (!grammarFolder.exists()) { throw new GrammarFolderDoesNotExistException(grammarFolder); } String suffix = grammarSuffix; if (grammarSuffix == null) { suffix = ""; } File file = new File(grammarFolder + File.separator + grammarBundleName + "_" + Locale.US.getLanguage().toLowerCase(Locale.US) + suffix); if (!file.exists()) { file = new File(grammarFolder + File.separator + grammarBundleName + suffix); } if (!file.exists()) { throw new GrammarBundleDoesNotExistException(grammarBundleName, grammarFolder); } } if (encoding != null) { if (!Charset.isSupported(encoding)) { throw new UnsupportedCharsetQueryjException(encoding); } else { try { Charset.forName(encoding); } catch (@NotNull final IllegalCharsetNameException illegalCharset) { throw new UnsupportedCharsetQueryjException(encoding, illegalCharset); } catch (@NotNull final IllegalArgumentException nullCharset) { // should not happen since encoding is optional anyway. throw new NullCharsetException(nullCharset); } // catch (final UnsupportedCharsetException unsupportedCharset) // { // // Should not happen since this has been checked beforehand. // throw new QueryJBuildException(UNSUPPORTED_ENCODING); // } } } if (threadCount <= 0) { throw new IllegalThreadCountException(threadCount); } }
From source file:org.acmsl.queryj.tools.QueryJChain.java
/** * Performs any clean up whenever an error occurs. * @param buildException the error that triggers this clean-up. * @param command the command.//from w w w .j av a 2s . c o m */ @Override protected void cleanUpOnError(@NotNull final QueryJBuildException buildException, @NotNull final QueryJCommand command) { @Nullable final Log t_Log = UniqueLogFactory.getLog(QueryJChain.class); if (t_Log != null) { t_Log.info("Performing clean up"); } try { new JdbcConnectionClosingHandler().handle(command); } catch (@NotNull final QueryJBuildException closingException) { if (t_Log != null) { t_Log.error("Error closing the connection", closingException); } } }
From source file:org.adeptnet.atlassian.common.AuthenticatorInterface.java
default public Principal getUserFromUserName(final HttpServletRequest request, final HttpServletResponse response, final String userName, final String method) { final Log log = getLog(); final Principal user = getUser(userName); if (user == null) { log.warn(String.format("User not found: %s", userName)); return null; }/*from w w w. j ava 2 s. co m*/ log.info(String.format("Logged in %s via %s", user, method)); if (!authoriseUserAndEstablishSession(request, response, user)) { log.warn(String.format("User not authorised: %s", userName)); return null; } return user; }
From source file:org.alfresco.extension.bulkimport.util.LogUtils.java
public final static void info(final Log log, final String message) { log.info(PREFIX + message); }