Exemplo n.º 1
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();
  }
Exemplo n.º 2
0
  public boolean isAllowedToOverride(String parameterName) {
    if (unmodifiableParameters.contains(parameterName)) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(
            "Parameter "
                + parameterName
                + " is not overridden because it is set to 'unmodifiable' via system properties in the "
                + SystemParametersPersistenceConfigurator.class.getSimpleName());
      }
      return false;
    }

    if (beforeInitializeParameters.contains(parameterName)) {
      if (workspaceInitializer == null) {
        parametersToValidate.put(parameterName, new Exception());
        return true;
      } else {
        if (workspaceInitializer.isWorkspaceInitialized()) {
          if (LOG.isWarnEnabled()) {
            LOG.warn(
                "Parameter "
                    + parameterName
                    + " is not overridden because workspace is already initialized and parameter is set to 'before-initialize'"
                    + " via system properties in the "
                    + SystemParametersPersistenceConfigurator.class.getSimpleName());
          }
          return false;
        }
      }
    }

    return true;
  }
Exemplo n.º 3
0
  public void validateOverriddenParameters() {
    for (Map.Entry<String, Exception> mapEntry : parametersToValidate.entrySet()) {
      parametersToValidate.remove(mapEntry.getKey());

      if (workspaceInitializer.isWorkspaceInitialized()) {
        sppc.rollback();

        throw new IllegalStateException(
            "Unable to override parameter '"
                + mapEntry.getKey()
                + "' set in system property because this operation is allowed only for non initialized workspaces",
            mapEntry.getValue());
      }
    }
  }