@Override public void processMeta(XmlMetadata fileMeta) { Document document = fileMeta.getParsedDocument(); if (document == null) { if (LOG.isDebugEnabled()) { LOG.debug("Document was null. Problem parsing: " + fileMeta.getFilePointer().getAbsolutePath()); } // attach the bad file so we see it in the reports... fileMeta.getArchiveMeta().getEntries().add(fileMeta); return; } super.processMeta(fileMeta); }
@Override public void processMeta(final XmlMetadata meta) { if (meta.getParsedDocument() == null) { LOG.warn("Skipping XPathClassifyingDecorator: " + meta.getFilePointer().getAbsolutePath() + " because the document is unparsed."); return; Document doc = meta.getParsedDocument(); if (doc == null) { throw new NullPointerException(); LOG.debug("Found results for: " + meta.getFilePointer().getAbsolutePath()); meta.getContext().put(contextTarget, match);
@Override public void processMeta(XmlMetadata file) { String relativeDirectory = StringUtils.substringBeforeLast(file.getFilePointer().getAbsolutePath(), File.separator); String fileName = StringUtils.substringAfterLast(file.getFilePointer().getAbsolutePath(), File.separator); fileName = StringUtils.replace(fileName, ".", "-"); fileName = fileName + outputExtension; File relativeFile = new File(relativeDirectory + File.separator + fileName); Source xmlSource = new DOMSource(file.getParsedDocument()); Result xmlResult = new StreamResult(relativeFile); try { xsltTransformer.transform(xmlSource, xmlResult); Link linkResult = new Link(); linkResult.setDescription(outputDescription); linkResult.setLink(fileName); linkResult.setEffort(effort); if (LOG.isDebugEnabled()) { LOG.debug("Created link: " + ReflectionToStringBuilder.toString(linkResult)); } file.getDecorations().add(linkResult); } catch (TransformerException e) { LOG.error("Exception transforming XML.", e); } }
@Override protected boolean continueProcessing(XmlMetadata meta) { if (meta.getParsedDocument() == null) { LOG.warn("Skipping XPathClassifyingDecorator; no parsed doc: " + meta.getFilePointer().getAbsolutePath()); return false; } try { final Boolean nodes = (Boolean) expression.evaluate(meta.getParsedDocument(), XPathConstants.BOOLEAN); if (nodes != null) { if (LOG.isDebugEnabled()) { LOG.debug("Returning: " + nodes.booleanValue() + " for XPath: " + xpathExpression + " on file: " + meta.getFilePointer().getAbsolutePath()); } return nodes.booleanValue(); } } catch (Exception e) { LOG.error("Exception running xpath.", e); } return false; } }
@Override public XmlMetadata archiveEntryToMeta(ZipEntryMetadata archiveEntry) { File file = archiveEntry.getFilePointer(); LOG.debug("Processing XML: " + file.getAbsolutePath()); FileMetadata meta = null; if (file.length() > 1048576L * 1) { LOG.warn("XML larger than 1 MB: " + file.getAbsolutePath() + "; Skipping processing."); meta = new FileMetadata(); meta.setArchiveMeta(archiveEntry.getArchiveMeta()); meta.setFilePointer(file); Summary sr = new Summary(); sr.setDescription("File is too large; skipped."); sr.setLevel(NotificationLevel.WARNING); meta.getDecorations().add(sr); } else { XmlMetadata xmlMeta = new XmlMetadata(); xmlMeta.setArchiveMeta(archiveEntry.getArchiveMeta()); xmlMeta.setFilePointer(file); meta = xmlMeta; return xmlMeta; } return null; }
@Override public void processMeta(XmlMetadata file) { Document doc = file.getParsedDocument(); try { String description = extractStringValue(xPath, doc); if (StringUtils.isNotBlank(description)) { Summary result = new Summary(); result.setDescription(description); // add the link to the archive. file.getArchiveMeta().getDecorations().add(result); } } catch (XPathExpressionException e) { LOG.error("Exception running xpath expression.", e); } }
@Override public void processMeta(XmlMetadata file) { Doctype docType = (Doctype) file.getParsedDocument().getUserData(LocationAwareContentHandler.DOCTYPE_KEY_NAME); if (docType != null && matchesAny(docType)) { Classification cr = new Classification(); cr.setDescription(matchDescription); cr.setEffort(effort); file.getDecorations().add(cr); // if it is of a certain type, recurse to the child processors chainDecorators(file); } }
@Override public void processMeta(XmlMetadata file) { if (controlDoc == null){ // some action and } else { // real work here if (this.xpathExp == null){ // make this an assertion test } else { Document testDoc = getDocFragment(xpathExp, file); if (testDoc != null) { if (isdifferent(testDoc, controlDoc)) { // process for print formating (identify specific) LOG.debug("XML differences found"); } else { // remove this from list of things to report. LOG.debug("Remove from list. XML has default settings"); LinkedList < AbstractDecoration > dList = new LinkedList<AbstractDecoration>(file.getDecorations()); try { file.getDecorations().remove(dList.removeLast()); } catch (NoSuchElementException ne){ LOG.debug("Nothing removed. Decoration list is empty."); } } } } } return; }
protected boolean isActive(XmlMetadata file) { for (AbstractDecoration dr : file.getArchiveMeta().getDecorations()) { if (dr instanceof PomVersion) { LOG.debug("Already has version result: " + dr.toString()); return false; } } return true; }
Node node = (Node) xpath.evaluate(xpathExp, file.getParsedDocument(), XPathConstants.NODE);
XmlMetadata xmlMeta = new XmlMetadata(); xmlMeta.setArchiveMeta(entry.getArchiveMeta()); xmlMeta.setFilePointer(file); meta = xmlMeta;
@Override public void processMeta(final XmlMetadata meta) { if (meta.getParsedDocument() == null) { LOG.warn("Skipping XPathClassifyingDecorator: " + meta.getFilePointer().getAbsolutePath() + " because the document is unparsed."); return; Document doc = meta.getParsedDocument(); if (doc == null) { throw new NullPointerException(); LOG.debug("Found results for: " + meta.getFilePointer().getAbsolutePath());
@Override public void processMeta(XmlMetadata file) { Document doc = file.getParsedDocument(); try { String link = extractStringValue(linkXPath, doc); if (StringUtils.isNotBlank(link)) { Link result = new Link(); result.setLink(link); result.setDescription("Project Site"); // add the link to the archive. file.getArchiveMeta().getDecorations().add(result); } } catch (XPathExpressionException e) { LOG.error("Exception running xpath expression.", e); } }
@Override protected void chainDecorators(XmlMetadata meta) { LOG.debug("chainDecorators: " + meta); // this is only called when the XPathGate is true. Classification result = new Classification(); result.setDescription(matchDescription); result.setEffort(effort); result.setPattern(this.xpathExpression); meta.getDecorations().add(result); super.chainDecorators(meta); } }
protected void createVersionResult(XmlMetadata file, String groupId, String artifactId, String versionId, String name) { PomVersion vr = new PomVersion(); // default to artifact ID if name isn't provided. if (StringUtils.isBlank(name)) { name = artifactId; } vr.setName(name); vr.setVersion(versionId); vr.setArchetypeId(artifactId); vr.setGroupId(groupId); file.getArchiveMeta().getDecorations().add(vr); if(file.getArchiveMeta() instanceof ZipMetadata) { ZipMetadata zip = (ZipMetadata)file.getArchiveMeta(); knownArchiveProfiler.isKnownVendor(zip, groupId); } }
IOUtils.copy(new InputStreamReader(resp.getBody()), new FileOutputStream(outputPath)); XmlMetadata xmlMeta = new XmlMetadata(); xmlMeta.setFilePointer(outputPath); xmlMeta.setArchiveMeta(meta);
Document doc = meta.getParsedDocument(); if (doc == null) { throw new NullPointerException(); LOG.debug("Found results for: " + meta.getFilePointer().getAbsolutePath()); simpleHint.setMarkdown("Create a local interface for the Entity bean to support Container Managed Relationship (CMR)."); result.getHints().add(simpleHint); meta.getDecorations().add(result); meta.getDecorations().add(result);
boolean isProcessed = false; if (meta.getParsedDocument() == null) { LOG.warn("Skipping XPathClassifyingDecorator: " + meta.getFilePointer().getAbsolutePath() + " because the document is unparsed."); return isProcessed; Document doc = meta.getParsedDocument(); if (doc == null) { throw new NullPointerException(); LOG.debug("Found results for: " + meta.getFilePointer().getAbsolutePath());
protected void createSummaryMeta(final XmlMetadata meta, String description, String match) { Summary result = new Summary(); result.setDescription(description); result.setPattern(match); result.setEffort(effort); for (ResultProcessor hint : hints) { hint.process(result); } meta.getDecorations().add(result); }
Document doc = file.getParsedDocument(); try { String groupId = extractStringValue(groupIdXPath, doc); LOG.debug("GroupId not found for file: " + file.getFilePointer().getAbsolutePath() + "; trying parent groupId..."); LOG.debug("Parent groupId not found for file: " + file.getFilePointer().getAbsolutePath() + "; skipping."); return; LOG.debug("Version not found for file: " + file.getFilePointer().getAbsolutePath() + "; trying parent version..."); LOG.debug("Parent version not found for file: " + file.getFilePointer().getAbsolutePath() + "; skipping."); return; LOG.debug("ArtifactId not found for file: " + file.getFilePointer().getAbsolutePath()); return;