private DescribeSecurityGroupsResponseType describeSecurityGroups ( ) { DescribeSecurityGroupsResponseType ret = new DescribeSecurityGroupsResponseType ( ) ; ret . setRequestId ( UUID . randomUUID ( ) . toString ( ) ) ; SecurityGroupSetType securityGroupSet = new SecurityGroupSetType ( ) ; for ( Iterator < MockSecurityGroup > mockSecurityGroup = mockSecurityGroupController . describeSecurityGroups ( ) . iterator ( ) ; mockSecurityGroup . hasNext ( ) ; ) { MockSecurityGroup item = mockSecurityGroup . next ( ) ; // initialize securityGroupItem SecurityGroupItemType securityGroupItem = new SecurityGroupItemType ( ) ; securityGroupItem . setOwnerId ( MOCK_SECURITY_OWNER_ID ) ; securityGroupItem . setGroupName ( item . getGroupName ( ) ) ; if ( ! DEFAULT_MOCK_PLACEMENT . getAvailabilityZone ( ) . equals ( currentRegion ) ) { securityGroupItem . setGroupId ( currentRegion + "_" + item . getGroupId ( ) ) ; securityGroupItem . setVpcId ( currentRegion + "_" + item . getVpcId ( ) ) ; } else { securityGroupItem . setGroupId ( item . getGroupId ( ) ) ; securityGroupItem . setVpcId ( item . getVpcId ( ) ) ; } securityGroupItem . setGroupDescription ( item . getGroupDescription ( ) ) ; IpPermissionSetType ipPermissionSet = new IpPermissionSetType ( ) ; for ( MockIpPermissionType mockIpPermissionType : item . getIpPermissions ( ) ) { // initialize ipPermission IpPermissionType ipPermission = new IpPermissionType ( ) ; ipPermission . setFromPort ( mockIpPermissionType . getFromPort ( ) ) ; ipPermission . setToPort ( mockIpPermissionType . getToPort ( ) ) ; ipPermission . setIpProtocol ( mockIpPermissionType . getIpProtocol ( ) ) ; ipPermissionSet . getItem ( ) . add ( ipPermission ) ; } IpPermissionSetType ipPermissionEgressSet = new IpPermissionSetType ( ) ; for ( MockIpPermissionType mockIpPermissionType : item . getIpPermissionsEgress ( ) ) { // initialize ipPermission IpPermissionType ipPermission = new IpPermissionType ( ) ; ipPermission . setFromPort ( mockIpPermissionType . getFromPort ( ) ) ; ipPermission . setToPort ( mockIpPermissionType . getToPort ( ) ) ; ipPermission . setIpProtocol ( mockIpPermissionType . getIpProtocol ( ) ) ; ipPermissionEgressSet . getItem ( ) . add ( ipPermission ) ; } securityGroupItem . setIpPermissionsEgress ( ipPermissionEgressSet ) ; securityGroupSet . getItem ( ) . add ( securityGroupItem ) ; } ret . setSecurityGroupInfo ( securityGroupSet ) ; return ret ; }
Handles describeSecurityGroups request and returns response with a security group .