Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-597] Adjust WebTopicCtrlHandler class implementation #456

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ public enum WebFieldDef {
ISRESERVEDDATA(77, "isReservedData", "isRsvDt",
WebFieldType.BOOLEAN, "Whether to keep topic data in the broker"),
WITHCTRLINFO(78, "ctrlData", "cD",
WebFieldType.BOOLEAN, "With topic control data info.");
WebFieldType.BOOLEAN, "With topic control data info."),
WITHDEPLOYINFO(79, "withDeployInfo", "wDI",
WebFieldType.BOOLEAN, "With topic deploy info."),

TOPICCTRLSET(80, "topicCtrlJsonSet", "tCtrlSet", WebFieldType.JSONSET,
"The topic control info set that needs to be added or modified");


public final int id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.tubemq.corebase.policies.FlowCtrlRuleHandler;
import org.apache.tubemq.corebase.utils.TStringUtils;
import org.apache.tubemq.corebase.utils.Tuple2;
import org.apache.tubemq.corebase.utils.Tuple3;
import org.apache.tubemq.server.broker.utils.DataStoreUtils;
import org.apache.tubemq.server.common.TServerConstants;
import org.apache.tubemq.server.common.TStatusConstants;
Expand Down Expand Up @@ -121,102 +120,87 @@ public static StringBuilder buildSuccWithData(String errMsg,
return strBuffer;
}

/**
* Parse the parameter value required for add, update, delete record
*
* @param req Http Servlet Request
* @param isAdd if add commend
* @param result process result of parameter value, include a
* tuple3 object(dataVersionId, operator, opData) info
* @return process result
*/
public static boolean getAUDBaseInfo(HttpServletRequest req,
boolean isAdd,
ProcessResult result) {
boolean isAdd, ProcessResult result) {
// check and get data version id
if (!WebParameterUtils.getLongParamValue(req, WebFieldDef.DATAVERSIONID,
false, TServerConstants.DEFAULT_DATA_VERSION, result)) {
false, TBaseConstants.META_VALUE_UNDEFINED, result)) {
return result.isSuccess();
}
long dataVerId = (long) result.retData1;
// check and get createUser or modifyUser
String operator = null;
Date opDate = null;
String createUsr = "";
Date createDate = null;
if (isAdd) {
// check create user field
if (!WebParameterUtils.getStringParamValue(req,
WebFieldDef.CREATEUSER, true, null, result)) {
WebFieldDef.CREATEUSER, isAdd, null, result)) {
return result.isSuccess();
}
operator = (String) result.retData1;
createUsr = (String) result.retData1;
// check and get create date
if (!WebParameterUtils.getDateParameter(req,
WebFieldDef.CREATEDATE, false, new Date(), result)) {
return result.isSuccess();
}
opDate = (Date) result.retData1;

} else {
// check modify user field
if (!WebParameterUtils.getStringParamValue(req,
WebFieldDef.MODIFYUSER, true, null, result)) {
return result.isSuccess();
}
operator = (String) result.retData1;
// check and get modify date
if (!WebParameterUtils.getDateParameter(req,
WebFieldDef.MODIFYDATE, false, new Date(), result)) {
return result.isSuccess();
}
opDate = (Date) result.retData1;
createDate = (Date) result.retData1;
}
// check modify user field
if (!WebParameterUtils.getStringParamValue(req,
WebFieldDef.MODIFYUSER, !isAdd, createUsr, result)) {
return result.isSuccess();
}
result.setSuccResult(new Tuple3<Long, String, Date>(
dataVerId, operator, opDate));
String modifyUser = (String) result.retData1;
// check and get modify date
if (!WebParameterUtils.getDateParameter(req,
WebFieldDef.MODIFYDATE, false, createDate, result)) {
return result.isSuccess();
}
Date modifyDate = (Date) result.retData1;
result.setSuccResult(new BaseEntity(dataVerId,
createUsr, createDate, modifyUser, modifyDate));
return result.isSuccess();
}

public static boolean getAUDBaseInfo(Map<String, String> keyValueMap,
boolean isAdd,
ProcessResult result) {
public static boolean getAUDBaseInfo(Map<String, String> keyValueMap, boolean isAdd,
BaseEntity defOpInfoEntity, ProcessResult result) {
// check and get data version id
if (!WebParameterUtils.getLongParamValue(keyValueMap, WebFieldDef.DATAVERSIONID,
false, TBaseConstants.META_VALUE_UNDEFINED, result)) {
return result.isSuccess();
}
long dataVerId = (long) result.retData1;
// check and get createUser or modifyUser
String operator = null;
Date opDate = null;
String createUsr = null;
Date createDate = null;
if (isAdd) {
// check create user field
if (!WebParameterUtils.getStringParamValue(keyValueMap,
WebFieldDef.CREATEUSER, false, null, result)) {
WebFieldDef.CREATEUSER, false, defOpInfoEntity.getCreateUser(), result)) {
return result.isSuccess();
}
operator = (String) result.retData1;
createUsr = (String) result.retData1;
// check and get create date
if (!WebParameterUtils.getDateParameter(keyValueMap,
WebFieldDef.CREATEDATE, false, null, result)) {
return result.isSuccess();
}
opDate = (Date) result.retData1;

} else {
// check modify user field
if (!WebParameterUtils.getStringParamValue(keyValueMap,
WebFieldDef.MODIFYUSER, false, null, result)) {
return result.isSuccess();
}
operator = (String) result.retData1;
// check and get modify date
if (!WebParameterUtils.getDateParameter(keyValueMap,
WebFieldDef.MODIFYDATE, false, null, result)) {
WebFieldDef.CREATEDATE, false, defOpInfoEntity.getCreateDate(), result)) {
return result.isSuccess();
}
opDate = (Date) result.retData1;
createDate = (Date) result.retData1;
}
// check modify user field
if (!WebParameterUtils.getStringParamValue(keyValueMap,
WebFieldDef.MODIFYUSER, false, defOpInfoEntity.getModifyUser(), result)) {
return result.isSuccess();
}
String modifyUser = (String) result.retData1;
// check and get modify date
if (!WebParameterUtils.getDateParameter(keyValueMap,
WebFieldDef.MODIFYDATE, false, defOpInfoEntity.getModifyDate(), result)) {
return result.isSuccess();
}
result.setSuccResult(new Tuple3<Long, String, Date>(
dataVerId, operator, opDate));
Date modifyDate = (Date) result.retData1;
result.setSuccResult(new BaseEntity(dataVerId,
createUsr, createDate, modifyUser, modifyDate));
return result.isSuccess();
}

Expand Down
Loading