-
Notifications
You must be signed in to change notification settings - Fork 641
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
[ISSUE #3892] SendMessageRequestHeader, SendMessageBatchRequestHeader and SendMessageBatchV2RequestHeader have almost same body #3893
Open
pandaapo
wants to merge
3
commits into
apache:master
Choose a base branch
from
pandaapo:master-issue3892
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
234 changes: 234 additions & 0 deletions
234
...va/org/apache/eventmesh/common/protocol/http/header/message/BaseSendMsgRequestHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.eventmesh.common.protocol.http.header.message; | ||
|
||
import org.apache.eventmesh.common.Constants; | ||
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey; | ||
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion; | ||
import org.apache.eventmesh.common.protocol.http.header.Header; | ||
|
||
import org.apache.commons.collections4.MapUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Base class of {@link SendMessageRequestHeader}, {@link SendMessageBatchRequestHeader} | ||
* and {@link SendMessageBatchV2RequestHeader} | ||
* | ||
*/ | ||
public abstract class BaseSendMsgRequestHeader extends Header { | ||
|
||
//request code | ||
private String code; | ||
|
||
//requester language description | ||
private String language; | ||
|
||
//protocol version adopted by requester, default:1.0 | ||
private ProtocolVersion version; | ||
|
||
//protocol type, cloudevents or eventmeshMessage | ||
private String protocolType; | ||
|
||
//protocol version, cloudevents:1.0 or 0.3 | ||
private String protocolVersion; | ||
|
||
//protocol desc | ||
private String protocolDesc; | ||
|
||
//the environment number of the requester | ||
private String env; | ||
|
||
//the IDC of the requester | ||
private String idc; | ||
|
||
//subsystem of the requester | ||
private String sys; | ||
|
||
//PID of the requester | ||
private String pid; | ||
|
||
//IP of the requester | ||
private String ip; | ||
|
||
//USERNAME of the requester | ||
private String username; | ||
|
||
//PASSWD of the requester | ||
private String passwd; | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPasswd() { | ||
return passwd; | ||
} | ||
|
||
public void setPasswd(String passwd) { | ||
this.passwd = passwd; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getLanguage() { | ||
return language; | ||
} | ||
|
||
public void setLanguage(String language) { | ||
this.language = language; | ||
} | ||
Comment on lines
+97
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using the |
||
|
||
public ProtocolVersion getVersion() { | ||
return version; | ||
} | ||
|
||
public void setVersion(ProtocolVersion version) { | ||
this.version = version; | ||
} | ||
|
||
public String getEnv() { | ||
return env; | ||
} | ||
|
||
public void setEnv(String env) { | ||
this.env = env; | ||
} | ||
|
||
public String getIdc() { | ||
return idc; | ||
} | ||
|
||
public void setIdc(String idc) { | ||
this.idc = idc; | ||
} | ||
|
||
public String getSys() { | ||
return sys; | ||
} | ||
|
||
public void setSys(String sys) { | ||
this.sys = sys; | ||
} | ||
|
||
public String getPid() { | ||
return pid; | ||
} | ||
|
||
public void setPid(String pid) { | ||
this.pid = pid; | ||
} | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public void setIp(String ip) { | ||
this.ip = ip; | ||
} | ||
|
||
public String getProtocolType() { | ||
return protocolType; | ||
} | ||
|
||
public void setProtocolType(String protocolType) { | ||
this.protocolType = protocolType; | ||
} | ||
|
||
public String getProtocolVersion() { | ||
return protocolVersion; | ||
} | ||
|
||
public void setProtocolVersion(String protocolVersion) { | ||
this.protocolVersion = protocolVersion; | ||
} | ||
|
||
public String getProtocolDesc() { | ||
return protocolDesc; | ||
} | ||
|
||
public void setProtocolDesc(String protocolDesc) { | ||
this.protocolDesc = protocolDesc; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> toMap() { | ||
Map<String, Object> map = new HashMap<>(); | ||
map.put(ProtocolKey.REQUEST_CODE, code); | ||
map.put(ProtocolKey.LANGUAGE, language); | ||
map.put(ProtocolKey.VERSION, version); | ||
map.put(ProtocolKey.ClientInstanceKey.ENV, env); | ||
map.put(ProtocolKey.ClientInstanceKey.IDC, idc); | ||
map.put(ProtocolKey.ClientInstanceKey.SYS, sys); | ||
map.put(ProtocolKey.ClientInstanceKey.PID, pid); | ||
map.put(ProtocolKey.ClientInstanceKey.IP, ip); | ||
map.put(ProtocolKey.ClientInstanceKey.USERNAME, username); | ||
map.put(ProtocolKey.ClientInstanceKey.PASSWD, passwd); | ||
return map; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(this.getClass().getSimpleName() + "={") | ||
.append("code=").append(code).append(",") | ||
.append("language=").append(language).append(",") | ||
.append("version=").append(version).append(",") | ||
.append("env=").append(env).append(",") | ||
.append("idc=").append(idc).append(",") | ||
.append("sys=").append(sys).append(",") | ||
.append("pid=").append(pid).append(",") | ||
.append("ip=").append(ip).append(",") | ||
.append("username=").append(username).append(",") | ||
.append("passwd=").append(passwd).append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
protected static BaseSendMsgRequestHeader doBuildHeader(BaseSendMsgRequestHeader header, Map<String, Object> headerParam) { | ||
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE)); | ||
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION))); | ||
header.setProtocolType(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_TYPE)); | ||
header.setProtocolVersion(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_VERSION)); | ||
header.setProtocolDesc(MapUtils.getString(headerParam, ProtocolKey.PROTOCOL_DESC)); | ||
|
||
header.setLanguage( | ||
StringUtils.defaultIfBlank( | ||
MapUtils.getString(headerParam, ProtocolKey.LANGUAGE), Constants.LANGUAGE_JAVA) | ||
); | ||
header.setEnv(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.ENV)); | ||
header.setIdc(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.IDC)); | ||
header.setSys(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.SYS)); | ||
header.setPid(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.PID)); | ||
header.setIp(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.IP)); | ||
header.setUsername(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.USERNAME)); | ||
header.setPasswd(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.PASSWD)); | ||
return header; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using the
AbstractSendMsgRequestHeader
naming, to match the naming of other classes?