⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgupload.java

📁 同步接收web services请求
💻 JAVA
字号:
/**
 * 
 */
package com.aceway.vas.sjcraw.cbgp201;

import java.nio.ByteBuffer;
import java.util.Date;

import com.aceway.vas.sjcraw.cbgp201.common.DataFormat;
import com.aceway.vas.sjcraw.cbgp201.common.MsgInfo;


/**
 * @标题: 华为彩铃平台接口规范
 * @说明: 
 * @版权: Copyright(c) 2007 
 * @公司: 北京汉铭信通科技有限公司 
 * @部门: 增值业务部 
 * @作者: 武达
 * @Jun 5, 2007
 */
public class MsgUpload extends Msg {

	private int uploadType;

	private String accountId;

	private String ringId;

	private String fileName;

	private String path;

	private String ipAddress;

	private String ftpUser;

	private String ftpPwd;

	private int price;

	private String validDate;

	// 以下4个为可选
	private String ringName;

	private String author;

	private String supplier;

	private int uploadOpType;

	private static int operCode = MsgInfo.CRBT_UPLOAD;

	private static int lenBody = MsgInfo.LEN_UPLOAD;

	public MsgUpload(String seqNo, String linkId, int uploadType, String accountId, String ringId, 
			String fileName, String path,String ipAddress,String ftpUser,
			String ftpPwd,int price,Date validateDate,String ringName, 
			String author,String supplier, int uploadOpType){

		/*
		 * UploadType 1 Integer 上传铃音的用户类型 AccountID 21 String 上传铃音的用户ID
		 * 如果是SP上传,则该字段表示上传铃音的类型(RingLibCode) RingID 12 String 铃音ID Filename 40
		 * String 铃音文件名 Path 40 String 铃音文件存放路径 IPAddress 16 String Ftp服务器地址
		 * FTPUser 10 String 登录SP(或SPMS)的FTP服务器的用户名 FTPPwd 10 String
		 * 登录SP(或SPMS)的FTP服务器的密码 Price 4 Integer 铃音价格 ValidDate 10 Date
		 * 铃音的有效期截止日期 -------------以下是可先参数 RingName 40 String 铃音名称 Author 20
		 * String 铃音作者或歌手 Supplier 20 String 铃音提供者 UploadOpType 1 Integer
		 * 铃音上传的操作类型
		 * 
		 */
		this.uploadType = uploadType;
		this.accountId = DataFormat.makeString(accountId, 21);
		this.ringId = DataFormat.makeString(ringId, 12);
		this.fileName = DataFormat.makeString(fileName, 40);
		this.path = DataFormat.makeString(path, 40);
		this.ipAddress = DataFormat.makeString(ipAddress, 16);
		this.ftpUser = DataFormat.makeString(ftpUser, 10);
		this.ftpPwd = DataFormat.makeString(ftpPwd, 10);
		this.price = price;
		this.validDate = super.dateFormat.format(validDate);
		
		/*
		 * UploadOpType 铃音上传的操作类型 1 铃音上传; 2 铃音替换
		 * 
		 */
		if (uploadOpType==1 || uploadOpType==2){
			if (ringName !=null && !ringName.equals("")){
				this.ringName = DataFormat.makeString(ringName, 40);
			}else{
				this.ringName = DataFormat.makeTempStr(40);
			}
			if (author!=null && !author.equals("")){
				this.author = DataFormat.makeString(author, 20);
			}else{
				this.author = DataFormat.makeTempStr(20);
			}
			if (supplier!= null && !supplier.equals("")){
				this.supplier = DataFormat.makeString(supplier, 20);
			}else {
				this.supplier = DataFormat.makeTempStr(20);
			}
			this.uploadOpType = uploadOpType;
			this.lenBody +=81;
		} else if (supplier !=null && !supplier.equals("")){
			this.supplier = supplier;
			if (ringName !=null && !ringName.equals("")){
				this.ringName = DataFormat.makeString(ringName, 40);
			}else{
				this.ringName = DataFormat.makeTempStr(40);
			}
			if (author!=null && !author.equals("")){
				this.author = DataFormat.makeString(author, 20);
			}else{
				this.author = DataFormat.makeTempStr(20);
			}
			this.lenBody+=80;
		} else if (author!=null && !author.equals("")){
			this.author=author;
			if (ringName !=null && !ringName.equals("")){
				this.ringName = DataFormat.makeString(ringName, 40);
			}else{
				this.ringName = DataFormat.makeTempStr(40);
			}
			this.lenBody+=60;
		}else if (ringName !=null && !ringName.equals("")){
			this.ringName = ringName;
			this.lenBody+=40;
		}
		super.setCommandLength(lenBody);
		super.setMsgHead(operCode, "0", seqNo, linkId);
		ByteBuffer buff = ByteBuffer.allocate(lenBody);
		buff.putInt(this.uploadType);
		buff.put(this.accountId.getBytes());
		buff.put(this.ringId.getBytes());
		buff.put(this.fileName.getBytes());
		buff.put(this.path.getBytes());
		buff.put(this.ipAddress.getBytes());
		buff.put(this.ftpUser.getBytes());
		buff.put(this.ftpPwd.getBytes());
		buff.putInt(this.price);
		buff.put(this.validDate.getBytes());
		
		if (lenBody==245){
			buff.put(this.ringName.getBytes());
			buff.put(this.author.getBytes());
			buff.put(this.supplier.getBytes());
			buff.putInt(this.uploadOpType);
		} else if (lenBody == 244){
			buff.put(this.ringName.getBytes());
			buff.put(this.author.getBytes());
			buff.put(this.supplier.getBytes());
		} else if (lenBody == 224){
			buff.put(this.ringName.getBytes());
			buff.put(this.author.getBytes());
		} else if (lenBody == 204){
			buff.put(this.ringName.getBytes());
		} 
		buff.flip();
		super.setMsgBody(buff.array());
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	public String getAccountId() {
    	return this.accountId.trim();
    }

	public String getAuthor() {
    	return this.author.trim();
    }

	public String getFileName() {
    	return this.fileName.trim();
    }

	public String getFtpPwd() {
    	return this.ftpPwd.trim();
    }

	public String getFtpUser() {
    	return this.ftpUser.trim();
    }

	public String getIpAddress() {
    	return this.ipAddress.trim();
    }

	public String getPath() {
    	return this.path.trim();
    }

	public int getPrice() {
    	return this.price;
    }

	public String getRingId() {
    	return this.ringId.trim();
    }

	public String getRingName() {
    	return this.ringName.trim();
    }

	public String getSupplier() {
    	return this.supplier.trim();
    }

	public int getUploadOpType() {
    	return this.uploadOpType;
    }

	public int getUploadType() {
    	return this.uploadType;
    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -