| 1 |
|
package yarfraw.core.datamodel; |
| 2 |
|
|
| 3 |
|
import yarfraw.utils.ValidationUtils; |
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 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; |
| 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 |
|
} |