Exemple #1
0
 public void initWorkspaceComponentEntries(
     SystemParametersPersistenceConfigurator sppc, WorkspaceEntry workspaceEntry) {
   workspaceEntry.setUniqueName(getName() + "_" + workspaceEntry.getName());
   if (sppc != null) {
     for (ExtendedMappedParametrizedObjectEntry entry :
         getWorkspaceComponentEntries(workspaceEntry)) {
       entry.initSystemParameterUpdater(workspaceEntry, sppc);
     }
   }
 }
Exemple #2
0
  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);
      }
    }
  }
Exemple #3
0
  /**
   * Init workspace root node. If it's the system workspace init jcr:system too.
   *
   * @param wsConfig
   * @throws RepositoryException
   */
  private void initWorkspace(WorkspaceEntry wsConfig) throws RepositoryException {

    WorkspaceContainer workspaceContainer = getWorkspaceContainer(wsConfig.getName());

    // touch independent components
    workspaceContainer.getComponentInstanceOfType(IdGenerator.class);

    // Init Root and jcr:system if workspace is system workspace
    WorkspaceInitializer wsInitializer =
        (WorkspaceInitializer)
            workspaceContainer.getComponentInstanceOfType(WorkspaceInitializer.class);
    RepositoryCreationSynchronizer synchronizer =
        (RepositoryCreationSynchronizer)
            getComponentInstanceOfType(RepositoryCreationSynchronizer.class);
    // The synchronizer will be used to synchronize all the cluster
    // nodes to prevent any concurrent jcr initialization i.e. EXOJCR-887
    synchronizer.waitForApproval(wsInitializer.isWorkspaceInitialized());

    SystemParametersPersistenceConfigurator sppc =
        (SystemParametersPersistenceConfigurator)
            parent.getComponentInstanceOfType(SystemParametersPersistenceConfigurator.class);

    if (sppc != null) {
      setInitializerAndValidateOverriddenParameters(wsConfig, wsInitializer);
    }

    wsInitializer.initWorkspace();
  }
Exemple #4
0
 /**
  * Return {@link JDBCWorkspaceDataContainer#SOURCE_NAME} parameter from workspace configuration.
  */
 private static String getSourceNameParameter(WorkspaceEntry wsEntry) throws DBCleanException {
   try {
     return wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
   } catch (RepositoryConfigurationException e) {
     throw new DBCleanException(e);
   }
 }
Exemple #5
0
  /**
   * 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 ");
    //      }

  }
Exemple #6
0
  /**
   * Remove all file of workspace index.
   *
   * @param wsConfig - workspace configuration.
   * @param isSystem - 'true' to clean system workspace.
   * @throws RepositoryConfigurationException - exception on parsing workspace configuration
   * @throws IOException - exception on remove index folder
   */
  public void removeWorkspaceIndex(WorkspaceEntry wsConfig, boolean isSystem)
      throws RepositoryConfigurationException, IOException {
    String indexDirName =
        wsConfig.getQueryHandler().getParameterValue(QueryHandlerParams.PARAM_INDEX_DIR);

    File indexDir = new File(indexDirName);
    if (PrivilegedFileHelper.exists(indexDir)) {
      removeFolder(indexDir);
    }

    if (isSystem) {
      File systemIndexDir = new File(indexDirName + "_" + SystemSearchManager.INDEX_DIR_SUFFIX);
      if (PrivilegedFileHelper.exists(systemIndexDir)) {
        removeFolder(systemIndexDir);
      }
    }
  }
Exemple #7
0
 /**
  * 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;
 }
Exemple #8
0
  private List<ExtendedMappedParametrizedObjectEntry> getWorkspaceComponentEntries(
      WorkspaceEntry workspaceEntry) {
    List<ExtendedMappedParametrizedObjectEntry> entries =
        new ArrayList<ExtendedMappedParametrizedObjectEntry>();
    if (workspaceEntry.getAccessManager() != null) {
      entries.add(workspaceEntry.getAccessManager());
    }

    if (workspaceEntry.getCache() != null) {
      entries.add(workspaceEntry.getCache());
    }

    if (workspaceEntry.getInitializer() != null) {
      entries.add(workspaceEntry.getInitializer());
    }

    if (workspaceEntry.getLockManager() != null) {
      entries.add(workspaceEntry.getLockManager());
    }

    if (workspaceEntry.getQueryHandler() != null) {
      entries.add(workspaceEntry.getQueryHandler());
    }

    if (workspaceEntry.getContainer() != null) {
      entries.add(workspaceEntry.getContainer());
      if (workspaceEntry.getContainer().getValueStorages() != null) {
        for (ValueStorageEntry valueStorageEntry :
            workspaceEntry.getContainer().getValueStorages()) {
          entries.add(valueStorageEntry);
        }
      }
    }

    return entries;
  }