use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.
the class FilesystemStoreTools method initialize.
@Override
public void initialize() throws InitializationException {
try {
this.storageDir = new File(this.environment.getPermanentDirectory(), STORAGE_DIR_NAME).getCanonicalFile();
} catch (IOException e) {
throw new InitializationException("Invalid permanent directory", e);
}
if (config.cleanOnStartup()) {
final File dir = this.storageDir;
new Thread(() -> deleteEmptyDirs(dir, 0)).start();
}
}
use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.
the class DefaultWatchListNotificationCache method initialize.
/**
* Init watchlist store. Get all the intervals/jobs present in the wiki. Create the list of subscribers.
*
* @throws InitializationException if problems occur
*/
@Override
public void initialize() throws InitializationException {
XWikiContext context = contextProvider.get();
// Initialize the intervals cache.
try {
intervals = new ArrayList<String>();
if (xwikiProperties.getProperty("watchlist.realtime.enabled", false)) {
// If the realtime notification feature is explicitly enabled (temporarily disabled by default), then
// propose/use it as possible notification interval option.
intervals.add(REALTIME_INTERVAL_ID);
}
// Get all the watchlist job documents from the main wiki.
Query jobDocumentsQuery = queryManager.getNamedQuery("getWatchlistJobDocuments");
// Make double sure we run the query on the main wiki, since that is where the jobs are defined.
jobDocumentsQuery.setWiki(context.getWikiId());
List<String> jobDocumentNames = jobDocumentsQuery.execute();
// TODO: Sort them by cron expression.
// Add them to the list of intervals.
intervals.addAll(jobDocumentNames);
} catch (Exception e) {
throw new InitializationException("Failed to initialize the cache of watchlist intervals.", e);
}
// Initialize the subscribers cache.
for (String jobDocumentName : intervals) {
initSubscribersCache(jobDocumentName);
}
}
use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.
the class DefaultIconSetCacheTest method initializeWhenError.
@Test
public void initializeWhenError() throws Exception {
DefaultIconSetCache cache = mocker.getComponentUnderTest();
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
Exception exception = new CacheException("ERROR");
when(cacheFactory.newCache(any(CacheConfiguration.class))).thenThrow(exception);
Exception exceptionCaught = null;
try {
cache.initialize();
} catch (InitializationException e) {
exceptionCaught = e;
}
assertNotNull(exceptionCaught);
assertEquals("Failed to initialize the IconSet Cache.", exceptionCaught.getMessage());
assertEquals(exception, exceptionCaught.getCause());
}
use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.
the class DocumentTreeNode method initialize.
@Override
public void initialize() throws InitializationException {
String[] nonLeafChildNodeTypes = new String[] { "translations", "attachments", "classProperties", "objects" };
ComponentManager contextComponentManager = this.contextComponentManagerProvider.get();
try {
for (String nonLeafChildNodeType : nonLeafChildNodeTypes) {
TreeNode treeNode = contextComponentManager.getInstance(TreeNode.class, nonLeafChildNodeType);
this.nonLeafChildNodes.put(nonLeafChildNodeType, treeNode);
}
} catch (ComponentLookupException e) {
throw new InitializationException("Failed to lookup the child components.", e);
}
}
use of org.xwiki.component.phase.InitializationException in project xwiki-platform by xwiki.
the class XWikiCfgConfigurationSource method initialize.
@Override
public void initialize() throws InitializationException {
this.configurationLocation = getConfigPath();
InputStream xwikicfgis = loadConfiguration();
if (xwikicfgis != null) {
try {
this.properties.load(xwikicfgis);
} catch (Exception e) {
this.logger.error("Failed to load configuration", e);
}
}
}
Aggregations