cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [10/11] git commit: updated refs/heads/4.3 to d6bbfbb
Date Wed, 29 Jan 2014 20:59:41 GMT
Findbugs: different issues solved

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/dcda79e2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/dcda79e2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/dcda79e2

Branch: refs/heads/4.3
Commit: dcda79e2c02fda4e0fe52f61bf61712742e1f0db
Parents: 1fb32b5
Author: Daan Hoogland <daan@onecht.net>
Authored: Sun Jan 26 23:14:17 2014 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Wed Jan 29 21:40:21 2014 +0100

----------------------------------------------------------------------
 .../com/cloud/api/query/vo/UserVmJoinVO.java    | 23 ++++---
 .../com/cloud/consoleproxy/AgentHookBase.java   | 27 +++++----
 .../consoleproxy/ConsoleProxyManagerImpl.java   |  6 +-
 .../src/com/cloud/dc/DedicatedResourceVO.java   | 25 ++++++--
 .../com/cloud/network/IpAddressManagerImpl.java | 64 +++++++++++---------
 .../src/com/cloud/network/NetworkModelImpl.java | 11 ++--
 .../cloud/network/guru/ControlNetworkGuru.java  |  8 +--
 .../com/cloud/network/vpc/VpcManagerImpl.java   |  4 +-
 .../com/cloud/template/TemplateManagerImpl.java |  4 +-
 9 files changed, 97 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
index 25079ca..2bb0783 100644
--- a/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/UserVmJoinVO.java
@@ -35,6 +35,7 @@ import com.cloud.server.ResourceTag.ResourceObjectType;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Volume;
 import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 
@@ -47,10 +48,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     private long id;
 
     @Column(name="name", updatable=false, nullable=false, length=255)
-    private String name = null;
+    private final String name = null;
 
     @Column(name="display_name", updatable=false, nullable=false, length=255)
-    private String displayName = null;
+    private final String displayName = null;
 
     @Column(name="account_id")
     private long accountId;
@@ -59,7 +60,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     private String accountUuid;
 
     @Column(name="account_name")
-    private String accountName = null;
+    private final String accountName = null;
 
     @Column(name="account_type")
     private short accountType;
@@ -71,10 +72,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     private String domainUuid;
 
     @Column(name="domain_name")
-    private String domainName = null;
+    private final String domainName = null;
 
     @Column(name="domain_path")
-    private String domainPath = null;
+    private final String domainPath = null;
 
     @Column(name="instance_group_id")
     private long instanceGroupId;
@@ -96,7 +97,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
      */
     @Enumerated(value=EnumType.STRING)
     @Column(name="state", updatable=true, nullable=false, length=32)
-    private State state = null;
+    private final State state = null;
 
     @Column(name=GenericDao.CREATED_COLUMN)
     private Date created;
@@ -149,7 +150,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     private String dataCenterUuid;
 
     @Column(name="data_center_name")
-    private String dataCenterName = null;
+    private final String dataCenterName = null;
 
     @Column(name="security_group_enabled")
     private boolean securityGroupEnabled;
@@ -225,7 +226,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     private String volume_uuid;
 
     @Column(name = "volume_device_id")
-    private Long volumeDeviceId = null;
+    private final Long volumeDeviceId = null;
 
     @Column(name = "volume_type")
     @Enumerated(EnumType.STRING)
@@ -726,9 +727,11 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity
{
     }
 
     public String getDetail(String name) {
-        assert (details != null) : "Did you forget to load the details?";
+        if (details == null) {
+            throw new CloudRuntimeException("No details to get. Did you forget to load the
details?");
+        }
 
-        return details != null ? details.get(name) : null;
+        return details.get(name);
     }
 
     public String getUserData() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/consoleproxy/AgentHookBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/AgentHookBase.java b/server/src/com/cloud/consoleproxy/AgentHookBase.java
index aa9e4f8..660d1f2 100644
--- a/server/src/com/cloud/consoleproxy/AgentHookBase.java
+++ b/server/src/com/cloud/consoleproxy/AgentHookBase.java
@@ -22,6 +22,11 @@ import java.util.Random;
 
 import org.apache.log4j.Logger;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.AgentControlAnswer;
 import com.cloud.agent.api.Answer;
@@ -44,14 +49,10 @@ import com.cloud.server.ManagementServer;
 import com.cloud.servlet.ConsoleProxyPasswordBasedEncryptor;
 import com.cloud.servlet.ConsoleProxyServlet;
 import com.cloud.utils.Ternary;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.dao.VMInstanceDao;
 
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 /**
  * Utility class to manage interactions with agent-based console access
  * Extracted from ConsoleProxyManagerImpl so that other console proxy managers
@@ -72,12 +73,12 @@ public abstract class AgentHookBase implements AgentHook {
 
     public AgentHookBase(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao,
KeystoreManager ksMgr,
             AgentManager agentMgr, ManagementServer ms) {
-        this._instanceDao = instanceDao;
-        this._hostDao = hostDao;
-        this._agentMgr = agentMgr;
-        this._configDao = cfgDao;
-        this._ksMgr = ksMgr;
-        this._ms = ms;
+        _instanceDao = instanceDao;
+        _hostDao = hostDao;
+        _agentMgr = agentMgr;
+        _configDao = cfgDao;
+        _ksMgr = ksMgr;
+        _ms = ms;
     }
 
     @Override
@@ -204,7 +205,9 @@ public abstract class AgentHookBase implements AgentHook {
 
         assert (ksBits != null);
         if (ksBits == null) {
-            s_logger.error("Could not find and construct a valid SSL certificate");
+            String msg = "Could not find and construct a valid SSL certificate";
+            s_logger.error(msg);
+            throw new CloudRuntimeException(msg);
         }
         cmd = new StartConsoleProxyAgentHttpHandlerCommand(ksBits, storePassword);
         cmd.setEncryptorPassword(getEncryptorPassword());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 8a31d73..05adc5f 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -970,11 +970,7 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter
{
                 }
             } else {
                 if (s_logger.isDebugEnabled()) {
-                    if (template == null) {
-                        s_logger.debug("Zone host is ready, but console proxy template is
null");
-                    } else {
-                        s_logger.debug("Zone host is ready, but console proxy template: "
+ template.getId() + " is not ready on secondary storage.");
-                    }
+                    s_logger.debug("Zone host is ready, but console proxy template: " + template.getId()
+ " is not ready on secondary storage.");
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/dc/DedicatedResourceVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/DedicatedResourceVO.java b/server/src/com/cloud/dc/DedicatedResourceVO.java
index 9caa6b0..1f66ecf 100644
--- a/server/src/com/cloud/dc/DedicatedResourceVO.java
+++ b/server/src/com/cloud/dc/DedicatedResourceVO.java
@@ -20,7 +20,6 @@ import java.util.UUID;
 
 import javax.persistence.Column;
 import javax.persistence.Entity;
-
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -31,6 +30,11 @@ import javax.persistence.Table;
 @Table(name="dedicated_resources")
 public class DedicatedResourceVO implements DedicatedResources{
 
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -6659510127145101917L;
+
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name="id")
@@ -61,7 +65,7 @@ public class DedicatedResourceVO implements DedicatedResources{
     private long affinityGroupId;
 
     public DedicatedResourceVO() {
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
     }
 
     public DedicatedResourceVO(Long dataCenterId, Long podId, Long clusterId, Long hostId,
Long domainId,
@@ -72,14 +76,16 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.hostId = hostId;
         this.domainId = domainId;
         this.accountId = accountId;
-        this.uuid = UUID.randomUUID().toString();
+        uuid = UUID.randomUUID().toString();
         this.affinityGroupId = affinityGroupId;
     }
 
+    @Override
     public long getId() {
         return id;
     }
 
+    @Override
     public Long getDataCenterId() {
         return dataCenterId;
     }
@@ -88,6 +94,7 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.dataCenterId = dataCenterId;
     }
 
+    @Override
     public Long getPodId() {
         return podId;
     }
@@ -96,6 +103,7 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.podId = podId;
     }
 
+    @Override
     public Long getClusterId() {
         return clusterId;
     }
@@ -104,6 +112,7 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.clusterId = clusterId;
     }
 
+    @Override
     public Long getHostId() {
         return hostId;
     }
@@ -113,9 +122,10 @@ public class DedicatedResourceVO implements DedicatedResources{
     }
 
     public DedicatedResourceVO(long dedicatedResourceId) {
-        this.id = dedicatedResourceId;
+        id = dedicatedResourceId;
     }
 
+    @Override
     public Long getDomainId() {
         return domainId;
     }
@@ -124,6 +134,7 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.domainId = domainId;
     }
 
+    @Override
     public Long getAccountId() {
         return accountId;
     }
@@ -132,14 +143,16 @@ public class DedicatedResourceVO implements DedicatedResources{
         this.accountId = accountId;
     }
 
+    @Override
     public String getUuid() {
-        return this.uuid;
+        return uuid;
     }
 
     public void setUuid(String uuid) {
         this.uuid = uuid;
     }
 
+    @Override
     public long getAffinityGroupId() {
         return affinityGroupId;
     }
@@ -147,7 +160,7 @@ public class DedicatedResourceVO implements DedicatedResources{
     @Override
     public boolean equals(Object obj) {
         if (obj instanceof DedicatedResourceVO) {
-            return ((DedicatedResourceVO) obj).getId() == this.getId();
+            return ((DedicatedResourceVO) obj).getId() == getId();
         } else {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java
index f4bff58..1ccd0d6 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -17,6 +17,7 @@
 package com.cloud.network;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -29,6 +30,7 @@ import java.util.UUID;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.context.CallContext;
@@ -138,14 +140,14 @@ import com.cloud.utils.db.DB;
 import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.db.TransactionCallback;
-import com.cloud.utils.db.TransactionCallbackNoReturn;
-import com.cloud.utils.db.TransactionCallbackWithException;
 import com.cloud.utils.db.JoinBuilder.JoinType;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionCallback;
+import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionCallbackWithException;
 import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -578,8 +580,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
 
         IPAddressVO ip = markIpAsUnavailable(addrId);
 
-        assert (ip != null) : "Unable to mark the ip address id=" + addrId + " as unavailable.";
         if (ip == null) {
+            String msg = "Unable to mark the ip address id=" + addrId + " as unavailable.";
+            s_logger.error(msg);
             return true;
         }
 
@@ -692,10 +695,10 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
                 if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty())
{
                     fetchFromDedicatedRange = true;
                     sc.setParameters("vlanId", dedicatedVlanDbIds.toArray());
-                    errorMessage.append(", vlanId id=" + dedicatedVlanDbIds.toArray());
+                    errorMessage.append(", vlanId id=" + Arrays.toString(dedicatedVlanDbIds.toArray()));
                 } else if (nonDedicatedVlanDbIds != null && !nonDedicatedVlanDbIds.isEmpty())
{
                     sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
-                    errorMessage.append(", vlanId id=" + nonDedicatedVlanDbIds.toArray());
+                    errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
                 } else {
                     if (podId != null) {
                         InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient
address capacity", Pod.class, podId);
@@ -735,7 +738,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
                     if (useSystemIps && nonDedicatedVlanDbIds != null &&
!nonDedicatedVlanDbIds.isEmpty()) {
                         fetchFromDedicatedRange = false;
                         sc.setParameters("vlanId", nonDedicatedVlanDbIds.toArray());
-                        errorMessage.append(", vlanId id=" + nonDedicatedVlanDbIds.toArray());
+                        errorMessage.append(", vlanId id=" + Arrays.toString(nonDedicatedVlanDbIds.toArray()));
                         addrs = _ipAddressDao.lockRows(sc, filter, true);
                     }
                 }
@@ -868,6 +871,11 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
     public PublicIp assignDedicateIpAddress(Account owner, final Long guestNtwkId, final
Long vpcId, final long dcId, final boolean isSourceNat) throws ConcurrentOperationException,
         InsufficientAddressCapacityException {
 
+        if (owner == null) {
+            s_logger.error("No account to assign an ip to.");
+            return null;
+        }
+
         final long ownerId = owner.getId();
 
         PublicIp ip = null;
@@ -899,13 +907,11 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
 
             return ip;
         } finally {
-            if (owner != null) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Releasing lock account " + ownerId);
-                }
-
-                _accountDao.releaseFromLockTable(ownerId);
+            if (s_logger.isDebugEnabled()) {
+                s_logger.debug("Releasing lock account " + ownerId);
             }
+            _accountDao.releaseFromLockTable(ownerId);
+
             if (ip == null) {
                 s_logger.error("Unable to get source nat ip address for account " + ownerId);
             }
@@ -1253,7 +1259,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
 
         s_logger.debug("Associating ip " + ipToAssoc + " to network " + network);
 
-        IPAddressVO ip = _ipAddressDao.findById(ipId);
+        IPAddressVO ip = ipToAssoc; //_ipAddressDao.findById(ipId);
         //update ip address with networkId
         ip.setAssociatedWithNetworkId(networkId);
         ip.setSourceNat(isSourceNat);
@@ -1270,18 +1276,16 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
             return ip;
         } finally {
             if (!success && releaseOnFailure) {
-                if (ip != null) {
-                    try {
-                        s_logger.warn("Failed to associate ip address, so releasing ip from
the database " + ip);
-                        _ipAddressDao.markAsUnavailable(ip.getId());
-                        if (!applyIpAssociations(network, true)) {
-                            // if fail to apply ip assciations again, unassign ip address
without updating resource
-                            // count and generating usage event as there is no need to keep
it in the db
-                            _ipAddressDao.unassignIpAddress(ip.getId());
-                        }
-                    } catch (Exception e) {
-                        s_logger.warn("Unable to disassociate ip address for recovery", e);
+                try {
+                    s_logger.warn("Failed to associate ip address, so releasing ip from the
database " + ip);
+                    _ipAddressDao.markAsUnavailable(ip.getId());
+                    if (!applyIpAssociations(network, true)) {
+                        // if fail to apply ip assciations again, unassign ip address without
updating resource
+                        // count and generating usage event as there is no need to keep it
in the db
+                        _ipAddressDao.unassignIpAddress(ip.getId());
                     }
+                } catch (Exception e) {
+                    s_logger.warn("Unable to disassociate ip address for recovery", e);
                 }
             }
         }
@@ -1362,7 +1366,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipToAssoc, _vlanDao.findById(ipToAssoc.getVlanId()));
         ipList.add(publicIp);
         Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(ipList,
false, true);
-        if (ipToServices != null & !ipToServices.isEmpty()) {
+        if (ipToServices != null && !ipToServices.isEmpty()) {
             Set<Service> services = ipToServices.get(publicIp);
             if (services != null && !services.isEmpty()) {
                 throw new InvalidParameterValueException("IP " + ipToAssoc + " has services
and rules associated in the network " + networkId);
@@ -1403,7 +1407,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId()));
         ipList.add(publicIp);
         Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(ipList,
false, true);
-        if (ipToServices != null & !ipToServices.isEmpty()) {
+        if (ipToServices != null && !ipToServices.isEmpty()) {
             Set<Service> ipServices = ipToServices.get(publicIp);
             if (ipServices != null && !ipServices.isEmpty()) {
                 return false;
@@ -1732,14 +1736,14 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
 
     @Override
     public boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError,
boolean forRevoke) throws ResourceUnavailableException {
-        Network network = _networksDao.findById(staticNats.get(0).getNetworkId());
-        boolean success = true;
-
         if (staticNats == null || staticNats.size() == 0) {
             s_logger.debug("There are no static nat rules for the network elements");
             return true;
         }
 
+        Network network = _networksDao.findById(staticNats.get(0).getNetworkId());
+        boolean success = true;
+
         // get the list of public ip's owned by the network
         List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(),
null);
         List<PublicIp> publicIps = new ArrayList<PublicIp>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index 27b2006..7281beb 100755
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -1024,14 +1024,14 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
         List<NetworkOfferingServiceMapVO> map = _ntwkOfferingSrvcDao.listByNetworkOfferingId(networkOfferingId);
     
         for (NetworkOfferingServiceMapVO instance : map) {
-            String service = instance.getService();
+            Service service = Network.Service.getService(instance.getService());
             Set<Provider> providers;
             providers = serviceProviderMap.get(service);
             if (providers == null) {
                 providers = new HashSet<Provider>();
             }
             providers.add(Provider.getProvider(instance.getProvider()));
-            serviceProviderMap.put(Service.getService(service), providers);
+            serviceProviderMap.put(service, providers);
         }
     
         return serviceProviderMap;
@@ -1526,12 +1526,15 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
 
     @Override
     public void checkNetworkPermissions(Account owner, Network network) {
+        if (network == null) {
+            throw new CloudRuntimeException("no network to check permissions for.");
+        }
         // Perform account permission check
         if (network.getGuestType() != Network.GuestType.Shared
                 || (network.getGuestType() == Network.GuestType.Shared && network.getAclType()
== ACLType.Account)) {
             AccountVO networkOwner = _accountDao.findById(network.getAccountId());
             if(networkOwner == null)
-                throw new PermissionDeniedException("Unable to use network with id= " + ((network
!= null)? ((NetworkVO)network).getUuid() : "") + ", network does not have an owner");
+                throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid()
+ ", network does not have an owner");
             if(owner.getType() != Account.ACCOUNT_TYPE_PROJECT && networkOwner.getType()
== Account.ACCOUNT_TYPE_PROJECT){
                 if(!_projectAccountDao.canAccessProjectAccount(owner.getAccountId(), network.getAccountId())){
                     throw new PermissionDeniedException("Unable to use network with id= "
+ ((network != null)? ((NetworkVO)network).getUuid() : "") + ", permission denied");
@@ -1545,7 +1548,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
 
         } else {
             if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) {
-                throw new PermissionDeniedException("Shared network id=" + ((network != null)?
((NetworkVO)network).getUuid() : "") + " is not available in domain id=" + owner.getDomainId());
+                throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid()
+ " is not available in domain id=" + owner.getDomainId());
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/network/guru/ControlNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
index 26caa61..a8274d3 100755
--- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
@@ -134,7 +134,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements
NetworkGu
         assert nic.getTrafficType() == TrafficType.Control;
 
         // we have to get management/private ip for the control nic for vmware/hyperv due
ssh issues.
-         HypervisorType hType = dest.getHost().getHypervisorType(); 
+         HypervisorType hType = dest.getHost().getHypervisorType();
         if ( ( (hType == HypervisorType.VMware) || (hType == HypervisorType.Hyperv) )&&
isRouterVm(vm)) {
             if(dest.getDataCenter().getNetworkType() != NetworkType.Basic) {
                 super.reserve(nic, config, vm, dest, context);
@@ -168,7 +168,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements
NetworkGu
     @Override
     public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId)
{
         assert nic.getTrafficType() == TrafficType.Control;
-        HypervisorType hType = vm.getHypervisorType(); 
+        HypervisorType hType = vm.getHypervisorType();
         if ( ( (hType == HypervisorType.VMware) || (hType == HypervisorType.Hyperv) )&&
isRouterVm(vm)) {
             long dcId = vm.getVirtualMachine().getDataCenterId();
             DataCenterVO dcVo = _dcDao.findById(dcId);
@@ -218,12 +218,12 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements
NetworkGu
 
         Map<String, String> dbParams = _configDao.getConfiguration(params);
 
-        _cidr = dbParams.get(Config.ControlCidr);
+        _cidr = dbParams.get(Config.ControlCidr.toString());
         if (_cidr == null) {
             _cidr = "169.254.0.0/16";
         }
 
-        _gateway = dbParams.get(Config.ControlGateway);
+        _gateway = dbParams.get(Config.ControlGateway.toString());
         if (_gateway == null) {
             _gateway = NetUtils.getLinkLocalGateway();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index b9dd729..3ae194f 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -432,14 +432,14 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         List<VpcOfferingServiceMapVO> map = _vpcOffSvcMapDao.listByVpcOffId(vpcOffId);
 
         for (VpcOfferingServiceMapVO instance : map) {
-            String service = instance.getService();
+            Service service = Service.getService(instance.getService());
             Set<Provider> providers;
             providers = serviceProviderMap.get(service);
             if (providers == null) {
                 providers = new HashSet<Provider>();
             }
             providers.add(Provider.getProvider(instance.getProvider()));
-            serviceProviderMap.put(Service.getService(service), providers);
+            serviceProviderMap.put(service, providers);
         }
 
         return serviceProviderMap;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/dcda79e2/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 681be4a..33ba667 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -425,7 +425,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         if (isISO) {
             desc = Upload.Type.ISO.toString();
         }
-        eventId = eventId == null ? 0 : eventId;
+        eventId = (eventId == null ? 0 : eventId);
 
         if (!_accountMgr.isRootAdmin(caller.getType()) && _disableExtraction) {
             throw new PermissionDeniedException("Extraction has been disabled by admin");
@@ -1801,7 +1801,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         }
 
         // Don't allow to modify system template
-        if (id == Long.valueOf(1)) {
+        if (Long.valueOf(1).equals(id)) {
             InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to update template/iso of specified id");
             ex.addProxyObject(String.valueOf(id), "templateId");
             throw ex;


Mime
View raw message