private void initContent() { ContentManagerRemote contentManager = remoteClient.getContentManager(); List<PackageType> types = null; try { types = contentManager.findPackageTypes( remoteClient.getSubject(), resource.getResourceType().getName(), resource.getResourceType().getPlugin()); for (PackageType packageType : types) { contentTypes.put(packageType.getName(), new ContentType(packageType)); } } catch (ResourceTypeNotFoundException e) { LOG.error( "Could not find resource type while creating content mappings of the resource proxy for resource with id " + resourceId, e); } }
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) { Set<ResourcePackageDetails> results = new HashSet<ResourcePackageDetails>(); if (PACKAGE_TYPE.equals(type.getName())) { String jbossHomeDir = resourceContext .getParentResourceComponent() .getResourceContext() .getPluginConfiguration() .getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null); File binDirectory = new File(jbossHomeDir, "bin"); File scriptFile = new File(binDirectory, resourceContext.getResourceKey()); String sha256 = PACKAGE_VERSION; try { sha256 = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(scriptFile); } catch (IOException e) { log.warn( "Failed to compute the SHA256 digest of the script: " + scriptFile.getAbsolutePath(), e); } PackageDetailsKey key = new PackageDetailsKey( scriptFile.getName(), this.getVersion(sha256), PACKAGE_TYPE, PACKAGE_ARCHITECTURE); ResourcePackageDetails details = new ResourcePackageDetails(key); details.setDisplayName(scriptFile.getName()); details.setFileName(scriptFile.getAbsolutePath()); details.setFileSize(scriptFile.length()); details.setLocation(scriptFile.getAbsolutePath()); details.setFileCreatedDate(scriptFile.lastModified()); details.setInstallationTimestamp(System.currentTimeMillis()); details.setSHA256(sha256); results.add(details); } return results; }