Remove UUID parse from param processing workflow (#13065)

This commit is contained in:
Erik Böck 2026-04-28 04:13:05 -03:00 committed by GitHub
parent 6f4445c5c1
commit e2c13da419
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 25 additions and 33 deletions

View File

@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.inject.Inject;
@ -504,12 +503,6 @@ public abstract class BaseCmd {
}
public String getResourceUuid(String parameterName) {
UUID resourceUuid = CallContext.current().getApiResourceUuid(parameterName);
if (resourceUuid != null) {
return resourceUuid.toString();
}
return null;
return CallContext.current().getApiResourceUuid(parameterName);
}
}

View File

@ -63,7 +63,7 @@ public class CallContext {
private User user;
private long userId;
private final Map<Object, Object> context = new HashMap<Object, Object>();
private final Map<String, UUID> apiResourcesUuids = new HashMap<>();
private final Map<String, String> apiResourcesUuids = new HashMap<>();
private Project project;
private String apiName;
@ -389,11 +389,11 @@ public class CallContext {
isEventDisplayEnabled = eventDisplayEnabled;
}
public UUID getApiResourceUuid(String paramName) {
public String getApiResourceUuid(String paramName) {
return apiResourcesUuids.get(paramName);
}
public void putApiResourceUuid(String paramName, UUID uuid) {
public void putApiResourceUuid(String paramName, String uuid) {
apiResourcesUuids.put(paramName, uuid);
}

View File

@ -40,7 +40,7 @@ public class CreateIpv4SubnetForGuestNetworkCmdTest {
@Test
public void testCreateIpv4SubnetForGuestNetworkCmd() {
Long parentId = 1L;
UUID parentUuid = UUID.randomUUID();
String parentUuid = UUID.randomUUID().toString();
String subnet = "192.168.1.0/24";
Integer cidrSize = 26;

View File

@ -40,7 +40,7 @@ public class CreateIpv4SubnetForZoneCmdTest {
@Test
public void testCreateIpv4SubnetForZoneCmd() {
Long zoneId = 1L;
UUID zoneUuid = UUID.randomUUID();
String zoneUuid = UUID.randomUUID().toString();
String subnet = "192.168.1.0/24";
String accountName = "user";
Long projectId = 10L;

View File

@ -39,7 +39,7 @@ public class DedicateIpv4SubnetForZoneCmdTest {
@Test
public void testDedicateIpv4SubnetForZoneCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
String accountName = "user";
Long projectId = 10L;
Long domainId = 11L;

View File

@ -39,7 +39,7 @@ public class DeleteIpv4SubnetForGuestNetworkCmdTest {
@Test
public void testDeleteIpv4SubnetForGuestNetworkCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
DeleteIpv4SubnetForGuestNetworkCmd cmd = new DeleteIpv4SubnetForGuestNetworkCmd();
ReflectionTestUtils.setField(cmd, "id", id);

View File

@ -39,7 +39,7 @@ public class DeleteIpv4SubnetForZoneCmdTest {
@Test
public void testDeleteIpv4SubnetForZoneCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
DeleteIpv4SubnetForZoneCmd cmd = new DeleteIpv4SubnetForZoneCmd();
ReflectionTestUtils.setField(cmd, "id", id);

View File

@ -39,7 +39,7 @@ public class ReleaseDedicatedIpv4SubnetForZoneCmdTest {
@Test
public void testReleaseDedicatedIpv4SubnetForZoneCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
ReleaseDedicatedIpv4SubnetForZoneCmd cmd = new ReleaseDedicatedIpv4SubnetForZoneCmd();
ReflectionTestUtils.setField(cmd, "id", id);

View File

@ -40,7 +40,7 @@ public class UpdateIpv4SubnetForZoneCmdTest {
@Test
public void testUpdateIpv4SubnetForZoneCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
String subnet = "192.168.1.0/24";
UpdateIpv4SubnetForZoneCmd cmd = new UpdateIpv4SubnetForZoneCmd();

View File

@ -46,7 +46,7 @@ public class ChangeBgpPeersForNetworkCmdTest {
@Test
public void testChangeBgpPeersForNetworkCmd() {
Long networkId = 10L;
UUID networkUuid = UUID.randomUUID();
String networkUuid = UUID.randomUUID().toString();
List<Long> bgpPeerIds = Arrays.asList(20L, 21L);
ChangeBgpPeersForNetworkCmd cmd = new ChangeBgpPeersForNetworkCmd();

View File

@ -46,7 +46,7 @@ public class ChangeBgpPeersForVpcCmdTest {
@Test
public void testChangeBgpPeersForVpcCmd() {
Long VpcId = 10L;
UUID vpcUuid = UUID.randomUUID();
String vpcUuid = UUID.randomUUID().toString();
List<Long> bgpPeerIds = Arrays.asList(20L, 21L);
ChangeBgpPeersForVpcCmd cmd = new ChangeBgpPeersForVpcCmd();

View File

@ -40,7 +40,7 @@ public class CreateBgpPeerCmdTest {
@Test
public void testCreateBgpPeerCmd() {
Long zoneId = 1L;
UUID zoneUuid = UUID.randomUUID();
String zoneUuid = UUID.randomUUID().toString();
String accountName = "user";
Long projectId = 10L;
Long domainId = 11L;

View File

@ -39,7 +39,7 @@ public class DedicateBgpPeerCmdTest {
@Test
public void testDedicateBgpPeerCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
String accountName = "user";
Long projectId = 10L;
Long domainId = 11L;

View File

@ -39,7 +39,7 @@ public class DeleteBgpPeerCmdTest {
@Test
public void testDeleteBgpPeerCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
DeleteBgpPeerCmd cmd = new DeleteBgpPeerCmd();
ReflectionTestUtils.setField(cmd, "id", id);

View File

@ -39,7 +39,7 @@ public class ReleaseDedicatedBgpPeerCmdTest {
@Test
public void testReleaseDedicatedBgpPeerCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
ReleaseDedicatedBgpPeerCmd cmd = new ReleaseDedicatedBgpPeerCmd();
ReflectionTestUtils.setField(cmd, "id", id);

View File

@ -40,7 +40,7 @@ public class UpdateBgpPeerCmdTest {
@Test
public void testUpdateBgpPeerCmd() {
Long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
String ip4Address = "ip4-address";
String ip6Address = "ip6-address";
Long peerAsNumber = 15000L;

View File

@ -97,7 +97,7 @@ public class DownloadImageStoreObjectCmdTest {
@Test
public void testGetEventDescription() {
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
ReflectionTestUtils.setField(cmd, "storeId", 1L);
ReflectionTestUtils.setField(cmd, "path", "path/to/object");

View File

@ -44,7 +44,7 @@ public class UnmanageVolumeCmdTest {
public void testUnmanageVolumeCmd() {
long accountId = 2L;
Long volumeId = 3L;
UUID volumeUuid = UUID.randomUUID();
String volumeUuid = UUID.randomUUID().toString();
Volume volume = Mockito.mock(Volume.class);
Mockito.when(responseGenerator.findVolumeById(volumeId)).thenReturn(volume);

View File

@ -118,7 +118,7 @@ public class CreateSnapshotCmdTest extends TestCase {
AccountService accountService = Mockito.mock(AccountService.class);
Account account = Mockito.mock(Account.class);
Mockito.when(accountService.getAccount(anyLong())).thenReturn(account);
UUID volumeUuid = UUID.randomUUID();
String volumeUuid = UUID.randomUUID().toString();
CallContext.current().putApiResourceUuid("volumeid", volumeUuid);

View File

@ -56,7 +56,7 @@ public class UpdateConditionCmdTest {
private static final Long threshold = 100L;
private static final long accountId = 5L;
private static final UUID conditionUuid = UUID.randomUUID();
private static final String conditionUuid = UUID.randomUUID().toString();
@Before
public void setUp() {

View File

@ -49,7 +49,7 @@ public class DeleteRoutingFirewallRuleCmdTest {
ReflectionTestUtils.setField(cmd, "_firewallService", _firewallService);
long id = 1L;
UUID uuid = UUID.randomUUID();
String uuid = UUID.randomUUID().toString();
long accountId = 2L;
long networkId = 3L;

View File

@ -28,7 +28,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.regex.Matcher;
import javax.inject.Inject;
@ -526,7 +525,7 @@ public class ParamProcessWorker implements DispatchWorker {
continue;
}
String entityUuid = ((Identity) objVO).getUuid();
CallContext.current().putApiResourceUuid(annotation.name(), UUID.fromString(entityUuid));
CallContext.current().putApiResourceUuid(annotation.name(), entityUuid);
}
validateNaturalNumber(internalId, annotation.name());
return internalId;
@ -551,7 +550,7 @@ public class ParamProcessWorker implements DispatchWorker {
}
// Return on first non-null Id for the uuid entity
if (internalId != null){
CallContext.current().putApiResourceUuid(annotation.name(), UUID.fromString(uuid));
CallContext.current().putApiResourceUuid(annotation.name(), uuid);
CallContext.current().putContextParameter(entity, uuid);
break;
}