Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public class Topology extends BasePage {

public static final String CONNECTOR_SERVER_LOCATION_PREFIX = "connid://";

public static String sanitizeMarkupId(final String input) {
return input.replaceAll("[^a-zA-Z0-9._-]", "_");
}

@SpringBean
protected ServiceOps serviceOps;

Expand Down Expand Up @@ -224,7 +228,7 @@ public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
// Add Syncope (root topologynode)
// -----------------------------------------
String rootName = StringUtils.capitalize(Constants.SYNCOPE);
final TopologyNode syncopeTopologyNode = new TopologyNode(rootName, rootName, TopologyNode.Kind.SYNCOPE);
TopologyNode syncopeTopologyNode = new TopologyNode(rootName, rootName, TopologyNode.Kind.SYNCOPE);
syncopeTopologyNode.setX(origX);
syncopeTopologyNode.setY(origY);

Expand All @@ -234,9 +238,9 @@ public void onClick(final AjaxRequestTarget target, final Serializable ignore) {

body.add(topologyNodePanel(Constants.SYNCOPE, syncopeTopologyNode, false));

Map<Serializable, Map<Serializable, TopologyNode>> connections = new HashMap<>();
Map<Serializable, TopologyNode> syncopeConnections = new HashMap<>();
connections.put(syncopeTopologyNode.getKey(), syncopeConnections);
Map<String, Map<String, TopologyNode>> connections = new HashMap<>();
Map<String, TopologyNode> syncopeConnections = new HashMap<>();
connections.put(sanitizeMarkupId(syncopeTopologyNode.getKey()), syncopeConnections);

// required to retrieve parent positions
Map<String, TopologyNode> servers = new HashMap<>();
Expand Down Expand Up @@ -273,8 +277,8 @@ protected void populateItem(final ListItem<URI> item) {

item.add(topologyNodePanel("cs", topologynode, false));

syncopeConnections.put(url, topologynode);
connections.put(url, new HashMap<>());
syncopeConnections.put(sanitizeMarkupId(url), topologynode);
connections.put(sanitizeMarkupId(url), new HashMap<>());
}
};

Expand Down Expand Up @@ -312,8 +316,8 @@ protected void populateItem(final ListItem<URI> item) {

item.add(topologyNodePanel("fp", topologynode, false));

syncopeConnections.put(url, topologynode);
connections.put(url, new HashMap<>());
syncopeConnections.put(sanitizeMarkupId(url), topologynode);
connections.put(sanitizeMarkupId(url), new HashMap<>());
}
};

Expand Down Expand Up @@ -369,7 +373,7 @@ protected void populateItem(final ListItem<ConnInstanceTO> item) {
item.add(topologyNodePanel("conn", topologynode, conn.isErrored()));

// Update connections
Map<Serializable, TopologyNode> remoteConnections;
Map<String, TopologyNode> remoteConnections;
if (connections.containsKey(conn.getLocation())) {
remoteConnections = connections.get(conn.getLocation());
} else {
Expand Down Expand Up @@ -404,7 +408,7 @@ protected void populateItem(final ListItem<ConnInstanceTO> item) {
TopologyNode topologynode = new TopologyNode(
resourceTO.getKey(), resourceTO.getKey(), TopologyNode.Kind.RESOURCE);

Map<Serializable, TopologyNode> remoteConnections;
Map<String, TopologyNode> remoteConnections;
if (connections.containsKey(resourceTO.getConnector())) {
remoteConnections = connections.get(resourceTO.getConnector());
} else {
Expand Down Expand Up @@ -480,10 +484,11 @@ protected void populateItem(final ListItem<TopologyNode> item) {

@Override
public void renderHead(final Component component, final IHeaderResponse response) {
final StringBuilder jsPlumbConf = new StringBuilder();
jsPlumbConf.append(String.format(Locale.US, "activate(%.2f);", 0.68f));
StringBuilder jsPlumbConf = new StringBuilder(String.format(Locale.US, "activate(%.2f);", 0.68f));

connections.forEach((key, value) -> value.forEach((label, node) -> jsPlumbConf.append(
"connect('%s','%s','%s');".formatted(sanitizeMarkupId(key), label, node.getKind()))));

createConnections(connections).forEach(jsPlumbConf::append);
jsPlumbConf.append("restoreTopologyLayout();");

response.render(OnDomReadyHeaderItem.forScript(jsPlumbConf.toString()));
Expand Down Expand Up @@ -538,18 +543,9 @@ protected void populateItem(final ListItem<TopologyNode> item) {
newlyCreatedContainer.add(newlyCreated);
}

private static List<String> createConnections(final Map<Serializable, Map<Serializable, TopologyNode>> targets) {
List<String> list = new ArrayList<>();

targets.forEach((key, value) -> value.forEach((label, node) -> list.add(
"connect('%s','%s','%s');".formatted(key, label, node.getKind()))));

return list;
}

private TopologyNodePanel topologyNodePanel(final String id, final TopologyNode node, final boolean errored) {
TopologyNodePanel panel = new TopologyNodePanel(id, node, errored);
panel.setMarkupId(String.valueOf(node.getKey()));
panel.setMarkupId(sanitizeMarkupId(node.getKey()));
panel.setOutputMarkupId(true);

List<Behavior> behaviors = new ArrayList<>();
Expand All @@ -561,7 +557,7 @@ private TopologyNodePanel topologyNodePanel(final String id, final TopologyNode
@Override
public void renderHead(final Component component, final IHeaderResponse response) {
response.render(OnDomReadyHeaderItem.forScript("setPosition('%s', %d, %d)".
formatted(node.getKey(), node.getX(), node.getY())));
formatted(sanitizeMarkupId(node.getKey()), node.getX(), node.getY())));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public TopologyNodePanel(final String id, final TopologyNode node, final boolean
add(AttributeModifier.append("data-original-title", title));
}

this.setMarkupId(node.getDisplayName());
setMarkupId(Topology.sanitizeMarkupId(node.getDisplayName()));
}

@Override
Expand Down
25 changes: 2 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ under the License.
<jsplumb.version>2.0.7</jsplumb.version>
<chartjs.version>4.5.1</chartjs.version>

<wicket.version>10.12.0</wicket.version>
<wicketstuff.version>10.12.0</wicketstuff.version>
<wicket.version>11.0.0</wicket.version>
<wicketstuff.version>11.0.0-SNAPSHOT</wicketstuff.version>
<wicket-bootstrap.version>7.0.15</wicket-bootstrap.version>
<wicket-spring-boot.version>5.0.0</wicket-spring-boot.version>

Expand Down Expand Up @@ -2451,27 +2451,6 @@ under the License.
</plugins>
</build>
</profile>

<profile>
<id>jdk27</id>

<activation>
<jdk>[27,)</jdk>
</activation>

<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.17.8</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.17.8</version>
</dependency>
</dependencies>
</profile>
</profiles>

<modules>
Expand Down
Loading