Package org.eclipse.orion.server.cf.manifest.v2

Examples of org.eclipse.orion.server.cf.manifest.v2.Token


  @Override
  protected IStatus validateParams() {
    try {
      /* read deploy parameters */
      ManifestParseTree manifest = app.getManifest();
      ManifestParseTree manifestApp = manifest.get("applications").get(0); //$NON-NLS-1$

      if (app.getName() != null) {
        appName = app.getName();
        return Status.OK_STATUS;
      }

      appName = manifestApp.get(CFProtocolConstants.V2_KEY_NAME).getValue();
      return Status.OK_STATUS;
    } catch (InvalidAccessException e) {
      return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null);
    }
  }
View Full Code Here


  @Override
  protected IStatus validateParams() {
    try {
      /* read deploy parameters */
      ManifestParseTree manifest = application.getManifest();
      ManifestParseTree app = manifest.get(CFProtocolConstants.V2_KEY_APPLICATIONS).get(0);

      if (application.getName() != null)
        appName = application.getName();
      else
        appName = app.get(CFProtocolConstants.V2_KEY_NAME).getValue();

      ManifestParseTree commandNode = app.getOpt(CFProtocolConstants.V2_KEY_COMMAND);
      appCommand = (commandNode != null) ? commandNode.getValue() : ""; //$NON-NLS-1$

      ManifestParseTree instancesNode = app.getOpt(CFProtocolConstants.V2_KEY_INSTANCES);
      appInstances = (instancesNode != null) ? Integer.parseInt(instancesNode.getValue()) : 1;

      /* look for v2 memory property first */
      ManifestParseTree memoryNode = app.getOpt(CFProtocolConstants.V2_KEY_MEMORY);
      if (memoryNode != null)
        appMemory = ManifestUtils.normalizeMemoryMeasure(memoryNode.getValue());
      else {
        memoryNode = app.getOpt(CFProtocolConstants.V6_KEY_MEMORY);
        if (memoryNode != null)
          appMemory = ManifestUtils.normalizeMemoryMeasure(memoryNode.getValue());
        else
          /* default memory value */
          appMemory = 1024;
      }

      ManifestParseTree buildpackNode = app.getOpt(CFProtocolConstants.V2_KEY_BUILDPACK);
      buildPack = (buildpackNode != null) ? buildpackNode.getValue() : null;

      /* look for environment variables */
      ManifestParseTree envNode = manifest.getOpt(CFProtocolConstants.V2_KEY_ENV);
      if (envNode != null) {
        env = new JSONObject();
        for (ManifestParseTree var : envNode.getChildren())
          env.put(var.getLabel(), var.getValue());
      }

      return Status.OK_STATUS;

View Full Code Here

        return Status.OK_STATUS;
      else if (app == null && hostName == null)
        return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, "Missing host name parameter", null);

      /* read deploy parameters */
      ManifestParseTree manifest = app.getManifest();
      ManifestParseTree appNode = manifest.get("applications").get(0); //$NON-NLS-1$

      String appName = null;
      if (app.getName() != null)
        appName = app.getName();
      else
        appName = appNode.get(CFProtocolConstants.V2_KEY_NAME).getValue();

      /* if none provided, generate a default one */
      ManifestParseTree hostNode = appNode.getOpt(CFProtocolConstants.V2_KEY_HOST);
      hostName = (hostNode != null) ? hostNode.getValue() : ManifestUtils.slugify(appName);

      return Status.OK_STATUS;
    } catch (InvalidAccessException e) {
      return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null);
    }
View Full Code Here

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    File manifestFile = new File(FileLocator.toFileURL(entry).getPath().concat(manifestName));

    InputStream inputStream = new FileInputStream(manifestFile);
    ManifestParseTree manifest = parse(inputStream);

    ManifestParseTree application = manifest.get("applications").get(0); //$NON-NLS-1$
    ManifestParseTree path = application.get("path"); //$NON-NLS-1$

    assertEquals(".", path.getValue()); //$NON-NLS-1$

    ManifestParseTree host = application.get("host"); //$NON-NLS-1$
    assertEquals("quoted-path-application", host.getValue()); //$NON-NLS-1$

    ManifestParseTree domain = application.get("domain"); //$NON-NLS-1$

    assertEquals("cloud-foundry-domain.org", domain.getValue()); //$NON-NLS-1$
  }
View Full Code Here

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    File manifestFile = new File(FileLocator.toFileURL(entry).getPath().concat(manifestName));

    InputStream inputStream = new FileInputStream(manifestFile);
    ManifestParseTree manifest = parse(inputStream);
    SymbolResolver resolver = new SymbolResolver("api.sauron.mordor.com"); //$NON-NLS-1$
    resolver.apply(manifest);

    assertEquals("api.sauron.mordor.com", manifest.get("applications").get(0).get("domain").getValue()); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
    assertTrue(manifest.get("applications").get(0).get("url").getValue().endsWith(".api.sauron.mordor.com")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
  }
View Full Code Here

    String manifestName = "01.yml"; //$NON-NLS-1$
    File manifestFile = new File(FileLocator.toFileURL(entry).getPath().concat(manifestName));

    InputStream inputStream = new FileInputStream(manifestFile);
    ManifestParseTree manifest = parse(inputStream);

    ManifestTransformator transformator = new ManifestTransformator();
    transformator.apply(manifest);

    ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
    for (ManifestParseTree application : applications.getChildren())
      assertTrue(application.get("propertyA").getValue().equals("valueA") && application.get("propertyB").getValue().equals("valueB")); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$

    manifestName = "02.yml"; //$NON-NLS-1$
    manifestFile = new File(FileLocator.toFileURL(entry).getPath().concat(manifestName));

    inputStream = new FileInputStream(manifestFile);
    manifest = parse(inputStream);

    transformator = new ManifestTransformator();
    transformator.apply(manifest);

    applications = manifest.get("applications"); //$NON-NLS-1$
    assertEquals("nativeA", applications.get(0).get("A").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("nativeB", applications.get(0).get("B").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("overriddenC", applications.get(0).get("C").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("valueD", applications.get(0).get("D").get("overriddenD").getValue()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$

    assertEquals("overriddenA", applications.get(1).get("A").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("nativeB", applications.get(1).get("B").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("nativeC", applications.get(1).get("C").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("valueD", applications.get(1).get("D").get("overriddenD").getValue()); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$

    assertEquals("nativeA", applications.get(2).get("A").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("overriddenB", applications.get(2).get("B").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("nativeC", applications.get(2).get("C").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("valueD", applications.get(2).get("D").get("overriddenD").getValue()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$

    assertEquals("overriddenA", applications.get(3).get("A").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("overriddenB", applications.get(3).get("B").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("overriddenC", applications.get(3).get("C").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("valueD", applications.get(3).get("D").get("nativeD").getValue()); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
  }
View Full Code Here

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    File manifestFile = new File(FileLocator.toFileURL(entry).getPath().concat(manifestName));

    InputStream inputStream = new FileInputStream(manifestFile);
    ManifestParseTree manifest = parse(inputStream);

    ManifestParseTree application = manifest.get("applications").get(0); //$NON-NLS-1$
    ManifestParseTree services = application.get("services"); //$NON-NLS-1$

    assertEquals(2, services.getChildren().size());

    String service = services.get(0).getValue();
    assertEquals("Redis Cloud-fo service", service); //$NON-NLS-1$

    service = services.get(1).getValue();
    assertEquals("Redis-two", service); //$NON-NLS-1$
  }
View Full Code Here

    String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

    ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);
    ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
    assertEquals(4, applications.getChildren().size());

    for (ManifestParseTree application : applications.getChildren()) {
      assertTrue(application.has("domain")); //$NON-NLS-1$
      assertTrue(application.has("instances")); //$NON-NLS-1$
      assertTrue(application.has("path")); //$NON-NLS-1$
      assertTrue(application.has("memory")); //$NON-NLS-1$
    }
View Full Code Here

    String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

    ManifestParseTree manifest = ManifestUtils.parse(fs.getParent().getParent(), fs);
    ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
    assertEquals(2, applications.getChildren().size());

    for (ManifestParseTree application : applications.getChildren()) {
      assertTrue(application.has("domain")); //$NON-NLS-1$
      assertTrue(application.has("instances")); //$NON-NLS-1$
      assertTrue(application.has("path")); //$NON-NLS-1$
      assertTrue(application.has("memory")); //$NON-NLS-1$
    }
View Full Code Here

    String manifestName = "prod-manifest.yml"; //$NON-NLS-1$

    URL entry = ServerTestsActivator.getContext().getBundle().getEntry(MANIFEST_LOCATION);
    IFileStore fs = EFS.getStore(URIUtil.toURI(FileLocator.toFileURL(entry).getPath().concat(manifestName)));

    ManifestParseTree manifest = ManifestUtils.parse(fs.getParent(), fs);

    ManifestParseTree applications = manifest.get("applications"); //$NON-NLS-1$
    assertEquals(1, applications.getChildren().size());

    ManifestParseTree application = applications.get(0);

    assertEquals("512M", application.get("memory").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("2", application.get("instances").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals("example.com", application.get("domain").getValue()); //$NON-NLS-1$//$NON-NLS-2$
    assertEquals(".", application.get("path").getValue()); //$NON-NLS-1$//$NON-NLS-2$
  }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.cf.manifest.v2.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.