Updated Branches: refs/heads/master 560fa52fd -> 6e5577679
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e557767/server/src/com/cloud/vm/UserVmManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 96b9529..5657877 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3288,7 +3288,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } catch (CloudException e) { CloudRuntimeException ex = new CloudRuntimeException( "Unable to destroy with specified vmId", e); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } @@ -3315,7 +3315,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } else { CloudRuntimeException ex = new CloudRuntimeException( "Failed to destroy vm with specified vmId"); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } } @@ -3508,7 +3508,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (userVm == null) { InvalidParameterValueException ex = new InvalidParameterValueException( "unable to find a virtual machine with specified id"); - ex.addProxyObject(userVm, vmId, "vmId"); + ex.addProxyObject(String.valueOf(vmId), "vmId"); throw ex; } @@ -3550,7 +3550,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (vm.getState() != State.Stopped) { InvalidParameterValueException ex = new InvalidParameterValueException( "VM is not Stopped, unable to migrate the vm having the specified id"); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } @@ -3627,7 +3627,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } InvalidParameterValueException ex = new InvalidParameterValueException( "VM is not Running, unable to migrate the vm with specified id"); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } if (!vm.getHypervisorType().equals(HypervisorType.XenServer) @@ -3719,7 +3719,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } CloudRuntimeException ex = new CloudRuntimeException("VM is not Running, unable to migrate the vm with" + " specified id"); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } @@ -3849,7 +3849,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use } InvalidParameterValueException ex = new InvalidParameterValueException( "VM is Running, unable to move the vm with specified vmId"); - ex.addProxyObject(vm, cmd.getVmId(), "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } @@ -3863,7 +3863,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (oldAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) { InvalidParameterValueException ex = new InvalidParameterValueException( "Specified Vm id belongs to the project and can't be moved"); - ex.addProxyObject(vm, cmd.getVmId(), "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } Account newAccount = _accountService.getActiveAccountByName( @@ -4116,7 +4116,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (network == null) { InvalidParameterValueException ex = new InvalidParameterValueException( "Unable to find specified network id"); - ex.addProxyObject(network, networkId, "networkId"); + ex.addProxyObject(networkId.toString(), "networkId"); throw ex; } @@ -4129,7 +4129,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (networkOffering.isSystemOnly()) { InvalidParameterValueException ex = new InvalidParameterValueException( "Specified Network id is system only and can't be used for vm deployment"); - ex.addProxyObject(network, networkId, "networkId"); + ex.addProxyObject(network.getUuid(), "networkId"); throw ex; } applicableNetworks.add(network); @@ -4180,7 +4180,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use " resources as a part of network provision for persistent network due to ", ex); CloudRuntimeException e = new CloudRuntimeException("Failed to implement network" + " (with specified id) elements and resources as a part of network provision"); - e.addProxyObject(newNetwork, newNetwork.getId(), "networkId"); + e.addProxyObject(newNetwork.getUuid(), "networkId"); throw e; } } @@ -4241,7 +4241,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use UserVmVO vm = _vmDao.findById(vmId); if (vm == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Cannot find VM with ID " + vmId); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(String.valueOf(vmId), "vmId"); throw ex; } @@ -4287,7 +4287,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (rootVols.isEmpty()) { InvalidParameterValueException ex = new InvalidParameterValueException( "Can not find root volume for VM " + vm.getUuid()); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } @@ -4322,8 +4322,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use if (template == null) { InvalidParameterValueException ex = new InvalidParameterValueException( "Cannot find template/ISO for specified volumeid and vmId"); - ex.addProxyObject(vm, vmId, "vmId"); - ex.addProxyObject(root, root.getId(), "volumeId"); + ex.addProxyObject(vm.getUuid(), "vmId"); + ex.addProxyObject(root.getUuid(), "volumeId"); throw ex; } } @@ -4335,7 +4335,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use s_logger.debug("Stop vm " + vm.getUuid() + " failed", e); CloudRuntimeException ex = new CloudRuntimeException( "Stop vm failed for specified vmId"); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } } @@ -4396,7 +4396,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use s_logger.debug("Unable to start VM " + vm.getUuid(), e); CloudRuntimeException ex = new CloudRuntimeException( "Unable to start VM with specified id" + e.getMessage()); - ex.addProxyObject(vm, vmId, "vmId"); + ex.addProxyObject(vm.getUuid(), "vmId"); throw ex; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e557767/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java b/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java index ec0be8c..ac3b8f5 100644 --- a/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java +++ b/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java @@ -201,7 +201,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) { InvalidParameterValueException ex = new InvalidParameterValueException( "LB service is not supported in specified network id"); - ex.addProxyObject(network, network.getId(), "networkId"); + ex.addProxyObject(network.getUuid(), "networkId"); throw ex; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e557767/utils/src/com/cloud/utils/exception/CloudRuntimeException.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java index 00141f2..d3b4c19 100755 --- a/utils/src/com/cloud/utils/exception/CloudRuntimeException.java +++ b/utils/src/com/cloud/utils/exception/CloudRuntimeException.java @@ -18,7 +18,6 @@ package com.cloud.utils.exception; import java.util.ArrayList; -import com.cloud.utils.AnnotationHelper; import com.cloud.utils.SerialVersionUID; /** @@ -28,8 +27,8 @@ public class CloudRuntimeException extends RuntimeException { private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException; - // This holds a list of uuids and their names. Add uuid:fieldname pairs - protected ArrayList<String> idList = new ArrayList<String>(); + // This holds a list of uuids and their descriptive names. + protected ArrayList<ExceptionProxyObject> idList = new ArrayList<ExceptionProxyObject>(); protected int csErrorCode; @@ -49,21 +48,20 @@ public class CloudRuntimeException extends RuntimeException { setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName())); } + public void addProxyObject(ExceptionProxyObject obj){ + idList.add(obj); + } + public void addProxyObject(String uuid) { - idList.add(uuid); - return; + idList.add(new ExceptionProxyObject(uuid, null)); } - public void addProxyObject(Object voObj, Long id, String idFieldName) { - // Get the VO object's table name. - String tablename = AnnotationHelper.getTableName(voObj); - if (tablename != null) { - addProxyObject(tablename, id, idFieldName); - } - return; + public void addProxyObject(String voObjUuid, String description) { + ExceptionProxyObject proxy = new ExceptionProxyObject(voObjUuid, description); + idList.add(proxy); } - public ArrayList<String> getIdProxyList() { + public ArrayList<ExceptionProxyObject> getIdProxyList() { return idList; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e557767/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java ---------------------------------------------------------------------- diff --git a/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java b/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java new file mode 100644 index 0000000..01cbd63 --- /dev/null +++ b/utils/src/com/cloud/utils/exception/ExceptionProxyObject.java @@ -0,0 +1,50 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.utils.exception; + + +public class ExceptionProxyObject { + private String uuid; + private String description; + + public ExceptionProxyObject(){ + + } + + public ExceptionProxyObject(String uuid, String desc){ + this.uuid = uuid; + this.description = desc; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + +}