Пример #1
0
  @Override
  public ResponseContent handleRequest(
      String contentPath, BundleSet bundleSet, UrlContentAccessor contentAccessor, String version)
      throws MalformedRequestException, ContentProcessingException {
    ParsedContentPath parsedContentPath = contentPathParser.parse(contentPath);

    if (parsedContentPath.formName.equals(APP_META_REQUEST)) {
      try {
        App app = bundleSet.bundlableNode().app();
        // NOTE: this metadata is used by the BRAppMetaService
        // This can't be modeled as a SourceModule since it needs access to the version which is
        // only available to ContentPlugins
        return new CharResponseContent(
            brjs,
            "define('app-meta!$data', function(require, exports, module) {\n"
                + "// these variables should not be used directly but accessed via the 'br.app-meta-service' instead\n"
                + "module.exports.APP_VERSION = '"
                + version
                + "';\n"
                + "module.exports.VERSIONED_BUNDLE_PATH = '"
                + AppMetadataUtility.getRelativeVersionedBundlePath(app, version, "")
                + "';\n"
                + "module.exports.LOCALE_COOKIE_NAME = '"
                + app.appConf().getLocaleCookieName()
                + "';\n"
                + "module.exports.APP_LOCALES = {'"
                + Joiner.on("':true, '").join(app.appConf().getLocales())
                + "':true};\n"
                + "});\n");
      } catch (ConfigException ex) {
        throw new ContentProcessingException(ex);
      }
    } else {
      throw new ContentProcessingException(
          "unknown request form '" + parsedContentPath.formName + "'.");
    }
  }