public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) { XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); Document doc = xmlFileService.loadDocumentQuiet(event, context, payload); if (doc != null && isWebXml(payload, doc)) { addWebXmlMetadata(event, context, event.getGraphContext(), payload, doc); } }
private boolean isWebXml(XmlFileModel xml, Document doc) { // check it's doctype against the known doctype. return !(xml.getDoctype() != null && !processDoctypeMatches(xml.getDoctype())); }
WebXmlService webXmlService = new WebXmlService(context); String webXmlVersion = getVersion(xml, doc); List<EnvironmentReferenceModel> refs = processEnvironmentReference(context, doc.getDocumentElement()); for (EnvironmentReferenceModel ref : refs)
if (processDoctypeMatches(xml.getDoctype())) version = processDoctypeVersion(xml.getDoctype());
private List<EnvironmentReferenceModel> processEnvironmentReference(GraphContext context, Element element) { EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context); List<EnvironmentReferenceModel> resources = new ArrayList<>(); // find JMS references... for (Element resourceRef : $(element).find("resource-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "res-type", "res-ref-name", EnvironmentReferenceTagType.RESOURCE_REF); } for (Element resourceRef : $(element).find("ejb-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_REF); } for (Element resourceRef : $(element).find("ejb-local-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_LOCAL_REF); } for (Element resourceRef : $(element).find("message-destination-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "message-destination-type", "message-destination-ref-name", EnvironmentReferenceTagType.MSG_DESTINATION_REF); } return resources; }
private void addWebXmlMetadata(GraphContext context, XmlFileModel xml, Document doc) { TechnologyTagService technologyTagService = new TechnologyTagService(context); TechnologyTagModel technologyTag = technologyTagService.addTagToFileModel(xml, TECH_TAG, TECH_TAG_LEVEL); WebXmlService webXmlService = new WebXmlService(context); String webXmlVersion = getVersion(xml, doc); // check the root XML node. WebXmlModel webXml = webXmlService.addTypeToModel(xml); // change "_" in the version to "." if (StringUtils.isNotBlank(webXmlVersion)) { webXmlVersion = StringUtils.replace(webXmlVersion, "_", "."); webXml.setSpecificationVersion(webXmlVersion); // set the tag version technologyTag.setVersion(webXmlVersion); } String displayName = $(doc).child("display-name").text(); displayName = StringUtils.trimToNull(displayName); if (StringUtils.isNotBlank(displayName)) { webXml.setDisplayName(displayName); } // extract references. List<EnvironmentReferenceModel> refs = processEnvironmentReference(context, doc.getDocumentElement()); for (EnvironmentReferenceModel ref : refs) { webXml.addEnvironmentReference(ref); } }
if (processDoctypeMatches(xml.getDoctype())) version = processDoctypeVersion(xml.getDoctype());
private List<EnvironmentReferenceModel> processEnvironmentReference(GraphContext context, Element element) { EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context); List<EnvironmentReferenceModel> resources = new ArrayList<>(); // find JMS references... for (Element resourceRef : $(element).find("resource-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "res-type", "res-ref-name", EnvironmentReferenceTagType.RESOURCE_REF); } for (Element resourceRef : $(element).find("ejb-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_REF); } for (Element resourceRef : $(element).find("ejb-local-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_LOCAL_REF); } for (Element resourceRef : $(element).find("message-destination-ref").get()) { processElement(environmentReferenceService, resources, resourceRef, "message-destination-type", "message-destination-ref-name", EnvironmentReferenceTagType.MSG_DESTINATION_REF); } return resources; }
public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) { XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); Document doc = xmlFileService.loadDocumentQuiet(payload); if (doc != null && isWebXml(payload, doc)) { addWebXmlMetadata(event.getGraphContext(), payload, doc); } }
WebXmlService webXmlService = new WebXmlService(context); String webXmlVersion = getVersion(xml, doc); List<EnvironmentReferenceModel> refs = processEnvironmentReference(context, doc.getDocumentElement()); for (EnvironmentReferenceModel ref : refs)
if (processDoctypeMatches(xml.getDoctype())) version = processDoctypeVersion(xml.getDoctype());
private boolean isWebXml(XmlFileModel xml, Document doc) { // check it's doctype against the known doctype. if (xml.getDoctype() != null && !processDoctypeMatches(xml.getDoctype())) { return false; } return true; }
public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) { XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); Document doc = xmlFileService.loadDocumentQuiet(event, context, payload); if (doc != null && isWebXml(payload, doc)) { addWebXmlMetadata(event, context, event.getGraphContext(), payload, doc); } }
private boolean isWebXml(XmlFileModel xml, Document doc) { // check it's doctype against the known doctype. return !(xml.getDoctype() != null && !processDoctypeMatches(xml.getDoctype())); }