Github user iyovcheva commented on a diff in the pull request:
https://github.com/apache/brooklyn-library/pull/48#discussion_r70067818
--- Diff:
software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/WebAppServiceMethods.java
---
@@ -73,17 +73,26 @@ public static boolean isProtocolEnabled(Entity entity,
String protocol) {
public static String inferBrooklynAccessibleRootUrl(Entity entity) {
if (isProtocolEnabled(entity, "https")) {
- Integer rawPort = entity.getAttribute(HTTPS_PORT);
- checkNotNull(rawPort, "HTTPS_PORT sensors not set for %s; is
an acceptable port available?", entity);
- HostAndPort hp =
BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, rawPort);
- return String.format("https://%s:%s/", hp.getHostText(),
hp.getPort());
+ return inferBrooklynAccessibleRootUrl(entity, HTTPS_PORT);
} else if (isProtocolEnabled(entity, "http")) {
- Integer rawPort = entity.getAttribute(HTTP_PORT);
- checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an
acceptable port available?", entity);
- HostAndPort hp =
BrooklynAccessUtils.getBrooklynAccessibleAddress(entity, rawPort);
- return String.format("http://%s:%s/", hp.getHostText(),
hp.getPort());
+ return inferBrooklynAccessibleRootUrl(entity, HTTP_PORT);
} else {
throw new IllegalStateException("HTTP and HTTPS protocols not
enabled for "+entity+"; enabled protocols are "+getEnabledProtocols(entity));
}
}
+
+ public static String inferBrooklynAccessibleRootUrl(Entity entity,
AttributeSensor<Integer> sensor) {
--- End diff --
I don't think we need inferBrooklynAccessibleRootUrl(Entity entity,
AttributeSensor<Integer> sensor) signature as there are not defined other
protocols yet and there is double check once in
inferBrooklynAccessibleRootUrl(Entity entity) and once here. A sensor can be
set in the first method instead and this would simplify the code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---