Coverage Report - yarfraw.core.datamodel.Cloud
 
Classes in this File Line Coverage Branch Coverage Complexity
Cloud
91% 
100% 
0
 
 1  
 package yarfraw.core.datamodel;
 2  
 
 3  
 import yarfraw.utils.ValidationUtils;
 4  
 
 5  
 /**
 6  
  * <b>This is only used by Rss 2.0.</b>
 7  
  * 
 8  
  * <p>
 9  
  * It specifies a web service that supports the rssCloud interface which can be implemented in HTTP-POST, XML-RPC or SOAP 1.1.
 10  
  * Its purpose is to allow processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.
 11  
  * <cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="myCloud.rssPleaseNotify" protocol="xml-rpc" />
 12  
  * In this example, to request notification on the channel it appears in, you would send an XML-RPC message to rpc.sys.com on port 80, with a path of /RPC2. The procedure to call is myCloud.rssPleaseNotify.
 13  
  * <br/>
 14  
  * A full explanation of this element and the rssCloud interface is here.
 15  
  * <br/>
 16  
  * http://cyber.law.harvard.edu/rss/soapMeetsRss.html#rsscloudInterface
 17  
  * <p/>
 18  
  * Example: &lt;cloud domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="pingMe" protocol="soap"/>
 19  
  * @author jliang
 20  
  *
 21  
  */
 22  3
 public class Cloud extends AbstractBaseObject{
 23  
   private static final long serialVersionUID = 20070927L;
 24  
   private String _domain;
 25  
   private String _port;
 26  
   private String _path;
 27  
   private String _registerProcedure;
 28  
   private String _protocol;
 29  3
   public Cloud(){}
 30  
   public static Cloud create(){
 31  0
     return new Cloud();
 32  
   }
 33  
   public Cloud(String domain, String port, String path,
 34  
           String registerProcedure, String protocol) {
 35  12
     super();
 36  12
     setDomain(domain);
 37  12
     setPath(path);
 38  12
     setPort(port);
 39  12
     setRegisterProcedure(registerProcedure);
 40  12
     setProtocol(protocol);
 41  12
   }
 42  
   public String getDomain() {
 43  3
     return _domain;
 44  
   }
 45  
   public Cloud setDomain(String domain) {
 46  12
     _domain = domain;
 47  12
     return this;
 48  
   }
 49  
 
 50  
   public String getPort() {
 51  3
     return _port;
 52  
   }
 53  
   public void setPort(String port) {
 54  12
     _port = port;
 55  12
   }
 56  
   public String getPath() {
 57  3
     return _path;
 58  
   }
 59  
   public Cloud setPath(String path) {
 60  12
     _path = path;
 61  12
     return this;
 62  
   }
 63  
   public String getRegisterProcedure() {
 64  3
     return _registerProcedure;
 65  
   }
 66  
   public Cloud setRegisterProcedure(String registerProcedure) {
 67  12
     _registerProcedure = registerProcedure;
 68  12
     return this;
 69  
   }
 70  
   public String getProtocol() {
 71  3
     return _protocol;
 72  
   }
 73  
   public Cloud setProtocol(String protocol) {
 74  15
     _protocol = protocol;
 75  15
     return this;
 76  
   }
 77  
   @Override
 78  
   public void validate(FeedFormat format) throws ValidationException {
 79  9
     if(format != FeedFormat.RSS20){
 80  0
       return; //no support
 81  
     }
 82  
     
 83  9
     ValidationUtils.validateNotNull("Cloud: All fields in the cloud object should be not null", _domain, _path, _port, _protocol, _registerProcedure);
 84  6
     if(!_protocol.equals("xml-rpc") && !_protocol.equals("http-post") && !_protocol.equals("soap")){
 85  3
       throw new ValidationException("Cloud: Protocol should be one of the following: xml-rpc, soap, http-post");
 86  
     }
 87  
     
 88  3
     if(_port != null && (Integer.parseInt(_port) < 0 || Integer.parseInt(_port) > 65535)){
 89  0
       throw new ValidationException("Cloud: Invalid port number");
 90  
     }
 91  
     
 92  3
   }
 93  
 }