com.dahuatech.icc.multiinone.event.domain.BaseEventSubcribeInfo Maven / Gradle / Ivy
The newest version!
package com.dahuatech.icc.multiinone.event.domain;
import com.dahuatech.icc.common.ParamValidEnum;
import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.multiinone.utils.StringUtils;
import com.dahuatech.icc.multiinone.vo.BaseRequest;
/**
* 订阅信息基础类
*/
public class BaseEventSubcribeInfo extends BaseRequest {
/**接收地址*/
protected String receiveIp;
/**接收端口*/
protected String receivePort;
/**接收URI,相对路径*/
protected String uri;
/**协议类型*/
protected boolean isHttps = false;
protected String name;
public String getReceiveIp() {
return receiveIp;
}
public void setReceiveIp(String receiveIp) {
this.receiveIp = receiveIp;
}
public String getReceivePort() {
if(StringUtils.isEmpty(receivePort)){
return isHttps?"443" : "80";
}
return receivePort;
}
public void setReceivePort(String receivePort) {
this.receivePort = receivePort;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean https) {
isHttps = https;
}
public String getName() {
if(StringUtils.isEmpty(name)){
return receiveIp + "_" + receivePort;
}
return name;
}
public void setName(String name) {
this.name = name;
}
public void businessValid() throws BusinessException{
if(StringUtils.isEmpty(receiveIp)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),"接收ip为空");
}
if(StringUtils.isEmpty(uri)){
throw new BusinessException(ParamValidEnum.PARAM_NOT_EMPTY_ERROR.getCode(),"接收uri为空");
}
if(uri.startsWith("http")){
throw new BusinessException(ParamValidEnum.PARAM_FORMAT_ERROR.getCode(),"接收uri格式非法|相对路径");
}
}
}