Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CB4E510134 for ; Thu, 21 Nov 2013 16:12:54 +0000 (UTC) Received: (qmail 3859 invoked by uid 500); 21 Nov 2013 16:11:42 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 2592 invoked by uid 500); 21 Nov 2013 16:10:42 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 1643 invoked by uid 99); 21 Nov 2013 16:10:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Nov 2013 16:10:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8BB7E89B3B2; Thu, 21 Nov 2013 16:10:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ahuang@apache.org To: commits@cloudstack.apache.org Date: Thu, 21 Nov 2013 16:10:12 -0000 Message-Id: <3d94ef6d5e7b48d4aa9dc2f60f780720@git.apache.org> In-Reply-To: <3a74aa5f9b5f463a93af446726dc06f1@git.apache.org> References: <3a74aa5f9b5f463a93af446726dc06f1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/58] [abbrv] [partial] Reformatted all of the code. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java b/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java index 16c99bb..788f35a 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/S3BucketAction.java @@ -45,6 +45,7 @@ import org.w3c.dom.NodeList; import com.amazon.s3.GetBucketAccessControlPolicyResponse; import com.amazon.s3.ListAllMyBucketsResponse; import com.amazon.s3.ListBucketResponse; + import com.cloud.bridge.io.MTOMAwareResultStreamWriter; import com.cloud.bridge.model.BucketPolicyVO; import com.cloud.bridge.model.SAcl; @@ -93,7 +94,6 @@ import com.cloud.bridge.util.StringHelper; import com.cloud.bridge.util.XSerializer; import com.cloud.bridge.util.XSerializerXmlAdapter; import com.cloud.bridge.util.XmlHelper; -import com.cloud.utils.db.Transaction; import com.cloud.utils.db.TransactionLegacy; public class S3BucketAction implements ServletAction { @@ -772,7 +772,8 @@ public class S3BucketAction implements ServletAction { response.flushBuffer(); } catch (ObjectAlreadyExistsException oaee) { response.setStatus(409); - String xml = " OperationAbortedA conflicting conditional operation is currently in progress against this resource. Please try again.."; + String xml = + " OperationAbortedA conflicting conditional operation is currently in progress against this resource. Please try again.."; response.setContentType("text/xml; charset=UTF-8"); S3RestServlet.endResponse(response, xml.toString()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java b/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java index 22310a5..c854323 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/S3ObjectAction.java @@ -44,6 +44,7 @@ import org.w3c.dom.NodeList; import com.amazon.s3.CopyObjectResponse; import com.amazon.s3.GetObjectAccessControlPolicyResponse; + import com.cloud.bridge.io.MTOMAwareResultStreamWriter; import com.cloud.bridge.model.SAcl; import com.cloud.bridge.model.SAclVO; @@ -342,7 +343,8 @@ public class S3ObjectAction implements ServletAction { DataHandler dataHandler = engineResponse.getData(); if (dataHandler != null) { response.addHeader("ETag", "\"" + engineResponse.getETag() + "\""); - response.addHeader("Last-Modified", DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, engineResponse.getLastModified().getTime(), "E, d MMM yyyy HH:mm:ss z")); + response.addHeader("Last-Modified", + DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, engineResponse.getLastModified().getTime(), "E, d MMM yyyy HH:mm:ss z")); response.setContentLength((int)engineResponse.getContentLength()); S3RestServlet.writeResponse(response, dataHandler.getInputStream()); @@ -493,7 +495,8 @@ public class S3ObjectAction implements ServletAction { DataHandler dataHandler = engineResponse.getData(); if (dataHandler != null) { response.addHeader("ETag", "\"" + engineResponse.getETag() + "\""); - response.addHeader("Last-Modified", DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, engineResponse.getLastModified().getTime(), "E, d MMM yyyy HH:mm:ss z")); + response.addHeader("Last-Modified", + DateHelper.getDateDisplayString(DateHelper.GMT_TIMEZONE, engineResponse.getLastModified().getTime(), "E, d MMM yyyy HH:mm:ss z")); response.setContentLength((int)engineResponse.getContentLength()); } @@ -1035,10 +1038,10 @@ public class S3ObjectAction implements ServletAction { } // -> cannot have HTTP separators in an HTTP header - if (-1 != name.indexOf('(') || -1 != name.indexOf(')') || -1 != name.indexOf('@') || -1 != name.indexOf('<') || -1 != name.indexOf('>') || -1 != name.indexOf('\"') || - -1 != name.indexOf('[') || -1 != name.indexOf(']') || -1 != name.indexOf('=') || -1 != name.indexOf(',') || -1 != name.indexOf(';') || -1 != name.indexOf(':') || - -1 != name.indexOf('\\') || -1 != name.indexOf('/') || -1 != name.indexOf(' ') || -1 != name.indexOf('{') || -1 != name.indexOf('}') || -1 != name.indexOf('?') || - -1 != name.indexOf('\t')) + if (-1 != name.indexOf('(') || -1 != name.indexOf(')') || -1 != name.indexOf('@') || -1 != name.indexOf('<') || -1 != name.indexOf('>') || + -1 != name.indexOf('\"') || -1 != name.indexOf('[') || -1 != name.indexOf(']') || -1 != name.indexOf('=') || -1 != name.indexOf(',') || + -1 != name.indexOf(';') || -1 != name.indexOf(':') || -1 != name.indexOf('\\') || -1 != name.indexOf('/') || -1 != name.indexOf(' ') || + -1 != name.indexOf('{') || -1 != name.indexOf('}') || -1 != name.indexOf('?') || -1 != name.indexOf('\t')) ignoreMeta = true; if (ignoreMeta) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/controller/s3/S3SerializableServiceImplementation.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/S3SerializableServiceImplementation.java b/awsapi/src/com/cloud/bridge/service/controller/s3/S3SerializableServiceImplementation.java index 66f6c6d..842ca4a 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/S3SerializableServiceImplementation.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/S3SerializableServiceImplementation.java @@ -26,9 +26,8 @@ import com.amazon.s3.AccessControlPolicy; import com.amazon.s3.AmazonS3SkeletonInterface; import com.amazon.s3.CanonicalUser; import com.amazon.s3.CopyObject; -import com.amazon.s3.CopyObjectResult; -import com.amazon.s3.Group; import com.amazon.s3.CopyObjectResponse; +import com.amazon.s3.CopyObjectResult; import com.amazon.s3.CreateBucket; import com.amazon.s3.CreateBucketResponse; import com.amazon.s3.CreateBucketResult; @@ -49,6 +48,7 @@ import com.amazon.s3.GetObjectResponse; import com.amazon.s3.GetObjectResult; import com.amazon.s3.Grant; import com.amazon.s3.Grantee; +import com.amazon.s3.Group; import com.amazon.s3.ListAllMyBuckets; import com.amazon.s3.ListAllMyBucketsEntry; import com.amazon.s3.ListAllMyBucketsList; @@ -75,6 +75,7 @@ import com.amazon.s3.SetObjectAccessControlPolicy; import com.amazon.s3.SetObjectAccessControlPolicyResponse; import com.amazon.s3.Status; import com.amazon.s3.StorageClass; + import com.cloud.bridge.model.SAcl; import com.cloud.bridge.service.core.s3.S3AccessControlList; import com.cloud.bridge.service.core.s3.S3AccessControlPolicy; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java b/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java index c315db0..deb886f 100644 --- a/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java +++ b/awsapi/src/com/cloud/bridge/service/controller/s3/ServiceProvider.java @@ -34,13 +34,15 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import org.apache.axis2.AxisFault; -import org.apache.cloudstack.managed.context.ManagedContextTimerTask; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; import org.springframework.stereotype.Component; import com.amazon.ec2.AmazonEC2SkeletonInterface; import com.amazon.s3.AmazonS3SkeletonInterface; + +import org.apache.cloudstack.managed.context.ManagedContextTimerTask; + import com.cloud.bridge.model.MHostVO; import com.cloud.bridge.model.SHost; import com.cloud.bridge.model.SHostVO; @@ -60,7 +62,6 @@ import com.cloud.bridge.util.NetHelper; import com.cloud.bridge.util.OrderedPair; import com.cloud.utils.component.ManagerBase; import com.cloud.utils.db.DB; -import com.cloud.utils.db.Transaction; import com.cloud.utils.db.TransactionLegacy; @Component http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index cb3beec..59abca0 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -363,11 +363,13 @@ public class EC2Engine extends ManagerBase { } CloudStackSecurityGroup resp = null; if (ipPerm.getProtocol().equalsIgnoreCase("icmp")) { - resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, null, ipPerm.getIcmpCode(), ipPerm.getIcmpType(), - ipPerm.getProtocol(), null, request.getName(), null, secGroupList); + resp = + getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, null, ipPerm.getIcmpCode(), ipPerm.getIcmpType(), + ipPerm.getProtocol(), null, request.getName(), null, secGroupList); } else { - resp = getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, ipPerm.getToPort().longValue(), null, null, - ipPerm.getProtocol(), null, request.getName(), ipPerm.getFromPort().longValue(), secGroupList); + resp = + getApi().authorizeSecurityGroupIngress(null, constructList(ipPerm.getIpRangeSet()), null, ipPerm.getToPort().longValue(), null, null, + ipPerm.getProtocol(), null, request.getName(), ipPerm.getFromPort().longValue(), secGroupList); } if (resp != null) { List ingressRules = resp.getIngressRules(); @@ -805,8 +807,8 @@ public class EC2Engine extends ManagerBase { throw new Exception("Specified ipAddress doesn't exist"); CloudStackIpAddress cloudIp = cloudIps.get(0); - List vmList = getApi().listVirtualMachines(null, null, true, null, null, null, null, request.getInstanceId(), null, null, null, null, null, null, - null, null, null); + List vmList = + getApi().listVirtualMachines(null, null, true, null, null, null, null, request.getInstanceId(), null, null, null, null, null, null, null, null, null); if (vmList == null || vmList.size() == 0) { throw new Exception("Instance not found"); } @@ -962,8 +964,9 @@ public class EC2Engine extends ManagerBase { EC2Image[] imageSet = images.getImageSet(); String osTypeId = imageSet[0].getOsTypeId(); - CloudStackTemplate resp = getApi().createTemplate((request.getDescription() == null ? "" : request.getDescription()), request.getName(), osTypeId, null, null, null, - null, null, null, volumeId); + CloudStackTemplate resp = + getApi().createTemplate((request.getDescription() == null ? "" : request.getDescription()), request.getName(), osTypeId, null, null, null, null, null, + null, volumeId); if (resp == null || resp.getId() == null) { throw new Exception("Image couldn't be created"); } @@ -992,9 +995,10 @@ public class EC2Engine extends ManagerBase { public EC2CreateImageResponse registerImage(EC2RegisterImage request) { EC2CreateImageResponse image = new EC2CreateImageResponse(); try { - List templates = getApi().registerTemplate((request.getDescription() == null ? request.getName() : request.getDescription()), request.getFormat(), - request.getHypervisor(), request.getName(), toOSTypeId(request.getOsTypeName()), request.getLocation(), toZoneId(request.getZoneName(), null), null, null, null, - null, null, null, null, null, null); + List templates = + getApi().registerTemplate((request.getDescription() == null ? request.getName() : request.getDescription()), request.getFormat(), + request.getHypervisor(), request.getName(), toOSTypeId(request.getOsTypeName()), request.getLocation(), toZoneId(request.getZoneName(), null), null, + null, null, null, null, null, null, null, null); if (templates != null) { // technically we will only ever register a single template... for (CloudStackTemplate template : templates) { @@ -1214,7 +1218,8 @@ public class EC2Engine extends ManagerBase { } // // -> no volume name is given in the Amazon request but is required in the cloud API - CloudStackVolume vol = getApi().createVolume(UUID.randomUUID().toString(), null, diskOfferingId, null, size, snapshotId, toZoneId(request.getZoneName(), null)); + CloudStackVolume vol = + getApi().createVolume(UUID.randomUUID().toString(), null, diskOfferingId, null, size, snapshotId, toZoneId(request.getZoneName(), null)); if (vol != null) { resp.setAttached(vol.getAttached()); resp.setCreated(vol.getCreated()); @@ -1436,8 +1441,9 @@ public class EC2Engine extends ManagerBase { // now actually deploy the vms for (int i = 0; i < createInstances; i++) { try { - CloudStackUserVm resp = getApi().deployVirtualMachine(svcOffering.getId(), request.getTemplateId(), zoneId, null, null, null, null, null, null, null, - request.getKeyName(), null, null, groupIds, groupNames, request.getSize().longValue(), request.getUserData()); + CloudStackUserVm resp = + getApi().deployVirtualMachine(svcOffering.getId(), request.getTemplateId(), zoneId, null, null, null, null, null, null, null, + request.getKeyName(), null, null, groupIds, groupNames, request.getSize().longValue(), request.getUserData()); EC2Instance vm = new EC2Instance(); vm.setId(resp.getId().toString()); vm.setName(resp.getName()); @@ -1659,7 +1665,8 @@ public class EC2Engine extends ManagerBase { * @param virtualMachineIds - an array of instances we are interested in getting information on * @param ifs - filter out unwanted instances */ - private EC2DescribeInstancesResponse listVirtualMachines(String[] virtualMachineIds, EC2InstanceFilterSet ifs, List resourceTags) throws Exception { + private EC2DescribeInstancesResponse listVirtualMachines(String[] virtualMachineIds, EC2InstanceFilterSet ifs, List resourceTags) + throws Exception { EC2DescribeInstancesResponse instances = new EC2DescribeInstancesResponse(); if (null == virtualMachineIds || 0 == virtualMachineIds.length) { @@ -1873,10 +1880,12 @@ public class EC2Engine extends ManagerBase { * @return the same object passed in as the "instances" parameter modified with one or more * EC2Instance objects loaded. */ - private EC2DescribeInstancesResponse lookupInstances(String instanceId, EC2DescribeInstancesResponse instances, List resourceTagSet) throws Exception { + private EC2DescribeInstancesResponse lookupInstances(String instanceId, EC2DescribeInstancesResponse instances, List resourceTagSet) + throws Exception { String instId = instanceId != null ? instanceId : null; - List vms = getApi().listVirtualMachines(null, null, true, null, null, null, null, instId, null, null, null, null, null, null, null, null, resourceTagSet); + List vms = + getApi().listVirtualMachines(null, null, true, null, null, null, null, instId, null, null, null, null, null, null, null, null, resourceTagSet); if (vms != null && vms.size() > 0) { for (CloudStackUserVm cloudVm : vms) { @@ -2291,8 +2300,8 @@ public class EC2Engine extends ManagerBase { * @throws Exception */ private CloudStackNetwork createDefaultGuestNetwork(String zoneId, CloudStackNetworkOffering offering, CloudStackAccount owner) throws Exception { - return getApi().createNetwork(owner.getName() + "-network", owner.getName() + "-network", offering.getId(), zoneId, owner.getName(), owner.getDomainId(), true, null, null, - null, null, null, null, null, null); + return getApi().createNetwork(owner.getName() + "-network", owner.getName() + "-network", offering.getId(), zoneId, owner.getName(), owner.getDomainId(), true, + null, null, null, null, null, null, null, null); } /** @@ -2679,8 +2688,8 @@ public class EC2Engine extends ManagerBase { if (errorMessage.contains("Object vm_instance(uuid:") && errorMessage.contains(") does not exist")) { throw new EC2ServiceException(ClientError.InvalidInstanceID_NotFound, "Specified Instance ID does not exist"); } else if (errorMessage.contains("Unable to find security group by name") || errorMessage.contains("Unable to find security group") || - (errorMessage.contains("Object security_group(uuid:") && errorMessage.contains(") does not exist")) || - errorMessage.contains("Unable to find group by name ")) { + (errorMessage.contains("Object security_group(uuid:") && errorMessage.contains(") does not exist")) || + errorMessage.contains("Unable to find group by name ")) { throw new EC2ServiceException(ClientError.InvalidGroup_NotFound, "Specified Security Group does not exist"); } else if (errorMessage.contains("Invalid port numbers")) { throw new EC2ServiceException(ClientError.InvalidPermission_Malformed, "Specified Port value is invalid"); @@ -2699,7 +2708,7 @@ public class EC2Engine extends ManagerBase { } else if (errorMessage.contains("Object snapshots(uuid:") && errorMessage.contains(") does not exist")) { throw new EC2ServiceException(ClientError.InvalidSnapshot_NotFound, "Specified Snapshot ID doesn't exist"); } else if ((errorMessage.contains("A key pair with name '") && errorMessage.contains("' does not exist")) || - (errorMessage.contains("A key pair with name '") && errorMessage.contains("' was not found"))) { + (errorMessage.contains("A key pair with name '") && errorMessage.contains("' was not found"))) { throw new EC2ServiceException(ClientError.InvalidKeyPair_NotFound, "Specified Key pair name is invalid"); } else if (errorMessage.contains("A key pair with name '") && errorMessage.contains("' already exists")) { throw new EC2ServiceException(ClientError.InvalidKeyPair_Duplicate, "Specified Key pair already exists"); @@ -2726,7 +2735,7 @@ public class EC2Engine extends ManagerBase { } else if (errorMessage.contains("Unable to find tags by parameters specified")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified resourceTag for the specified resourceId doesn't exist"); } else if (errorMessage.contains("Failed to enable static nat for the ip address with specified ipId " - + "as vm with specified vmId is already associated with specified currentIp")) { + + "as vm with specified vmId is already associated with specified currentIp")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified publicIp is already associated to the specified VM"); } else if (errorMessage.contains("Specified IP address id is not associated with any vm Id")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified publicIp is not associated to any VM"); @@ -2773,7 +2782,8 @@ public class EC2Engine extends ManagerBase { } else if (errorMessage.contains("Template") && errorMessage.contains("has not been completely downloaded")) { throw new EC2ServiceException(ClientError.InvalidAMIID_NotFound, "Specified ImageId is unavailable"); } else if (errorMessage.contains("cannot stop VM") && errorMessage.contains("when it is in state Starting")) { - throw new EC2ServiceException(ClientError.IncorrectInstanceState, "Unable to stop. One or more of the specified instances is in an incorrect state 'pending'"); + throw new EC2ServiceException(ClientError.IncorrectInstanceState, + "Unable to stop. One or more of the specified instances is in an incorrect state 'pending'"); } else if (errorMessage.contains("Failed to authorize security group ingress rule(s)")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified Ip-permission is invalid" + " or the Ip-permission already exists"); } else if (errorMessage.contains("Failed to reboot vm instance")) { @@ -2787,7 +2797,8 @@ public class EC2Engine extends ManagerBase { if (errorMessage.contains("Maximum number of resources of type 'volume' for account") && errorMessage.contains("has been exceeded")) { throw new EC2ServiceException(ClientError.VolumeLimitExceeded, "You have reached the limit on the number of volumes that can be created"); } else if (errorMessage.contains("Maximum number of resources of type 'public_ip' for account") && errorMessage.contains("has been exceeded")) { - throw new EC2ServiceException(ClientError.AddressLimitExceeded, "You have reached the limit on the number of elastic ip addresses your account can have"); + throw new EC2ServiceException(ClientError.AddressLimitExceeded, + "You have reached the limit on the number of elastic ip addresses your account can have"); } else if (errorMessage.contains("Unable to apply save userdata entry on router")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "The value supplied for parameter UserData is invalid"); } else { @@ -2834,7 +2845,8 @@ public class EC2Engine extends ManagerBase { } else if (errorMessage.contains("Failed to start the stopped instance")) { throw new EC2ServiceException(ServerError.InternalError, "Unable to start the instance that was stopped during image creation"); } else if (errorMessage.contains("One or more of instanceIds specified is in stopped state")) { - throw new EC2ServiceException(ClientError.IncorrectInstanceState, "Unable to reboot. One or more of the specified instances is in an incorrect state 'stopped'"); + throw new EC2ServiceException(ClientError.IncorrectInstanceState, + "Unable to reboot. One or more of the specified instances is in an incorrect state 'stopped'"); } else if (errorMessage.contains("Specified ipAddress doesn't exist")) { throw new EC2ServiceException(ClientError.InvalidParameterValue, "Specified publicIp doesn't exist"); } else if (errorMessage.contains("Min Count is greater than the number of instances left to allocate")) { @@ -2852,7 +2864,8 @@ public class EC2Engine extends ManagerBase { } else if (errorMessage.contains("Instance not found")) { throw new EC2ServiceException(ClientError.InvalidInstanceID_NotFound, "One or more of the specified instanceId not found"); } else if (errorMessage.contains("Cannot modify, instance should be in stopped state")) { - throw new EC2ServiceException(ClientError.IncorrectInstanceState, "Unable to modify instance attribute. Specified instance is not in the correct state 'stopped'"); + throw new EC2ServiceException(ClientError.IncorrectInstanceState, + "Unable to modify instance attribute. Specified instance is not in the correct state 'stopped'"); } else { throw new EC2ServiceException(ServerError.InternalError, "An unexpected error occured"); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java index 74154ea..3c35da6 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RegisterImage.java @@ -71,7 +71,8 @@ public class EC2RegisterImage { public void setArchitecture(String param) { if (null != param) { if (!param.contains(":") || param.split(":").length < 4) { - throw new EC2ServiceException(ClientError.InvalidParameterValue, "Supported format for " + "parameter 'architecture' is format:zonename:ostypename:hypervisor"); + throw new EC2ServiceException(ClientError.InvalidParameterValue, "Supported format for " + + "parameter 'architecture' is format:zonename:ostypename:hypervisor"); } String parts[] = param.split(":"); format = parts[0]; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstancesResponse.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstancesResponse.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstancesResponse.java index e3e767a..3f65af4 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstancesResponse.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2RunInstancesResponse.java @@ -19,8 +19,6 @@ package com.cloud.bridge.service.core.ec2; import java.util.ArrayList; import java.util.List; -import com.cloud.bridge.service.core.ec2.EC2Instance; - public class EC2RunInstancesResponse { private List instanceSet = new ArrayList(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java index 03383f1..d44eea7 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java @@ -28,7 +28,6 @@ import java.util.TimeZone; import com.cloud.bridge.service.UserContext; import com.cloud.bridge.service.exception.EC2ServiceException; import com.cloud.bridge.service.exception.EC2ServiceException.ClientError; -import com.cloud.bridge.util.DateHelper; import com.cloud.bridge.util.EC2RestAuth; public class EC2SnapshotFilterSet { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java index 91aff0a..40f8e11 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java @@ -19,11 +19,11 @@ package com.cloud.bridge.service.core.ec2; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TimeZone; -import java.util.Date; import com.cloud.bridge.service.exception.EC2ServiceException; import com.cloud.bridge.service.exception.EC2ServiceException.ClientError; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java index 1af86ae..2dc7eaa 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3Engine.java @@ -85,7 +85,6 @@ import com.cloud.bridge.util.PolicyParser; import com.cloud.bridge.util.StringHelper; import com.cloud.bridge.util.Triple; import com.cloud.utils.db.DB; -import com.cloud.utils.db.Transaction; import com.cloud.utils.db.TransactionLegacy; /** @@ -222,8 +221,8 @@ public class S3Engine { throw new ObjectAlreadyExistsException("Bucket already exists"); shost_storagelocation_pair = allocBucketStorageHost(request.getBucketName(), null); - SBucketVO sbucket = new SBucketVO(request.getBucketName(), DateHelper.currentGMTTime(), UserContext.current().getCanonicalUserId(), - shost_storagelocation_pair.getFirst()); + SBucketVO sbucket = + new SBucketVO(request.getBucketName(), DateHelper.currentGMTTime(), UserContext.current().getCanonicalUserId(), shost_storagelocation_pair.getFirst()); shost_storagelocation_pair.getFirst().getBuckets().add(sbucket); // bucketDao.save(sbucket); @@ -642,8 +641,8 @@ public class S3Engine { * We are required to keep the connection alive by returning whitespace characters back periodically. */ - public S3PutObjectInlineResponse - concatentateMultipartUploads(HttpServletResponse httpResp, S3PutObjectInlineRequest request, S3MultipartPart[] parts, OutputStream outputStream) throws IOException { + public S3PutObjectInlineResponse concatentateMultipartUploads(HttpServletResponse httpResp, S3PutObjectInlineRequest request, S3MultipartPart[] parts, + OutputStream outputStream) throws IOException { // [A] Set up and initial error checking S3PutObjectInlineResponse response = new S3PutObjectInlineResponse(); String bucketName = request.getBucketName(); @@ -680,8 +679,9 @@ public class S3Engine { // explicit transaction control to avoid holding transaction during // long file concatenation process txn.start(); - OrderedPair result = bucketAdapter.concatentateObjects(host_storagelocation_pair.getSecond(), bucket.getName(), itemFileName, - ServiceProvider.getInstance().getMultipartDir(), parts, outputStream); + OrderedPair result = + bucketAdapter.concatentateObjects(host_storagelocation_pair.getSecond(), bucket.getName(), itemFileName, ServiceProvider.getInstance().getMultipartDir(), + parts, outputStream); response.setETag(result.getFirst()); response.setLastModified(DateHelper.toCalendar(object_objectitem_pair.getSecond().getLastModifiedTime())); @@ -1237,8 +1237,8 @@ public class S3Engine { * * TODO - how does the versionIdMarker work when there is a deletion marker in the object? */ - private S3ListBucketObjectEntry[] - composeListBucketContentEntries(List l, String prefix, String delimiter, int maxKeys, boolean enableVersion, String versionIdMarker) { + private S3ListBucketObjectEntry[] composeListBucketContentEntries(List l, String prefix, String delimiter, int maxKeys, boolean enableVersion, + String versionIdMarker) { List entries = new ArrayList(); SObjectItemVO latest = null; boolean hitIdMarker = false; @@ -1425,7 +1425,8 @@ public class S3Engine { * @throws IOException */ @SuppressWarnings("deprecation") - public OrderedPair allocObjectItem(SBucketVO bucket, String nameKey, S3MetaDataEntry[] meta, S3AccessControlList acl, String cannedAccessPolicy) { + public OrderedPair allocObjectItem(SBucketVO bucket, String nameKey, S3MetaDataEntry[] meta, S3AccessControlList acl, + String cannedAccessPolicy) { SObjectItemVO item = null; int versionSeq = 1; int versioningStatus = bucket.getVersioningStatus(); @@ -1684,7 +1685,8 @@ public class S3Engine { * @return S3BucketPolicy * @throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, ParseException */ - public static S3BucketPolicy loadPolicy(S3PolicyContext context) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, ParseException { + public static S3BucketPolicy loadPolicy(S3PolicyContext context) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, + ParseException { OrderedPair result = ServiceProvider.getInstance().getBucketPolicy(context.getBucketName()); S3BucketPolicy policy = result.getFirst(); if (null == policy) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java index 16adbde..d0db198 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3Grant.java @@ -18,10 +18,7 @@ package com.cloud.bridge.service.core.s3; import java.util.List; -import com.cloud.bridge.model.SAcl; import com.cloud.bridge.model.SAclVO; -import com.cloud.bridge.model.SBucket; -import com.cloud.bridge.service.exception.UnsupportedException; /** * Each relation holds http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3ListAllMyBucketsEntry.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3ListAllMyBucketsEntry.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3ListAllMyBucketsEntry.java index 85c412e..ea4d7a1 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3ListAllMyBucketsEntry.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3ListAllMyBucketsEntry.java @@ -17,7 +17,6 @@ package com.cloud.bridge.service.core.s3; import java.util.Calendar; -import java.util.TimeZone; public class S3ListAllMyBucketsEntry { private String name; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyArnCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyArnCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyArnCondition.java index 01d14be..d56ac01 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyArnCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyArnCondition.java @@ -110,7 +110,7 @@ public class S3PolicyArnCondition extends S3PolicyCondition { return false; } logger.info("S3PolicyArnCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith + ", valueInRule: " + - valueList[i] + ", result: " + keyResult); + valueList[i] + ", result: " + keyResult); } // -> if all key values are false, false then that key is false and then the entire condition is then false http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyCondition.java index 7e432e9..55bfee1 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyCondition.java @@ -28,7 +28,22 @@ import com.cloud.bridge.service.exception.PermissionDeniedException; public abstract class S3PolicyCondition { public enum ConditionKeys { - UnknownKey, CurrentTime, SecureTransport, SourceIp, SourceArn, UserAgent, EpochTime, Referer, Acl, Location, Prefix, Delimiter, MaxKeys, CopySource, MetaData, VersionId + UnknownKey, + CurrentTime, + SecureTransport, + SourceIp, + SourceArn, + UserAgent, + EpochTime, + Referer, + Acl, + Location, + Prefix, + Delimiter, + MaxKeys, + CopySource, + MetaData, + VersionId } protected PolicyConditions condition = null; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyDateCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyDateCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyDateCondition.java index 70ed117..d3b182d 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyDateCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyDateCondition.java @@ -134,8 +134,8 @@ public class S3PolicyDateCondition extends S3PolicyCondition { default: return false; } - logger.info("S3PolicyDateCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + DatatypeConverter.printDateTime(tod) + - ", valueInRule: " + DatatypeConverter.printDateTime(valueList[i]) + ", result: " + keyResult); + logger.info("S3PolicyDateCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + + DatatypeConverter.printDateTime(tod) + ", valueInRule: " + DatatypeConverter.printDateTime(valueList[i]) + ", result: " + keyResult); } // -> if all key values are, false then that key is false and then the entire condition is then false http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyIPAddressCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyIPAddressCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyIPAddressCondition.java index a0d667f..409708a 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyIPAddressCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyIPAddressCondition.java @@ -104,7 +104,7 @@ public class S3PolicyIPAddressCondition extends S3PolicyCondition { return false; } logger.info("S3PolicyIPAddressCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith.toString() + - ", valueInRule: " + valueList[i].toString() + ", result: " + keyResult); + ", valueInRule: " + valueList[i].toString() + ", result: " + keyResult); } // -> if all key values are false, false then that key is false and then the entire condition is then false http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyNumericCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyNumericCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyNumericCondition.java index a1f741c..8790d7c 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyNumericCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyNumericCondition.java @@ -123,8 +123,8 @@ public class S3PolicyNumericCondition extends S3PolicyCondition { default: return false; } - logger.info("S3PolicyNumericCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith + ", valueInRule: " + - valueList[i] + ", result: " + keyResult); + logger.info("S3PolicyNumericCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith + + ", valueInRule: " + valueList[i] + ", result: " + keyResult); } // -> if all key values are, false then that key is false and then the entire condition is then false http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyStringCondition.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyStringCondition.java b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyStringCondition.java index 78eb082..4f56d3e 100644 --- a/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyStringCondition.java +++ b/awsapi/src/com/cloud/bridge/service/core/s3/S3PolicyStringCondition.java @@ -120,8 +120,8 @@ public class S3PolicyStringCondition extends S3PolicyCondition { default: return false; } - logger.info("S3PolicyStringCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith + ", valueInRule: " + - valueList[i] + ", result: " + keyResult); + logger.info("S3PolicyStringCondition eval - SID: " + SID + ", " + condition + ", key: " + keyName + ", valuePassedIn: " + toCompareWith + + ", valueInRule: " + valueList[i] + ", result: " + keyResult); } // -> if all key values are false, false then that key is false and then the entire condition is then false http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/tool/CloudS3CmdTool.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/tool/CloudS3CmdTool.java b/awsapi/src/com/cloud/bridge/tool/CloudS3CmdTool.java index 4c88e73..190b7a7 100644 --- a/awsapi/src/com/cloud/bridge/tool/CloudS3CmdTool.java +++ b/awsapi/src/com/cloud/bridge/tool/CloudS3CmdTool.java @@ -222,7 +222,7 @@ public class CloudS3CmdTool { ListBucketResult result = response.getListBucketResponse(); System.out.println("\tContent of Bucket " + result.getName()); System.out.println("\tListing with prefix: " + result.getPrefix() + ", delimiter: " + result.getDelimiter() + ", marker: " + result.getMarker() + ", max: " + - result.getMaxKeys()); + result.getMaxKeys()); ListEntry[] entries = result.getContents(); if (entries != null) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/AuthenticationUtils.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/AuthenticationUtils.java b/awsapi/src/com/cloud/bridge/util/AuthenticationUtils.java index 4486769..bc5dcbf 100644 --- a/awsapi/src/com/cloud/bridge/util/AuthenticationUtils.java +++ b/awsapi/src/com/cloud/bridge/util/AuthenticationUtils.java @@ -16,12 +16,13 @@ // under the License. package com.cloud.bridge.util; -import org.apache.log4j.Logger; - +import java.math.BigInteger; import java.security.cert.Certificate; import java.security.cert.X509Certificate; + import javax.security.auth.x500.X500Principal; -import java.math.BigInteger; + +import org.apache.log4j.Logger; public class AuthenticationUtils { protected final static Logger logger = Logger.getLogger(AuthenticationUtils.class); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/ISO8601SimpleDateTimeFormat.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/ISO8601SimpleDateTimeFormat.java b/awsapi/src/com/cloud/bridge/util/ISO8601SimpleDateTimeFormat.java index 932870a..e5f3820 100644 --- a/awsapi/src/com/cloud/bridge/util/ISO8601SimpleDateTimeFormat.java +++ b/awsapi/src/com/cloud/bridge/util/ISO8601SimpleDateTimeFormat.java @@ -17,13 +17,12 @@ package com.cloud.bridge.util; -import java.text.SimpleDateFormat; - import java.text.DateFormat; import java.text.FieldPosition; import java.text.ParsePosition; -import java.util.Date; +import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import java.util.TimeZone; /** http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/IpAddressRange.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/IpAddressRange.java b/awsapi/src/com/cloud/bridge/util/IpAddressRange.java index 9757eb0..785c032 100644 --- a/awsapi/src/com/cloud/bridge/util/IpAddressRange.java +++ b/awsapi/src/com/cloud/bridge/util/IpAddressRange.java @@ -16,8 +16,6 @@ // under the License. package com.cloud.bridge.util; -import java.io.IOException; - /** * Represents a network IP address or a range of addresses. * A range is useful when representing IP addresses defined in http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/JsonAccessor.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/JsonAccessor.java b/awsapi/src/com/cloud/bridge/util/JsonAccessor.java index 7fbb2fe..2a94dea 100644 --- a/awsapi/src/com/cloud/bridge/util/JsonAccessor.java +++ b/awsapi/src/com/cloud/bridge/util/JsonAccessor.java @@ -22,12 +22,13 @@ import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.cloud.bridge.service.exception.InternalErrorException; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import com.cloud.bridge.service.exception.InternalErrorException; + /** * JsonAccessor provides the functionality to allow navigating JSON object graph using simple expressions, * for example, following property access expressions are all valid ones http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/PolicyParser.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/PolicyParser.java b/awsapi/src/com/cloud/bridge/util/PolicyParser.java index 9bcbdbc..a19bc96 100644 --- a/awsapi/src/com/cloud/bridge/util/PolicyParser.java +++ b/awsapi/src/com/cloud/bridge/util/PolicyParser.java @@ -25,15 +25,15 @@ import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import com.cloud.bridge.service.core.s3.S3BucketPolicy; +import com.cloud.bridge.service.core.s3.S3BucketPolicy.PolicyAccess; import com.cloud.bridge.service.core.s3.S3ConditionFactory; import com.cloud.bridge.service.core.s3.S3PolicyAction; +import com.cloud.bridge.service.core.s3.S3PolicyAction.PolicyActions; import com.cloud.bridge.service.core.s3.S3PolicyCondition; +import com.cloud.bridge.service.core.s3.S3PolicyCondition.ConditionKeys; import com.cloud.bridge.service.core.s3.S3PolicyConditionBlock; import com.cloud.bridge.service.core.s3.S3PolicyPrincipal; import com.cloud.bridge.service.core.s3.S3PolicyStatement; -import com.cloud.bridge.service.core.s3.S3BucketPolicy.PolicyAccess; -import com.cloud.bridge.service.core.s3.S3PolicyAction.PolicyActions; -import com.cloud.bridge.service.core.s3.S3PolicyCondition.ConditionKeys; import com.cloud.bridge.service.exception.PermissionDeniedException; /** @@ -345,8 +345,8 @@ public class PolicyParser { testBucketName = testBucketName.substring(0, offset); if (!testBucketName.equals(bucketName)) - throw new PermissionDeniedException("The S3 Bucket Policy must only refer to the single bucket: \"" + bucketName + "\", but it referres to the following resource: \"" + - resourcePath + "\""); + throw new PermissionDeniedException("The S3 Bucket Policy must only refer to the single bucket: \"" + bucketName + + "\", but it referres to the following resource: \"" + resourcePath + "\""); } public static void badPolicy(String place, String badValue) throws ParseException { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/RestAuth.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/RestAuth.java b/awsapi/src/com/cloud/bridge/util/RestAuth.java index 613ee41..c370c4a 100644 --- a/awsapi/src/com/cloud/bridge/util/RestAuth.java +++ b/awsapi/src/com/cloud/bridge/util/RestAuth.java @@ -16,11 +16,16 @@ // under the License. package com.cloud.bridge.util; -import java.security.InvalidKeyException; -import java.security.SignatureException; -import java.util.*; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.security.InvalidKeyException; +import java.security.SignatureException; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/XSerializerJsonAdapter.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/XSerializerJsonAdapter.java b/awsapi/src/com/cloud/bridge/util/XSerializerJsonAdapter.java index cc59a34..27d8d53 100644 --- a/awsapi/src/com/cloud/bridge/util/XSerializerJsonAdapter.java +++ b/awsapi/src/com/cloud/bridge/util/XSerializerJsonAdapter.java @@ -57,7 +57,8 @@ public class XSerializerJsonAdapter implements XSerializerAdapter { if (value != null) { indent(true, indentLevel, writer); writer.print(elementName + ":\""); - writer.print(DateHelper.getGMTDateFormat("yyyy-MM-dd").format((Date)value) + "T" + DateHelper.getGMTDateFormat("HH:mm:ss").format((Date)value) + ".000Z"); + writer.print(DateHelper.getGMTDateFormat("yyyy-MM-dd").format((Date)value) + "T" + DateHelper.getGMTDateFormat("HH:mm:ss").format((Date)value) + + ".000Z"); writer.print("\""); } else { if (!serializer.omitNullField(f)) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/XSerializerXmlAdapter.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/XSerializerXmlAdapter.java b/awsapi/src/com/cloud/bridge/util/XSerializerXmlAdapter.java index 248b059..c21d3b3 100644 --- a/awsapi/src/com/cloud/bridge/util/XSerializerXmlAdapter.java +++ b/awsapi/src/com/cloud/bridge/util/XSerializerXmlAdapter.java @@ -61,7 +61,8 @@ public class XSerializerXmlAdapter implements XSerializerAdapter { if (value != null) { indent(true, indentLevel, writer); writer.print("<" + elementName + ">"); - writer.print(DateHelper.getGMTDateFormat("yyyy-MM-dd").format((Date)value) + "T" + DateHelper.getGMTDateFormat("HH:mm:ss").format((Date)value) + ".000Z"); + writer.print(DateHelper.getGMTDateFormat("yyyy-MM-dd").format((Date)value) + "T" + DateHelper.getGMTDateFormat("HH:mm:ss").format((Date)value) + + ".000Z"); writer.print(""); } else { if (!serializer.omitNullField(f)) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/bridge/util/XmlHelper.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/util/XmlHelper.java b/awsapi/src/com/cloud/bridge/util/XmlHelper.java index 92cd013..0bcd245 100644 --- a/awsapi/src/com/cloud/bridge/util/XmlHelper.java +++ b/awsapi/src/com/cloud/bridge/util/XmlHelper.java @@ -23,14 +23,6 @@ import java.io.InputStream; import java.io.StringWriter; import java.util.Properties; -import org.apache.log4j.Logger; -import org.w3c.dom.Document; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -42,6 +34,14 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.apache.log4j.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + public class XmlHelper { protected static Logger logger = Logger.getLogger(XmlHelper.class); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/stack/CloudStackApi.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/stack/CloudStackApi.java b/awsapi/src/com/cloud/stack/CloudStackApi.java index ab6cb91..b7a1210 100644 --- a/awsapi/src/com/cloud/stack/CloudStackApi.java +++ b/awsapi/src/com/cloud/stack/CloudStackApi.java @@ -21,6 +21,8 @@ import java.util.List; import org.apache.log4j.Logger; +import com.google.gson.reflect.TypeToken; + import com.cloud.stack.models.ApiConstants; import com.cloud.stack.models.CloudStackAccount; import com.cloud.stack.models.CloudStackCapabilities; @@ -44,7 +46,6 @@ import com.cloud.stack.models.CloudStackPortForwardingRule; import com.cloud.stack.models.CloudStackResourceLimit; import com.cloud.stack.models.CloudStackResourceTag; import com.cloud.stack.models.CloudStackSecurityGroup; -import com.cloud.stack.models.CloudStackSecurityGroupIngress; import com.cloud.stack.models.CloudStackServiceOffering; import com.cloud.stack.models.CloudStackSnapshot; import com.cloud.stack.models.CloudStackSnapshotPolicy; @@ -53,7 +54,6 @@ import com.cloud.stack.models.CloudStackTemplatePermission; import com.cloud.stack.models.CloudStackUserVm; import com.cloud.stack.models.CloudStackVolume; import com.cloud.stack.models.CloudStackZone; -import com.google.gson.reflect.TypeToken; /** * The goal here is to wrap the actual CloudStack API calls... @@ -139,8 +139,8 @@ public class CloudStackApi { * @throws Exception */ public CloudStackUserVm deployVirtualMachine(String serviceOfferingId, String templateId, String zoneId, String account, String diskOfferingId, String displayName, - String domainId, String group, String hostId, String hypervisor, String keyPair, String name, String networkId, String securityGroupIds, String securityGroupNames, - Long size, String userData) throws Exception { + String domainId, String group, String hostId, String hypervisor, String keyPair, String name, String networkId, String securityGroupIds, + String securityGroupNames, Long size, String userData) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.DEPLOY_VIRTUAL_MACHINE); if (cmd != null) { // these are required @@ -368,8 +368,9 @@ public class CloudStackApi { if (resourceTags != null && resourceTags.size() > 0) cmd = setParams(cmd, null, null, resourceTags); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_VIRTUAL_MACHINES_RESPONSE, ApiConstants.VIRTUAL_MACHINE, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_VIRTUAL_MACHINES_RESPONSE, ApiConstants.VIRTUAL_MACHINE, + new TypeToken>() { + }.getType()); } /** @@ -405,8 +406,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackTemplate createTemplate(String displayText, String name, String osTypeId, String bits, Boolean isFeatured, Boolean isPublic, Boolean passwordEnabled, - Boolean requiresHVM, String snapshotId, String volumeId) throws Exception { + public CloudStackTemplate createTemplate(String displayText, String name, String osTypeId, String bits, Boolean isFeatured, Boolean isPublic, + Boolean passwordEnabled, Boolean requiresHVM, String snapshotId, String volumeId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.CREATE_TEMPLATE); if (cmd != null) { cmd.setParam(ApiConstants.DISPLAY_TEXT, displayText); @@ -452,8 +453,9 @@ public class CloudStackApi { * @return * @throws Exception */ - public List registerTemplate(String displayText, String format, String hypervisor, String name, String osTypeId, String url, String zoneId, String account, - String bits, String checksum, String domainId, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, Boolean passwordEnabled, Boolean requiresHVM) throws Exception { + public List registerTemplate(String displayText, String format, String hypervisor, String name, String osTypeId, String url, String zoneId, + String account, String bits, String checksum, String domainId, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, Boolean passwordEnabled, + Boolean requiresHVM) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.REGISTER_TEMPLATE); if (cmd != null) { cmd.setParam(ApiConstants.DISPLAY_TEXT, displayText); @@ -571,8 +573,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public List listTemplates(String templateFilter, String account, String domainId, String hypervisor, String id, String keyWord, String name, String zoneId) - throws Exception { + public List listTemplates(String templateFilter, String account, String domainId, String hypervisor, String id, String keyWord, String name, + String zoneId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_TEMPLATES); if (cmd != null) { cmd.setParam(ApiConstants.TEMPLATE_FILTER, templateFilter); @@ -609,7 +611,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackInfoResponse updateTemplatePermissions(String id, String accounts, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, String op) throws Exception { + public CloudStackInfoResponse updateTemplatePermissions(String id, String accounts, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, String op) + throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.UPDATE_TEMPLATE_PERMISSIONS); if (cmd != null) { cmd.setParam(ApiConstants.ID, id); @@ -645,7 +648,8 @@ public class CloudStackApi { if (domainId != null) cmd.setParam(ApiConstants.DOMAIN_ID, domainId); } - return _client.call(cmd, apiKey, secretKey, false, ApiConstants.LIST_TEMPLATE_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE_PERMISSION, CloudStackTemplatePermission.class); + return _client.call(cmd, apiKey, secretKey, false, ApiConstants.LIST_TEMPLATE_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE_PERMISSION, + CloudStackTemplatePermission.class); } /** @@ -720,8 +724,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public List listIsos(String account, Boolean bootable, String domainId, String hypervisor, String id, String isoFilter, Boolean isPublic, Boolean isReady, - String keyWord, String name, String zoneId) throws Exception { + public List listIsos(String account, Boolean bootable, String domainId, String hypervisor, String id, String isoFilter, Boolean isPublic, + Boolean isReady, String keyWord, String name, String zoneId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_ISOS); if (cmd != null) { if (account != null) @@ -768,8 +772,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackTemplate registerIso(String displayText, String name, String url, String zoneId, String account, Boolean bootable, String domainId, Boolean isExtractable, - Boolean isFeatured, Boolean isPublic, String osTypeId) throws Exception { + public CloudStackTemplate registerIso(String displayText, String name, String url, String zoneId, String account, Boolean bootable, String domainId, + Boolean isExtractable, Boolean isFeatured, Boolean isPublic, String osTypeId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.REGISTER_ISO); if (cmd != null) { cmd.setParam(ApiConstants.DISPLAY_TEXT, displayText); @@ -807,7 +811,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackTemplate updateIso(String id, Boolean bootable, String displayText, String format, String name, String osTypeId, Boolean passwordEnabled) throws Exception { + public CloudStackTemplate updateIso(String id, Boolean bootable, String displayText, String format, String name, String osTypeId, Boolean passwordEnabled) + throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.UPDATE_ISO); if (cmd != null) { cmd.setParam(ApiConstants.ID, id); @@ -875,7 +880,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackInfoResponse updateIsoPermissions(String id, String accounts, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, String op) throws Exception { + public CloudStackInfoResponse updateIsoPermissions(String id, String accounts, Boolean isExtractable, Boolean isFeatured, Boolean isPublic, String op) + throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.UPDATE_ISO_PERMISSIONS); if (cmd != null) { cmd.setParam(ApiConstants.ID, id); @@ -910,8 +916,9 @@ public class CloudStackApi { if (domainId != null) cmd.setParam(ApiConstants.DOMAIN_ID, domainId); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_ISO_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_ISO_PERMISSIONS_RESPONSE, ApiConstants.TEMPLATE, + new TypeToken>() { + }.getType()); } /** @@ -992,7 +999,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackVolume createVolume(String name, String account, String diskOfferingId, String domainId, Long size, String snapshotId, String zoneId) throws Exception { + public CloudStackVolume createVolume(String name, String account, String diskOfferingId, String domainId, Long size, String snapshotId, String zoneId) + throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.CREATE_VOLUME); if (cmd != null) { cmd.setParam(ApiConstants.NAME, name); @@ -1240,8 +1248,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackSecurityGroup authorizeSecurityGroupIngress(String account, String cidrList, String domainId, Long endPort, String icmpCode, String icmpType, String protocol, - String securityGroupId, String securityGroupName, Long startPort, List userSecurityGroupList) throws Exception { + public CloudStackSecurityGroup authorizeSecurityGroupIngress(String account, String cidrList, String domainId, Long endPort, String icmpCode, String icmpType, + String protocol, String securityGroupId, String securityGroupName, Long startPort, List userSecurityGroupList) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.AUTHORIZE_SECURITY_GROUP_INGRESS); if (cmd != null) { if (account != null) @@ -1273,7 +1281,8 @@ public class CloudStackApi { } } } - return _client.call(cmd, apiKey, secretKey, true, ApiConstants.AUTHORIZE_SECURITY_GROUP_INGRESS_RESPONSE, ApiConstants.SECURITY_GROUP, CloudStackSecurityGroup.class); + return _client.call(cmd, apiKey, secretKey, true, ApiConstants.AUTHORIZE_SECURITY_GROUP_INGRESS_RESPONSE, ApiConstants.SECURITY_GROUP, + CloudStackSecurityGroup.class); } /** @@ -1321,8 +1330,9 @@ public class CloudStackApi { if (virtualMachineId != null) cmd.setParam(ApiConstants.VIRTUAL_MACHINE_ID, virtualMachineId); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_SECURITY_GROUPS_RESPONSE, ApiConstants.SECURITY_GROUP, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_SECURITY_GROUPS_RESPONSE, ApiConstants.SECURITY_GROUP, + new TypeToken>() { + }.getType()); } // Accounts @@ -1340,8 +1350,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public List listAccounts(Long accountType, String domainId, String id, Boolean isCleanupRequired, Boolean isRecursive, String keyWord, String name, - String state) throws Exception { + public List listAccounts(Long accountType, String domainId, String id, Boolean isCleanupRequired, Boolean isRecursive, String keyWord, + String name, String state) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_ACCOUNTS); if (cmd != null) { if (accountType != null) @@ -1506,8 +1516,9 @@ public class CloudStackApi { if (keyWord != null) cmd.setParam(ApiConstants.KEYWORD, keyWord); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_SNAPSHOT_POLICIES_RESPONSE, ApiConstants.SNAPSHOT, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_SNAPSHOT_POLICIES_RESPONSE, ApiConstants.SNAPSHOT, + new TypeToken>() { + }.getType()); } // Events @@ -1673,8 +1684,9 @@ public class CloudStackApi { if (name != null) cmd.setParam(ApiConstants.NAME, name); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_DISK_OFFERINGS_RESPONSE, ApiConstants.DISK_OFFERING, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_DISK_OFFERINGS_RESPONSE, ApiConstants.DISK_OFFERING, + new TypeToken>() { + }.getType()); } // SSH keys @@ -1811,8 +1823,8 @@ public class CloudStackApi { * @param id * @return */ - public List listPublicIpAddresses(String account, Boolean allocatedOnly, String domainId, Boolean forVirtualNetwork, String id, String ipAddress, - String keyWord, String vlanId, String zoneId) throws Exception { + public List listPublicIpAddresses(String account, Boolean allocatedOnly, String domainId, Boolean forVirtualNetwork, String id, + String ipAddress, String keyWord, String vlanId, String zoneId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_PUBLIC_IP_ADDRESSES); if (cmd != null) { if (account != null) @@ -1834,8 +1846,9 @@ public class CloudStackApi { if (zoneId != null) cmd.setParam(ApiConstants.ZONE_ID, zoneId); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_PUBLIC_IP_ADDRESSES_RESPONSE, ApiConstants.PUBLIC_IP_ADDRESS, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_PUBLIC_IP_ADDRESSES_RESPONSE, ApiConstants.PUBLIC_IP_ADDRESS, + new TypeToken>() { + }.getType()); } // Firewall @@ -1883,8 +1896,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public CloudStackPortForwardingRule createPortForwardingRule(String ipAddressId, Long privatePort, String protocol, Long publicPort, String virtualMachineId, String cidrList, - Long privateEndPort, Long publicEndPort) throws Exception { + public CloudStackPortForwardingRule createPortForwardingRule(String ipAddressId, Long privatePort, String protocol, Long publicPort, String virtualMachineId, + String cidrList, Long privateEndPort, Long publicEndPort) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.CREATE_PORT_FORWARDING_RULE); if (cmd != null) { cmd.setParam(ApiConstants.IP_ADDRESS_ID, ipAddressId); @@ -1899,7 +1912,8 @@ public class CloudStackApi { if (publicEndPort != null) cmd.setParam(ApiConstants.PUBLIC_END_PORT, publicEndPort.toString()); } - return _client.call(cmd, apiKey, secretKey, true, ApiConstants.CREATE_PORT_FORWARDING_RULE_RESPONSE, ApiConstants.PORT_FORWARDING_RULE, CloudStackPortForwardingRule.class); + return _client.call(cmd, apiKey, secretKey, true, ApiConstants.CREATE_PORT_FORWARDING_RULE_RESPONSE, ApiConstants.PORT_FORWARDING_RULE, + CloudStackPortForwardingRule.class); } /** @@ -1953,7 +1967,8 @@ public class CloudStackApi { if (endPort != null) cmd.setParam(ApiConstants.END_PORT, endPort.toString()); } - return _client.call(cmd, apiKey, secretKey, true, ApiConstants.CREATE_IP_FORWARDING_RULE_RESPONSE, ApiConstants.IP_FORWARDING_RULE, CloudStackPortForwardingRule.class); + return _client.call(cmd, apiKey, secretKey, true, ApiConstants.CREATE_IP_FORWARDING_RULE_RESPONSE, ApiConstants.IP_FORWARDING_RULE, + CloudStackPortForwardingRule.class); } /** @@ -1983,8 +1998,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public List listIpForwardingRules(String account, String domainId, String id, String ipAddressId, String keyWord, String virtualMachineId) - throws Exception { + public List listIpForwardingRules(String account, String domainId, String id, String ipAddressId, String keyWord, + String virtualMachineId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_IP_FORWARDING_RULES); if (cmd != null) { if (account != null) @@ -2265,8 +2280,9 @@ public class CloudStackApi { if (name != null) cmd.setParam(ApiConstants.NAME, name); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_INSTANCE_GROUPS_RESPONSE, ApiConstants.INSTANCE_GROUP, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_INSTANCE_GROUPS_RESPONSE, ApiConstants.INSTANCE_GROUP, + new TypeToken>() { + }.getType()); } @@ -2492,8 +2508,8 @@ public class CloudStackApi { * @return * @throws Exception */ - public List listNetworkOfferings(String availability, String displayText, String guestIpType, String id, Boolean isDefault, Boolean isShared, - String keyWord, String name, String specifyVLan, String trafficType, String zoneId) throws Exception { + public List listNetworkOfferings(String availability, String displayText, String guestIpType, String id, Boolean isDefault, + Boolean isShared, String keyWord, String name, String specifyVLan, String trafficType, String zoneId) throws Exception { CloudStackCommand cmd = new CloudStackCommand(ApiConstants.LIST_NETWORK_OFFERINGS); if (cmd != null) { if (availability != null) @@ -2562,8 +2578,9 @@ public class CloudStackApi { if (resourceType != null) cmd.setParam(ApiConstants.RESOURCE_TYPE, resourceType); } - return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_RESOURCE_LIMITS_RESPONSE, ApiConstants.RESOURCE_LIMIT, new TypeToken>() { - }.getType()); + return _client.listCall(cmd, apiKey, secretKey, ApiConstants.LIST_RESOURCE_LIMITS_RESPONSE, ApiConstants.RESOURCE_LIMIT, + new TypeToken>() { + }.getType()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/src/com/cloud/stack/CloudStackClient.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/stack/CloudStackClient.java b/awsapi/src/com/cloud/stack/CloudStackClient.java index c8d63cd..03eba96 100644 --- a/awsapi/src/com/cloud/stack/CloudStackClient.java +++ b/awsapi/src/com/cloud/stack/CloudStackClient.java @@ -27,11 +27,12 @@ import java.util.List; import org.apache.log4j.Logger; -import com.cloud.bridge.util.JsonAccessor; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonParser; +import com.cloud.bridge.util.JsonAccessor; + /** * CloudStackClient implements a simple CloudStack client object, it can be used to execute CloudStack commands * with JSON response @@ -85,8 +86,8 @@ public class CloudStackClient { return this; } - public T call(CloudStackCommand cmd, String apiKey, String secretKey, boolean followToAsyncResult, String responseName, String responseObjName, Class responseClz) - throws Exception { + public T call(CloudStackCommand cmd, String apiKey, String secretKey, boolean followToAsyncResult, String responseName, String responseObjName, + Class responseClz) throws Exception { assert (responseName != null); @@ -104,7 +105,7 @@ public class CloudStackClient { switch (jobStatus) { case 2: throw new Exception(queryAsyncJobResponse.getAsString("queryasyncjobresultresponse.jobresult.errortext") + " Error Code - " + - queryAsyncJobResponse.getAsString("queryasyncjobresultresponse.jobresult.errorcode")); + queryAsyncJobResponse.getAsString("queryasyncjobresultresponse.jobresult.errorcode")); case 0: try { @@ -138,7 +139,8 @@ public class CloudStackClient { } // collectionType example : new TypeToken>() {}.getType(); - public List listCall(CloudStackCommand cmd, String apiKey, String secretKey, String responseName, String responseObjName, Type collectionType) throws Exception { + public List listCall(CloudStackCommand cmd, String apiKey, String secretKey, String responseName, String responseObjName, Type collectionType) + throws Exception { assert (responseName != null); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/test/com/cloud/gate/service/ServiceTestCase.java ---------------------------------------------------------------------- diff --git a/awsapi/test/com/cloud/gate/service/ServiceTestCase.java b/awsapi/test/com/cloud/gate/service/ServiceTestCase.java index a939b13..e768365 100644 --- a/awsapi/test/com/cloud/gate/service/ServiceTestCase.java +++ b/awsapi/test/com/cloud/gate/service/ServiceTestCase.java @@ -27,6 +27,7 @@ import com.amazon.s3.client.AmazonS3Stub.CreateBucket; import com.amazon.s3.client.AmazonS3Stub.CreateBucketResponse; import com.amazon.s3.client.AmazonS3Stub.DeleteBucket; import com.amazon.s3.client.AmazonS3Stub.DeleteBucketResponse; + import com.cloud.gate.testcase.BaseTestCase; public class ServiceTestCase extends BaseTestCase { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/test/com/cloud/gate/util/CloudStackClientTestCase.java ---------------------------------------------------------------------- diff --git a/awsapi/test/com/cloud/gate/util/CloudStackClientTestCase.java b/awsapi/test/com/cloud/gate/util/CloudStackClientTestCase.java index 1ed4952..826cb3a 100644 --- a/awsapi/test/com/cloud/gate/util/CloudStackClientTestCase.java +++ b/awsapi/test/com/cloud/gate/util/CloudStackClientTestCase.java @@ -22,11 +22,12 @@ import junit.framework.Assert; import org.apache.log4j.Logger; +import com.google.gson.reflect.TypeToken; + import com.cloud.gate.testcase.BaseTestCase; import com.cloud.stack.CloudStackClient; import com.cloud.stack.CloudStackCommand; import com.cloud.stack.models.CloudStackUserVm; -import com.google.gson.reflect.TypeToken; public class CloudStackClientTestCase extends BaseTestCase { protected final static Logger logger = Logger.getLogger(CloudStackClientTestCase.class); @@ -57,8 +58,9 @@ public class CloudStackClientTestCase extends BaseTestCase { command.setParam("page", "1"); command.setParam("pagesize", "20"); try { - List vms = client.listCall(command, API_KEY, SECRET_KEY, "listvirtualmachinesresponse", "virtualmachine", new TypeToken>() { - }.getType()); + List vms = + client.listCall(command, API_KEY, SECRET_KEY, "listvirtualmachinesresponse", "virtualmachine", new TypeToken>() { + }.getType()); for (CloudStackUserVm vm : vms) { logger.info("id: " + vm.getId() + ", name: " + vm.getName()); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/test/com/cloud/gate/util/JsonAccessorTestCase.java ---------------------------------------------------------------------- diff --git a/awsapi/test/com/cloud/gate/util/JsonAccessorTestCase.java b/awsapi/test/com/cloud/gate/util/JsonAccessorTestCase.java index 8b59f53..8603e59 100644 --- a/awsapi/test/com/cloud/gate/util/JsonAccessorTestCase.java +++ b/awsapi/test/com/cloud/gate/util/JsonAccessorTestCase.java @@ -20,13 +20,14 @@ import junit.framework.Assert; import org.apache.log4j.Logger; -import com.cloud.bridge.util.JsonAccessor; -import com.cloud.gate.testcase.BaseTestCase; -import com.cloud.stack.models.CloudStackSnapshot; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonParser; +import com.cloud.bridge.util.JsonAccessor; +import com.cloud.gate.testcase.BaseTestCase; +import com.cloud.stack.models.CloudStackSnapshot; + public class JsonAccessorTestCase extends BaseTestCase { protected final static Logger logger = Logger.getLogger(UtilTestCase.class); @@ -53,7 +54,8 @@ public class JsonAccessorTestCase extends BaseTestCase { } public void testGson() { - String response = "{ \"queryasyncjobresultresponse\" : {\"jobid\":5868,\"jobstatus\":1,\"jobprocstatus\":0,\"jobresultcode\":0,\"jobresulttype\":\"object\",\"jobresult\":{\"snapshot\":{\"id\":3161,\"account\":\"admin\",\"domainid\":1,\"domain\":\"ROOT\",\"snapshottype\":\"MANUAL\",\"volumeid\":186928,\"volumename\":\"KY-DATA-VOL\",\"volumetype\":\"DATADISK\",\"created\":\"2011-06-02T05:05:41-0700\",\"name\":\"i-2-246446-VM_KY-DATA-VOL_20110602120541\",\"intervaltype\":\"MANUAL\",\"state\":\"BackedUp\"}}}}"; + String response = + "{ \"queryasyncjobresultresponse\" : {\"jobid\":5868,\"jobstatus\":1,\"jobprocstatus\":0,\"jobresultcode\":0,\"jobresulttype\":\"object\",\"jobresult\":{\"snapshot\":{\"id\":3161,\"account\":\"admin\",\"domainid\":1,\"domain\":\"ROOT\",\"snapshottype\":\"MANUAL\",\"volumeid\":186928,\"volumename\":\"KY-DATA-VOL\",\"volumetype\":\"DATADISK\",\"created\":\"2011-06-02T05:05:41-0700\",\"name\":\"i-2-246446-VM_KY-DATA-VOL_20110602120541\",\"intervaltype\":\"MANUAL\",\"state\":\"BackedUp\"}}}}"; JsonParser parser = new JsonParser(); JsonElement json = parser.parse(response); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/awsapi/test/com/cloud/gate/util/UtilTestCase.java ---------------------------------------------------------------------- diff --git a/awsapi/test/com/cloud/gate/util/UtilTestCase.java b/awsapi/test/com/cloud/gate/util/UtilTestCase.java index b9b43d2..3e25622 100644 --- a/awsapi/test/com/cloud/gate/util/UtilTestCase.java +++ b/awsapi/test/com/cloud/gate/util/UtilTestCase.java @@ -23,6 +23,8 @@ import java.util.Calendar; import java.util.Date; import java.util.List; +import junit.framework.Assert; + import org.apache.log4j.Logger; import com.cloud.bridge.util.DateHelper; @@ -33,8 +35,6 @@ import com.cloud.bridge.util.XSerializerJsonAdapter; import com.cloud.bridge.util.XSerializerXmlAdapter; import com.cloud.gate.testcase.BaseTestCase; -import junit.framework.Assert; - class SubFoo { @XElement(name = "Name") private String name; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/core/src/com/cloud/agent/api/AgentControlCommand.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/AgentControlCommand.java b/core/src/com/cloud/agent/api/AgentControlCommand.java index 772bc45..5d3de86 100644 --- a/core/src/com/cloud/agent/api/AgentControlCommand.java +++ b/core/src/com/cloud/agent/api/AgentControlCommand.java @@ -21,6 +21,7 @@ public class AgentControlCommand extends Command { public AgentControlCommand() { } + @Override public boolean executeInSequence() { return false; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/core/src/com/cloud/agent/api/AttachVolumeCommand.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/AttachVolumeCommand.java b/core/src/com/cloud/agent/api/AttachVolumeCommand.java index de78aea..db0cd0a 100644 --- a/core/src/com/cloud/agent/api/AttachVolumeCommand.java +++ b/core/src/com/cloud/agent/api/AttachVolumeCommand.java @@ -44,8 +44,8 @@ public class AttachVolumeCommand extends Command { protected AttachVolumeCommand() { } - public AttachVolumeCommand(boolean attach, boolean managed, String vmName, StoragePoolType pooltype, String volumePath, String volumeName, Long volumeSize, Long deviceId, - String chainInfo) { + public AttachVolumeCommand(boolean attach, boolean managed, String vmName, StoragePoolType pooltype, String volumePath, String volumeName, Long volumeSize, + Long deviceId, String chainInfo) { this.attach = attach; this._managed = managed; this.vmName = vmName; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d620df2b/core/src/com/cloud/agent/api/BackupSnapshotCommand.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/api/BackupSnapshotCommand.java b/core/src/com/cloud/agent/api/BackupSnapshotCommand.java index 3bc53be..6e1e3be 100644 --- a/core/src/com/cloud/agent/api/BackupSnapshotCommand.java +++ b/core/src/com/cloud/agent/api/BackupSnapshotCommand.java @@ -52,8 +52,8 @@ public class BackupSnapshotCommand extends SnapshotCommand { * @param isVolumeInactive True if the volume belongs to a VM that is not running or is detached. * @param secHostId This is the Id of the secondary storage. */ - public BackupSnapshotCommand(String secondaryStoragePoolURL, Long dcId, Long accountId, Long volumeId, Long snapshotId, Long secHostId, String volumePath, StoragePool pool, - String snapshotUuid, String snapshotName, String prevSnapshotUuid, String prevBackupUuid, boolean isVolumeInactive, String vmName, int wait) { + public BackupSnapshotCommand(String secondaryStoragePoolURL, Long dcId, Long accountId, Long volumeId, Long snapshotId, Long secHostId, String volumePath, + StoragePool pool, String snapshotUuid, String snapshotName, String prevSnapshotUuid, String prevBackupUuid, boolean isVolumeInactive, String vmName, int wait) { super(pool, secondaryStoragePoolURL, snapshotUuid, snapshotName, dcId, accountId, volumeId); this.snapshotId = snapshotId; this.prevSnapshotUuid = prevSnapshotUuid;