예제 #1
0
 @Override
 public List<String> getValidContentPaths(
     BundleSet bundleSet, RequestMode requestMode, Locale... locales)
     throws ContentProcessingException {
   try {
     return Arrays.asList(contentPathParser.createRequest(APP_META_REQUEST));
   } catch (MalformedTokenException e) {
     throw new ContentProcessingException(e);
   }
 }
예제 #2
0
  @Override
  public List<String> getValidDevContentPaths(BundleSet bundleSet, String... locales)
      throws ContentProcessingException {
    List<String> result = new ArrayList<String>();
    XmlBundlerConfig config = new XmlBundlerConfig(brjs);
    if (!config.isbundleConigAvailable()) {
      return result;
    }

    try {
      result.add(contentPathParser.createRequest("bundle-request"));
    } catch (MalformedTokenException e) {
      throw new ContentProcessingException(e);
    }
    return result;
  }
예제 #3
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 + "'.");
    }
  }