119 lines
4.5 KiB
Java
119 lines
4.5 KiB
Java
package client;
|
|
|
|
import conf.SimConfFile;
|
|
import dbcmnp.soa.mobilenumberportabilitymgmt.x20150511.PortOutCreditRequest;
|
|
import dbcmnp.soa.mobilenumberportabilitymgmt.x20150511.TipoEventoTYPE;
|
|
|
|
import it.telecomitalia.soa.soap.soapheader.HeaderType;
|
|
import it.telecomitalia.soa.soap.soapheader.InteractionDateType;
|
|
import it.valueteam.mnp.ws.dbss.client.MobileNumberPortabilityMgmt10;
|
|
import it.valueteam.mnp.ws.dbss.client.MobileNumberPortabilityMgmt10_Impl;
|
|
import it.valueteam.mnp.ws.dbss.client.MobileNumberPortabilityMgmtPortType;
|
|
import mnp.utility.UUIDHelper;
|
|
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import javax.xml.rpc.Stub;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Properties;
|
|
|
|
public class ClientDBSSTFC {
|
|
|
|
private static final int NUM_PAR = 4;
|
|
private static final String SOURCE_SYSTEM = "DBSS-COM";
|
|
private static final int DEFAULT_TIMEOUT = 30000;
|
|
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
|
private static final String TIME_FORMAT = "HH:mm:ss";
|
|
private static final String CREDITO_PATTERN = "[0-9]{1,5}.[0-9]{2}";
|
|
|
|
public static void main(String args[]) {
|
|
|
|
try {
|
|
|
|
if (args.length != NUM_PAR) {
|
|
throw new IllegalArgumentException("Errore nei parametri");
|
|
}
|
|
|
|
String idRIchiesta = args[0];
|
|
String orderItemId = args[1];
|
|
String importoCreditoResiduo = args[2];
|
|
String tipoEvento = args[3];
|
|
|
|
if (idRIchiesta.length() > 23) {
|
|
System.out.println("ClientDBSSTFC: id richiesta - lunghezza errata");
|
|
return;
|
|
}
|
|
|
|
if (orderItemId.length() > 30) {
|
|
System.out.println("ClientDBSSTFC: order item id - lunghezza errata");
|
|
return;
|
|
}
|
|
|
|
Pattern r = Pattern.compile(CREDITO_PATTERN);
|
|
Matcher m = r.matcher(importoCreditoResiduo);
|
|
if (!m.find()) {
|
|
System.out.println("ClientDBSSTFC: credito residuo - formato errato");
|
|
return;
|
|
}
|
|
|
|
if (!"01".equals(tipoEvento) && !"03".equals(tipoEvento)) {
|
|
System.out.println("ClientDBSSTFC: tipo evento - valore errato");
|
|
return;
|
|
}
|
|
|
|
if ("01".equals(tipoEvento) && !"NULL".equals(orderItemId)) {
|
|
System.out.println("ClientDBSSTFC: order item deve essere NULL per tipo evento = 01");
|
|
return;
|
|
}
|
|
|
|
if ("03".equals(tipoEvento) && "NULL".equals(orderItemId)) {
|
|
System.out.println("ClientDBSSTFC: order item non puo' essere NULL per tipo evento = 03");
|
|
return;
|
|
}
|
|
|
|
if (orderItemId.equals("NULL")) {
|
|
orderItemId = ClientDBSSGenerator.getRandomString(30, false);
|
|
}
|
|
|
|
PortOutCreditRequest reqBody = new PortOutCreditRequest();
|
|
reqBody.setIMPORTO_CREDITO_RESIDUO(importoCreditoResiduo);
|
|
reqBody.setTIPO_EVENTO(TipoEventoTYPE.fromString(tipoEvento));
|
|
reqBody.setID_RICHIESTA_DBC(idRIchiesta);
|
|
reqBody.setORDER_ITEM_ID(orderItemId);
|
|
|
|
HeaderType reqHeader = new HeaderType();
|
|
|
|
Properties properties = SimConfFile.getInstance().ReadSection("DBSS");
|
|
String url = properties.getProperty("dbssWsUrl");
|
|
MobileNumberPortabilityMgmt10 service = new MobileNumberPortabilityMgmt10_Impl();
|
|
MobileNumberPortabilityMgmtPortType port = service.getMobileNumberPortabilityMgmt();
|
|
|
|
((Stub) port)._setProperty("javax.xml.rpc.service.endpoint.address", url);
|
|
|
|
((Stub) port)._setProperty("weblogic.wsee.transport.connection.timeout", DEFAULT_TIMEOUT);
|
|
|
|
reqHeader.setSourceSystem(SOURCE_SYSTEM);
|
|
|
|
Date date = new Date();
|
|
String d = new SimpleDateFormat(DATE_FORMAT).format(date);
|
|
String t = new SimpleDateFormat(TIME_FORMAT).format(date);
|
|
InteractionDateType intDate = new InteractionDateType();
|
|
intDate.setDate(d);
|
|
intDate.setTime(t);
|
|
reqHeader.setInteractionDate(intDate);
|
|
|
|
reqHeader.setBusinessID(UUIDHelper.generateBusinessID());
|
|
reqHeader.setMessageID(UUIDHelper.generateBusinessID());
|
|
reqHeader.setTransactionID(UUIDHelper.generateBusinessID());
|
|
|
|
port.portOutCredit(reqHeader, reqBody);
|
|
|
|
} catch (Exception ex) {
|
|
ex.printStackTrace();
|
|
System.out.println("ClientDBSSTFC failed ex: " + ex);
|
|
}
|
|
}
|
|
}
|
|
|