예제 #1
0
  @Override
  public void execute(AdminCommandContext context) {
    ProgressStatus ps = context.getProgressStatus();
    // Do some before logic
    ps.progress("Preparing");
    for (int i = 0; i < 10; i++) {
      doSomeLogic();
      ps.progress(1);
    }

    // Execute other command
    final CommandRunner.CommandInvocation commandInvocation =
        commandRunner.getCommandInvocation(
            "progress-simple",
            context.getActionReport().addSubActionsReport(),
            context.getSubject());
    commandInvocation
        // .subject(context.getSubject())
        .progressStatusChild(
            ps.createChild(
                "subcommand",
                20)) // Number 20 is little bit tricky. Please see javadoc of ProgressStatus
        .execute();

    // Do some after logic
    ps.progress("Finishing outer command");
    for (int i = 0; i < 10; i++) {
      doSomeLogic();
      ps.progress(1);
    }
    ps.complete("Finished outer command");
  }
예제 #2
0
  public void execute(AdminCommandContext context) {

    final ActionReport report = context.getActionReport();

    // invoke the deploy command with domain target to submit the
    // application to domain

    CommandRunner.CommandInvocation inv =
        commandRunner.getCommandInvocation("deploy", report, context.getSubject());

    final ParameterMap parameters = new ParameterMap();

    parameters.set("DEFAULT", path.getAbsolutePath());

    parameters.set(DeploymentProperties.TARGET, DeploymentUtils.DOMAIN_TARGET_NAME);
    inv.parameters(parameters).execute();

    // do any necessary initialization work here
  }
예제 #3
0
  /**
   * Disable the enabled version of the application if it exists. This method is used in versioning
   * context.
   *
   * @param appName application's name
   * @param target an option supply from admin command, it's retained for compatibility with other
   *     releases
   * @param report ActionReport, report object to send back to client.
   * @param subject the Subject on whose behalf to run
   */
  public void handleDisable(
      final String appName, final String target, final ActionReport report, final Subject subject)
      throws VersioningSyntaxException {

    Set<String> versionsToDisable = Collections.EMPTY_SET;

    if (DeploymentUtils.isDomainTarget(target)) {
      // retrieve the enabled versions on each target in the domain
      Map<String, Set<String>> enabledVersions = getEnabledVersionsInReferencedTargets(appName);

      if (!enabledVersions.isEmpty()) {
        versionsToDisable = enabledVersions.keySet();
      }
    } else {
      // retrieve the currently enabled version of the application
      String enabledVersion = getEnabledVersion(appName, target);

      if (enabledVersion != null && !enabledVersion.equals(appName)) {
        versionsToDisable = new HashSet<String>();
        versionsToDisable.add(enabledVersion);
      }
    }

    Iterator<String> it = versionsToDisable.iterator();
    while (it.hasNext()) {
      String currentVersion = it.next();
      // invoke disable if the currently enabled version is not itself
      if (currentVersion != null && !currentVersion.equals(appName)) {
        final ParameterMap parameters = new ParameterMap();
        parameters.add("DEFAULT", currentVersion);
        parameters.add("target", target);

        ActionReport subReport = report.addSubActionsReport();

        CommandRunner.CommandInvocation inv =
            commandRunner.getCommandInvocation("disable", subReport, subject);
        inv.parameters(parameters).execute();
      }
    }
  }