Skip to content

Commit 74303f8

Browse files
committed
normalize descriptions to use string contatenation and enhance some descriptions
1 parent 6d93d41 commit 74303f8

File tree

11 files changed

+33
-45
lines changed

11 files changed

+33
-45
lines changed

api/src/main/java/org/apache/cloudstack/api/command/admin/network/MigrateNetworkCmd.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void execute() {
115115

116116
@Override
117117
public String getEventDescription() {
118-
StringBuilder eventMsg = new StringBuilder("Migrating network with ID: " + getResourceUuid(ApiConstants.NETWORK_ID));
118+
String description = "Migrating network with ID: " + getResourceUuid(ApiConstants.NETWORK_ID);
119119
if (getNetworkOfferingId() != null) {
120120
Network network = _networkService.getNetwork(getId());
121121
if (network == null) {
@@ -128,11 +128,11 @@ public String getEventDescription() {
128128
throw new InvalidParameterValueException("Network offering id supplied is invalid");
129129
}
130130

131-
eventMsg.append(". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid());
131+
description += ". Original network offering id: " + oldOff.getUuid() + ", new network offering id: " + newOff.getUuid();
132132
}
133133
}
134134

135-
return eventMsg.toString();
135+
return description;
136136
}
137137

138138
@Override

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/MigrateVMCmd.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ public String getEventType() {
124124

125125
@Override
126126
public String getEventDescription() {
127-
String eventDescription;
127+
String description = "Attempting to migrate VM with ID: " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
128+
128129
if (getHostId() != null) {
129-
eventDescription = String.format("Attempting to migrate VM with ID: %s to host with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID), getResourceUuid(ApiConstants.HOST_ID));
130+
description += " to host with ID: " +getResourceUuid(ApiConstants.HOST_ID);
130131
} else if (getStoragePoolId() != null) {
131-
eventDescription = String.format("Attempting to migrate VM with ID: %s to storage pool with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID), getResourceUuid(ApiConstants.STORAGE_ID));
132-
} else {
133-
eventDescription = String.format("Attempting to migrate VM with ID: %s", getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID));
132+
description = " to storage pool with ID: " + getResourceUuid(ApiConstants.STORAGE_ID);
134133
}
135-
return eventDescription;
134+
135+
return description;
136136
}
137137

138138
@Override

api/src/main/java/org/apache/cloudstack/api/command/admin/volume/UnmanageVolumeCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public String getEventType() {
8181

8282
@Override
8383
public String getEventDescription() {
84-
return String.format("Unmanaging Volume with ID %s", getResourceUuid(ApiConstants.ID));
84+
return "Unmanaging Volume with ID: " + getResourceUuid(ApiConstants.ID);
8585
}
8686

8787
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,21 @@ public String getEventType() {
136136

137137
@Override
138138
public String getEventDescription() {
139-
StringBuilder descBuilder = new StringBuilder("Copying template: " + getResourceUuid(ApiConstants.ID));
139+
String description = "Copying template: " + getResourceUuid(ApiConstants.ID);
140140

141141
if (getSourceZoneId() != null) {
142-
descBuilder.append(" from zone: ").append(getResourceUuid(ApiConstants.SOURCE_ZONE_ID));
142+
description += " from zone: " + getResourceUuid(ApiConstants.SOURCE_ZONE_ID);
143143
}
144144

145145
if (getDestinationZoneIds() != null) {
146-
descBuilder.append(" to zones: ");
146+
description += " to zones: ";
147147
for (Long destId : getDestinationZoneIds()) {
148-
descBuilder.append(this._uuidMgr.getUuid(DataCenter.class, destId));
149-
descBuilder.append(", ");
148+
description += this._uuidMgr.getUuid(DataCenter.class, destId);
149+
description += ", ";
150150
}
151151
}
152152

153-
return descBuilder.toString();
153+
return description;
154154
}
155155

156156
@Override

api/src/main/java/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ public String getEventType() {
100100

101101
@Override
102102
public String getEventDescription() {
103-
String baseDescription = String.format("Extracting template with ID: %s", getResourceUuid(ApiConstants.ID));
103+
String description = "Extracting template with ID: " + getResourceUuid(ApiConstants.ID);
104104

105105
Long zoneId = getZoneId();
106-
if (zoneId == null) {
107-
return baseDescription;
106+
if (zoneId != null) {
107+
description += "from zone with ID: " + getResourceUuid(ApiConstants.ZONE_ID);
108108
}
109109

110-
return String.format("%s from zone with ID: %s", baseDescription, getResourceUuid(ApiConstants.ZONE_ID));
110+
return description;
111111
}
112112

113113
@Override

api/src/main/java/org/apache/cloudstack/api/command/user/volume/CheckAndRepairVolumeCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public String getEventType() {
105105

106106
@Override
107107
public String getEventDescription() {
108-
return String.format("Starting checking and repairing operation on volume: %s", getResourceUuid(ApiConstants.ID));
108+
return "Starting checking and repairing operation on volume: " + getResourceUuid(ApiConstants.ID);
109109
}
110110

111111
@Override

api/src/main/java/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,19 @@ public String getEventType() {
126126

127127
@Override
128128
public String getEventDescription() {
129-
StringBuilder sb = new StringBuilder("Detaching volume");
129+
String description = "Detaching volume";
130130

131131
if (id != null) {
132-
sb.append(": ").append(getResourceUuid(ApiConstants.ID));
133-
} else if ((deviceId != null) && (virtualMachineId != null)) {
134-
sb.append(" with device id: ").append(deviceId).append(" from vm: ").append((getVirtualMachineId() != null) ? getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID) : "");
132+
description += ": " + getResourceUuid(ApiConstants.ID);
133+
}
134+
135+
if ((deviceId != null) && (virtualMachineId != null)) {
136+
description += " with device id: " + deviceId + " from vm: " + getResourceUuid(ApiConstants.VIRTUAL_MACHINE_ID);
135137
} else {
136-
sb.append(" <error: either volume id or deviceId/vmId need to be specified>");
138+
description += " <error: either volume id or deviceId/vmId need to be specified>";
137139
}
138140

139-
return sb.toString();
141+
return description;
140142
}
141143

142144
@Override

plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/AddNodesToKubernetesClusterCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public String getEventType() {
9999

100100
@Override
101101
public String getEventDescription() {
102-
return String.format("Adding %s nodes to the Kubernetes cluster with ID: %s", nodeIds.size(), getResourceUuid(ApiConstants.ID));
102+
return "Adding " + nodeIds.size() + " nodes to Kubernetes cluster with ID: " + getResourceUuid(ApiConstants.ID);
103103
}
104104

105105
@Override

plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/DeleteKubernetesClusterCmd.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ public Long getApiResourceId() {
126126

127127
@Override
128128
public String getEventDescription() {
129-
String description = "Deleting Kubernetes cluster";
130-
KubernetesCluster cluster = _entityMgr.findById(KubernetesCluster.class, getId());
131-
if (cluster != null) {
132-
description += String.format(" with ID: %s", cluster.getUuid());
133-
} else {
134-
description += String.format(" with ID: %s", getResourceUuid(ApiConstants.ID));
135-
}
136-
return description;
129+
return "Deleting Kubernetes cluster with ID: " + getResourceUuid(ApiConstants.ID);
137130
}
138131

139132
}

plugins/integrations/kubernetes-service/src/main/java/org/apache/cloudstack/api/command/user/kubernetes/cluster/RemoveNodesFromKubernetesClusterCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public String getEventType() {
8989

9090
@Override
9191
public String getEventDescription() {
92-
return String.format("Removing %s nodes from the Kubernetes Cluster with ID: %s", nodeIds.size(), getResourceUuid(ApiConstants.ID));
92+
return "Removing " + nodeIds.size() + " nodes from the Kubernetes Cluster with ID: " + getResourceUuid(ApiConstants.ID);
9393
}
9494

9595
@Override

0 commit comments

Comments
 (0)