cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [5/6] git commit: updated refs/heads/rbac to 84a528f
Date Thu, 13 Mar 2014 21:53:26 GMT
Fixed some problems reported by FindBugs


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

Branch: refs/heads/rbac
Commit: 90c485e5d659afdd8a6a09ec3b81e54ab7398296
Parents: 67ab321
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Mar 13 13:29:25 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Mar 13 13:45:30 2014 -0700

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/BaseListCmd.java  |   2 +-
 .../security/dao/VmRulesetLogDaoImpl.java       |   2 +-
 .../src/com/cloud/projects/ProjectVO.java       |   5 +
 .../jobs/impl/JobSerializerHelper.java          |   5 +-
 .../mom/rabbitmq/RabbitMQEventBus.java          |  18 ++-
 .../src/com/cloud/dc/DedicatedResourceVO.java   |   7 ++
 .../com/cloud/network/IpAddressManagerImpl.java |   4 +-
 .../com/cloud/server/ManagementServerImpl.java  | 123 +------------------
 8 files changed, 29 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/api/src/org/apache/cloudstack/api/BaseListCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseListCmd.java b/api/src/org/apache/cloudstack/api/BaseListCmd.java
index f280003..407ad22 100644
--- a/api/src/org/apache/cloudstack/api/BaseListCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseListCmd.java
@@ -24,7 +24,7 @@ import com.cloud.utils.exception.CSExceptionErrorCode;
 public abstract class BaseListCmd extends BaseCmd {
 
     private static Long s_maxPageSize = null;
-    public static Long s_pageSizeUnlimited = -1L;
+    public static final Long s_pageSizeUnlimited = -1L;
 
     // ///////////////////////////////////////////////////
     // ///////// BaseList API parameters /////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java b/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
index c941055..90f8349 100644
--- a/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java
@@ -39,7 +39,7 @@ import com.cloud.utils.db.TransactionLegacy;
 @Component
 @Local(value = {VmRulesetLogDao.class})
 public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> implements
VmRulesetLogDao {
-    protected static Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class);
+    protected static final Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class);
     private SearchBuilder<VmRulesetLogVO> VmIdSearch;
     private String InsertOrUpdateSQl = "INSERT INTO op_vm_ruleset_log (instance_id, created,
logsequence) "
         + " VALUES(?, now(), 1) ON DUPLICATE KEY UPDATE logsequence=logsequence+1";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/engine/schema/src/com/cloud/projects/ProjectVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/projects/ProjectVO.java b/engine/schema/src/com/cloud/projects/ProjectVO.java
index d49e484..77eed40 100644
--- a/engine/schema/src/com/cloud/projects/ProjectVO.java
+++ b/engine/schema/src/com/cloud/projects/ProjectVO.java
@@ -31,6 +31,7 @@ import javax.persistence.Table;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
+import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.db.GenericDao;
 
 @Entity
@@ -161,4 +162,8 @@ public class ProjectVO implements Project, Identity, InternalIdentity
{
         this.uuid = uuid;
     }
 
+    @Override
+    public int hashCode() {
+        return NumbersUtil.hash(id);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java
index 67c4b86..735d7cf 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java
@@ -29,6 +29,7 @@ import java.lang.reflect.Type;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonDeserializationContext;
@@ -40,14 +41,12 @@ import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
-import com.cloud.utils.exception.CloudRuntimeException;
-
 /**
  * Note: toPairList and appendPairList only support simple POJO objects currently
  */
 public class JobSerializerHelper {
     private static final Logger s_logger = Logger.getLogger(JobSerializerHelper.class);
-    public static String token = "/";
+    public static final String token = "/";
 
     private static Gson s_gson;
     static {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
----------------------------------------------------------------------
diff --git a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
index 8ad7033..8403271 100644
--- a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
+++ b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java
@@ -30,8 +30,16 @@ import java.util.concurrent.Executors;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.framework.events.Event;
+import org.apache.cloudstack.framework.events.EventBus;
+import org.apache.cloudstack.framework.events.EventBusException;
+import org.apache.cloudstack.framework.events.EventSubscriber;
+import org.apache.cloudstack.framework.events.EventTopic;
+import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.log4j.Logger;
 
+import com.cloud.utils.Ternary;
+import com.cloud.utils.component.ManagerBase;
 import com.rabbitmq.client.AMQP;
 import com.rabbitmq.client.AlreadyClosedException;
 import com.rabbitmq.client.Channel;
@@ -43,16 +51,6 @@ import com.rabbitmq.client.MessageProperties;
 import com.rabbitmq.client.ShutdownListener;
 import com.rabbitmq.client.ShutdownSignalException;
 
-import org.apache.cloudstack.framework.events.Event;
-import org.apache.cloudstack.framework.events.EventBus;
-import org.apache.cloudstack.framework.events.EventBusException;
-import org.apache.cloudstack.framework.events.EventSubscriber;
-import org.apache.cloudstack.framework.events.EventTopic;
-import org.apache.cloudstack.managed.context.ManagedContextRunnable;
-
-import com.cloud.utils.Ternary;
-import com.cloud.utils.component.ManagerBase;
-
 @Local(value = EventBus.class)
 public class RabbitMQEventBus extends ManagerBase implements EventBus {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/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 2e0fde7..79c563c 100644
--- a/server/src/com/cloud/dc/DedicatedResourceVO.java
+++ b/server/src/com/cloud/dc/DedicatedResourceVO.java
@@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import com.cloud.utils.NumbersUtil;
+
 @Entity
 @Table(name = "dedicated_resources")
 public class DedicatedResourceVO implements DedicatedResources {
@@ -163,4 +165,9 @@ public class DedicatedResourceVO implements DedicatedResources {
             return false;
         }
     }
+
+    @Override
+    public int hashCode() {
+        return NumbersUtil.hash(id);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/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 15d1458..20eae3a 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -1346,7 +1346,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.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);
@@ -1387,7 +1387,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.isEmpty()) {
             Set<Service> ipServices = ipToServices.get(publicIp);
             if (ipServices != null && !ipServices.isEmpty()) {
                 return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/90c485e5/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index cb73519..2b63ae9 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -40,15 +40,10 @@ import javax.crypto.spec.SecretKeySpec;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.affinity.AffinityGroupProcessor;
 import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
 import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd;
 import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd;
 import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd;
@@ -465,6 +460,8 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.GetVncPortAnswer;
@@ -556,18 +553,14 @@ import com.cloud.storage.GuestOSHypervisor;
 import com.cloud.storage.GuestOSHypervisorVO;
 import com.cloud.storage.GuestOSVO;
 import com.cloud.storage.GuestOsCategory;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
-import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.GuestOSHypervisorDao;
-import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.tags.ResourceTagVO;
@@ -575,7 +568,6 @@ import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.template.TemplateManager;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
-import com.cloud.user.AccountService;
 import com.cloud.user.SSHKeyPair;
 import com.cloud.user.SSHKeyPairVO;
 import com.cloud.user.User;
@@ -583,7 +575,6 @@ import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.SSHKeyPairDao;
 import com.cloud.user.dao.UserDao;
-import com.cloud.utils.EnumUtils;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.PasswordGenerator;
@@ -668,8 +659,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Inject
     private DiskOfferingDao _diskOfferingDao;
     @Inject
-    private VMTemplateDao _templateDao;
-    @Inject
     private DomainDao _domainDao;
     @Inject
     private AccountDao _accountDao;
@@ -734,15 +723,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     @Inject
     private UserVmManager _userVmMgr;
     @Inject
-    private AccountService _accountService;
-    @Inject
     private ServiceOfferingDao _offeringDao;
-
     @Inject
     private DeploymentPlanningManager _dpMgr;
 
     private LockMasterListener _lockMasterListener;
-
     private final ScheduledExecutorService _eventExecutor = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("EventChecker"));
     private final ScheduledExecutorService _alertExecutor = Executors.newScheduledThreadPool(1,
new NamedThreadFactory("AlertChecker"));
     @Inject
@@ -1809,108 +1794,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     }
      */
 
-    private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
-        Long id = cmd.getId();
-        String name = cmd.getTemplateName();
-        String displayText = cmd.getDisplayText();
-        String format = cmd.getFormat();
-        Long guestOSId = cmd.getOsTypeId();
-        Boolean passwordEnabled = cmd.isPasswordEnabled();
-        Boolean bootable = cmd.isBootable();
-        Integer sortKey = cmd.getSortKey();
-        Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
-        Boolean isRoutingTemplate = cmd.isRoutingType();
-        Account account = CallContext.current().getCallingAccount();
-
-        // verify that template exists
-        VMTemplateVO template = _templateDao.findById(id);
-        if (template == null || template.getRemoved() != null) {
-            InvalidParameterValueException ex = new InvalidParameterValueException("unable
to find template/iso with specified id");
-            ex.addProxyObject(id.toString(), "templateId");
-            throw ex;
-        }
-
-        // Don't allow to modify system template
-        if (id.equals(Long.valueOf(1))) {
-            InvalidParameterValueException ex = new InvalidParameterValueException("Unable
to update template/iso of specified id");
-            ex.addProxyObject(template.getUuid(), "templateId");
-            throw ex;
-        }
-
-        // do a permission check
-        _accountMgr.checkAccess(account, AccessType.ModifyEntry, true, template);
-
-        if (cmd.isRoutingType() != null) {
-            if (!_accountService.isRootAdmin(account.getType())) {
-                throw new PermissionDeniedException("Parameter isrouting can only be specified
by a Root Admin, permission denied");
-            }
-        }
-        boolean updateNeeded = !(name == null && displayText == null && format
== null && guestOSId == null && passwordEnabled == null && bootable
== null && sortKey == null
-                && isDynamicallyScalable == null && isRoutingTemplate ==
null);
-        if (!updateNeeded) {
-            return template;
-        }
-
-        template = _templateDao.createForUpdate(id);
-
-        if (name != null) {
-            template.setName(name);
-        }
-
-        if (displayText != null) {
-            template.setDisplayText(displayText);
-        }
-
-        if (sortKey != null) {
-            template.setSortKey(sortKey);
-        }
-
-        ImageFormat imageFormat = null;
-        if (format != null) {
-            try {
-                imageFormat = ImageFormat.valueOf(format.toUpperCase());
-            } catch (IllegalArgumentException e) {
-                throw new InvalidParameterValueException("Image format: " + format + " is
incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values()));
-            }
-
-            template.setFormat(imageFormat);
-        }
-
-        if (guestOSId != null) {
-            GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
-
-            if (guestOS == null) {
-                throw new InvalidParameterValueException("Please specify a valid guest OS
ID.");
-            } else {
-                template.setGuestOSId(guestOSId);
-            }
-        }
-
-        if (passwordEnabled != null) {
-            template.setEnablePassword(passwordEnabled);
-        }
-
-        if (bootable != null) {
-            template.setBootable(bootable);
-        }
-
-        if (isDynamicallyScalable != null) {
-            template.setDynamicallyScalable(isDynamicallyScalable);
-        }
-
-        if (isRoutingTemplate != null) {
-            if (isRoutingTemplate) {
-                template.setTemplateType(TemplateType.ROUTING);
-            } else {
-                template.setTemplateType(TemplateType.USER);
-            }
-        }
-
-        _templateDao.update(id, template);
-
-        return _templateDao.findById(id);
-    }
-
     @Override
     public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd
cmd) {
         Object keyword = cmd.getKeyword();
@@ -3462,7 +3345,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             }
         }
 
-        long diskOffMaxSize = _volumeMgr.CustomDiskOfferingMaxSize.value();
+        long diskOffMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
         KVMSnapshotEnabled = Boolean.parseBoolean(_configDao.getValue("KVM.snapshot.enabled"));
 
         boolean userPublicTemplateEnabled = TemplateManager.AllowPublicUserTemplates.valueIn(caller.getId());


Mime
View raw message