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

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


        line = processLine(line);
        if (line.isEmpty() || line.trim().isEmpty())
          continue;

        InputLine inputLine = new InputLine(line, currentLine);
        contents.add(inputLine);
      }

      return contents;
View Full Code Here


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

      /* optional */
      ManifestParseTree domainNode = app.getOpt(CFProtocolConstants.V2_KEY_DOMAIN);
      appDomain = (domainNode != null) ? domainNode.getValue() : ""; //$NON-NLS-1$

      ManifestParseTree noRouteNode = app.getOpt(CFProtocolConstants.V2_KEY_NO_ROUTE);
      noRoute = (noRouteNode != null) ? Boolean.parseBoolean(noRouteNode.getValue()) : false;

      return Status.OK_STATUS;

    } catch (InvalidAccessException e) {
      return new MultiServerStatus(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("applications").get(0); //$NON-NLS-1$

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

      /* extract host information if present */
      ManifestParseTree hostNode = app.getOpt(CFProtocolConstants.V2_KEY_HOST);
      appHost = (hostNode != null) ? hostNode.getValue() : ManifestUtils.slugify(appName);

      if (appHost != null)
        return Status.OK_STATUS;

      return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, "Route not found", null);
View Full Code Here

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

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

      appName = app.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

            IStatus status = parseManifestCommand.doIt();
            if (!status.isOK())
              return status;

            /* get the manifest name */
            ManifestParseTree manifest = parseManifestCommand.getManifest();
            if (manifest != null) {
              ManifestParseTree applications = manifest.get(CFProtocolConstants.V2_KEY_APPLICATIONS);
              if (applications.getChildren().size() > 0) {
                manifestAppName = applications.get(0).get(CFProtocolConstants.V2_KEY_NAME).getValue();
                return new GetAppCommand(target, manifestAppName).doIt();
              }
            }

            return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, "Can not determine the application name", null);
View Full Code Here

          Target target = computeTarget.getTarget();

          /* parse the application manifest */
          String manifestAppName = null;
          ManifestParseTree manifest = null;
          IFileStore appStore = null;

          if (contentLocation != null && state == null) {

            /* check for non-manifest deployment */
            if (manifestJSON != null) {

              ParseManifestJSONCommand parseManifestJSONCommand = new ParseManifestJSONCommand(manifestJSON, userId, contentLocation);
              status = parseManifestJSONCommand.doIt();
              if (!status.isOK())
                return status;

              /* get the manifest name */
              manifest = parseManifestJSONCommand.getManifest();
              appStore = parseManifestJSONCommand.getAppStore();

              if (manifest != null) {
                ManifestParseTree applications = manifest.get(CFProtocolConstants.V2_KEY_APPLICATIONS);
                if (applications.getChildren().size() > 0)
                  manifestAppName = applications.get(0).get(CFProtocolConstants.V2_KEY_NAME).getValue();

                if (persistManifest) {
                  /* non-manifest deployment - persist at contentLocation/manifest.yml */
                  IFileStore persistBaseLocation = parseManifestJSONCommand.getPersistBaseLocation();
                  IFileStore persistLocation = persistBaseLocation.getChild(ManifestConstants.MANIFEST_FILE_NAME);
                  manifest.persist(persistLocation);
                }
              }

            } else {

              ParseManifestCommand parseManifestCommand = new ParseManifestCommand(target, userId, contentLocation);
              status = parseManifestCommand.doIt();
              if (!status.isOK())
                return status;

              /* get the manifest name */
              manifest = parseManifestCommand.getManifest();
              appStore = parseManifestCommand.getAppStore();

              if (manifest != null) {
                ManifestParseTree applications = manifest.get(CFProtocolConstants.V2_KEY_APPLICATIONS);
                if (applications.getChildren().size() > 0)
                  manifestAppName = applications.get(0).get(CFProtocolConstants.V2_KEY_NAME).getValue();
              }

            }
          }

View Full Code Here

    try {

      if (manifest == null)
        manifest = ManifestUtils.createBoilerplate(getApplicationName(contentLocation));

      ManifestParseTree application = manifest.get(ManifestConstants.APPLICATIONS).get(0);
      String defaultName = getApplicationName(contentLocation);

      set(application, ManifestConstants.NAME, defaultName);
      set(application, ManifestConstants.HOST, ManifestUtils.slugify(defaultName));

      set(application, ManifestConstants.MEMORY, ManifestUtils.DEFAULT_MEMORY);
      set(application, ManifestConstants.INSTANCES, ManifestUtils.DEFAULT_INSTANCES);
      set(application, ManifestConstants.PATH, ManifestUtils.DEFAULT_PATH);

      /* node.js application require a start command */
      if (application.has(ManifestConstants.COMMAND))
        return new Plan(getId(), getWizardId(), TYPE, manifest);

      InputStream is = null;
      try {

        is = packageStore.openInputStream(EFS.NONE, null);
        JSONObject packageJSON = new JSONObject(new JSONTokener(new InputStreamReader(is)));
        if (packageJSON.has(NodeJSConstants.SCRIPTS)) {
          JSONObject scripts = packageJSON.getJSONObject(NodeJSConstants.SCRIPTS);
          if (scripts.has(NodeJSConstants.START)) {
            application.put(ManifestConstants.COMMAND, scripts.getString(NodeJSConstants.START));
            return new Plan(getId(), getWizardId(), TYPE, manifest);
          }
        }

      } catch (JSONException ex) {
        /* can't parse the package.json, fail */
        return null;

      } finally {
        IOUtilities.safeClose(is);
      }

      /* look for server.js or app.js files */
      IFileStore serverJS = contentLocation.getChild(NodeJSConstants.SERVER_JS);
      if (serverJS.fetchInfo().exists()) {
        application.put(ManifestConstants.COMMAND, NodeJSConstants.NODE_SERVER_JS);
        return new Plan(getId(), getWizardId(), TYPE, manifest);
      }

      IFileStore appJS = contentLocation.getChild(NodeJSConstants.APP_JS);
      if (appJS.fetchInfo().exists()) {
        application.put(ManifestConstants.COMMAND, NodeJSConstants.NODE_APP_JS);
        return new Plan(getId(), getWizardId(), TYPE, manifest);
      }

      /* could not deduce command, mark as required */
      Plan plan = new Plan(getId(), getWizardId(), TYPE, manifest);
View Full Code Here

  @Override
  public List<Plan> getDeploymentPlans(IFileStore contentLocation, ManifestParseTree manifest) {
    List<Plan> plans = new ArrayList<Plan>();
    for (IDeploymentPlanner planner : planners) {
      Plan plan = planner.getDeploymentPlan(contentLocation, manifest != null ? new ManifestParseTree(manifest) : null);
      if (plan != null)
        plans.add(plan);
    }

    return plans;
View Full Code Here

      if (manifest == null)
        manifest = ManifestUtils.createBoilerplate(applicationName);

      /* set up generic defaults */
      ManifestParseTree application = manifest.get(ManifestConstants.APPLICATIONS).get(0);
      set(application, ManifestConstants.HOST, ManifestUtils.slugify(applicationName));
      set(application, ManifestConstants.MEMORY, ManifestUtils.DEFAULT_MEMORY);
      set(application, ManifestConstants.INSTANCES, ManifestUtils.DEFAULT_INSTANCES);
      set(application, ManifestConstants.PATH, ManifestUtils.DEFAULT_PATH);
      return new Plan(getId(), getWizardId(), TYPE, manifest);
View Full Code Here

          ParseManifestCommand parseManifestCommand = new ParseManifestCommand(null, userId, path);
          IStatus status = parseManifestCommand.doIt();
          if (!status.isOK())
            return status;

          ManifestParseTree manifest = parseManifestCommand.getManifest();
          Manifest resp = new Manifest(manifest);

          return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, resp.toJSON());

        } catch (Exception e) {
View Full Code Here

TOP

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

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.