private List<EnvironmentReferenceModel> processEnvironmentReference(GraphContext context, Element element) { EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context); List<EnvironmentReferenceModel> resources = new LinkedList<EnvironmentReferenceModel>(); // find JMS references... List<Element> queueReferences = $(element).find("resource-env-ref").get(); for (Element e : queueReferences) { String type = $(e).child("resource-env-ref-type").text(); String name = $(e).child("resource-env-ref-name").text(); type = StringUtils.trim(type); name = StringUtils.trim(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, type); if (ref == null) { ref = environmentReferenceService.create(); ref.setName(name); ref.setReferenceType(type); } resources.add(ref); } return resources; }
/** * Finds a {@link EnvironmentReferenceModel} by name and type. */ public EnvironmentReferenceModel findEnvironmentReference(String name, EnvironmentReferenceTagType type) { Traversal<?, ?> query = findAllQuery().getRawTraversal().has(EnvironmentReferenceModel.NAME, name).has( EnvironmentReferenceModel.TAG_TYPE, type); return getUnique(query); }
private void processBinding(EnvironmentReferenceService envRefService, JNDIResourceService jndiResourceService, Set<ProjectModel> applications, Element resourceRef, String tagName) { String href = $(resourceRef).child(tagName).attr("href"); String resourceId = StringUtils.substringAfterLast(href, "ejb-jar.xml#"); String jndiLocation = $(resourceRef).attr("jndiName"); if (StringUtils.isNotBlank(jndiLocation) && StringUtils.isNotBlank(resourceId)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI Name: " + jndiLocation + " to Resource: " + resourceId); // now, look up the resource which is resolved by DiscoverEjbConfigurationXmlRuleProvider for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.REFERENCE_ID, resourceId)) { envRefService.associateEnvironmentToJndi(resource, ref); } } }
public EnvironmentReferenceModel findEnvironmentReference(String name, String type) { GraphQuery query = getTypedQuery().has(EnvironmentReferenceModel.NAME, name).has( EnvironmentReferenceModel.REFERENCE_TYPE, type); return getUnique(query); } }
@Override public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) { EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext()); Document doc = xmlFileService.loadDocumentQuiet(event, context, payload); VendorSpecificationExtensionService vendorSpecificationService = new VendorSpecificationExtensionService(event.getGraphContext()); // mark as vendor extension; create reference to web.xml vendorSpecificationService.associateAsVendorExtension(payload, "web.xml"); technologyTagService.addTagToFileModel(payload, "WebLogic Web XML", TechnologyTagLevel.IMPORTANT); Set<ProjectModel> applications = ProjectTraversalCache.getApplicationsForProject(event.getGraphContext(), payload.getProjectModel()); for (Element resourceRef : $(doc).find("resource-description").get()) { String jndiLocation = $(resourceRef).child("jndi-name").text(); String resourceName = $(resourceRef).child("res-ref-name").text(); if (StringUtils.isNotBlank(jndiLocation)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI: " + jndiLocation + " Resource: " + resourceName); // now, look up the resource by name, and associate the type which is resolved by DiscoverWebXmlRuleProvider for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.NAME, resourceName)) { envRefService.associateEnvironmentToJndi(resource, ref); } } } }
private void processElement(EnvironmentReferenceService environmentReferenceService, List<EnvironmentReferenceModel> resources, Element element, String typeLocation, String nameLocation, EnvironmentReferenceTagType refType) { String id = $(element).attr("id"); String type = $(element).child(typeLocation).text(); String name = $(element).child(nameLocation).text(); type = StringUtils.trim(type); name = StringUtils.trim(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, refType); if (ref == null) { ref = environmentReferenceService.create(); ref.setName(name); ref.setReferenceType(type); ref.setReferenceTagType(refType); LOG.info("Added: "+ref); } else { if(ref.getReferenceTagType() != null && (ref.getReferenceTagType() != refType)) { LOG.warning("Expected type: "+EnvironmentReferenceTagType.RESOURCE_REF +" but actually: "+ref.getReferenceType()); } } ref.setReferenceId(id); resources.add(ref); }
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; }
@Override public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) { EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); TechnologyTagService technologyTagService = new TechnologyTagService(event.getGraphContext()); Document doc = xmlFileService.loadDocumentQuiet(event, context, payload); VendorSpecificationExtensionService vendorSpecificationService = new VendorSpecificationExtensionService(event.getGraphContext()); // mark as vendor extension; create reference to web.xml vendorSpecificationService.associateAsVendorExtension(payload, "web.xml"); technologyTagService.addTagToFileModel(payload, "WebLogic Web XML", TechnologyTagLevel.IMPORTANT); Set<ProjectModel> applications = ProjectTraversalCache.getApplicationsForProject(event.getGraphContext(), payload.getProjectModel()); for (Element resourceRef : $(doc).find("resource-description").get()) { String jndiLocation = $(resourceRef).child("jndi-name").text(); String resourceName = $(resourceRef).child("res-ref-name").text(); if (StringUtils.isNotBlank(jndiLocation)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI: " + jndiLocation + " Resource: " + resourceName); // now, look up the resource by name, and associate the type which is resolved by DiscoverWebXmlRuleProvider for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.NAME, resourceName)) { envRefService.associateEnvironmentToJndi(resource, ref); } } } }
private void processElement(EnvironmentReferenceService environmentReferenceService, List<EnvironmentReferenceModel> resources, Element element, String typeLocation, String nameLocation, EnvironmentReferenceTagType refType) { String id = $(element).attr("id"); String type = $(element).child(typeLocation).text(); String name = $(element).child(nameLocation).text(); type = StringUtils.trim(type); name = StringUtils.trim(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, refType); if (ref == null) { ref = environmentReferenceService.create(); ref.setName(name); ref.setReferenceType(type); ref.setReferenceTagType(refType); LOG.info("Added: "+ref); } else { if(ref.getReferenceTagType() != null && (ref.getReferenceTagType() != refType)) { LOG.warning("Expected type: "+EnvironmentReferenceTagType.RESOURCE_REF +" but actually: "+ref.getReferenceType()); } } ref.setReferenceId(id); resources.add(ref); }
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; }
@Override public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.NAME, resourceName)) envRefService.associateEnvironmentToJndi(resource, ref);
private List<EnvironmentReferenceModel> processEnvironmentReference(GraphContext context, Element element) { EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context); List<EnvironmentReferenceModel> resources = new ArrayList<>(); // find JMS references... List<Element> queueReferences = $(element).find("resource-ref").get(); for (Element e : queueReferences) { String id = $(e).attr("id"); String type = $(e).child("res-type").text(); String name = $(e).child("res-ref-name").text(); type = StringUtils.trim(type); name = StringUtils.trim(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, type); if (ref == null) { ref = environmentReferenceService.create(); ref.setName(name); ref.setReferenceType(type); } ref.setReferenceId(id); resources.add(ref); } return resources; } }
private void processBinding(EnvironmentReferenceService envRefService, JNDIResourceService jndiResourceService, Set<ProjectModel> applications, Element resourceRef, String tagName) { String href = $(resourceRef).child(tagName).attr("href"); String resourceId = StringUtils.substringAfterLast(href, "ejb-jar.xml#"); String jndiLocation = $(resourceRef).attr("jndiName"); if (StringUtils.isNotBlank(jndiLocation) && StringUtils.isNotBlank(resourceId)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI Name: " + jndiLocation + " to Resource: " + resourceId); // now, look up the resource which is resolved by DiscoverEjbConfigurationXmlRuleProvider for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.REFERENCE_ID, resourceId)) { envRefService.associateEnvironmentToJndi(resource, ref); } } }
EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); JmsDestinationService jmsDestinationService = new JmsDestinationService(event.getGraphContext());
/** * Finds a {@link EnvironmentReferenceModel} by name and type. */ public EnvironmentReferenceModel findEnvironmentReference(String name, EnvironmentReferenceTagType type) { Traversal<?, ?> query = findAllQuery().getRawTraversal().has(EnvironmentReferenceModel.NAME, name).has( EnvironmentReferenceModel.TAG_TYPE, type); return getUnique(query); }
@Override public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); XmlFileService xmlFileService = new XmlFileService(event.getGraphContext()); for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.NAME, resourceName)) envRefService.associateEnvironmentToJndi(resource, ref);
EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context); List<EnvironmentReferenceModel> resources = new LinkedList<>(); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, EnvironmentReferenceTagType.RESOURCE_REF); if (ref == null) ref = environmentReferenceService.create(); ref.setName(name); ref.setReferenceId(id); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, EnvironmentReferenceTagType.RESOURCE_ENV_REF); if (ref == null) ref = environmentReferenceService.create(); ref.setReferenceId(id); ref.setName(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, EnvironmentReferenceTagType.MSG_DESTINATION_REF); if (ref == null) ref = environmentReferenceService.create(); ref.setReferenceId(id); ref.setName(name); EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, EnvironmentReferenceTagType.EJB_LOCAL_REF); if (ref == null) ref = environmentReferenceService.create();
private void processBinding(EnvironmentReferenceService envRefService, JNDIResourceService jndiResourceService, Set<ProjectModel> applications, Element resourceRef, String tagName) { String jndiLocation = $(resourceRef).attr("jndiName"); String resourceId = $(resourceRef).child(tagName).attr("href"); resourceId = StringUtils.substringAfter(resourceId, "WEB-INF/web.xml#"); if (StringUtils.isBlank(resourceId)) { LOG.info("Issue Element: " + $(resourceRef).toString()); return; } if (StringUtils.isNotBlank(jndiLocation)) { JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation); LOG.info("JNDI: " + jndiLocation + " Resource: " + resourceId); // now, look up the resource for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.REFERENCE_ID, resourceId)) { LOG.info(" - Associating JNDI: " + jndiLocation + " Resource: " + ref); envRefService.associateEnvironmentToJndi(resource, ref); } } }
EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); JmsDestinationService jmsDestinationService = new JmsDestinationService(event.getGraphContext());
@Override public void perform(GraphRewrite event, EvaluationContext context, XmlFileModel payload) EnvironmentReferenceService envRefService = new EnvironmentReferenceService(event.getGraphContext()); JNDIResourceService jndiResourceService = new JNDIResourceService(event.getGraphContext()); JmsDestinationService jmsDestinationService = new JmsDestinationService(event.getGraphContext()); LOG.info("JNDI Name: " + jndiLocation + " to Resource: " + resourceName); for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.NAME, resourceName)) envRefService.associateEnvironmentToJndi(resource, ref);