mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6895: 1. Populate firstclass entities as uuids in the context instead of dbids for performance.
2. Add ctxDetails in the ParamGenericValidationWorker to avoid warning for api validation
3. Add some missing events.
4. Correcting mapping for ResourceObjectType.NetworkACL and ResourceObjectType.NetworkACLItem
(cherry picked from commit 8a9092c3cd)
This commit is contained in:
parent
f657de5401
commit
745ba5cd49
|
|
@ -20,12 +20,14 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Site2SiteCustomerGateway;
|
||||
import com.cloud.network.Site2SiteVpnGateway;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.network.vpc.NetworkACL;
|
||||
import com.cloud.network.vpc.NetworkACLItem;
|
||||
import com.cloud.network.Site2SiteVpnConnection;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.vm.ConsoleProxy;
|
||||
import com.cloud.vm.SecondaryStorageVm;
|
||||
|
|
@ -572,7 +574,7 @@ public class EventTypes {
|
|||
entityEventDetails.put(EVENT_ASSIGN_TO_LOAD_BALANCER_RULE, FirewallRule.class);
|
||||
entityEventDetails.put(EVENT_REMOVE_FROM_LOAD_BALANCER_RULE, FirewallRule.class);
|
||||
entityEventDetails.put(EVENT_LOAD_BALANCER_CREATE, LoadBalancer.class);
|
||||
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, LoadBalancer.class);
|
||||
entityEventDetails.put(EVENT_LOAD_BALANCER_DELETE, FirewallRule.class);
|
||||
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_CREATE, StickinessPolicy.class);
|
||||
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_UPDATE, StickinessPolicy.class);
|
||||
entityEventDetails.put(EVENT_LB_STICKINESSPOLICY_DELETE, StickinessPolicy.class);
|
||||
|
|
@ -720,12 +722,12 @@ public class EventTypes {
|
|||
entityEventDetails.put(EVENT_VPN_USER_REMOVE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_CREATE, Site2SiteVpnGateway.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_GATEWAY_DELETE, Site2SiteVpnGateway.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, RemoteAccessVpn.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE, Site2SiteCustomerGateway.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE, Site2SiteCustomerGateway.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE, Site2SiteCustomerGateway.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_CREATE, Site2SiteVpnConnection.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_DELETE, Site2SiteVpnConnection.class);
|
||||
entityEventDetails.put(EVENT_S2S_VPN_CONNECTION_RESET, Site2SiteVpnConnection.class);
|
||||
|
||||
// Custom certificates
|
||||
entityEventDetails.put(EVENT_UPLOAD_CUSTOM_CERTIFICATE, "Certificate");
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ public abstract class BaseCmd {
|
|||
Object key = entry.getKey();
|
||||
Class clz = Class.forName((String)key);
|
||||
if(Displayable.class.isAssignableFrom(clz)){
|
||||
final Object objVO = _entityMgr.findById(clz, getInternalId(entry.getValue()));
|
||||
final Object objVO = getEntityVO(clz, entry.getValue());
|
||||
isDisplay = ((Displayable) objVO).isDisplay();
|
||||
}
|
||||
|
||||
|
|
@ -388,17 +388,25 @@ public abstract class BaseCmd {
|
|||
|
||||
}
|
||||
|
||||
private static Long getInternalId(Object internalIdObj){
|
||||
Long internalId = null;
|
||||
private Object getEntityVO(Class entityType, Object entityId){
|
||||
|
||||
// In case its an async job the value would be a string because of json deserialization
|
||||
if(internalIdObj instanceof String){
|
||||
internalId = Long.valueOf((String) internalIdObj);
|
||||
}else if (internalIdObj instanceof Long){
|
||||
internalId = (Long) internalIdObj;
|
||||
// entityId can be internal db id or UUID so accordingly call findbyId or findByUUID
|
||||
|
||||
if (entityId instanceof Long){
|
||||
// Its internal db id - use findById
|
||||
return _entityMgr.findById(entityType, (Long)entityId);
|
||||
} else if(entityId instanceof String){
|
||||
try{
|
||||
// In case its an async job the internal db id would be a string because of json deserialization
|
||||
Long internalId = Long.valueOf((String) entityId);
|
||||
return _entityMgr.findById(entityType, internalId);
|
||||
} catch (NumberFormatException e){
|
||||
// It is uuid - use findByUuid`
|
||||
return _entityMgr.findByUuid(entityType, (String)entityId);
|
||||
}
|
||||
}
|
||||
|
||||
return internalId;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue