private void transformBundleSymbolicName(
     BundleManifest manifest, InstallationOptions options, boolean isWebApplicationBundle) {
   if (options.getBundleSymbolicName() != null) {
     if (isWebApplicationBundle) {
       throw new IllegalArgumentException(
           "Bundle-SymbolicName URL parameter cannot modify a Web Application Bundle");
     }
     manifest.getBundleSymbolicName().setSymbolicName(options.getBundleSymbolicName());
   }
 }
 private void transformBundleManifestVersion(
     BundleManifest manifest, InstallationOptions options, boolean isWebApplicationBundle) {
   if (options.getBundleManifestVersion() != null) {
     if (isWebApplicationBundle) {
       throw new IllegalArgumentException(
           "Bundle-ManifestVersion URL parameter cannot modify a Web Application Bundle");
     }
     manifest.setBundleManifestVersion(
         parseBundleManifestVersion(options.getBundleManifestVersion()));
   }
 }
 /** @param isWebApplicationBundle */
 private void transformWebContextPath(
     BundleManifest manifest, InstallationOptions options, boolean isWebApplicationBundle) {
   String webContextPathOption = options.getWebContextPath();
   if (webContextPathOption != null) {
     manifest.setHeader(
         WebContainerUtils.HEADER_WEB_CONTEXT_PATH, validateWebContextPath(webContextPathOption));
   } else if (!options.getDefaultWABHeaders()) {
     String webContextPathHeader = manifest.getHeader(WebContainerUtils.HEADER_WEB_CONTEXT_PATH);
     if (webContextPathHeader == null || webContextPathHeader.trim().length() == 0) {
       throw new IllegalArgumentException(
           WebContainerUtils.HEADER_WEB_CONTEXT_PATH + " is missing");
     }
   }
 }
예제 #4
0
  private InstallationOptions prepareInstallationOptions(
      boolean strictWABHeaders, String warName, BundleManifest manifest) {
    Map<String, String> map = new HashMap<String, String>();
    String webContextPathHeader = manifest.getHeader(HEADER_WEB_CONTEXT_PATH);
    if (webContextPathHeader == null || webContextPathHeader.trim().length() == 0) {
      if (warName.equals(ROOT_WAR_NAME)) {
        map.put(HEADER_WEB_CONTEXT_PATH, DEFAULT_CONTEXT_PATH);
      } else {
        map.put(HEADER_WEB_CONTEXT_PATH, replaceHashSigns(warName, SLASH_CHAR));
      }
    }

    InstallationOptions installationOptions = new InstallationOptions(map);
    installationOptions.setDefaultWABHeaders(!strictWABHeaders);

    return installationOptions;
  }
 private void transformBundleClassPath(
     BundleManifest manifest, InstallationOptions options, boolean isWebApplicationBundle) {
   List<String> bundleClassPath = manifest.getBundleClasspath();
   String bundleClassPathOption = options.getBundleClassPath();
   if (bundleClassPathOption != null) {
     if (isWebApplicationBundle) {
       throw new IllegalArgumentException(
           "Bundle-ClassPath URL parameter cannot modify a Web Application Bundle");
     }
     for (String entry : parseBundleClassPath(bundleClassPathOption)) {
       if (!bundleClassPath.contains(entry)) {
         bundleClassPath.add(entry);
       }
     }
   }
 }
 private void transformImportPackage(
     BundleManifest manifest, InstallationOptions options, boolean isWebApplicationBundle) {
   String ipd = options.getImportPackageDeclaration();
   if (ipd != null) {
     if (isWebApplicationBundle) {
       throw new IllegalArgumentException(
           "Import-Package URL parameter cannot modify a Web Application Bundle");
     }
     HeaderParser parser = HeaderParserFactory.newHeaderParser(new TransformerParserLogger());
     List<HeaderDeclaration> packageHeader =
         parser.parsePackageHeader(ipd, Constants.IMPORT_PACKAGE);
     for (HeaderDeclaration headerDeclaration : packageHeader) {
       for (String name : headerDeclaration.getNames()) {
         PackageMergeUtils.mergeImportPackage(
             manifest, name, headerDeclaration.getAttributes(), headerDeclaration.getDirectives());
       }
     }
   }
 }