You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by pz...@apache.org on 2018/07/24 18:22:40 UTC
[4/7] knox git commit: KNOX-1397 - Admin UI Topologies List needs to
Refresh on New or Deleted Topologies
http://git-wip-us.apache.org/repos/asf/knox/blob/8efac135/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
----------------------------------------------------------------------
diff --git a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
index 1cfac54..81e0c75 100644
--- a/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
+++ b/gateway-service-admin/src/main/java/org/apache/knox/gateway/service/admin/TopologiesResource.java
@@ -105,26 +105,27 @@ public class TopologiesResource {
public Topology getTopology(@PathParam("id") String id) {
GatewayServices services =
(GatewayServices) request.getServletContext().getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
- GatewayConfig config =
- (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
-
- TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
-
- for (org.apache.knox.gateway.topology.Topology t : ts.getTopologies()) {
- if (t.getName().equals(id)) {
- try {
- t.setUri(new URI( buildURI(t, config, request) ));
- } catch (URISyntaxException se) {
- t.setUri(null);
- }
+ if (services != null) {
+ TopologyService ts = services.getService(GatewayServices.TOPOLOGY_SERVICE);
- // For any read-only override topology, mark it as generated to discourage modification.
- List<String> ambariManagedTopos = config.getReadOnlyOverrideTopologyNames();
- if (ambariManagedTopos.contains(t.getName())) {
- t.setGenerated(true);
+ GatewayConfig config =
+ (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+ for (org.apache.knox.gateway.topology.Topology t : ts.getTopologies()) {
+ if (t.getName().equals(id)) {
+ try {
+ t.setUri(new URI( buildURI(t, config, request) ));
+ } catch (URISyntaxException se) {
+ t.setUri(null);
+ }
+
+ // For any read-only override topology, mark it as generated to discourage modification.
+ List<String> ambariManagedTopos = config.getReadOnlyOverrideTopologyNames();
+ if (ambariManagedTopos.contains(t.getName())) {
+ t.setGenerated(true);
+ }
+
+ return BeanConverter.getTopology(t);
}
-
- return BeanConverter.getTopology(t);
}
}
return null;