Beispiel #1
0
 private void persistApplicationVersion(ResourcePackageDetails packageDetails, File appFile) {
   String packageName = appFile.getName();
   log.debug(
       "Persisting application version '"
           + packageDetails.getVersion()
           + "' for package '"
           + packageName //$NON-NLS-1$ //$NON-NLS-2$
           + "'"); //$NON-NLS-1$
   PackageVersions versions = loadPackageVersions();
   versions.putVersion(packageName, packageDetails.getVersion());
 }
Beispiel #2
0
  @Override
  public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {

    // PLEASE DO NOT REMOVE THIS METHOD. IT IS REQUIRED FOR THE CONTENT TAB.

    Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
    this.deploymentUrl = pluginConfig.getSimple("url").getStringValue(); // $NON-NLS-1$

    if (this.deploymentUrl != null) {
      this.deploymentFile =
          new File(this.deploymentUrl.substring(deploymentUrl.indexOf(":/") + 1)); // $NON-NLS-1$
    }

    if (!deploymentFile.exists())
      throw new IllegalStateException(
          "Deployment file '" //$NON-NLS-1$
              + this.deploymentFile
              + "' for "
              + this.getComponentType() // $NON-NLS-1$
              + " does not exist."); //$NON-NLS-1$

    String fileName = deploymentFile.getName();
    org.rhq.core.pluginapi.content.version.PackageVersions packageVersions = loadPackageVersions();
    String version = packageVersions.getVersion(fileName);
    if (version == null) {
      // This is either the first time we've discovered this VDB, or
      // someone purged the PC's data dir.
      version = "1.0"; // $NON-NLS-1$
      packageVersions.putVersion(fileName, version);
      packageVersions.saveToDisk();
    }

    // Package name is the deployment's file name (e.g. foo.ear).
    PackageDetailsKey key = new PackageDetailsKey(fileName, version, PKG_TYPE_VDB, ARCHITECTURE);
    ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
    packageDetails.setFileName(fileName);
    packageDetails.setLocation(deploymentFile.getPath());
    if (!deploymentFile.isDirectory()) packageDetails.setFileSize(deploymentFile.length());
    packageDetails.setFileCreatedDate(null);
    Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
    packages.add(packageDetails);

    return packages;
  }