public void eatVersionInfo() { if (maybeEatHeaderName("Manifest-Version")) { eatColon(); eatVersionNumber(); eatNewline(); } else { // The problem will have been reported - jump out of here which will // treat this (whatever it is...) as a regular header } }
private void checkForRogueNewlinesProceedingInput() { // boolean rogueNewlines = false; while (maybeEatNewline()) { // rogueNewlines = true; } // if (rogueNewlines) { // recordProblem(ManifestProblemKind.UNEXPECTED_BLANK_LINES_AT_START_OF_MANIFEST, 0, tokenStream.peek().getStartOffset()); // } }
/** * Record a problem with parsing. * * @param parseProblem the kind of problem that occurred * @param startOffset the start offset of the problem * @param endOffset the end offset of the problem * @param inserts the inserts for the problem message text */ private void recordProblem(ManifestProblemKind parseProblem, int startOffset, int endOffset, String... inserts) { tokenStream .recordProblem(new ManifestProblem(parseProblem, tokenStream.getSourceContext(), startOffset, endOffset, inserts)); }
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 mergeManifests(ManifestContents base, ManifestContents add) { base.getMainAttributes().putAll(add.getMainAttributes()); for (String sectionName : add.getSectionNames()) { base.getAttributesForSection(sectionName).putAll(add.getAttributesForSection(sectionName)); } }
public static ManifestContents getManifest(Reader reader) { ManifestParser parser = new RecoveringManifestParser(); try { ManifestContents manifest = parser.parse(reader); if (parser.foundProblems()) { for (ManifestProblem problem : parser.getProblems()) { System.err.println(problem.toStringWithContext()); System.err.println(); } throw new RuntimeException("There was a problem with the manifest"); } return manifest; } catch (IOException e) { throw new RuntimeException(e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // Nothing to do } } } }
ManifestContents parseManifest() { checkForRogueNewlinesProceedingInput(); boolean cont = eatSection(true); // cont indicates whether the visitor // decided to stop processing early while (tokenStream.hasMore() && cont) { cont = eatSection(false); } if (cont) { confirmEnd(); } return visitor.getManifestContents(); }
private void removeTemplateOnlyHeaders(ManifestContents manifest, List<String> names) { for (String name : names) { manifest.getMainAttributes().remove(name); } }
public int getStartColumn(ManifestProblem manifestParserProblemInstance) { int lb = getRelevantStartLinebreakEntry(manifestParserProblemInstance.getStartOffset()); return manifestParserProblemInstance.getStartOffset() - linebreaks[lb]; }
public ManifestContents parse(String manifestString) { tokenStream = RecoveringManifestLexer.tokenize(manifestString); return parseManifest(); }
public int getEndColumn(ManifestProblem manifestParserProblemInstance) { int lb = getRelevantEndLinebreakEntry(manifestParserProblemInstance.getEndOffset()); return manifestParserProblemInstance.getEndOffset() - linebreaks[lb]; }
private void recordProblem(ManifestProblemKind problemKind, int start, int end, String... inserts) { tokenStream.recordProblem(new ManifestProblem(problemKind, context, start, end, inserts)); }
/** * Logs the ManifestProblem <code>problem</code>. */ private void logManifestProblem(ManifestProblem problem) { TOSCAMetaFileParser.LOGGER.warn(problem.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); } }
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()); } }
public int getLine(ManifestProblem manifestParserProblemInstance) { return getRelevantStartLinebreakEntry(manifestParserProblemInstance.getStartOffset()) + 1; }
public ManifestContents parse(Reader reader) throws IOException { tokenStream = RecoveringManifestLexer.tokenize(reader); return parseManifest(); }
/** * {@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); } }
/** * {@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)); } } }