use of com.helger.config.IConfig in project phase4 by phax.
the class DropFolderUserMessage method init.
public static void init(@Nonnull final IAS4CryptoFactory aCryptoFactory) {
if (s_aWatch != null)
throw new IllegalStateException("Already inited!");
final IConfig aConfig = AS4Configuration.getConfig();
final Path aOutgoingDir = Paths.get(aConfig.getAsString("server.directory.outgoing", "out"));
final Path aIncomingDir = Paths.get(aConfig.getAsString("server.directory.incoming", "in"));
try {
// Ensure directories are present
Files.createDirectories(aOutgoingDir.resolve(PATH_DONE));
Files.createDirectories(aOutgoingDir.resolve(PATH_ERROR));
Files.createDirectories(aIncomingDir);
// Start watching directory for changes
final IWatchDirCallback aCB = (eAction, aCurFile) -> {
if (LOGGER.isDebugEnabled())
LOGGER.debug("WatchEvent " + eAction + " - " + aCurFile);
if (!eAction.equals(EWatchDirAction.DELETE) && aCurFile.toFile().isFile() && aCurFile.getFileName() != null && aCurFile.getFileName().toString().endsWith(".xml")) {
_send(aCryptoFactory, aCurFile, aIncomingDir);
}
};
s_aWatch = WatchDir.createAsyncRunningWatchDir(aOutgoingDir, false, aCB);
// Send initially for all existing files
try (final DirectoryStream<Path> aStream = Files.newDirectoryStream(aOutgoingDir, x -> x.toFile().isFile() && x.getFileName() != null && x.getFileName().toString().endsWith(".xml"))) {
for (final Path aCur : aStream) _send(aCryptoFactory, aCur, aIncomingDir);
}
} catch (final IOException ex) {
// Checked to unchecked conversion
throw new UncheckedIOException(ex);
}
}
use of com.helger.config.IConfig in project phase4 by phax.
the class AS4CryptoProperties method createFromConfig.
/**
* @return A new {@link AS4CryptoProperties} object filled with all values
* from the global configuration file. Values not present in the
* configuration are not set and stay with their default values.
* @since 0.11.0
*/
@Nonnull
public static AS4CryptoProperties createFromConfig() {
final IConfig aConfig = AS4Configuration.getConfig();
final AS4CryptoProperties ret = new AS4CryptoProperties();
for (final String sKey : new String[] { CRYPTO_PROVIDER, KEYSTORE_TYPE, KEYSTORE_FILE, KEYSTORE_PASSWORD, KEY_ALIAS, KEY_PASSWORD, LOAD_CACERTS, TRUSTSTORE_PROVIDER, TRUSTSTORE_TYPE, TRUSTSTORE_FILE, TRUSTSTORE_PASSWORD }) {
final String sConfigValue = aConfig.getAsString(sKey);
if (sConfigValue != null)
ret.m_aProps.put(sKey, sConfigValue);
}
return ret;
}
use of com.helger.config.IConfig in project phoss-directory by phax.
the class PDClientConfiguration method setConfig.
/**
* Overwrite the global configuration. This is only needed for testing.
*
* @param aNewConfig
* The configuration to use globally. May not be <code>null</code>.
* @return The old value of {@link IConfig}. Never <code>null</code>.
*/
@Nonnull
public static IConfig setConfig(@Nonnull final IConfig aNewConfig) {
ValueEnforcer.notNull(aNewConfig, "NewConfig");
final IConfig ret;
RW_LOCK.writeLock().lock();
try {
ret = s_aConfig;
s_aConfig = aNewConfig;
} finally {
RW_LOCK.writeLock().unlock();
}
if (!EqualsHelper.identityEqual(ret, aNewConfig))
LOGGER.info("The SMPClient configuration provider was changed to " + aNewConfig);
return ret;
}
use of com.helger.config.IConfig in project peppol-commons by phax.
the class SMPClientConfiguration method setConfig.
/**
* Overwrite the global configuration. This is only needed for testing.
*
* @param aNewConfig
* The configuration to use globally. May not be <code>null</code>.
* @return The old value of {@link IConfig}. Never <code>null</code>.
*/
@Nonnull
public static IConfig setConfig(@Nonnull final IConfig aNewConfig) {
ValueEnforcer.notNull(aNewConfig, "NewConfig");
final IConfig ret;
RW_LOCK.writeLock().lock();
try {
ret = s_aConfig;
s_aConfig = aNewConfig;
} finally {
RW_LOCK.writeLock().unlock();
}
if (!EqualsHelper.identityEqual(ret, aNewConfig))
LOGGER.info("The SMPClient configuration provider was changed to " + aNewConfig);
return ret;
}
use of com.helger.config.IConfig in project phase4 by phax.
the class AS4Configuration method setConfig.
/**
* Overwrite the global configuration. This is only needed for testing.
*
* @param aNewConfig
* The configuration to use globally. May not be <code>null</code>.
* @return The old value of {@link IConfig}. Never <code>null</code>.
*/
@Nonnull
public static IConfig setConfig(@Nonnull final IConfig aNewConfig) {
ValueEnforcer.notNull(aNewConfig, "NewConfig");
final IConfig ret;
RW_LOCK.writeLock().lock();
try {
ret = s_aConfig;
s_aConfig = aNewConfig;
} finally {
RW_LOCK.writeLock().unlock();
}
if (!EqualsHelper.identityEqual(ret, aNewConfig))
LOGGER.info("The phase4 configuration provider was changed to " + aNewConfig);
return ret;
}
Aggregations