private void mergeManifests(ManifestContents base, ManifestContents add) { base.getMainAttributes().putAll(add.getMainAttributes()); for (String sectionName : add.getSectionNames()) { base.getAttributesForSection(sectionName).putAll(add.getAttributesForSection(sectionName)); } }
protected ProvenanceVerification verifyFileInManifest(ModelProvenanceElement element, String fileId, String checksum) throws SerializationException { // 1. parse element.state as ManifestContent ManifestContents manifestContents = new RecoveringManifestParser() .parse(element.getFingerprint()); if (manifestContents.getSectionNames().contains(fileId)) { String storedHash = manifestContents.getAttributesForSection(fileId).get(TOSCAMetaFileAttributes.HASH); if (Objects.isNull(storedHash)) { return NO_HASH_AVAILABLE; } else if (storedHash.equals(checksum)) { // 2.1 if section == fileId and hash == checksum -> file verified return VERIFIED; } else { return INVALID; } } return ID_NOT_FOUND; }
private void removeTemplateOnlyHeaders(ManifestContents manifest, List<String> names) { for (String name : names) { manifest.getMainAttributes().remove(name); } }
List<String> names = mf.getSectionNames(); Map<String, String> attr = mf.getAttributesForSection(name); contentType = attr.get(TOSCAMetaFileAttributes.CONTENT_TYPE);
public void contribute(ManifestContents manifest) { if (bundleClassPaths.size() > 0) { StringBuilder sb = new StringBuilder("."); for (String bundleClassPath : bundleClassPaths) { sb.append(String.format(",%s", bundleClassPath)); } manifest.getMainAttributes().put(Constants.BUNDLE_CLASSPATH, sb.toString()); } }
/** * Creates a new instance based on the data in the given manifest content * * @param manifestContent to create from */ public TOSCAMetaFile(ManifestContents manifestContent) { this.block0 = manifestContent.getMainAttributes(); for (String name : manifestContent.getSectionNames()) { Map<String, String> fileBlock = new HashMap<String, String>(); fileBlock.put(TOSCAMetaFileAttributes.NAME, name); fileBlock.putAll(manifestContent.getAttributesForSection(name)); this.fileBlocks.add(fileBlock); } }
.parse(modelProvenanceElement.getFingerprint()); for (String name : manifestContents.getSectionNames()) { if (name.equals(fileId)) { modelProvenanceElement.setAuthorizedFlag(authorizationInfo); currentFile.setAddressInImmutableStorage(manifestContents.getAttributesForSection(name) .get(TOSCAMetaFileAttributes.IMMUTABLE_ADDRESS)); currentFile.setFileHash(TOSCAMetaFileAttributes.HASH + "-" + manifestContents.getAttributesForSection(name) .get(TOSCAMetaFileAttributes.HASH)); currentFile.setFileName(fileId);
/** * {@inheritDoc} */ public void modify(ManifestContents manifest) { String version = this.getClass().getPackage().getImplementationVersion(); if (version == null) { version = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); } manifest.getMainAttributes().put(HEADER, String.format(VALUE_FORMAT, version)); } }
public void modify(ManifestContents manifest) { PlaceholderValueTransformer transformer = new VersionExpansionTransformer(manifest); PropertyPlaceholderResolver placeholderResolver = new PropertyPlaceholderResolver(); for (Entry<String, String> entry : manifest.getMainAttributes().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); manifest.getMainAttributes().put(key, placeholderResolver.resolve(value, this.properties, transformer)); } for(String name : manifest.getSectionNames()) { for(Entry<String, String> entry : manifest.getAttributesForSection(name).entrySet()) { String key = entry.getKey(); String value = entry.getValue(); manifest.getAttributesForSection(name).put(key, placeholderResolver.resolve(value, this.properties, transformer)); } } }
/** * {@inheritDoc} */ public void modify(ManifestContents manifest) { for (String ignoredExistingHeader : ignoredExistingHeaders) { Pattern pattern = Pattern.compile(ignoredExistingHeader.replace("*", ".*")); Map<String, String> attributes = manifest.getMainAttributes(); Iterator<String> i = attributes.keySet().iterator(); while(i.hasNext()) { String header = i.next(); if (pattern.matcher(header).matches()) { i.remove(); } } } }
public void modify(ManifestContents manifestTemplate) { synchronized (this.monitor) { String importPackageString = manifestTemplate.getMainAttributes().get(Constants.IMPORT_PACKAGE); this.importPackage.addAll(parseTemplate(importPackageString)); if (importPackageString != null) { String importTemplateString = manifestTemplate.getMainAttributes().get("Import-Template"); if (importTemplateString == null) { manifestTemplate.getMainAttributes().put("Import-Template", importPackageString); } else { manifestTemplate.getMainAttributes().put("Import-Template", String.format("%s,%s", importTemplateString, importPackageString)); } } String exportPackageString = manifestTemplate.getMainAttributes().get(Constants.EXPORT_PACKAGE); this.exportPackage.addAll(parseTemplate(exportPackageString)); if (exportPackageString != null) { String exportTemplateString = manifestTemplate.getMainAttributes().get("Export-Template"); if (exportTemplateString == null) { manifestTemplate.getMainAttributes().put("Export-Template", exportPackageString); } else { manifestTemplate.getMainAttributes().put("Export-Template", String.format("%s,%s", exportTemplateString, exportPackageString)); } } } }
private ManifestContents toManifestContents(BundleManifest bundleManifest) { Dictionary<String, String> headers = bundleManifest.toDictionary(); ManifestContents manifest = new SimpleManifestContents(headers.get("Manifest-Version")); Map<String, String> attributes = manifest.getMainAttributes(); Enumeration<String> headerNames = headers.keys(); while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); attributes.put(headerName, headers.get(headerName)); } return manifest; }
private final void readContextPaths(ManifestContents manifest) { String value = manifest.getMainAttributes().get(CONTEXT_PATH_HEADER); List<HeaderDeclaration> headers = parseTemplate(value); if (headers.size() == 0) { contextPaths.add(DEFAULT_CONTEXT_LOCATION); } else { for (HeaderDeclaration header : headers) { contextPaths.add(header.getNames().get(0)); } } }
/** * {@inheritDoc} */ public void readManifestTemplate(ManifestContents manifestTemplate) { synchronized (ignoredExistingHeadersMonitor) { String value = manifestTemplate.getMainAttributes().get(ATTR_IGNORED_EXISTING_HEADERS); List<HeaderDeclaration> headers = parseTemplate(value); for (HeaderDeclaration header : headers) { ignoredExistingHeaders.add(header.getNames().get(0)); } } }
/** * {@inheritDoc} */ public void modify(ManifestContents manifestTemplate) { if (systemPackages.size() != 0) { List<HeaderDeclaration> existingHeaders = parseTemplate(manifestTemplate.getMainAttributes().get(IMPORT_TEMPLATE)); String newValue = createValueString(existingHeaders, systemPackages); manifestTemplate.getMainAttributes().put(IMPORT_TEMPLATE, newValue); } if (bootDelegation.size() != 0) { List<HeaderDeclaration> existingHeaders = parseTemplate(manifestTemplate.getMainAttributes().get(EXCLUDED_IMPORTS)); String newValue = createValueString(existingHeaders, bootDelegation); manifestTemplate.getMainAttributes().put(EXCLUDED_IMPORTS, newValue); } }
public void readManifestTemplate(ManifestContents manifestTemplate) { synchronized (excludedImportsMonitor) { String value = manifestTemplate.getMainAttributes().get(ATTR_EXCLUDED_IMPORTS); List<HeaderDeclaration> headers = parseTemplate(value); for (HeaderDeclaration header : headers) { excludedImports.add(header.getNames().get(0)); } } synchronized (excludedExportsMonitor) { String value = manifestTemplate.getMainAttributes().get(ATTR_EXCLUDED_EXPORTS); List<HeaderDeclaration> headers = parseTemplate(value); for (HeaderDeclaration header : headers) { excludedExports.add(header.getNames().get(0)); } } }
public VersionExpansionTransformer(ManifestContents manifestTemplate) { String value = manifestTemplate.getMainAttributes().get(VERSION_PATTERNS); List<HeaderDeclaration> headers = parseTemplate(value); for (HeaderDeclaration header : headers) { String name = header.getNames().get(0); String pattern = header.getAttributes().get(ATT_PATTERN); expanders.put(name, VersionExpansionParser.parseVersionExpander(pattern)); } }
String topology = null; Map<String, String> mainAttr = mf.getMainAttributes();
/** * Resolves the imports. */ private void processImports(BundleManifest result, ManifestContents template, ReadablePartialManifest partial) { String importTemplate = template.getMainAttributes().get(ATTR_IMPORT_TEMPLATE); List<HeaderDeclaration> importTemplateDeclarations = parseTemplate(importTemplate); List<ImportedPackage> packageImports = new ArrayList<ImportedPackage>(); for (String importedPackage : partial.getImportedPackages()) { HeaderDeclaration match = findMostSpecificDeclaration(importTemplateDeclarations, importedPackage); ImportedPackage packageImport = result.getImportPackage().addImportedPackage(importedPackage); if (match != null) { packageImport.getAttributes().putAll(match.getAttributes()); packageImport.setResolution(parseResolution(match)); } packageImports.add(packageImport); } }
/** * Resolves the exports. */ private void processExports(BundleManifest result, ManifestContents templateManifest, ReadablePartialManifest partial) { String bundleVersion = templateManifest.getMainAttributes().get(ATTR_BUNDLE_VERSION); String exportTemplate = templateManifest.getMainAttributes().get(ATTR_EXPORT_TEMPLATE); List<HeaderDeclaration> exportTemplateDeclarations = parseTemplate(exportTemplate); List<ExportedPackage> packageExports = new ArrayList<ExportedPackage>(); for (String exportedPackage : partial.getExportedPackages()) { HeaderDeclaration declaration = findMostSpecificDeclaration(exportTemplateDeclarations, exportedPackage); ExportedPackage export = result.getExportPackage().addExportedPackage(exportedPackage); if (declaration != null) { export.getAttributes().putAll(declaration.getAttributes()); Map<String, String> directives = declaration.getDirectives(); addCommaSeparated(export.getExclude(), directives.get("excluded")); addCommaSeparated(export.getInclude(), directives.get("include")); addCommaSeparated(export.getMandatory(), directives.get("mandatory")); addCommaSeparated(export.getUses(), directives.get("uses")); } Set<String> uses = partial.getUses(exportedPackage); export.getUses().addAll(uses); String version = resolveVersion(declaration, bundleVersion); if (StringUtils.hasText(version)) { export.getAttributes().put("version", version); } packageExports.add(export); } }