package jp.ac.nii.prl.mape.monitoring.service;

import java.util.UUID;

import org.springframework.stereotype.Service;

import com.amazonaws.services.ec2.model.IpPermission;

import jp.ac.nii.prl.mape.monitoring.model.FirewallRule;

@Service("firewallRuleService")
public class FirewallRuleServiceImpl implements FirewallRuleService {
	
	/* (non-Javadoc)
	 * @see jp.ac.nii.prl.mape.monitoring.service.FirewallRuleService#fromAWS(com.amazonaws.services.ec2.model.IpPermission)
	 */
	@Override
	public FirewallRule fromAWS(IpPermission ipPermission) {
		FirewallRule firewallRule = new FirewallRule();
		
		firewallRule.setFwRuleID(UUID.randomUUID().toString());
		firewallRule.setFwStatus(0);
		firewallRule.setIp(ipPermission.getIpRanges().get(0));
		
		return firewallRule;
	}
}

@@ -686,16 +686,62 @@
 tus(0);%0A
+%09%09if (!ipPermission.getIpRanges().isEmpty())%0A%09
 %09%09firewa
@@ -789,16 +789,135 @@
 et(0));%0A
+%09%09firewallRule.setPort(ipPermission.getToPort().toString());%0A%09%09firewallRule.setProtocol(ipPermission.getIpProtocol());%0A
 %09%09%0A%09%09ret

Set port and protocol