diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java index 68e9f94a8ba..c4b2e99cb28 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java @@ -86,8 +86,8 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd { Iterator iter = parameterCollection.iterator(); while (iter.hasNext()) { HashMap value = (HashMap)iter.next(); - for (String key : value.keySet()) { - customparameterMap.put(key, value.get(key)); + for (Map.Entry entry : value.entrySet()) { + customparameterMap.put(entry.getKey(), entry.getValue()); } } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java index d71ef03244b..f087077bc16 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java @@ -81,8 +81,8 @@ public class UpgradeSystemVMCmd extends BaseCmd { Iterator iter = parameterCollection.iterator(); while (iter.hasNext()) { HashMap value = (HashMap)iter.next(); - for (String key : value.keySet()) { - customparameterMap.put(key, value.get(key)); + for (Map.Entryentry : value.entrySet()) { + customparameterMap.put(entry.getKey(), entry.getValue()); } } } diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java index f29ae961fc4..73da826155e 100644 --- a/api/src/org/apache/cloudstack/context/CallContext.java +++ b/api/src/org/apache/cloudstack/context/CallContext.java @@ -332,8 +332,8 @@ public class CallContext { public void putContextParameters(Map details){ if (details == null) return; - for(Object key : details.keySet()){ - putContextParameter(key, details.get(key)); + for(Map.Entryentry : details.entrySet()){ + putContextParameter(entry.getKey(), entry.getValue()); } } diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 7bb6f5ea6ce..de1049b1d38 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -476,15 +476,14 @@ public class VirtualRoutingResource { LoadBalancerConfigurator cfgtr = new HAProxyConfigurator(); String[] config = cfgtr.generateConfiguration(cmd); - String tmpCfgFileContents = ""; + StringBuffer buff = new StringBuffer(); for (int i = 0; i < config.length; i++) { - tmpCfgFileContents += config[i]; - tmpCfgFileContents += "\n"; + buff.append(config[i]); + buff.append("\n"); } - String tmpCfgFilePath = "/etc/haproxy/"; String tmpCfgFileName = "haproxy.cfg.new." + String.valueOf(System.currentTimeMillis()); - cfg.add(new ConfigItem(tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents)); + cfg.add(new ConfigItem(tmpCfgFilePath, tmpCfgFileName, buff.toString())); String[][] rules = cfgtr.generateFwRules(cmd); @@ -610,18 +609,28 @@ public class VirtualRoutingResource { LinkedList cfg = new LinkedList<>(); String args = ""; + StringBuffer buff = new StringBuffer(); List revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { - args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; - } + buff.append(ipAliasTO.getAlias_count()); + buff.append(":"); + buff.append(ipAliasTO.getRouterip()); + buff.append(":"); + buff.append(ipAliasTO.getNetmask()); + buff.append("-"); + } //this is to ensure that thre is some argument passed to the deleteipAlias script when there are no revoked rules. - args = args + "- "; + buff.append("- "); List activeIpAliasTOs = cmd.getCreateIpAliasTos(); for (IpAliasTO ipAliasTO : activeIpAliasTOs) { - args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; + buff.append(ipAliasTO.getAlias_count()); + buff.append(":"); + buff.append(ipAliasTO.getRouterip()); + buff.append(":"); + buff.append(ipAliasTO.getNetmask()); + buff.append("-"); } - - cfg.add(new ConfigItem(VRScripts.IPALIAS_DELETE, args)); + cfg.add(new ConfigItem(VRScripts.IPALIAS_DELETE, buff.toString())); return cfg; } @@ -629,22 +638,29 @@ public class VirtualRoutingResource { LinkedList cfg = new LinkedList<>(); List dhcpTos = cmd.getIps(); - String args = ""; + StringBuffer buff = new StringBuffer(); for (DhcpTO dhcpTo : dhcpTos) { - args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-"; + buff.append(dhcpTo.getRouterIp()); + buff.append(":"); + buff.append(dhcpTo.getGateway()); + buff.append(":"); + buff.append(dhcpTo.getNetmask()); + buff.append(":"); + buff.append(dhcpTo.getStartIpOfSubnet()); + buff.append("-"); } - - cfg.add(new ConfigItem(VRScripts.DNSMASQ_CONFIG, args)); + cfg.add(new ConfigItem(VRScripts.DNSMASQ_CONFIG, buff.toString())); return cfg; } private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) { - String args = ""; - for (String ip : cmd.getVpnIps()) { - args += ip + " "; - } - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_CHECK, args); + StringBuffer buff = new StringBuffer(); + for (String ip : cmd.getVpnIps()) { + buff.append(ip); + buff.append(" "); + } + ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_CHECK, buff.toString()); return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(), result.getDetails()); } diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java index f11f69f3c53..0f02792493f 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java @@ -126,7 +126,7 @@ public abstract class AgentAttache { _maintenance = maintenance; _requests = new LinkedList(); _agentMgr = agentMgr; - _nextSequence = new Long(s_rand.nextInt(Short.MAX_VALUE)) << 48; + _nextSequence = new Long(s_rand.nextInt(Short.MAX_VALUE)).longValue() << 48; } public synchronized long getNextSequence() { diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index f79edc4cd9d..a9840bdc094 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -643,8 +643,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe Map args = new HashMap(); Task task = null; try { - for (String key : params.keySet()) { - args.put(key, params.get(key)); + for (Map.Entry< String, String > entry : params.entrySet()) { + args.put(entry.getKey(), entry.getValue()); } if (s_logger.isTraceEnabled()) { s_logger.trace("callHostPlugin executing for command " + cmd @@ -2313,8 +2313,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe return new GetVmStatsAnswer(cmd, vmStatsNameMap); } - for (String vmUUID : vmStatsUUIDMap.keySet()) { - vmStatsNameMap.put(vmNames.get(vmUUIDs.indexOf(vmUUID)), vmStatsUUIDMap.get(vmUUID)); + for (Map.Entryentry : vmStatsUUIDMap.entrySet()) { + vmStatsNameMap.put(vmNames.get(vmUUIDs.indexOf(entry.getKey())), entry.getValue()); } return new GetVmStatsAnswer(cmd, vmStatsNameMap); @@ -2387,8 +2387,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } - for (String vmUUID : vmResponseMap.keySet()) { - VmStatsEntry vmStatsAnswer = vmResponseMap.get(vmUUID); + for (Map.Entry entry: vmResponseMap.entrySet()) { + VmStatsEntry vmStatsAnswer = entry.getValue(); if (vmStatsAnswer.getNumCPUs() != 0) { vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() / vmStatsAnswer.getNumCPUs()); @@ -6533,8 +6533,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe s_logger.warn("Unable to find vdi by uuid: " + vdiUuid + ", skip it"); } } - for (VDI vdi : vdiMap.keySet()) { - VolumeObjectTO volumeTO = vdiMap.get(vdi); + for (Map.Entryentry : vdiMap.entrySet()) { + VDI vdi = entry.getKey(); + VolumeObjectTO volumeTO = entry.getValue(); VBD.Record vbdr = new VBD.Record(); vbdr.VM = vm; vbdr.VDI = vdi; diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java index 804220904bc..9cbf71fea8b 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerPoolVms.java @@ -80,8 +80,10 @@ public class XenServerPoolVms { public String toString() { StringBuilder sbuf = new StringBuilder("PoolVms="); for (HashMap> clusterVM : _clusterVms.values()) { - for (String vmname : clusterVM.keySet()) { - sbuf.append(vmname).append("-").append(clusterVM.get(vmname).second()).append(","); + for (Map.Entry> entry: clusterVM.entrySet()) { + String vmname = entry.getKey(); + Pair vmstate= entry.getValue(); + sbuf.append(vmname).append("-").append(vmstate.second()).append(","); } } return sbuf.toString(); diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java index 5199f602eb3..9e679f61356 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java +++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java @@ -677,11 +677,13 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl // NetScaler can only act as Lb and Static Nat service provider if (services != null && !services.isEmpty() && !netscalerServices.containsAll(services)) { s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + services + " is not supported."); - String servicesList = ""; + + StringBuffer buff = new StringBuffer(); for (Service service : services) { - servicesList += service.getName() + " "; + buff.append(service.getName()); + buff.append(" "); } - s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + servicesList + " is not supported."); + s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + buff.toString() + " is not supported."); s_logger.warn("NetScaler network element can only support LB and Static NAT services and service combination " + services + " is not supported."); return false; } diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java index 8c5aa1fb30d..93b084ecca3 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java +++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java @@ -1763,14 +1763,14 @@ public class NetscalerResource implements ServerResource { } private static String genGslbObjectName(Object... args) { - String objectName = ""; + StringBuffer buff = new StringBuffer(); for (int i = 0; i < args.length; i++) { - objectName += args[i]; + buff.append(args[i]); if (i != args.length - 1) { - objectName += "-"; + buff.append("-"); } } - return objectName; + return buff.toString(); } } @@ -3767,14 +3767,14 @@ public class NetscalerResource implements ServerResource { } private String genObjectName(Object... args) { - String objectName = ""; + StringBuffer buff = new StringBuffer(); for (int i = 0; i < args.length; i++) { - objectName += args[i]; + buff.append(args[i]); if (i != args.length - 1) { - objectName += _objectNamePathSep; + buff.append(_objectNamePathSep); } } - return objectName; + return buff.toString(); } @Override diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java index 619280dda6e..a586ae87c4c 100644 --- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java +++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java @@ -155,7 +155,7 @@ public class LDAPConfigCmd extends BaseCmd { } public Integer getPort() { - return port <= 0 ? 389 : port; + return (Integer)(port.intValue() <= 0 ? 389 : port.intValue()); } public void setPort(Integer port) { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index ed48d0bde05..51122e0c9e9 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -1906,7 +1906,8 @@ public class ApiResponseHelper implements ResponseGenerator { Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(network.getId(), network.getDataCenterId()); List serviceResponses = new ArrayList(); if (serviceCapabilitiesMap != null) { - for (Service service : serviceCapabilitiesMap.keySet()) { + for (Map.Entry>entry : serviceCapabilitiesMap.entrySet()) { + Service service = entry.getKey(); ServiceResponse serviceResponse = new ServiceResponse(); // skip gateway service if (service == Service.Gateway) { @@ -1916,11 +1917,12 @@ public class ApiResponseHelper implements ResponseGenerator { // set list of capabilities for the service List capabilityResponses = new ArrayList(); - Map serviceCapabilities = serviceCapabilitiesMap.get(service); + Map serviceCapabilities = entry.getValue(); if (serviceCapabilities != null) { - for (Capability capability : serviceCapabilities.keySet()) { + for (Map.Entry ser_cap_entries : serviceCapabilities.entrySet()) { + Capability capability = ser_cap_entries.getKey(); CapabilityResponse capabilityResponse = new CapabilityResponse(); - String capabilityValue = serviceCapabilities.get(capability); + String capabilityValue = ser_cap_entries.getValue(); capabilityResponse.setName(capability.getName()); capabilityResponse.setValue(capabilityValue); capabilityResponse.setObjectName("capability"); @@ -2605,7 +2607,9 @@ public class ApiResponseHelper implements ResponseGenerator { Map> serviceProviderMap = ApiDBUtils.listVpcOffServices(vpc.getVpcOfferingId()); List serviceResponses = new ArrayList(); - for (Service service : serviceProviderMap.keySet()) { + for (Map.Entry>entry : serviceProviderMap.entrySet()) { + Service service = entry.getKey(); + Set serviceProviders = entry.getValue(); ServiceResponse svcRsp = new ServiceResponse(); // skip gateway service if (service == Service.Gateway) { @@ -2613,7 +2617,7 @@ public class ApiResponseHelper implements ResponseGenerator { } svcRsp.setName(service.getName()); List providers = new ArrayList(); - for (Provider provider : serviceProviderMap.get(service)) { + for (Provider provider : serviceProviders) { if (provider != null) { ProviderResponse providerRsp = new ProviderResponse(); providerRsp.setName(provider.getName()); diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 2ce62811d78..f5f5c81aff6 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -478,7 +478,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer s_logger.error("invalid request, no command sent"); if (s_logger.isTraceEnabled()) { s_logger.trace("dumping request parameters"); - for (final Object key : params.keySet()) { + for (final Object key : params.keySet()) { final String keyStr = (String)key; final String[] value = (String[])params.get(key); s_logger.trace(" key: " + keyStr + ", value: " + ((value == null) ? "'null'" : value[0])); @@ -652,7 +652,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer // save the scheduled event final Long eventId = - ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId, asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), + ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? (Long)User.UID_SYSTEM : callerUserId, asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), asyncCmd.getEventDescription(), asyncCmd.isDisplay(), startEventId); if (startEventId == 0) { // There was no create event before, set current event id as start eventId diff --git a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java index 1592b93fe22..07c45babf6a 100644 --- a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java +++ b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java @@ -33,6 +33,7 @@ import java.util.regex.Matcher; import javax.inject.Inject; + import org.apache.log4j.Logger; import org.apache.cloudstack.acl.ControlledEntity; @@ -229,9 +230,10 @@ public class ParamProcessWorker implements DispatchWorker { if (!entitiesToAccess.isEmpty()) { // check that caller can access the owner account. _accountMgr.checkAccess(caller, null, true, owner); - for (Object entity : entitiesToAccess.keySet()) { + for (Map.Entryentry : entitiesToAccess.entrySet()) { + Object entity = entry.getKey(); if (entity instanceof ControlledEntity) { - _accountMgr.checkAccess(caller, entitiesToAccess.get(entity), true, (ControlledEntity) entity); + _accountMgr.checkAccess(caller, entry.getValue(), true, (ControlledEntity) entity); } else if (entity instanceof InfrastructureEntity) { // FIXME: Move this code in adapter, remove code from // Account manager diff --git a/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java b/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java index 12e12265d4d..c9bad2c686c 100644 --- a/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java +++ b/server/src/com/cloud/api/dispatch/ParamUnpackWorker.java @@ -33,7 +33,8 @@ public class ParamUnpackWorker implements DispatchWorker { public void handle(final DispatchTask task) throws ServerApiException { final Map lowercaseParams = new HashMap(); final Map params = task.getParams(); - for (final String key : params.keySet()) { + for (final Map.Entry entry : params.entrySet()) { + final String key = entry.getKey(); final int arrayStartIndex = key.indexOf('['); final int arrayStartLastIndex = key.lastIndexOf('['); if (arrayStartIndex != arrayStartLastIndex) { @@ -99,11 +100,11 @@ public class ParamUnpackWorker implements DispatchWorker { } // we are ready to store the value for a particular field into the map for this object - mapValue.put(fieldName, params.get(key)); + mapValue.put(fieldName, entry.getValue()); lowercaseParams.put(paramName, mapArray); } else { - lowercaseParams.put(key.toLowerCase(), params.get(key)); + lowercaseParams.put(key.toLowerCase(), entry.getValue()); } } diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java index 1182be575a6..b09bb0fbbf4 100644 --- a/server/src/com/cloud/api/query/QueryManagerImpl.java +++ b/server/src/com/cloud/api/query/QueryManagerImpl.java @@ -857,10 +857,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (tags != null && !tags.isEmpty()) { SearchCriteria tagSc = _userVmJoinDao.createSearchCriteria(); - for (String key : tags.keySet()) { + for (Map.Entry entry : tags.entrySet()) { SearchCriteria tsc = _userVmJoinDao.createSearchCriteria(); - tsc.addAnd("tagKey", SearchCriteria.Op.EQ, key); - tsc.addAnd("tagValue", SearchCriteria.Op.EQ, tags.get(key)); + tsc.addAnd("tagKey", SearchCriteria.Op.EQ,entry.getKey()); + tsc.addAnd("tagValue", SearchCriteria.Op.EQ, entry.getValue()); tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc); } sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc); @@ -2739,9 +2739,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { if (resourceTags != null && !resourceTags.isEmpty()) { int count = 0; sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.Zone.toString()); - for (String key : resourceTags.keySet()) { - sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key); - sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), resourceTags.get(key)); + for (Map.Entry entry : resourceTags.entrySet()) { + sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), entry.getKey()); + sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), entry.getValue()); count++; } } @@ -2859,7 +2859,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { VMTemplateVO template = null; Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm")); - isAscending = (isAscending == null ? true : isAscending); + isAscending = (isAscending == null ? Boolean.TRUE : isAscending); Filter searchFilter = new Filter(TemplateJoinVO.class, "sortKey", isAscending, startIndex, pageSize); SearchBuilder sb = _templateJoinDao.createSearchBuilder(); @@ -2999,10 +2999,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService { // add tags criteria if (tags != null && !tags.isEmpty()) { SearchCriteria scc = _templateJoinDao.createSearchCriteria(); - for (String key : tags.keySet()) { + for (Map.Entryentry : tags.entrySet()) { SearchCriteria scTag = _templateJoinDao.createSearchCriteria(); - scTag.addAnd("tagKey", SearchCriteria.Op.EQ, key); - scTag.addAnd("tagValue", SearchCriteria.Op.EQ, tags.get(key)); + scTag.addAnd("tagKey", SearchCriteria.Op.EQ, entry.getKey()); + scTag.addAnd("tagValue", SearchCriteria.Op.EQ, entry.getValue()); if (isIso) { scTag.addAnd("tagResourceType", SearchCriteria.Op.EQ, ResourceObjectType.ISO); } else { diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java index 80ef0f6ed7d..4c8ada1b581 100644 --- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java @@ -380,7 +380,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase im } // query details by batches Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm")); - isAscending = (isAscending == null ? true : isAscending); + isAscending = (isAscending == null ? Boolean.TRUE : isAscending); Filter searchFilter = new Filter(TemplateJoinVO.class, "sortKey", isAscending, null, null); List uvList = new ArrayList(); // query details by batches diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index bb32c376571..897f8e1ce9b 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -4004,9 +4004,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati void validateConnectivityServiceCapablities(Set providers, Map connectivityServiceCapabilityMap) { if (connectivityServiceCapabilityMap != null && !connectivityServiceCapabilityMap.isEmpty()) { - for (Capability capability: connectivityServiceCapabilityMap.keySet()) { + for (Map.Entryentry: connectivityServiceCapabilityMap.entrySet()) { + Capability capability = entry.getKey(); if (capability == Capability.StretchedL2Subnet) { - String value = connectivityServiceCapabilityMap.get(capability).toLowerCase(); + String value = entry.getValue().toLowerCase(); if (!(value.contains("true") ^ value.contains("false"))) { throw new InvalidParameterValueException("Invalid value (" + value + ") for " + capability + " should be true/false"); diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index a574f10bd82..b3de9e313a5 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -1693,9 +1693,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { if (tags != null && !tags.isEmpty()) { int count = 0; sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.Network.toString()); - for (String key : tags.keySet()) { - sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key); - sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key)); + for ( Map.Entry entry: tags.entrySet()) { + sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), entry.getKey()); + sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), entry.getValue()); count++; } } diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index 71f2316a80c..a1029eed155 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -1051,9 +1051,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis if (tags != null && !tags.isEmpty()) { int count = 0; sc.setJoinParameters("tagSearch", "resourceType", ResourceObjectType.Vpc.toString()); - for (String key : tags.keySet()) { - sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key); - sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), tags.get(key)); + for (Map.Entryentry : tags.entrySet()) { + sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), entry.getKey()); + sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), entry.getValue()); count++; } } diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 694f3cdd2ff..14690480264 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -1248,9 +1248,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio defaultVpcNetworkOfferingProvidersNoLB.put(Service.PortForwarding, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProvidersNoLB.put(Service.Vpn, Provider.VPCVirtualRouter); - for (Service service : defaultVpcNetworkOfferingProvidersNoLB.keySet()) { + for (Map.Entry entry : defaultVpcNetworkOfferingProvidersNoLB.entrySet()) { NetworkOfferingServiceMapVO offService = - new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service)); + new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), entry.getKey(), entry.getValue()); _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java index 29ace932026..9f4c14e7f1f 100755 --- a/server/src/com/cloud/server/StatsCollector.java +++ b/server/src/com/cloud/server/StatsCollector.java @@ -912,15 +912,17 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc AutoScalePolicyVO policyVo = _asPolicyDao.findById(gpMap.getPolicyId()); Integer duration = policyVo.getDuration(); //get collection of counter name - String counterNames = ""; + + StringBuffer buff = new StringBuffer(); List lstPCmap = _asConditionMapDao.findByPolicyId(policyVo.getId()); for (AutoScalePolicyConditionMapVO pcMap : lstPCmap) { String counterName = getCounternamebyCondition(pcMap.getConditionId()); - - counterNames += counterName + "," + pcMap.getConditionId(); + buff.append(counterName); + buff.append(","); + buff.append(pcMap.getConditionId()); } // add to result - Pair pair = new Pair(counterNames, duration); + Pair pair = new Pair(buff.toString(), duration); result.add(pair); } diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 7af404e9728..a557c0e7a4c 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -820,7 +820,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (!shrinkOk) { /* Check resource limit for this account on primary storage resource */ _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()), ResourceType.primary_storage, volume.isDisplayVolume(), new Long(newSize - - currentSize)); + - currentSize).longValue()); } /* If this volume has never been beyond allocated state, short circuit everything and simply update the database */ @@ -1667,7 +1667,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic // retrieve the migrated new volume from job result if (jobResult != null && jobResult instanceof Long) { - return _entityMgr.findById(VolumeVO.class, ((Long)jobResult).longValue()); + return _entityMgr.findById(VolumeVO.class, ((Long)jobResult)); } return null; } diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 71cf0832c9d..11362e4f8c7 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -1079,7 +1079,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, try { _resourceLimitMgr.checkResourceLimit(owner, ResourceType.snapshot); - _resourceLimitMgr.checkResourceLimit(owner, ResourceType.secondary_storage, new Long(volume.getSize())); + _resourceLimitMgr.checkResourceLimit(owner, ResourceType.secondary_storage, new Long(volume.getSize()).longValue()); } catch (ResourceAllocationException e) { if (snapshotType != Type.MANUAL) { String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots"; diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index e2204daea61..92383a031ed 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -363,7 +363,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat Account account = CallContext.current().getCallingAccount(); Long zoneId = cmd.getZoneId(); - VMTemplateVO template = _tmpltDao.findById(templateId.longValue()); + VMTemplateVO template = _tmpltDao.findById(templateId); if (template == null) { throw new InvalidParameterValueException("unable to find template with id " + templateId); } @@ -388,7 +388,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat Long userId = CallContext.current().getCallingUserId(); Long zoneId = cmd.getZoneId(); - VMTemplateVO template = _tmpltDao.findById(templateId.longValue()); + VMTemplateVO template = _tmpltDao.findById(templateId); if (template == null) { throw new InvalidParameterValueException("unable to find template with id " + templateId); } @@ -402,7 +402,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat Account account = CallContext.current().getCallingAccount(); Long zoneId = cmd.getZoneId(); - VMTemplateVO template = _tmpltDao.findById(templateId.longValue()); + VMTemplateVO template = _tmpltDao.findById(templateId); if (template == null) { throw new InvalidParameterValueException("unable to find iso with id " + templateId); } diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 694bd034518..7876a5a56f1 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -381,8 +381,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (isISO) { desc = Upload.Type.ISO.toString(); } - eventId = eventId == null ? 0 : eventId; - if (!_accountMgr.isRootAdmin(caller.getId()) && _disableExtraction) { throw new PermissionDeniedException("Extraction has been disabled by admin"); } @@ -628,7 +626,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, TemplateDataStoreVO srcTmpltStore = _tmplStoreDao.findByStoreTemplate(srcSecStore.getId(), tmpltId); _resourceLimitMgr.checkResourceLimit(account, ResourceType.template); - _resourceLimitMgr.checkResourceLimit(account, ResourceType.secondary_storage, new Long(srcTmpltStore.getSize())); + _resourceLimitMgr.checkResourceLimit(account, ResourceType.secondary_storage, new Long(srcTmpltStore.getSize()).longValue()); // Event details String copyEventType; @@ -1593,7 +1591,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } _resourceLimitMgr.checkResourceLimit(templateOwner, ResourceType.template); - _resourceLimitMgr.checkResourceLimit(templateOwner, ResourceType.secondary_storage, new Long(volume != null ? volume.getSize() : snapshot.getSize())); + _resourceLimitMgr.checkResourceLimit(templateOwner, ResourceType.secondary_storage, new Long(volume != null ? volume.getSize() : snapshot.getSize()).longValue()); if (!isAdmin || featured == null) { featured = Boolean.FALSE;