View Javadoc

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  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    public Cloud(){}
30    public static Cloud create(){
31      return new Cloud();
32    }
33    public Cloud(String domain, String port, String path,
34            String registerProcedure, String protocol) {
35      super();
36      setDomain(domain);
37      setPath(path);
38      setPort(port);
39      setRegisterProcedure(registerProcedure);
40      setProtocol(protocol);
41    }
42    public String getDomain() {
43      return _domain;
44    }
45    public Cloud setDomain(String domain) {
46      _domain = domain;
47      return this;
48    }
49  
50    public String getPort() {
51      return _port;
52    }
53    public void setPort(String port) {
54      _port = port;
55    }
56    public String getPath() {
57      return _path;
58    }
59    public Cloud setPath(String path) {
60      _path = path;
61      return this;
62    }
63    public String getRegisterProcedure() {
64      return _registerProcedure;
65    }
66    public Cloud setRegisterProcedure(String registerProcedure) {
67      _registerProcedure = registerProcedure;
68      return this;
69    }
70    public String getProtocol() {
71      return _protocol;
72    }
73    public Cloud setProtocol(String protocol) {
74      _protocol = protocol;
75      return this;
76    }
77    @Override
78    public void validate(FeedFormat format) throws ValidationException {
79      if(format != FeedFormat.RSS20){
80        return; //no support
81      }
82      
83      ValidationUtils.validateNotNull("Cloud: All fields in the cloud object should be not null", _domain, _path, _port, _protocol, _registerProcedure);
84      if(!_protocol.equals("xml-rpc") && !_protocol.equals("http-post") && !_protocol.equals("soap")){
85        throw new ValidationException("Cloud: Protocol should be one of the following: xml-rpc, soap, http-post");
86      }
87      
88      if(_port != null && (Integer.parseInt(_port) < 0 || Integer.parseInt(_port) > 65535)){
89        throw new ValidationException("Cloud: Invalid port number");
90      }
91      
92    }
93  }