@Override
  public void updateProperties(RequestContext ctx, ResourceState state, Responder responder)
      throws Exception {
    String name = (String) state.getProperty("name");
    if (name != null && !name.isEmpty()) {
      this.app.setName(name);
    }

    Boolean visible = (Boolean) state.getProperty("visible");
    if (visible != null) {
      this.app.setVisible(visible);
    }

    String htmlPath = (String) state.getProperty("html-app");
    if (htmlPath != null) {
      if (!htmlPath.startsWith("/" + this.app.id())) {
        htmlPath = "/" + this.app.id() + htmlPath;
      }
      this.app.setHtmlApplicationPath(htmlPath);
    }

    String versionResourceId = (String) state.getProperty("version-resource-id");
    if (versionResourceId != null) {
      boolean resourceFound = false;
      for (Resource resource : this.extensions.members(ctx)) {
        if (resource.id().equals(versionResourceId)) {
          resourceFound = true;
          break;
        }
      }
      if (!resourceFound) {
        throw new PropertyException("No versioning resource found with id: " + versionResourceId);
      }
      this.app.setVersionResourceId(versionResourceId);
    }

    this.configManager.updateApplication(this.app);

    Boolean partOfGitInstallProcess = (Boolean) state.getProperty("git-install-process");
    if (this.app.versioned() && (partOfGitInstallProcess == null || !partOfGitInstallProcess)) {
      // Wrap current responder with one that will perform commit of version changes
      responder =
          new ConfigVersioningResponder(
              responder,
              app.versioned(),
              app.versionedResourcePath(),
              this.client,
              ctx.securityContext());
    }

    responder.resourceUpdated(this);
  }
Exemple #2
0
 @Override
 public void execute(TraversalPlan.StepContext context, Resource resource) throws Exception {
   if (complete) {
     if (resource instanceof BinaryResource) {
       ((BinaryResource) resource)
           .updateContent(context.requestContext(), context.state(), context.responder());
     } else {
       resource.updateProperties(context.requestContext(), context.state(), context.responder());
     }
   } else {
     if (resource instanceof BinaryResource) {
       BinaryResource binResource = (BinaryResource) resource;
       if (binResource.willProcessUpdate(
           context.requestContext(), context.state(), context.responder())) {
         arrangeCompletion(context);
       }
     } else {
       if (!arrangeCompletion(context)) {
         resource.updateProperties(context.requestContext(), context.state(), context.responder());
       }
     }
   }
 }