Ejemplo n.º 1
0
  @Override
  public void updateProperties(RequestContext ctx, ResourceState state, Responder responder)
      throws Exception {
    // TODO: put this code in a common location since its also used when creating
    Object nameProperty = state.getProperty(NAME);
    if (nameProperty != null) {
      name = nameProperty.toString();
    } else {
      name = null;
    }

    Object descriptionProperty = state.getProperty(DESCRIPTION);
    if (descriptionProperty != null) {
      description = descriptionProperty.toString();
    } else {
      description = null;
    }

    Object enabledProperty = state.getProperty(ENABELD);
    if (enabledProperty != null && enabledProperty instanceof Boolean) {
      enabled = (Boolean) enabledProperty;
    } else {
      enabled = false;
    }

    libraries.clear();
    Object libraries = state.getProperty(LIBRARIES);
    if (libraries != null && libraries instanceof List) {
      for (Object entry : (List) libraries) {
        if (entry instanceof String) {
          this.libraries.add((String) entry);
        }
      }
    } else if (libraries != null) {
      throw new InvalidPropertyTypeException(LIBRARIES, List.class);
    }

    Object targetProperty = state.getProperty(TARGET_PATH);
    if (targetProperty != null && targetProperty instanceof String) {
      target = (String) targetProperty;
    } else {
      throw new InvalidPropertyTypeException(TARGET_PATH, String.class);
    }

    Object priorityProperty = state.getProperty(PRIORITY);
    if (priorityProperty != null && priorityProperty instanceof Integer) {
      priority = (Integer) priorityProperty;
    } else if (priorityProperty != null) {
      throw new InvalidPropertyTypeException(PRIORITY, Integer.class);
    }

    parent.getResourceInterceptorManager().addResource(this);
    parent.writeMetadataFile(this.id(), ConversionUtils.convert(state));
    responder.resourceUpdated(this);
  }
Ejemplo n.º 2
0
  @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);
  }