Author: jstrachan Date: Mon Aug 9 10:25:10 2010 New Revision: 983575 URL: http://svn.apache.org/viewvc?rev=983575&view=rev Log: fix for CAMEL-3036 using CAMEL-3035 as a way to make easier endpoint links
Modified: camel/trunk/components/camel-web/pom.xml camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/EndpointLink.java camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/EndpointsResource.java camel/trunk/components/camel-web/src/main/resources/logback.xml camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/CamelContextResource.index.ssp Modified: camel/trunk/components/camel-web/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/pom.xml?rev=983575&r1=983574&r2=983575&view=diff ============================================================================== --- camel/trunk/components/camel-web/pom.xml (original) +++ camel/trunk/components/camel-web/pom.xml Mon Aug 9 10:25:10 2010 @@ -334,6 +334,16 @@ <plugin> <groupId>org.codehaus.mojo</groupId> + <artifactId>tomcat-maven-plugin</artifactId> + <version>1.0</version> + <configuration> + <path>/rider</path> + </configuration> + </plugin> + + + <plugin> + <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1</version> <executions> Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/EndpointLink.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/EndpointLink.java?rev=983575&r1=983574&r2=983575&view=diff ============================================================================== --- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/EndpointLink.java (original) +++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/model/EndpointLink.java Mon Aug 9 10:25:10 2010 @@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAttr import javax.xml.bind.annotation.XmlRootElement; import org.apache.camel.Endpoint; +import org.apache.camel.spi.HasId; import org.apache.camel.web.util.UriCharactersEncoder; /** @@ -55,12 +56,12 @@ public class EndpointLink { public void load(Endpoint endpoint) { this.uri = endpoint.getEndpointUri(); - this.href = createHref(uri); + this.href = createHref(uri, endpoint); } public void load(String key, Endpoint endpoint) { this.uri = endpoint.getEndpointUri(); - this.href = createHref(key); + this.href = createHref(key, endpoint); } public String getHref() { @@ -79,10 +80,16 @@ public class EndpointLink { this.uri = uri; } - protected String createHref(String uri) { - // must not include :// in endpoint link - // TODO: might need to use org.apache.camel.util.UnsafeUriCharactersEncoder to safely encode URI for the web - return "/endpoints/" + UriCharactersEncoder.encode(uri); + protected String createHref(String uri, Endpoint endpoint) { + if (endpoint instanceof HasId) { + HasId hasId = (HasId) endpoint; + String id = hasId.getId(); + return "/endpoints/" + id; + } else { + // must not include :// in endpoint link + // TODO: might need to use org.apache.camel.util.UnsafeUriCharactersEncoder to safely encode URI for the web + return "/endpoints/" + UriCharactersEncoder.encode(uri); + } } } Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/EndpointsResource.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/EndpointsResource.java?rev=983575&r1=983574&r2=983575&view=diff ============================================================================== --- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/EndpointsResource.java (original) +++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/EndpointsResource.java Mon Aug 9 10:25:10 2010 @@ -33,8 +33,11 @@ import javax.ws.rs.core.UriInfo; import com.sun.jersey.api.representation.Form; import com.sun.jersey.api.view.Viewable; import org.apache.camel.Endpoint; +import org.apache.camel.spi.HasId; import org.apache.camel.web.model.EndpointLink; import org.apache.camel.web.model.Endpoints; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * The active endpoints in Camel @@ -42,6 +45,8 @@ import org.apache.camel.web.model.Endpoi * @version $Revision$ */ public class EndpointsResource extends CamelChildResourceSupport { + private static final transient Log LOG = LogFactory.getLog(EndpointsResource.class); + private String error = ""; private String newUri = "mock:someName"; @@ -75,9 +80,22 @@ public class EndpointsResource extends C endpoint = getCamelContext().getEndpoint(id); } } + if (endpoint == null) { + for (Endpoint e : getCamelContext().getEndpoints()) { + if (e instanceof HasId) { + HasId hasId = (HasId) e; + String value = hasId.getId(); + if (value != null && value.equals(id)) { + endpoint = e; + break; + } + } + } + } if (endpoint != null) { return new EndpointResource(getContextResource(), id, endpoint); } else { + LOG.warn("No endpoint found for id: " + id); return null; } } Modified: camel/trunk/components/camel-web/src/main/resources/logback.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/resources/logback.xml?rev=983575&r1=983574&r2=983575&view=diff ============================================================================== --- camel/trunk/components/camel-web/src/main/resources/logback.xml (original) +++ camel/trunk/components/camel-web/src/main/resources/logback.xml Mon Aug 9 10:25:10 2010 @@ -42,7 +42,7 @@ <logger name="org.fusesource.scalate.servlet.ServletTemplateEngine.SourceMap" level="INFO" /> - <root level="info"> + <root level="debug"> <appender-ref ref="FILE" /> <appender-ref ref="STDOUT" /> </root> Modified: camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/CamelContextResource.index.ssp URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/CamelContextResource.index.ssp?rev=983575&r1=983574&r2=983575&view=diff ============================================================================== --- camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/CamelContextResource.index.ssp (original) +++ camel/trunk/components/camel-web/src/main/webapp/org/apache/camel/web/resources/CamelContextResource.index.ssp Mon Aug 9 10:25:10 2010 @@ -1,6 +1,6 @@ <%@ import val it: CamelContextResource %> -#{ attributes("title") = "Apache Camel ${it.getVersion}"}# +#{ attributes("title") = "Apache Camel " + it.getVersion }# <h1>Welcome to Apache Camel ${it.getVersion}</h1>