public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) { Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>(); Configuration pluginConfiguration = getResourceContext().getPluginConfiguration(); String fullFileName = pluginConfiguration.getSimpleValue(PROPERTY_FILENAME, null); if (fullFileName == null) { throw new IllegalStateException("Plugin configuration does not contain the full file name of the WAR file."); } // If the parent WAR resource was found, this file should exist File file = new File(fullFileName); if (file.exists()) { // Package name and file name of the application are the same String fileName = new File(fullFileName).getName(); String sha256 = getSHA256(file); String version = getVersion(sha256); String displayVersion = getDisplayVersion(file); PackageDetailsKey key = new PackageDetailsKey(fileName, version, PKG_TYPE_FILE, ARCHITECTURE); ResourcePackageDetails details = new ResourcePackageDetails(key); details.setFileName(fileName); details.setLocation(file.getPath()); if (!file.isDirectory()) details.setFileSize(file.length()); details.setFileCreatedDate(null); // TODO: get created date via SIGAR details.setInstallationTimestamp(System.currentTimeMillis()); // TODO: anything better than discovery time details.setSHA256(sha256); details.setDisplayVersion(displayVersion); packages.add(details); } return packages; }
@Override public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) { if (deploymentFile == null) { return Collections.emptySet(); } String name = getDeploymentName(); String sha256 = getSHA256(deploymentFile); String version = getVersion(sha256); PackageDetailsKey key = new PackageDetailsKey(name, version, type.getName(), "noarch"); ResourcePackageDetails details = new ResourcePackageDetails(key); details.setDisplayVersion(getDisplayVersion(deploymentFile)); details.setFileCreatedDate(null); //TODO figure this out from Sigar somehow? details.setFileName(name); details.setFileSize(deploymentFile.length()); details.setInstallationTimestamp(deploymentFile.lastModified()); details.setLocation(deploymentFile.getAbsolutePath()); details.setSHA256(sha256); return Collections.singleton(details); }
details.setClassification(MIME_TYPE_JAR); details.setSHA256(sha256); details.setDisplayVersion(getDisplayVersion(file));