mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
server: Replace Hashtable with LinkedHashMap in createIsoResponse (#7844)
* Replace Hashtable with LinkedHashMap in createIsoResponse This change replaces the use of Hashtable with LinkedHashMap in the `createIsoResponse` method of `ViewResponseHelper`. The reason for this modification is to maintain the insertion order of entries, which isn't the case with Hashtable. This could lead to more predictable results and behaviors in calling methods. * Replace Hashtable with LinkedHashMap in view response creation methods Changed Hashtable to LinkedHashMap in various response creation methods within ViewResponseHelper class. This modification ensures an ordered iteration which is beneficial for scenarios where the insertion order of responses needs to be maintained consistently. --------- Co-authored-by: Sina Kashipazha <soreana@users.noreply.github.com>
This commit is contained in:
parent
cf249f64a3
commit
e8b491177f
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -150,7 +149,7 @@ public class ViewResponseHelper {
|
||||
public static List<UserVmResponse> createUserVmResponse(ResponseView view, String objectName, Set<VMDetails> details, Boolean accumulateStats, Boolean showUserData,
|
||||
UserVmJoinVO... userVms) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
|
||||
LinkedHashMap<Long, UserVmResponse> vmDataList = new LinkedHashMap<>();
|
||||
// Initialise the vmdatalist with the input data
|
||||
|
||||
for (UserVmJoinVO userVm : userVms) {
|
||||
@ -169,7 +168,7 @@ public class ViewResponseHelper {
|
||||
|
||||
public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
|
||||
LinkedHashMap<Long, DomainRouterResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (DomainRouterJoinVO vr : routers) {
|
||||
DomainRouterResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -187,7 +186,7 @@ public class ViewResponseHelper {
|
||||
|
||||
public static List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
|
||||
LinkedHashMap<Long, SecurityGroupResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (SecurityGroupJoinVO vr : securityGroups) {
|
||||
SecurityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -205,7 +204,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<ProjectResponse> createProjectResponse(EnumSet<DomainDetails> details, ProjectJoinVO... projects) {
|
||||
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
|
||||
LinkedHashMap<Long, ProjectResponse> prjDataList = new LinkedHashMap<>();
|
||||
// Initialise the prjdatalist with the input data
|
||||
for (ProjectJoinVO p : projects) {
|
||||
ProjectResponse pData = prjDataList.get(p.getId());
|
||||
@ -247,7 +246,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<HostResponse> createHostResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
|
||||
Hashtable<Long, HostResponse> vrDataList = new Hashtable<Long, HostResponse>();
|
||||
LinkedHashMap<Long, HostResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (HostJoinVO vr : hosts) {
|
||||
HostResponse vrData = ApiDBUtils.newHostResponse(vr, details);
|
||||
@ -257,7 +256,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<HostForMigrationResponse> createHostForMigrationResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
|
||||
Hashtable<Long, HostForMigrationResponse> vrDataList = new Hashtable<Long, HostForMigrationResponse>();
|
||||
LinkedHashMap<Long, HostForMigrationResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (HostJoinVO vr : hosts) {
|
||||
HostForMigrationResponse vrData = ApiDBUtils.newHostForMigrationResponse(vr, details);
|
||||
@ -267,7 +266,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
|
||||
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
|
||||
LinkedHashMap<Long, VolumeResponse> vrDataList = new LinkedHashMap<>();
|
||||
DecimalFormat df = new DecimalFormat("0.0%");
|
||||
for (VolumeJoinVO vr : volumes) {
|
||||
VolumeResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -308,7 +307,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<StoragePoolResponse> createStoragePoolResponse(StoragePoolJoinVO... pools) {
|
||||
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
|
||||
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (StoragePoolJoinVO vr : pools) {
|
||||
StoragePoolResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -345,7 +344,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO... stores) {
|
||||
Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<Long, ImageStoreResponse>();
|
||||
LinkedHashMap<Long, ImageStoreResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (ImageStoreJoinVO vr : stores) {
|
||||
ImageStoreResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -362,7 +361,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
|
||||
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
|
||||
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
|
||||
// Initialise the vrdatalist with the input data
|
||||
for (StoragePoolJoinVO vr : pools) {
|
||||
StoragePoolResponse vrData = vrDataList.get(vr.getId());
|
||||
@ -577,7 +576,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<TemplateResponse> createTemplateResponse(EnumSet<ApiConstants.DomainDetails> detailsView, ResponseView view, TemplateJoinVO... templates) {
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<String, TemplateResponse>();
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
|
||||
if (vrData == null) {
|
||||
@ -594,7 +593,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<TemplateResponse> createTemplateUpdateResponse(ResponseView view, TemplateJoinVO... templates) {
|
||||
Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
|
||||
LinkedHashMap<Long, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getId());
|
||||
if (vrData == null) {
|
||||
@ -610,7 +609,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<TemplateResponse> createIsoResponse(ResponseView view, TemplateJoinVO... templates) {
|
||||
Hashtable<String, TemplateResponse> vrDataList = new Hashtable<>();
|
||||
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (TemplateJoinVO vr : templates) {
|
||||
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
|
||||
if (vrData == null) {
|
||||
@ -626,7 +625,7 @@ public class ViewResponseHelper {
|
||||
}
|
||||
|
||||
public static List<AffinityGroupResponse> createAffinityGroupResponses(List<AffinityGroupJoinVO> groups) {
|
||||
Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<Long, AffinityGroupResponse>();
|
||||
LinkedHashMap<Long, AffinityGroupResponse> vrDataList = new LinkedHashMap<>();
|
||||
for (AffinityGroupJoinVO vr : groups) {
|
||||
AffinityGroupResponse vrData = vrDataList.get(vr.getId());
|
||||
if (vrData == null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user