コード例 #1
0
    @Override
    public ModifableExtensionPlanTree clone() {
      ModifableExtensionPlanTree tree = new ModifableExtensionPlanTree();

      for (ExtensionPlanNode node : this) {
        tree.add(((ModifableExtensionPlanNode) node).clone());
      }

      return tree;
    }
コード例 #2
0
  /**
   * Install provided extension.
   *
   * @param extensionId the identifier of the extension to install
   * @param dependency indicate if the extension is installed as a dependency
   * @param namespace the namespace where to install the extension
   * @param parentBranch the children of the parent {@link DefaultExtensionPlanNode}
   * @throws InstallException error when trying to install provided extension
   * @throws ResolveException unexpected exception has been raised
   */
  protected void installExtension(
      ExtensionId extensionId,
      boolean dependency,
      String namespace,
      ModifableExtensionPlanTree parentBranch)
      throws InstallException, ResolveException {
    if (getRequest().isVerbose()) {
      if (namespace != null) {
        this.logger.info(
            LOG_RESOLVE_NAMESPACE,
            "Resolving extension [{}] on namespace [{}]",
            extensionId,
            namespace);
      } else {
        this.logger.info(LOG_RESOLVE, "Resolving extension [{}] on all namespaces", extensionId);
      }
    }

    // Make sure the extension is not already a core extension
    if (this.coreExtensionRepository.exists(extensionId.getId())) {
      throw new InstallException(
          String.format("There is already a core extension with the id [%s]", extensionId.getId()));
    }

    InstalledExtension previousExtension =
        checkAlreadyInstalledExtension(extensionId.getId(), extensionId.getVersion(), namespace);

    ModifableExtensionPlanNode node =
        installExtension(previousExtension, extensionId, dependency, namespace);

    addExtensionNode(node);
    parentBranch.add(node);
  }