Skip to content

Commit f901c6f

Browse files
committed
change logic to use the UUID translations flow
1 parent fc2d459 commit f901c6f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

api/src/main/java/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public Map<String, String> convertExternalDetailsToMap(Map externalDetails) {
501501
}
502502

503503
public String getResourceUuid(String parameterName) {
504-
String resourceUuid = fullUrlParams.get(parameterName);
504+
String resourceUuid = CallContext.current().getApiResourceUuid(parameterName);
505505

506506
if (UuidUtils.isUuid(resourceUuid)) {
507507
return resourceUuid;

api/src/main/java/org/apache/cloudstack/context/CallContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ protected Stack<CallContext> initialValue() {
6363
private User user;
6464
private long userId;
6565
private final Map<Object, Object> context = new HashMap<Object, Object>();
66+
private final Map<String, String > apiResourcesUuids = new HashMap<>();
6667
private Project project;
6768
private String apiName;
6869

@@ -388,6 +389,14 @@ public void setEventDisplayEnabled(boolean eventDisplayEnabled) {
388389
isEventDisplayEnabled = eventDisplayEnabled;
389390
}
390391

392+
public String getApiResourceUuid(String paramName) {
393+
return apiResourcesUuids.get(paramName);
394+
}
395+
396+
public void putApiResourceUuid(String paramName, String uuid) {
397+
apiResourcesUuids.put(paramName, uuid);
398+
}
399+
391400
public Map<Object, Object> getContextParameters() {
392401
return context;
393402
}

server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@ private Long translateUuidToInternalId(final String uuid, final Parameter annota
532532
// Populate CallContext for each of the entity.
533533
for (final Class<?> entity : entities) {
534534
CallContext.current().putContextParameter(entity, internalId);
535+
final Object objVO = _entityMgr.findByUuidIncludingRemoved(entity, uuid);
536+
if (objVO == null) {
537+
continue;
538+
}
539+
CallContext.current().putApiResourceUuid(annotation.name(), uuid);
535540
}
536541
validateNaturalNumber(internalId, annotation.name());
537542
return internalId;
@@ -556,6 +561,7 @@ private Long translateUuidToInternalId(final String uuid, final Parameter annota
556561
}
557562
// Return on first non-null Id for the uuid entity
558563
if (internalId != null){
564+
CallContext.current().putApiResourceUuid(annotation.name(), uuid);
559565
CallContext.current().putContextParameter(entity, uuid);
560566
break;
561567
}

0 commit comments

Comments
 (0)