001 /**
002 *
003 */
004 package de.jw.cloud42.webservice.wrapper;
005
006 import java.util.ArrayList;
007 import java.util.List;
008
009 /**
010 *
011 * Extends Typicas GroupDescription and adds list of permissions as an array of
012 * {@link Cloud42IpPermission} since Axis2 does not recognize the standard list of the nested type
013 * <code>GroupDescription.IpPermission</code>.
014 *
015 * @author fbitzer
016 *
017 */
018 public class Cloud42GroupDescription extends com.xerox.amazonws.ec2.GroupDescription{
019
020 public Cloud42GroupDescription(String name, String desc, String owner){
021 super( name, desc, owner);
022 }
023
024
025 /**
026 * Load the properties of the given "original" GroupDescription in this instance.
027 *
028 * @param gd
029 */
030 public static Cloud42GroupDescription parse(com.xerox.amazonws.ec2.GroupDescription gd){
031
032 Cloud42GroupDescription result = new Cloud42GroupDescription(gd.getName(),gd.getDescription(), gd.getOwner());
033
034 List<IpPermission> permissions = gd.getPermissions();
035
036 for (IpPermission p : permissions){
037
038 result.addPermission(p.getProtocol(), p.getFromPort(), p.getToPort());
039
040 }
041
042 return result;
043
044 }
045
046 /**
047 * Return current permissions as array of type Cloud42IpPermission.
048 * Reason: Typica's GroupDescription uses a List of the nested type GroupDescription.IpPermission
049 * and Axis2 does not recognize and publish this type, so it is not accessible in client applications
050 * unless you include Typica.
051
052 * @return
053 */
054 public Cloud42IpPermission[] getPermissionsAsArray() {
055
056 List<IpPermission> pList = super.getPermissions();
057
058 List<Cloud42IpPermission> cloud42List = new ArrayList<Cloud42IpPermission>();
059
060 for (IpPermission p : pList){
061 cloud42List.add(new Cloud42IpPermission(p));
062 }
063
064 return cloud42List.toArray(new Cloud42IpPermission[0]);
065
066 }
067
068
069 }