diff --git a/api/src/com/cloud/api/response/ExceptionResponse.java b/api/src/com/cloud/api/response/ExceptionResponse.java index b200f8c8170..3ceaf4eb6b9 100644 --- a/api/src/com/cloud/api/response/ExceptionResponse.java +++ b/api/src/com/cloud/api/response/ExceptionResponse.java @@ -47,10 +47,11 @@ public class ExceptionResponse extends BaseResponse { this.errorText = errorText; } - public void setProxyObject(String table_name, Long id) { + public void setProxyObject(String table_name, String idFieldName, Long id) { this.id = new IdentityProxy(); this.id.setTableName(table_name); this.id.setValue(id); + this.id.setidFieldName(idFieldName); return; } diff --git a/api/src/com/cloud/exception/CloudException.java b/api/src/com/cloud/exception/CloudException.java index 6b373e454d1..27b19e62cd0 100644 --- a/api/src/com/cloud/exception/CloudException.java +++ b/api/src/com/cloud/exception/CloudException.java @@ -52,10 +52,11 @@ public class CloudException extends Exception { super(); } - public void setProxyObject(String table_name, Long id) { + public void setProxyObject(String table_name, String idFieldName, Long id) { this.id = new IdentityProxy(); this.id.setTableName(table_name); this.id.setValue(id); + this.id.setidFieldName(idFieldName); return; } diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index f97b064b5e7..4e0e41f6d82 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -142,51 +142,51 @@ public class ApiDispatcher { // earlier, we'd log the db id as part of the log message, but now since we've pushed // the id into a IdentityProxy object, we would need to dump that object alongwith the // message. - InvalidParameterValueException ref = (InvalidParameterValueException)t; + InvalidParameterValueException ref = (InvalidParameterValueException) t; ServerApiException ex = new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getProxyObject(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); - s_logger.info(t.getMessage() + " uuid: " + id.getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); + s_logger.info(t.getMessage() + " db_id: " + id.getValue()); } else { s_logger.info(t.getMessage()); - } + } throw ex; - } else if(t instanceof IllegalArgumentException) { + } else if(t instanceof IllegalArgumentException) { throw new ServerApiException(BaseCmd.PARAM_ERROR, t.getMessage()); - } else if (t instanceof PermissionDeniedException) { + } else if (t instanceof PermissionDeniedException) { PermissionDeniedException ref = (PermissionDeniedException)t; ServerApiException ex = new ServerApiException(BaseCmd.ACCOUNT_ERROR, t.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getProxyObject(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); s_logger.info("PermissionDenied: " + t.getMessage() + "uuid: " + id.getValue()); } else { s_logger.info("PermissionDenied: " + t.getMessage()); } throw ex; - } else if (t instanceof AccountLimitException) { + } else if (t instanceof AccountLimitException) { AccountLimitException ref = (AccountLimitException)t; ServerApiException ex = new ServerApiException(BaseCmd.ACCOUNT_RESOURCE_LIMIT_ERROR, t.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getProxyObject(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); - s_logger.info(t.getMessage() + "uuid: " + id.getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); + s_logger.info(t.getMessage() + "db_id: " + id.getValue()); } else { s_logger.info(t.getMessage()); } throw ex; - } else if (t instanceof InsufficientCapacityException) { + } else if (t instanceof InsufficientCapacityException) { InsufficientCapacityException ref = (InsufficientCapacityException)t; ServerApiException ex = new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, t.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getIdProxy(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); - s_logger.info(t.getMessage() + "uuid: " + id.getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); + s_logger.info(t.getMessage() + "db_id: " + id.getValue()); } else { s_logger.info(t.getMessage()); } @@ -197,8 +197,8 @@ public class ApiDispatcher { // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getIdProxy(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); - s_logger.warn("Exception: " + t.getMessage() + "uuid: " + ref.getIdProxy().getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); + s_logger.warn("Exception: " + t.getMessage() + "db_id: " + ref.getIdProxy().getValue()); } else { s_logger.warn("Exception: ", t); } @@ -209,8 +209,8 @@ public class ApiDispatcher { // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getIdProxy(); if (id != null) { - ex.setProxyObject(id.getTableName(), id.getValue()); - s_logger.warn("Exception: " + t.getMessage() + "uuid: " + ref.getIdProxy().getValue()); + ex.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); + s_logger.warn("Exception: " + t.getMessage() + "db_id: " + ref.getIdProxy().getValue()); } else { s_logger.warn("Exception: ", t); } diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 43165f47d70..474d7905f1e 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -350,7 +350,7 @@ public class ApiServer implements HttpRequestHandler { writeResponse(response, responseText, HttpStatus.SC_OK, responseType, null); } catch (ServerApiException se) { - String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se); + String responseText = getSerializedApiError(se.getErrorCode(), se.getDescription(), parameterMap, responseType, se); writeResponse(response, responseText, se.getErrorCode(), responseType, se.getDescription()); sb.append(" " + se.getErrorCode() + " " + se.getDescription()); } catch (RuntimeException e) { @@ -432,8 +432,8 @@ public class ApiServer implements HttpRequestHandler { ServerApiException e = new ServerApiException(BaseCmd.PARAM_ERROR, ex.getMessage()); // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getProxyObject(); - if (id != null) { - e.setProxyObject(id.getTableName(), id.getValue()); + if (id != null) { + e.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); } throw e; } else if (ex instanceof PermissionDeniedException) { @@ -442,7 +442,7 @@ public class ApiServer implements HttpRequestHandler { // copy over the IdentityProxy information as well and throw the serverapiexception. IdentityProxy id = ref.getProxyObject(); if (id != null) { - e.setProxyObject(id.getTableName(), id.getValue()); + e.setProxyObject(id.getTableName(), id.getidFieldName(), id.getValue()); } throw e; } else if (ex instanceof ServerApiException) { @@ -1004,7 +1004,6 @@ public class ApiServer implements HttpRequestHandler { } } } - ExceptionResponse apiResponse = new ExceptionResponse(); apiResponse.setErrorCode(errorCode); apiResponse.setErrorText(errorText); @@ -1018,23 +1017,23 @@ public class ApiServer implements HttpRequestHandler { if (ex instanceof ServerApiException || ex instanceof PermissionDeniedException || ex instanceof InvalidParameterValueException) { // Cast the exception appropriately and retrieve the IdentityProxy - if (ex instanceof ServerApiException) { + if (ex instanceof ServerApiException) { ServerApiException ref = (ServerApiException) ex; IdentityProxy uuidproxy = ref.getProxyObject(); if (uuidproxy != null) { - apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getValue()); + apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getidFieldName(), uuidproxy.getValue()); } } else if (ex instanceof PermissionDeniedException) { PermissionDeniedException ref = (PermissionDeniedException) ex; IdentityProxy uuidproxy = ref.getProxyObject(); if (uuidproxy != null) { - apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getValue()); + apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getidFieldName(), uuidproxy.getValue()); } } else if (ex instanceof InvalidParameterValueException) { InvalidParameterValueException ref = (InvalidParameterValueException) ex; IdentityProxy uuidproxy = ref.getProxyObject(); if (uuidproxy != null) { - apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getValue()); + apiResponse.setProxyObject(uuidproxy.getTableName(), uuidproxy.getidFieldName(), uuidproxy.getValue()); } } } diff --git a/server/src/com/cloud/api/IdentityTypeAdapter.java b/server/src/com/cloud/api/IdentityTypeAdapter.java index 34d632a12e1..6078e50e58d 100644 --- a/server/src/com/cloud/api/IdentityTypeAdapter.java +++ b/server/src/com/cloud/api/IdentityTypeAdapter.java @@ -48,7 +48,7 @@ public class IdentityTypeAdapter implements JsonSerializer, JsonD if(uuid == null) return context.serialize(null); - return new JsonPrimitive(uuid); + return new JsonPrimitive(uuid); } else { return new JsonPrimitive(String.valueOf(src.getValue())); } diff --git a/server/src/com/cloud/api/response/ApiResponseSerializer.java b/server/src/com/cloud/api/response/ApiResponseSerializer.java index 3500a7f9433..1160818a07a 100644 --- a/server/src/com/cloud/api/response/ApiResponseSerializer.java +++ b/server/src/com/cloud/api/response/ApiResponseSerializer.java @@ -100,6 +100,16 @@ public class ApiResponseSerializer { String jsonErrorText = gson.toJson((ExceptionResponse) result); jsonErrorText = unescape(jsonErrorText); sb.append(jsonErrorText); + // Since the IdentityTypeAdapter only converts the uuid, let's append the idFieldName explicitly. + IdentityProxy ref = ((ExceptionResponse) result).getProxyObject(); + if (ref != null) { + // bump off the } at the end. We'll re-add it after the idFieldName. + sb.deleteCharAt(sb.length()-1); + String idFieldName = ref.getidFieldName(); + if (idFieldName != null) { + sb.append(",\"uuidProperty\":" + "\"" + idFieldName + "\"}"); + } + } } else { String jsonStr = gson.toJson(result); if ((jsonStr != null) && !"".equals(jsonStr)) { @@ -230,6 +240,11 @@ public class ApiResponseSerializer { } if(id != null && !id.isEmpty()) sb.append("<" + serializedName.value() + ">" + id + ""); + // Append the new idFieldName property also. + String idFieldName = idProxy.getidFieldName(); + if (idFieldName != null) { + sb.append("<" + "uuidProperty" + ">" + idFieldName + ""); + } } else { String resultString = escapeSpecialXmlChars(fieldValue.toString()); if (!(obj instanceof ExceptionResponse)) { diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index ca1e3e1ffb6..0e654ec6018 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -403,12 +403,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (podId != null) { InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", Pod.class, podId); // for now, we hardcode the table names, but we should ideally do a lookup for the tablename from the VO object. - ex.setProxyObject("Pod", podId); + ex.setProxyObject("Pod", "podId", podId); throw ex; } s_logger.warn(errorMessage.toString()); InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId); - ex.setProxyObject("data_center", dcId); + ex.setProxyObject("data_center", "dcId", dcId); throw ex; } @@ -495,7 +495,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // this ownerId comes from owner or type Account. See the class "AccountVO" and the annotations in that class // to get the table name and field name that is queried to fill this ownerid. ConcurrentOperationException ex = new ConcurrentOperationException("Unable to lock account"); - ex.setProxyObject("account", ownerId); + ex.setProxyObject("account", "ownerId", ownerId); throw ex; } if (s_logger.isDebugEnabled()) { @@ -577,7 +577,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (domainId != null) { if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) { PermissionDeniedException ex = new PermissionDeniedException("Invalid domain id given, permission denied"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } if (accountName != null) { @@ -586,7 +586,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag account = userAccount; } else { PermissionDeniedException ex = new PermissionDeniedException("Unable to find account " + accountName + " in specified domain, permission denied"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } } @@ -682,7 +682,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } else { CloudRuntimeException ex = new CloudRuntimeException("Multiple generic soure NAT IPs provided for network"); // see the IPAddressVO.java class. - ex.setProxyObject("user_ip_address", ip.getAssociatedWithNetworkId()); + ex.setProxyObject("user_ip_address", "networkId", ip.getAssociatedWithNetworkId()); throw ex; } } @@ -970,7 +970,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Network network = _networksDao.findById(networkId); if (network == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Network id is invalid"); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); } // check permissions @@ -1003,7 +1003,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) { // zone is of type DataCenter. See DataCenterVO.java. PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled"); - ex.setProxyObject("data_center", zone.getId()); + ex.setProxyObject("data_center", "zoneId", zone.getId()); throw ex; } @@ -1049,7 +1049,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (ip == null) { InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Unable to find available public IP addresses", DataCenter.class, zone.getId()); - ex.setProxyObject("data_center", zone.getId()); + ex.setProxyObject("data_center", "zoneId", zone.getId()); throw ex; } UserContext.current().setEventDetails("Ip Id: " + ip.getId()); @@ -1463,7 +1463,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (networks.size() < 1) { // see networkOfferingVO.java CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering to network profile"); - ex.setProxyObject("network_offerings", offering.getId()); + ex.setProxyObject("network_offerings", "networkOfferingId", offering.getId()); throw ex; } @@ -1668,7 +1668,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (network == null) { // see NetworkVO.java ConcurrentOperationException ex = new ConcurrentOperationException("Unable to acquire network configuration"); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); throw ex; } @@ -1745,7 +1745,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter")) { // see NetworkVO.java. CloudRuntimeException ex = new CloudRuntimeException("Service provider " + element.getProvider().getName() + "either doesn't exist or is not enabled in specified physical network id"); - ex.setProxyObject("networks", network.getPhysicalNetworkId()); + ex.setProxyObject("networks", "physicalNetworkId", network.getPhysicalNetworkId()); } if (s_logger.isDebugEnabled()) { s_logger.debug("Asking " + element.getName() + " to implemenet " + network); @@ -1762,7 +1762,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag s_logger.warn("Failed to re-program the network as a part of network " + network + " implement"); // see DataCenterVO.java ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class, network.getDataCenterId()); - ex.setProxyObject("data_center", network.getDataCenterId()); + ex.setProxyObject("data_center", "dataCenterId", network.getDataCenterId()); throw ex; } } @@ -1958,7 +1958,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag IPAddressVO ipVO = _ipAddressDao.findById(ipAddressId); if (ipVO == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find ip address by id"); - ex.setProxyObject("user_ip_address", ipAddressId); + ex.setProxyObject("user_ip_address", "ipAddressId", ipAddressId); throw ex; } @@ -1987,7 +1987,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) { //see IPaddressVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Sepcified IP address uuid belongs to Account wide IP pool and cannot be disassociated"); - ex.setProxyObject("user_ip_address", ipAddressId); + ex.setProxyObject("user_ip_address", "ipAddressId", ipAddressId); throw ex; } @@ -2033,7 +2033,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag String mac = _networksDao.getNextAvailableMacAddress(networkId); if (mac == null) { InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); throw ex; } return mac; @@ -2131,7 +2131,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (cidrSubnet.equals(ntwkCidrSubnet)) { InvalidParameterValueException ex = new InvalidParameterValueException("Warning: The specified existing network has conflict CIDR subnets with new network!"); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); throw ex; } } @@ -2163,7 +2163,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); if (networkOffering == null || networkOffering.isSystemOnly()) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering by specified id"); - ex.setProxyObject("network_offerings", networkOfferingId); + ex.setProxyObject("network_offerings", "networkOfferingId", networkOfferingId); throw ex; } // validate physical network and zone @@ -2173,7 +2173,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag pNtwk = _physicalNetworkDao.findById(physicalNetworkId); if (pNtwk == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a physical network having the given id"); - ex.setProxyObject("physical_network", physicalNetworkId); + ex.setProxyObject("physical_network", "physicalNetworkId", physicalNetworkId); throw ex; } } @@ -2186,7 +2186,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) { // See DataCenterVO.java PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation since specified Zone is currently disabled"); - ex.setProxyObject("data_center", zone.getId()); + ex.setProxyObject("data_center", "zoneId", zone.getId()); throw ex; } @@ -2244,7 +2244,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (domain == null) { // see DomainVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain by specified if"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } _accountMgr.checkAccess(caller, domain); @@ -2383,7 +2383,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (networkOffering.getState() != NetworkOffering.State.Enabled) { // see NetworkOfferingVO InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network offering id as its stat is not " + NetworkOffering.State.Enabled); - ex.setProxyObject("network_offerings", networkOfferingId); + ex.setProxyObject("network_offerings", "networkOfferingId", networkOfferingId); throw ex; } @@ -2391,7 +2391,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (pNtwk.getState() != PhysicalNetwork.State.Enabled) { // see PhysicalNetworkVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Specified physical network id is in incorrect state:" + pNtwk.getState()); - ex.setProxyObject("physical_network", pNtwk.getId()); + ex.setProxyObject("physical_network", "physicalNetworkId", pNtwk.getId()); throw ex; } @@ -2605,7 +2605,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (domain == null) { // see DomainVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Specified domain id doesn't exist in the system"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } @@ -2615,7 +2615,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (owner == null) { // see DomainVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } @@ -2644,13 +2644,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (project == null) { // see ProjectVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by specified id"); - ex.setProxyObject("projects", projectId); + ex.setProxyObject("projects", "projectId", projectId); throw ex; } if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) { // see ProjectVO.java InvalidParameterValueException ex = new InvalidParameterValueException("Account " + caller + " cannot access specified project id"); - ex.setProxyObject("projects", projectId); + ex.setProxyObject("projects", "projectId", projectId); throw ex; } permittedAccounts.add(project.getProjectAccountId()); @@ -3256,7 +3256,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkVO network = _networksDao.findById(networkId); if (network == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id doesn't exist"); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); throw ex; } @@ -3943,7 +3943,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // see NetworkVO.java //throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system"); InvalidParameterValueException ex = new InvalidParameterValueException("Specified network id doesn't exist in the system"); - ex.setProxyObject("networks", networkId); + ex.setProxyObject("networks", "networkId", networkId); throw ex; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index fcd9c936a5c..e0e687e17cd 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1837,7 +1837,7 @@ public class ManagementServerImpl implements ManagementServer { if (!domains.isEmpty() && !sameDomain) { InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + domainName + "' since it already exists in the system"); - ex.setProxyObject("domain", domainId); + ex.setProxyObject("domain", "domainId", domainId); throw ex; } } diff --git a/utils/src/com/cloud/utils/IdentityProxy.java b/utils/src/com/cloud/utils/IdentityProxy.java index 77b0b58a9ff..adbd99f568f 100644 --- a/utils/src/com/cloud/utils/IdentityProxy.java +++ b/utils/src/com/cloud/utils/IdentityProxy.java @@ -20,6 +20,7 @@ package com.cloud.utils; public class IdentityProxy { private String _tableName; private Long _value; + private String _idFieldName; public IdentityProxy() { } @@ -43,4 +44,12 @@ public class IdentityProxy { public void setValue(Long value) { _value = value; } + + public void setidFieldName(String value) { + _idFieldName = value; + } + + public String getidFieldName() { + return _idFieldName; + } } diff --git a/utils/src/com/cloud/utils/exception/RuntimeCloudException.java b/utils/src/com/cloud/utils/exception/RuntimeCloudException.java index 91448871ff6..46a6f6ef594 100644 --- a/utils/src/com/cloud/utils/exception/RuntimeCloudException.java +++ b/utils/src/com/cloud/utils/exception/RuntimeCloudException.java @@ -52,10 +52,11 @@ public class RuntimeCloudException extends RuntimeException { super(); } - public void setProxyObject(String table_name, Long id) { + public void setProxyObject(String table_name, String idFieldName, Long id) { this.id = new IdentityProxy(); this.id.setTableName(table_name); this.id.setValue(id); + this.id.setidFieldName(idFieldName); return; }