/** * Cleans repository data from database. * * @param rEntry the repository configuration * @throws DBCleanException */ public static void cleanRepositoryData(RepositoryEntry rEntry) throws DBCleanException { SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION); WorkspaceEntry wsEntry = rEntry.getWorkspaceEntries().get(0); boolean multiDB = getMultiDbParameter(wsEntry); if (multiDB) { for (WorkspaceEntry entry : rEntry.getWorkspaceEntries()) { cleanWorkspaceData(entry); } } else { Connection jdbcConn = getConnection(wsEntry); String dialect = resolveDialect(jdbcConn, wsEntry); boolean autoCommit = dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE); try { jdbcConn.setAutoCommit(autoCommit); DBCleanerTool dbCleaner = getRepositoryDBCleaner(jdbcConn, rEntry); doClean(dbCleaner); } catch (SQLException e) { throw new DBCleanException(e); } finally { try { jdbcConn.close(); } catch (SQLException e) { LOG.error("Can not close connection", e); } } } }
private void registerWorkspacesComponents() throws RepositoryException, RepositoryConfigurationException { // System workspace should be first initialized. for (WorkspaceEntry we : config.getWorkspaceEntries()) { if (we.getName().equals(config.getSystemWorkspaceName())) { registerWorkspace(we); } } // Initialize other (non system) workspaces. for (WorkspaceEntry we : config.getWorkspaceEntries()) { if (!we.getName().equals(config.getSystemWorkspaceName())) { registerWorkspace(we); } } }
private void initAllWorkspaceComponentEntries(ExoContainer parent) { SystemParametersPersistenceConfigurator sppc = (SystemParametersPersistenceConfigurator) parent.getComponentInstanceOfType(SystemParametersPersistenceConfigurator.class); for (WorkspaceEntry workspaceEntry : config.getWorkspaceEntries()) { initWorkspaceComponentEntries(sppc, workspaceEntry); } }
/** * Initialize worspaces (root node and jcr:system for system workspace). * * <p>Runs on container start. * * @throws RepositoryException * @throws RepositoryConfigurationException */ private void init() throws RepositoryException, RepositoryConfigurationException { List<WorkspaceEntry> wsEntries = config.getWorkspaceEntries(); NodeTypeDataManager typeManager = (NodeTypeDataManager) this.getComponentInstanceOfType(NodeTypeDataManager.class); NamespaceRegistryImpl namespaceRegistry = (NamespaceRegistryImpl) this.getComponentInstanceOfType(NamespaceRegistry.class); for (WorkspaceEntry ws : wsEntries) { initWorkspace(ws); WorkspaceContainer workspaceContainer = getWorkspaceContainer(ws.getName()); SearchManager searchManager = (SearchManager) workspaceContainer.getComponentInstanceOfType(SearchManager.class); // if (searchManager != null) // { // typeManager.addQueryHandler(searchManager.getHandler()); // namespaceRegistry.addQueryHandler(searchManager.getHandler()); // } // else // { // log.warn("Search manager not configured for " + ws.getName()); // } } SystemSearchManagerHolder searchManager = (SystemSearchManagerHolder) this.getComponentInstanceOfType(SystemSearchManagerHolder.class); // if (searchManager != null) // { // typeManager.addQueryHandler(searchManager.get().getHandler()); // namespaceRegistry.addQueryHandler(searchManager.get().getHandler()); // } // else // { // log.warn("System search manager not configured "); // } }
/** * Returns database cleaner for repository. * * @param jdbcConn database connection which need to use * @param rEntry repository configuration * @return DBCleanerTool * @throws DBCleanException */ public static DBCleanerTool getRepositoryDBCleaner(Connection jdbcConn, RepositoryEntry rEntry) throws DBCleanException { SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION); WorkspaceEntry wsEntry = rEntry.getWorkspaceEntries().get(0); boolean multiDb = getMultiDbParameter(wsEntry); if (multiDb) { throw new DBCleanException( "It is not possible to create cleaner with common connection for multi database repository configuration"); } String dialect = resolveDialect(jdbcConn, wsEntry); boolean autoCommit = dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE); DBCleaningScripts scripts = DBCleaningScriptsFactory.prepareScripts(dialect, rEntry); return new DBCleanerTool( jdbcConn, autoCommit, scripts.getCleaningScripts(), scripts.getCommittingScripts(), scripts.getRollbackingScripts()); }
/** * Get workspace configuration entry by name. * * @param wsName workspace name * @return WorkspaceEntry */ public WorkspaceEntry getWorkspaceEntry(String wsName) { for (WorkspaceEntry entry : config.getWorkspaceEntries()) { if (entry.getName().equals(wsName)) return entry; } return null; }