ARTEMIS-565 fix more broken Json stuff
This commit is contained in:
parent
41d87490f7
commit
1de4dbbe27
|
@ -40,8 +40,8 @@ public class JMSConnectionInfo {
|
||||||
JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
|
JMSConnectionInfo[] infos = new JMSConnectionInfo[array.size()];
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
JsonObject obj = array.getJsonObject(i);
|
JsonObject obj = array.getJsonObject(i);
|
||||||
String cid = obj.isNull("clientID") ? null : obj.getString("clientID");
|
String cid = obj.containsKey("clientID") ? obj.getString("clientID") : null;
|
||||||
String uname = obj.isNull("principal") ? null : obj.getString("principal");
|
String uname = obj.containsKey("principal") ? obj.getString("principal") : null;
|
||||||
|
|
||||||
JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"),
|
JMSConnectionInfo info = new JMSConnectionInfo(obj.getString("connectionID"), obj.getString("clientAddress"),
|
||||||
obj.getJsonNumber("creationTime").longValue(),
|
obj.getJsonNumber("creationTime").longValue(),
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class JMSConsumerInfo {
|
||||||
JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
|
JMSConsumerInfo[] infos = new JMSConsumerInfo[array.size()];
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
JsonObject sub = array.getJsonObject(i);
|
JsonObject sub = array.getJsonObject(i);
|
||||||
JMSConsumerInfo info = new JMSConsumerInfo(sub.getString("consumerID"), sub.getString("connectionID"),
|
JMSConsumerInfo info = new JMSConsumerInfo(sub.getJsonNumber("consumerID").toString(), sub.getString("connectionID"),
|
||||||
sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"),
|
sub.getString("destinationName"), sub.getString("destinationType"), sub.getBoolean("browseOnly"),
|
||||||
sub.getJsonNumber("creationTime").longValue(),
|
sub.getJsonNumber("creationTime").longValue(),
|
||||||
sub.getBoolean("durable"), sub.getString("filter", null));
|
sub.getBoolean("durable"), sub.getString("filter", null));
|
||||||
|
|
|
@ -620,15 +620,20 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
|
||||||
for (RemotingConnection connection : connections) {
|
for (RemotingConnection connection : connections) {
|
||||||
ServerSession session = jmsSessions.get(connection.getID());
|
ServerSession session = jmsSessions.get(connection.getID());
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
JsonObject obj = Json.createObjectBuilder()
|
JsonObjectBuilder objectBuilder = Json.createObjectBuilder()
|
||||||
.add("connectionID", connection.getID().toString())
|
.add("connectionID", connection.getID().toString())
|
||||||
.add("clientAddress", connection.getRemoteAddress())
|
.add("clientAddress", connection.getRemoteAddress())
|
||||||
.add("creationTime", connection.getCreationTime())
|
.add("creationTime", connection.getCreationTime());
|
||||||
// Notice: this will be null when the user haven't set the client-id
|
|
||||||
.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY))
|
if (session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY) != null) {
|
||||||
.add("principal", session.getUsername())
|
objectBuilder.add("clientID", session.getMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY));
|
||||||
.build();
|
}
|
||||||
array.add(obj);
|
|
||||||
|
if (session.getUsername() != null) {
|
||||||
|
objectBuilder.add("principal", session.getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
array.add(objectBuilder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.build().toString();
|
return array.build().toString();
|
||||||
|
@ -651,8 +656,15 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
|
||||||
for (RemotingConnection connection : connections) {
|
for (RemotingConnection connection : connections) {
|
||||||
if (connectionID.equals(connection.getID().toString())) {
|
if (connectionID.equals(connection.getID().toString())) {
|
||||||
List<ServerSession> sessions = server.getActiveMQServer().getSessions(connectionID);
|
List<ServerSession> sessions = server.getActiveMQServer().getSessions(connectionID);
|
||||||
JsonArray jsonSessions = toJsonArray(sessions);
|
for (ServerSession session : sessions) {
|
||||||
array.add(jsonSessions);
|
Set<ServerConsumer> consumers = session.getServerConsumers();
|
||||||
|
for (ServerConsumer consumer : consumers) {
|
||||||
|
JsonObject obj = toJSONObject(consumer);
|
||||||
|
if (obj != null) {
|
||||||
|
array.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array.build().toString();
|
return array.build().toString();
|
||||||
|
|
|
@ -1398,8 +1398,12 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
||||||
JsonObjectBuilder obj = Json.createObjectBuilder()
|
JsonObjectBuilder obj = Json.createObjectBuilder()
|
||||||
.add("sessionID", sess.getName())
|
.add("sessionID", sess.getName())
|
||||||
.add("creationTime", sess.getCreationTime())
|
.add("creationTime", sess.getCreationTime())
|
||||||
.add("principal", sess.getValidatedUser())
|
|
||||||
.add("consumerCount", sess.getServerConsumers().size());
|
.add("consumerCount", sess.getServerConsumers().size());
|
||||||
|
|
||||||
|
if (sess.getValidatedUser() != null) {
|
||||||
|
obj.add("principal", sess.getValidatedUser());
|
||||||
|
}
|
||||||
|
|
||||||
array.add(obj);
|
array.add(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue