@Test public void testExtractConsumer0() throws XRd4JException { ConsumerEndpoint temp = ConsumerGatewayUtil.findMatch("GET /www.hel.fi/palvelukarttaws/rest/v2/organization/", map); assertEquals(false, temp == null); assertEquals("FI_PILOT.GOV.0245437-2.ConsumerService", temp.getClientId()); assertEquals("FI_PILOT.GOV.1019125-0.Demo2Service.getOrganizationList.v1", temp.getServiceId()); assertEquals("/www.hel.fi/palvelukarttaws/rest/v2/organization/", temp.getResourcePath()); assertEquals(null, temp.getResourceId()); assertEquals(false, temp.isModifyUrl()); assertEquals("http: assertEquals("ts1", temp.getPrefix()); assertEquals("http: assertEquals(false, temp.isRequestEncrypted()); assertEquals(false, temp.isResponseEncrypted()); assertEquals(new ConsumerMember("FI_PILOT", "GOV", "0245437-2", "ConsumerService").toString(), temp.getConsumer().toString()); assertEquals(new ProducerMember("FI_PILOT", "GOV", "1019125-0", "Demo2Service", "getOrganizationList", "v1").toString(), temp.getProducer().toString()); }
public static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints) { if (endpoints.containsKey(serviceId)) { log.debug("Found match by service id : \"{}\".", serviceId); return endpoints.get(serviceId); } for (Map.Entry<String, ConsumerEndpoint> entry : endpoints.entrySet()) { String key = entry.getKey(); String keyMod = key.replaceAll("\\{" + Constants.PARAM_RESOURCE_ID + "\\}", "([\\\\w\\\\-]+?)"); log.trace("Modified key used for comparison : \"{}\".", keyMod); if (serviceId.matches(keyMod)) { log.debug("Found partial match by service id. Request value : \"{}\", matching value : \"{}\".", serviceId, key); ConsumerEndpoint endpoint = entry.getValue(); parseResourceId(key, endpoint, serviceId); return endpoint; } } log.debug("No match by service id was found. Service id : \"{}\".", serviceId); return null; }
ConsumerGatewayUtil { public static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints) { if (endpoints.containsKey(serviceId)) { log.debug("Found match by service id : \"{}\".", serviceId); return endpoints.get(serviceId); } for (Map.Entry<String, ConsumerEndpoint> entry : endpoints.entrySet()) { String key = entry.getKey(); String keyMod = key.replaceAll("\\{" + Constants.PARAM_RESOURCE_ID + "\\}", "([\\\\w\\\\-]+?)"); log.trace("Modified key used for comparison : \"{}\".", keyMod); if (serviceId.matches(keyMod)) { log.debug("Found partial match by service id. Request value : \"{}\", matching value : \"{}\".", serviceId, key); ConsumerEndpoint endpoint = entry.getValue(); parseResourceId(key, endpoint, serviceId); return endpoint; } } log.debug("No match by service id was found. Service id : \"{}\".", serviceId); return null; } }
ConsumerGatewayUtil { public static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints) { if (endpoints.containsKey(serviceId)) { log.debug("Found match by service id : \"{}\".", serviceId); return endpoints.get(serviceId); } for (Map.Entry<String, ConsumerEndpoint> entry : endpoints.entrySet()) { String key = entry.getKey(); String keyMod = key.replaceAll("\\{" + Constants.PARAM_RESOURCE_ID + "\\}", "([\\\\w\\\\-]+?)"); log.trace("Modified key used for comparison : \"{}\".", keyMod); if (serviceId.matches(keyMod)) { log.debug("Found partial match by service id. Request value : \"{}\", matching value : \"{}\".", serviceId, key); ConsumerEndpoint endpoint = entry.getValue(); parseResourceId(key, endpoint, serviceId); return endpoint; } } log.debug("No match by service id was found. Service id : \"{}\".", serviceId); return null; } private  ConsumerGatewayUtil(); }
ConsumerGatewayUtil { public static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints) { if (endpoints.containsKey(serviceId)) { log.debug("Found match by service id : \"{}\".", serviceId); return endpoints.get(serviceId); } for (Map.Entry<String, ConsumerEndpoint> entry : endpoints.entrySet()) { String key = entry.getKey(); String keyMod = key.replaceAll("\\{" + Constants.PARAM_RESOURCE_ID + "\\}", "([\\\\w\\\\-]+?)"); log.trace("Modified key used for comparison : \"{}\".", keyMod); if (serviceId.matches(keyMod)) { log.debug("Found partial match by service id. Request value : \"{}\", matching value : \"{}\".", serviceId, key); ConsumerEndpoint endpoint = entry.getValue(); parseResourceId(key, endpoint, serviceId); return endpoint; } } log.debug("No match by service id was found. Service id : \"{}\".", serviceId); return null; } private  ConsumerGatewayUtil(); static Map<String, ConsumerEndpoint> extractConsumers(Properties endpoints, Properties gatewayProperties); static void extractEndpoints(String key, Properties endpoints, ConsumerEndpoint endpoint); static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints); static String rewriteUrl(String servletUrl, String pathToResource, String responseStr); static ConsumerEndpoint createUnconfiguredEndpoint(Properties props, String pathToResource); static String removeResponseTag(String message); static boolean checkEncryptionProperties(Properties props, Map<String, ConsumerEndpoint> endpoints,
                                                    Map<String, Encrypter> asymmetricEncrypterCache); }
ConsumerGatewayUtil { public static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints) { if (endpoints.containsKey(serviceId)) { log.debug("Found match by service id : \"{}\".", serviceId); return endpoints.get(serviceId); } for (Map.Entry<String, ConsumerEndpoint> entry : endpoints.entrySet()) { String key = entry.getKey(); String keyMod = key.replaceAll("\\{" + Constants.PARAM_RESOURCE_ID + "\\}", "([\\\\w\\\\-]+?)"); log.trace("Modified key used for comparison : \"{}\".", keyMod); if (serviceId.matches(keyMod)) { log.debug("Found partial match by service id. Request value : \"{}\", matching value : \"{}\".", serviceId, key); ConsumerEndpoint endpoint = entry.getValue(); parseResourceId(key, endpoint, serviceId); return endpoint; } } log.debug("No match by service id was found. Service id : \"{}\".", serviceId); return null; } private  ConsumerGatewayUtil(); static Map<String, ConsumerEndpoint> extractConsumers(Properties endpoints, Properties gatewayProperties); static void extractEndpoints(String key, Properties endpoints, ConsumerEndpoint endpoint); static ConsumerEndpoint findMatch(String serviceId, Map<String, ConsumerEndpoint> endpoints); static String rewriteUrl(String servletUrl, String pathToResource, String responseStr); static ConsumerEndpoint createUnconfiguredEndpoint(Properties props, String pathToResource); static String removeResponseTag(String message); static boolean checkEncryptionProperties(Properties props, Map<String, ConsumerEndpoint> endpoints,
                                                    Map<String, Encrypter> asymmetricEncrypterCache);  }