📄 cmppsubmit.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: CMPPSubmit.java
package com.cmpp3_0.process;
import com.cmpp3_0.body.BodySubmit;
import com.cmpp3_0.body.Header;
import com.cmpp3_0.util.*;
import java.io.*;
import java.net.SocketException;
// Referenced classes of package com.cmpp3_0.process:
// CMPPSocket, CMPPAPIs
public class CMPPSubmit
{
private byte bodyBytes[];
private BodySubmit bodyContent;
private byte headBytes[];
private Header headContent;
private CMPPSocket socket;
public CMPPSubmit(CMPPSocket socket)
{
bodyContent = new BodySubmit();
headContent = new Header(12, 4, 0);
this.socket = socket;
headBytes = new byte[12];
}
private int checkAllDstTermId(String destTerminalId)
{
int result = 0;
int counts = 0;
String s = new String(destTerminalId);
StringBuffer modifiedDstTermId = new StringBuffer();
s = s.trim();
for(int index = 0; index >= 0; Nop)
{
char c = ',';
index = s.indexOf(c);
if(index >= 0)
{
counts++;
String subsId = s.substring(0, index);
String rs = checkDstTermId(subsId);
if(rs == null)
return -221;
if(modifiedDstTermId.length() >= 13)
modifiedDstTermId.append("," + rs);
else
modifiedDstTermId.append(rs);
s = s.substring(index + 1);
continue;
}
if(s.length() <= 0)
continue;
counts++;
String rs = checkDstTermId(s);
if(rs == null)
return -221;
if(modifiedDstTermId.length() >= 13)
modifiedDstTermId.append("," + rs);
else
modifiedDstTermId.append(rs);
break;
}
bodyContent.dstTermId = modifiedDstTermId.toString();
return counts;
}
private int checkContent()
{
int result = 0;
if(bodyContent.feeUserType != 0 && bodyContent.feeUserType != 1 && bodyContent.feeUserType != 2 && bodyContent.feeUserType != 3)
{
Logger.writeLog(-2, "submit error: 提交的短信的Fee_User_Type字段无效!", "cmpp");
return -226;
}
if(!bodyContent.feeType.equals("01") && !bodyContent.feeType.equals("02") && !bodyContent.feeType.equals("03"))
{
Logger.writeLog(-2, "submit error: 提交的短信的feeType字段无效!", "cmpp");
return -223;
}
if(bodyContent.dstUserTl > 100 || bodyContent.dstUserTl <= 0)
{
Logger.writeLog(-2, "submit error: 提交的短信的Dest_User_Tl(" + bodyContent.dstUserTl + ")无效,发送短信的用户太多!", "cmpp");
return -227;
} else
{
result = checkAllDstTermId(bodyContent.dstTermId);
return result;
}
}
private String checkDstTermId(String dstTermId)
{
if(dstTermId.length() < 11)
{
Logger.writeLog(-2, "SUBMIT ERROR: 在提交的短信包中,Dest_terminal_Id包含的号码" + dstTermId + " 长度太短,此包将被抛弃!!", "cmpp");
return null;
}
if(dstTermId.length() == 11 && !dstTermId.startsWith("13") || dstTermId.length() == 13 && !dstTermId.startsWith("8613"))
{
Logger.writeLog(-2, "SUBMIT ERROR: 在提交的短信包中,Dest_terminal_Id包含的号码" + dstTermId + " 格式不正确,此包将被抛弃!!", "cmpp");
return null;
} else
{
String rs = "86" + dstTermId;
return rs;
}
}
public BodySubmit getBodyContent()
{
return bodyContent;
}
public int getTotalLength()
{
return headContent.getTotalLength();
}
private int retrieveBytes(BodySubmit bodyContent)
{
CMPPUtil.bytesCopy(CMPPUtil.intToFourBytes(headContent.getCommandId()), headBytes, 0, 4, 4);
CMPPUtil.bytesCopy(CMPPUtil.intToFourBytes(headContent.getSeqId()), headBytes, 0, 4, 8);
bodyContent.msgFmt;
JVM INSTR lookupswitch 5: default 416
// 0: 107
// 3: 107
// 4: 96
// 8: 313
// 15: 210;
goto _L1 _L2 _L2 _L3 _L4 _L5
_L3:
byte msgBytes[];
msgBytes = HexStringParser.HexStringToBytes(bodyContent.msgContent);
break; /* Loop/switch isn't completed */
_L2:
if(bodyContent.msgContent.getBytes("gb18030").length > CMPPAPIs.getMaxMsgLenAscii())
{
msgBytes = new byte[CMPPAPIs.getMaxMsgLenAscii()];
CMPPUtil.bytesCopy(bodyContent.msgContent.getBytes(), msgBytes, 0, CMPPAPIs.getMaxMsgLenAscii(), 0);
Logger.writeLog(-1, "提交短信(英文)的字节长度" + bodyContent.msgContent.length() + "大于允许的最大长度" + CMPPAPIs.getMaxMsgLenAscii() + ",多余部分将被抛弃!!", "cmpp");
} else
{
msgBytes = bodyContent.msgContent.getBytes("gb18030");
}
break; /* Loop/switch isn't completed */
_L5:
if(bodyContent.msgContent.getBytes("gb18030").length > CMPPAPIs.getMaxMsgLenOther())
{
msgBytes = new byte[CMPPAPIs.getMaxMsgLenAscii()];
CMPPUtil.bytesCopy(bodyContent.msgContent.getBytes(), msgBytes, 0, CMPPAPIs.getMaxMsgLenOther(), 0);
Logger.writeLog(-1, "提交短信(中文)的字节长度" + bodyContent.msgContent.length() + "大于允许的最大长度" + CMPPAPIs.getMaxMsgLenAscii() + ",多余部分将被抛弃!!", "cmpp");
} else
{
msgBytes = bodyContent.msgContent.getBytes("gb18030");
}
break; /* Loop/switch isn't completed */
_L4:
if(bodyContent.msgContent.getBytes("iso-10646-ucs-2").length > CMPPAPIs.getMaxMsgLenOther())
{
msgBytes = new byte[CMPPAPIs.getMaxMsgLenAscii()];
CMPPUtil.bytesCopy(bodyContent.msgContent.getBytes(), msgBytes, 0, CMPPAPIs.getMaxMsgLenOther(), 0);
Logger.writeLog(-1, "提交短信(Unicode)的字节长度" + bodyContent.msgContent.length() + "大于允许的最大长度" + CMPPAPIs.getMaxMsgLenAscii() + ",多余部分将被抛弃!!", "cmpp");
} else
{
msgBytes = bodyContent.msgContent.getBytes("gb18030");
}
break; /* Loop/switch isn't completed */
_L1:
Logger.writeLog(-2, "要发送的短信的MsgFormat字段无效,此包将被抛弃!", "cmpp");
return -224;
try
{
break MISSING_BLOCK_LABEL_461;
}
catch(Exception e)
{
System.out.println("操作系统不支持gb18030 或iso-10646-ucs-2 字符集合!必须更改字符集!");
Logger.writeLog(-2, " 操作系统不支持gb18030 或iso-10646-ucs-2 字符集合!必须更改字符集合!", "cmpp");
e.printStackTrace();
}
return -250;
int bodyBytesLength = 129 + 32 * bodyContent.dstUserTl + 1 + 1 + msgBytes.length + 20;
bodyContent.msgLength = msgBytes.length;
bodyBytes = new byte[bodyBytesLength];
int pos = 0;
CMPPUtil.bytesCopy(CMPPUtil.longToEightBytes(bodyContent.msgId), bodyBytes, 0, 8, pos);
pos += 8;
bodyBytes[pos++] = (byte)bodyContent.pkTotal;
bodyBytes[pos++] = (byte)bodyContent.pkNumber;
bodyBytes[pos++] = (byte)bodyContent.regDelivery;
bodyBytes[pos++] = (byte)bodyContent.msgLevel;
CMPPUtil.bytesCopy(bodyContent.serviceId.getBytes(), bodyBytes, 0, 10, pos);
pos += 10;
bodyBytes[pos++] = (byte)bodyContent.feeUserType;
CMPPUtil.bytesCopy(bodyContent.feeTermId.getBytes(), bodyBytes, 0, 32, pos);
pos += 32;
bodyBytes[pos++] = (byte)bodyContent.feeTermType;
bodyBytes[pos++] = (byte)bodyContent.tpPid;
bodyBytes[pos++] = (byte)bodyContent.tpUdhi;
bodyBytes[pos++] = (byte)bodyContent.msgFmt;
CMPPUtil.bytesCopy(bodyContent.msgSrc.getBytes(), bodyBytes, 0, 6, pos);
pos += 6;
CMPPUtil.bytesCopy(bodyContent.feeType.getBytes(), bodyBytes, 0, 2, pos);
pos += 2;
CMPPUtil.bytesCopy(bodyContent.feeCode.getBytes(), bodyBytes, 0, 6, pos);
pos += 6;
CMPPUtil.bytesCopy(bodyContent.validTime.getBytes(), bodyBytes, 0, 17, pos);
pos += 17;
CMPPUtil.bytesCopy(bodyContent.atTime.getBytes(), bodyBytes, 0, 17, pos);
pos += 17;
CMPPUtil.bytesCopy(bodyContent.srcTermId.getBytes(), bodyBytes, 0, 21, pos);
pos += 21;
bodyBytes[pos++] = (byte)bodyContent.dstUserTl;
int destTermIdLength = 32 * bodyContent.dstUserTl;
CMPPUtil.bytesCopy(bodyContent.dstTermId.getBytes(), bodyBytes, 0, destTermIdLength, pos);
pos += destTermIdLength;
bodyBytes[pos++] = (byte)bodyContent.dstTermType;
bodyBytes[pos++] = (byte)msgBytes.length;
CMPPUtil.bytesCopy(msgBytes, bodyBytes, 0, msgBytes.length, pos);
pos += msgBytes.length;
CMPPUtil.bytesCopy(bodyContent.linkId.getBytes(), bodyBytes, 0, 20, pos);
pos += 20;
headContent.setTotalLength(12 + pos);
CMPPUtil.bytesCopy(CMPPUtil.intToFourBytes(headContent.getTotalLength()), headBytes, 0, 4, 0);
return 0;
NullPointerException npe;
npe;
System.out.println("NullPointer--在提交的短信包中发现有空项,此包将被抛弃");
Logger.writeLog(-2, "NullPointer--在提交的短信包中发现有空项,此包将被抛弃", "cmpp");
npe.printStackTrace();
return -220;
}
public int sendSubmit()
{
int result = 0;
socket.out.write(headBytes);
socket.out.write(bodyBytes);
socket.out.flush();
break MISSING_BLOCK_LABEL_136;
SocketException se;
se;
Logger.writeLog(-2, "SUBMIT SocketException----可能是TCP/IP连接出现错误,发送短信包" + bodyContent + "失败!", "cmpp");
result = -502;
return result;
IOException ie;
ie;
Logger.writeLog(-2, "SUBMIT IOException--在提交短信时碰到IO Exception--此短信将被重新发送", "cmpp");
result = -108;
return result;
NullPointerException npe;
npe;
Logger.writeLog(-2, "SUBMIT NullPointerException--在提交短信时碰到NullPointerException--此短信将被抛弃", "cmpp");
result = -107;
return result;
Exception e;
e;
Logger.writeLog(-2, "SUBMIT Exception--在提交短信时碰到Exception--发送短信失败!", "cmpp");
result = -109;
return result;
System.out.println("发送了一条短信!--seqId --" + headContent.getSeqId());
return result;
}
public int setBodyContent(BodySubmit bodySubmit)
{
bodyContent = bodySubmit;
int result = checkContent();
if(result < 0)
{
return result;
} else
{
result = retrieveBytes(bodyContent);
return result;
}
}
public void setSequeneceId(int seqId)
{
headContent.setSeqId(seqId);
CMPPUtil.bytesCopy(CMPPUtil.intToFourBytes(headContent.getSeqId()), headBytes, 0, 4, 8);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -