public ComponentViewResolver() { super(); // Create templates for the REST URIs that are supported by this view resolver. Previously this was done using the // spring-surf-config.xml file but made little sense because to change the URI templates required changing the Spring Surf // configuration, the Spring Bean configuration and providing a new view resolver. It is simpler to define new templates // just through a new view resolver that is provided to support those templates. ArrayList<UriTemplate> uriTemplates = new ArrayList<UriTemplate>(); uriTemplates.add(new UriTemplate("/regionId/{regionId}")); uriTemplates.add(new UriTemplate("/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/mode/{mode}/focus/{focus}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/focus/{focus}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/mode/{mode}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); setUriTemplateIndex(new UriTemplateListIndex(uriTemplates)); // Populate the prefixes List with the 2 prefixes that we need to initially support. This code block // can be removed if we decide to allow prefixes to be specified via Spring property injection. addPrefix(URI_PREFIX_COMPONENT_SHORT); addPrefix(URI_PREFIX_COMPONENT_FULL); // NOTE: There are no request parameters to add as these are not currently used to identify component views. }
public ComponentViewResolver() { super(); // Create templates for the REST URIs that are supported by this view resolver. Previously this was done using the // spring-surf-config.xml file but made little sense because to change the URI templates required changing the Spring Surf // configuration, the Spring Bean configuration and providing a new view resolver. It is simpler to define new templates // just through a new view resolver that is provided to support those templates. ArrayList<UriTemplate> uriTemplates = new ArrayList<UriTemplate>(); uriTemplates.add(new UriTemplate("/regionId/{regionId}")); uriTemplates.add(new UriTemplate("/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/mode/{mode}/focus/{focus}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/focus/{focus}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); uriTemplates.add(new UriTemplate("/mode/{mode}/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); setUriTemplateIndex(new UriTemplateListIndex(uriTemplates)); // Populate the prefixes List with the 2 prefixes that we need to initially support. This code block // can be removed if we decide to allow prefixes to be specified via Spring property injection. addPrefix(URI_PREFIX_COMPONENT_SHORT); addPrefix(URI_PREFIX_COMPONENT_FULL); // NOTE: There are no request parameters to add as these are not currently used to identify component views. }
public RegionViewResolver() { super(); // Create templates for the REST URIs that are supported by this view resolver. Previously this was done using the // spring-surf-config.xml file but made little sense because to change the URI templates required changing the Spring Surf // configuration, the Spring Bean configuration and providing a new view resolver. It is simpler to define new templates // just through a new view resolver that is provided to support those templates. ArrayList<UriTemplate> uriTemplates = new ArrayList<UriTemplate>(); uriTemplates.add(new UriTemplate("/regionId/{regionId}")); uriTemplates.add(new UriTemplate("/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); setUriTemplateIndex(new UriTemplateListIndex(uriTemplates)); // Populate the prefixes List with the 2 prefixes that we need to initially support. This code block // can be removed if we decide to allow prefixes to be specified via Spring property injection. addPrefix(URI_PREFIX_REGION_SHORT); addPrefix(URI_PREFIX_REGION_FULL); // NOTE: There are no request parameters to add as these are not currently used to identify region views. }
public RegionViewResolver() { super(); // Create templates for the REST URIs that are supported by this view resolver. Previously this was done using the // spring-surf-config.xml file but made little sense because to change the URI templates required changing the Spring Surf // configuration, the Spring Bean configuration and providing a new view resolver. It is simpler to define new templates // just through a new view resolver that is provided to support those templates. ArrayList<UriTemplate> uriTemplates = new ArrayList<UriTemplate>(); uriTemplates.add(new UriTemplate("/regionId/{regionId}")); uriTemplates.add(new UriTemplate("/scope/{scopeId}/regionId/{regionId}/sourceId/{sourceId}")); setUriTemplateIndex(new UriTemplateListIndex(uriTemplates)); // Populate the prefixes List with the 2 prefixes that we need to initially support. This code block // can be removed if we decide to allow prefixes to be specified via Spring property injection. addPrefix(URI_PREFIX_REGION_SHORT); addPrefix(URI_PREFIX_REGION_FULL); // NOTE: There are no request parameters to add as these are not currently used to identify region views. }
UriTemplate uriTemplate = new UriTemplate(template);
UriTemplate uriTemplate = new UriTemplate(template);
UriTemplate uriTemplate = new UriTemplate(template);
UriTemplate uriTemplate = new UriTemplate(template);
IndexEntry entry = new IndexEntry(desc.getMethod(), new UriTemplate(uri), extension, script); if (index.containsKey(entry))
IndexEntry entry = new IndexEntry(desc.getMethod(), new UriTemplate(uri), extension, script); if (index.containsKey(entry))
IndexEntry entry = new IndexEntry(desc.getMethod(), new UriTemplate(uri), extension, script); if (index.containsKey(entry))
public void testTemplateDotMatch() { UriTemplate i1 = new UriTemplate("/a/b/{b}/c"); Map<String, String> values1 = i1.match("/a/b/x/y/z.ext/c"); assertEquals(1, values1.size()); assertEquals("x/y/z.ext", values1.get("b")); }
public void testIndexSort() IndexEntry i1 = new IndexEntry("GET", new UriTemplate("/"), false, null); IndexEntry i2 = new IndexEntry("POST", new UriTemplate("/a/{a}"), false, null); IndexEntry i3 = new IndexEntry("get", new UriTemplate("/a/{a}/b"), false, null); IndexEntry i4 = new IndexEntry("get", new UriTemplate("/a"), false, null); IndexEntry i5 = new IndexEntry("get", new UriTemplate("/c/d"), false, null); IndexEntry i6 = new IndexEntry("get", new UriTemplate("/c/d/{e}"), true, null); IndexEntry i7 = new IndexEntry("get", new UriTemplate("/a/b"), false, null); IndexEntry i8 = new IndexEntry("get", new UriTemplate("/c/d/{e}/{e}"), false, null); IndexEntry i9 = new IndexEntry("get", new UriTemplate("/e"), false, null); IndexEntry i10 = new IndexEntry("GET", new UriTemplate("/a/{a}"), false, null);
new UriTemplate(null); fail("Failed to catch null template"); try new UriTemplate(""); fail("Failed to catch empty template"); try new UriTemplate("//"); fail("Failed to catch double /"); new UriTemplate("/a//"); fail("Failed to catch double /"); new UriTemplate("/a//b"); fail("Failed to catch double /"); new UriTemplate("/{1a}"); fail("Failed to catch var name beginning with number"); new UriTemplate("/;a"); fail("Failed to catch semi-colon without prefix"); new UriTemplate("/{1;a}"); fail("Failed to catch semi-colon in template var name");
new UriTemplate("/"); try new UriTemplate("/a;"); try new UriTemplate("/a;aaaa"); try new UriTemplate("/a;a;aaaa"); try new UriTemplate("/{a_b}"); try new UriTemplate("/ads/test-2/{storeid}/{path}"); try new UriTemplate("/ads/test_2/{storeid}/{path}");
public void testTemplateMatch() UriTemplate i1 = new UriTemplate("/a/{a1}/b/b{b1}b"); assertNull(i1.match("/")); assertNull(i1.match("/a")); assertEquals("2", values1.get("b1")); UriTemplate i2 = new UriTemplate("/a/{a1}/b/{b1}"); Map<String, String> values2 = i2.match("/a/1/b/2/3"); assertNotNull(values2); assertEquals("2/3", values2.get("b1")); UriTemplate i3 = new UriTemplate("/a/{a1}/b/{a1}"); Map<String, String> values3 = i3.match("/a/1/b/2"); assertNull(values3); UriTemplate i4 = new UriTemplate("/a/b{b}/{c}"); Map<String, String> values4 = i4.match("/a/b/c"); assertEquals(2, values4.size()); assertEquals("c", values4.get("c")); UriTemplate i5 = new UriTemplate("/a/b{b}/{c}"); Map<String, String> values5 = i5.match("/a/bb/c"); assertEquals(2, values5.size());
public void testParseTemplate() { UriTemplate i1 = new UriTemplate("/"); assertEquals("/", i1.getTemplate()); assertEquals("/", i1.getRegex().pattern()); assertEquals(1, i1.getStaticCharCount()); assertEquals(0, i1.getVariableNames().length); UriTemplate i2 = new UriTemplate("/a/{a1}/b{b1}b/{c_c}"); assertEquals("/a/{a1}/b{b1}b/{c_c}", i2.getTemplate()); assertEquals("/a/(.*?)/b(.*?)b/(.*?)", i2.getRegex().pattern()); assertEquals(7, i2.getStaticCharCount()); assertEquals(3, i2.getVariableNames().length); assertEquals("a1", i2.getVariableNames()[0]); assertEquals("b1", i2.getVariableNames()[1]); assertEquals("c_c", i2.getVariableNames()[2]); }