当前位置: 首页>>代码示例>>Java>>正文


Java AddOrChangeUnitResponse类代码示例

本文整理汇总了Java中com.owera.xapsws.AddOrChangeUnitResponse的典型用法代码示例。如果您正苦于以下问题:Java AddOrChangeUnitResponse类的具体用法?Java AddOrChangeUnitResponse怎么用?Java AddOrChangeUnitResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AddOrChangeUnitResponse类属于com.owera.xapsws包,在下文中一共展示了AddOrChangeUnitResponse类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.owera.xapsws.AddOrChangeUnitResponse; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		XAPSWSProxy tp = new XAPSWSProxy();
		// Choose 1 out of 2 options:
		// Send traffic to redirect-URL - the Web Service Server will log XML to file
		tp.setEndpoint("http://localhost/xapsws/redirect");
		// Send traffic directly to Web Service Server:
		// tp.setEndpoint("http://localhost/xapsws/services/xAPSWS");
		
		// Populate data on unit, profile and unittype, add two parameters to set on the unit
		Unit unit = new Unit();
		unit.setSerialNumber("012345678902");
		Profile p = new Profile();
		p.setName("Default");
		Unittype ut = new Unittype();
		ut.setName("NPA201E");

		Parameter[] parameterArr = new Parameter[2];
		parameterArr[0] = new Parameter("InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthPassword", "freyrsSipPassword", null);
		parameterArr[1] = new Parameter("InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.1.Line.1.SIP.AuthUserName", "freyrsSipUsername", "AC");
		ParameterList parameters = new ParameterList(parameterArr);
		
		unit.setParameters(parameters);
		unit.setProfile(p);
		unit.setUnittype(ut);
		
		// Populate login object
		Login login = new Login("user", "pass");
		
		// Perform login and service
		AddOrChangeUnitRequest auReq = new AddOrChangeUnitRequest(login, unit);
		
		// Response received
		AddOrChangeUnitResponse auRes = tp.addOrChangeUnit(auReq);
		
		// Dump some data to sysout, loop through parameter list of unit
		System.out.println("UnitId: " + auRes.getUnit().getUnitId());
		ParameterList parameterList = auRes.getUnit().getParameters();
		if (parameterList != null && parameterList.getParameterArray() != null) {
			int counter = 0;
			for (Parameter param : parameterList.getParameterArray()) {
				System.out.println("Parameter-" + counter + ": " + param.getName() + " = " + param.getValue() + " (" + param.getFlags() + ")");
				counter++;
			}
		}
	} catch (Throwable t) {
		System.err.println("Throwable: " + t);
		t.printStackTrace();
	}

}
 
开发者ID:freeacs,项目名称:wstc,代码行数:52,代码来源:AddOrChangeUnitUseCase134.java

示例2: addOrChangeUnit

import com.owera.xapsws.AddOrChangeUnitResponse; //导入依赖的package包/类
public AddOrChangeUnitResponse addOrChangeUnit(AddOrChangeUnitRequest aocur) throws RemoteException {
	try {
		
		xapsWS = XAPSWSFactory.getXAPSWS(aocur.getLogin());
		xaps = xapsWS.getXAPS();
		xapsUnit = xapsWS.getXAPSUnit(xaps);

		/* 
		 * We need to support these use cases
		 * UC1 - Add unit:
		 *  unittype (must exist in xAPS)
		 *  profile (must exist in xAPS) 
		 *  unitId (should be <OUI>-<ProductClass>-<SerialNumber>
		 *  secret (must match protocol pattern)
		 * UC2 - Change unit: 
		 *  unittype (must exist in xAPS)
		 *  profile (must exist in xAPS) 
		 * 	unitId (must match protocol pattern)
		 * UC3 - Change unit:
		 *  unittype (must exist in xAPS)
		 *  profile (must exist in xAPS) 
		 * 	serialNumber (no requirements)
		 * 
		 * To find out which UC it is, use following algorithm:
		 * 1. If uniqueId is present -> UC2
		 * 2. If serialNumber is present, but no unit Id is present -> UC4
		 * 3. UC1 and UC3 are basically the same when it comes to logic performed
		 * 
		 * Additional rules: 
		 * 1. unittype and profile must be specified and must exist in xAPS
		 * 2. If a secret is specified it must adhere to the protocol pattern
		 * 3. If a unit id is specified it must adhere to the protocol pattern
		 */
		Unit unitWS = aocur.getUnit();
		if (unitWS.getUnittype() == null || unitWS.getProfile() == null)
			throw XAPSWS.error(logger, "Unittype and/or Profile object are missing");
		Profile profile = xapsWS.getProfileFromXAPS(unitWS.getUnittype().getName(), unitWS.getProfile().getName());
		String unitId = validateUnitId(unitWS, profile.getUnittype(), profile);
		List<String> unitIds = new ArrayList<String>();
		unitIds.add(unitId);
		List<UnitParameter> acParams = validateAddOrChangeUnitParameters(unitWS, profile.getUnittype(), profile);
		List<UnitParameter> dParams = validateDeleteUnitParameters(unitWS, profile.getUnittype(), profile);
		xapsUnit.addUnits(unitIds, profile);
		xapsUnit.addOrChangeUnitParameters(acParams, profile);
		xapsUnit.deleteUnitParameters(dParams);
		return new AddOrChangeUnitResponse(unitWS);
	} catch (Throwable t) {
		if (t instanceof RemoteException)
			throw (RemoteException) t;
		else {
			throw XAPSWS.error(logger, t);
		}
	}
}
 
开发者ID:freeacs,项目名称:ws,代码行数:55,代码来源:AddOrChangeUnit.java


注:本文中的com.owera.xapsws.AddOrChangeUnitResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。