juneau-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamesbog...@apache.org
Subject incubator-juneau git commit: Bug fixes.
Date Sat, 10 Jun 2017 22:24:19 GMT
Repository: incubator-juneau
Updated Branches:
  refs/heads/master d08110b10 -> 4029f1f5f


Bug fixes.

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/4029f1f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/4029f1f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/4029f1f5

Branch: refs/heads/master
Commit: 4029f1f5f95e575620c69bb470a49445879ee449
Parents: d08110b
Author: JamesBognar <jamesbognar@apache.org>
Authored: Sat Jun 10 18:24:16 2017 -0400
Committer: JamesBognar <jamesbognar@apache.org>
Committed: Sat Jun 10 18:24:16 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/juneau/html/HtmlParser.java |  4 +-
 .../examples/rest/DockerRegistryResource.java   |  2 +-
 .../juneau/examples/rest/RootResourcesTest.java | 10 +---
 .../rest/labels/ChildResourceDescriptions.java  |  3 +-
 .../juneau/rest/labels/ResourceDescription.java | 63 +++-----------------
 5 files changed, 14 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4029f1f5/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
index 5376b0a..0e2b201 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParser.java
@@ -134,7 +134,7 @@ public class HtmlParser extends XmlParser {
 			else
 				isValid = false;
 
-		} else if (tag == STRING) {
+		} else if (tag == STRING || (tag == A && pMeta != null && pMeta.getExtendedMeta(HtmlBeanPropertyMeta.class).getLink()
!= null)) {
 			String text = session.getElementText(r);
 			if (sType.isObject() || sType.isCharSequence())
 				o = text;
@@ -146,7 +146,7 @@ public class HtmlParser extends XmlParser {
 				o = sType.newInstanceFromNumber(session, outer, parseNumber(text, sType.getNewInstanceFromNumberClass()));
 			else
 				isValid = false;
-			skipTag(r, xSTRING);
+			skipTag(r, tag == STRING ? xSTRING : xA);
 
 		} else if (tag == NUMBER) {
 			String text = session.getElementText(r);

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4029f1f5/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
index ae3f18b..aac1d8a 100644
--- a/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
+++ b/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DockerRegistryResource.java
@@ -63,7 +63,7 @@ public class DockerRegistryResource extends Resource {
 	@RestMethod(name="GET", path="/")
 	public ResourceDescription[] getChildren(RestRequest req) {
 		return new ResourceDescription[] {
-			new ResourceDescription(req, "search", "Search Registry")
+			new ResourceDescription("search", "Search Registry")
 		};
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4029f1f5/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
----------------------------------------------------------------------
diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
index 81307c1..b0ac910 100644
--- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
+++ b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/RootResourcesTest.java
@@ -25,7 +25,6 @@ import org.junit.*;
 
 public class RootResourcesTest extends RestTestcase {
 
-	private static String path = SamplesMicroservice.getURI().getPath();              // /jazz/juneau/sample
 	private static boolean debug = false;
 
 	private RestClient jsonClient = SamplesMicroservice.DEFAULT_CLIENT;
@@ -39,8 +38,7 @@ public class RootResourcesTest extends RestTestcase {
 		RestClient client = SamplesMicroservice.DEFAULT_CLIENT;
 		RestCall r = client.doGet("");
 		ResourceDescription[] x = r.getResponse(ResourceDescription[].class);
-		assertEquals("helloWorld", x[0].getName().getName());
-		assertEquals(path + "/helloWorld", x[0].getName().getHref());
+		assertEquals("helloWorld", x[0].getName());
 		assertEquals("Hello World", x[0].getDescription());
 
 		r = jsonClient.doOptions("");
@@ -58,8 +56,7 @@ public class RootResourcesTest extends RestTestcase {
 		RestClient client = SamplesMicroservice.client().parser(XmlParser.DEFAULT).build();
 		RestCall r = client.doGet("");
 		ResourceDescription[] x = r.getResponse(ResourceDescription[].class);
-		assertEquals("helloWorld", x[0].getName().getName());
-		assertEquals(path + "/helloWorld", x[0].getName().getHref());
+		assertEquals("helloWorld", x[0].getName());
 		assertEquals("Hello World", x[0].getDescription());
 
 		r = jsonClient.doOptions("");
@@ -79,8 +76,7 @@ public class RootResourcesTest extends RestTestcase {
 		RestClient client = SamplesMicroservice.client().parser(HtmlParser.DEFAULT).accept("text/html+stripped").build();
 		RestCall r = client.doGet("");
 		ResourceDescription[] x = r.getResponse(ResourceDescription[].class);
-		assertEquals("helloWorld", x[0].getName().getName());
-		assertTrue(x[0].getName().getHref().endsWith("/helloWorld"));
+		assertEquals("helloWorld", x[0].getName());
 		assertEquals("Hello World", x[0].getDescription());
 
 		r = jsonClient.doOptions("").accept("text/json");

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4029f1f5/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ChildResourceDescriptions.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ChildResourceDescriptions.java
b/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ChildResourceDescriptions.java
index 23ed8bf..69efb27 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ChildResourceDescriptions.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ChildResourceDescriptions.java
@@ -45,9 +45,8 @@ public class ChildResourceDescriptions extends LinkedList<ResourceDescription>
{
 	 * Default is to maintain the order as specified in the annotation.
 	 */
 	public ChildResourceDescriptions(RestContext context, RestRequest req, boolean sort) {
-		String uri = req.getTrimmedRequestURI();
 		for (Map.Entry<String,RestContext> e : context.getChildResources().entrySet())
-			add(new ResourceDescription(uri, e.getKey(), e.getValue().getInfoProvider().getTitle(req)));
+			add(new ResourceDescription(e.getKey(), e.getValue().getInfoProvider().getTitle(req)));
 		if (sort)
 			Collections.sort(this);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/4029f1f5/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ResourceDescription.java
----------------------------------------------------------------------
diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ResourceDescription.java
b/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ResourceDescription.java
index 994c3fb..966c1b7 100644
--- a/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ResourceDescription.java
+++ b/juneau-rest/src/main/java/org/apache/juneau/rest/labels/ResourceDescription.java
@@ -12,21 +12,14 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.rest.labels;
 
-import static org.apache.juneau.internal.StringUtils.*;
-
-import org.apache.juneau.dto.*;
-import org.apache.juneau.rest.*;
+import org.apache.juneau.html.annotation.*;
 
 /**
  * Shortcut label for child resources.  Typically used in router resources.
  *
  * <h5 class='section'>Example:</h5>
  * <p class='bcode'>
- * 	<jc>// Instead of this...</jc>
- * 	<jk>new</jk> NameDescription(<jk>new</jk> Link(<js>"httpTool"</js>,
uri + <js>"/httpTool"</js>), <js>"HTTP request test client"</js>);
- *
- * 	<jc>// ...use this simpler equivalent...</jc>
- * 	<jk>new</jk> ResourceLink(uri, <js>"httpTool"</js>, <js>"HTTP
request test client"</js>);
+ * 	<jk>new</jk> ResourceLink(<js>"httpTool"</js>, <js>"HTTP
request test client"</js>);
  * </p>
  */
 public final class ResourceDescription extends NameDescription implements Comparable<ResourceDescription>
{
@@ -34,67 +27,25 @@ public final class ResourceDescription extends NameDescription implements
Compar
 	/**
 	 * Constructor.
 	 *
-	 * @param rootUrl The root URI of the child resource (e.g. the URI of the parent resource).
-	 * Must not end with <js>'/'</js>.
-	 * Must be URL-Encoded.
-	 * @param name The name of the child resource.
-	 * This will be URL-encoded and appended onto the root URL to create the hyperlink for the
resource.
-	 * @param description The description of the child resource.
-	 */
-	public ResourceDescription(String rootUrl, String name, String description) {
-		super(new Link(name, (rootUrl.equals("/") || rootUrl.isEmpty() ? "/" : rootUrl + "/") +
urlEncode(name)), description);
-	}
-
-	/**
-	 * Constructor for resources that are children of a REST resource.
-	 *
-	 * @param req The HTTP request.
-	 * @param childPath The childPath The path of the child resource relative to the servlet.
-	 * @param description The description of the child resource.
-	 */
-	public ResourceDescription(RestRequest req, String childPath, String description) {
-		super(new Link(calcName(childPath), calcHref(req, childPath)), description);
-	}
-
-	private static String calcName(String childPath) {
-		return urlDecode(childPath.indexOf('/') == -1 ? childPath : childPath.substring(childPath.lastIndexOf('/')+1));
-	}
-
-	// TODO
-	private static String calcHref(RestRequest req, String childPath) {
-		return req.getServletURIBuilder().append('/').append(childPath).toString();
-	}
-
-	/**
-	 * Constructor.
-	 *
 	 * @param name The name of the child resource.
 	 * @param description The description of the child resource.
 	 */
 	public ResourceDescription(String name, String description) {
-		super(new Link(name, name), description);
+		super(name, description);
 	}
 
 	/** No-arg constructor.  Used for JUnit testing of OPTIONS pages. */
 	public ResourceDescription() {}
 
 	@Override /* NameDescription */
-	public Link getName() {
-		return (Link)super.getName();
-	}
-
-	/**
-	 * Overridden setter.
-	 *
-	 * @param name The new name.
-	 */
-	public void setName(Link name) {
-		super.setName(name);
+	@Html(link="servlet:/{name}")
+	public Object getName() {
+		return super.getName();
 	}
 
 	@Override /* Comparable */
 	public int compareTo(ResourceDescription o) {
-		return getName().compareTo(o.getName());
+		return getName().toString().compareTo(o.getName().toString());
 	}
 
 	@Override /* Object */


Mime
View raw message