Ejemplo n.º 1
0
 private String getLocationForBundlesInfo(String extractionFolderName) {
   final File warDir = new File(this.webAppsDir, extractionFolderName);
   if (!warDir.exists()) {
     logger.warn(
         "Directory with name ["
             + extractionFolderName
             + "] cannot be found in web applications directory."
             + " See logs for previous failures during install.");
     return null;
   }
   return BundleLocationUtil.getRelativisedURI(kernelHomeFile, warDir).toString();
 }
Ejemplo n.º 2
0
  @Override
  public final boolean undeploy(Bundle bundle) {
    String bundleLocation = removeTrailingFileSeparator(bundle.getLocation());
    String warPath = extractWarPath(bundleLocation);
    String extractedWarNameFromBundleLocation = extractWarNameFromBundleLocation(warPath);
    final File warDir = new File(warPath);
    String warName =
        StatusFileModificator.deleteStatusFileByNamePattern(
            extractedWarNameFromBundleLocation.replaceAll("[.]", "[^a-zA-Z0-9_-]"), this.pickupDir);
    if (("").equals(warName)) {
      warName = extractedWarNameFromBundleLocation;
    }

    try {
      if (this.logger.isInfoEnabled()) {
        this.logger.info(
            "Removing bundle '"
                + bundle.getSymbolicName()
                + "' version '"
                + bundle.getVersion()
                + "' from bundles.info.");
      }
      if (this.bundleInfosUpdaterUtil != null && this.bundleInfosUpdaterUtil.isAvailable()) {
        String locationForBundlesInfo =
            BundleLocationUtil.getRelativisedURI(kernelHomeFile, warDir).toString();
        BundleInfosUpdater.unregisterToBundlesInfo(bundle, locationForBundlesInfo, NOT_A_FRAGMENT);
        this.logger.info(
            "Successfully removed bundle '"
                + bundle.getSymbolicName()
                + "' version '"
                + bundle.getVersion()
                + "' from bundles.info.");
      } else {
        this.logger.error(
            "BundleInfosUpdater not available. Failed to remove bundle '"
                + bundle.getSymbolicName()
                + "' version '"
                + bundle.getVersion()
                + "' from bundles.info.");
      }
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_STOPPING, bundle.getSymbolicName(), bundle.getVersion());
      bundle.stop();
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_STOPPED, bundle.getSymbolicName(), bundle.getVersion());
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_UNINSTALLING, bundle.getSymbolicName(), bundle.getVersion());
      bundle.uninstall();
      // we need to decode the path before delete or a /webapps entry might leak
      FileSystemUtils.deleteRecursively(new File(warDir.getAbsolutePath()));
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_UNINSTALLED, bundle.getSymbolicName(), bundle.getVersion());
      wabStates.remove((String) bundle.getSymbolicName());
    } catch (BundleException e) {
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_UNDEPLOY_ERROR,
          e,
          bundle.getSymbolicName(),
          bundle.getVersion());
      StatusFileModificator.createStatusFile(
          warName, this.pickupDir, StatusFileModificator.OP_UNDEPLOY, STATUS_ERROR, -1, -1);
      return STATUS_ERROR;
    } catch (IOException e) {
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_PERSIST_ERROR,
          e,
          bundle.getSymbolicName(),
          bundle.getVersion());
    } catch (URISyntaxException e) {
      this.eventLogger.log(
          WARDeployerLogEvents.NANO_PERSIST_ERROR,
          e,
          bundle.getSymbolicName(),
          bundle.getVersion());
    }

    StatusFileModificator.createStatusFile(
        warName, this.pickupDir, StatusFileModificator.OP_UNDEPLOY, STATUS_OK, -1, -1);
    return STATUS_OK;
  }