package com.owera.xaps.tr069.methods;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.owera.xaps.Properties.Module;
import com.owera.xaps.base.DownloadLogic;
import com.owera.xaps.base.JobLogic;
import com.owera.xaps.base.Log;
import com.owera.xaps.base.ServiceWindow;
import com.owera.xaps.base.UnitJob;
import com.owera.xaps.base.Util;
import com.owera.xaps.base.db.DBAccessSessionTR069;
import com.owera.xaps.dbi.Job;
import com.owera.xaps.dbi.JobFlag.JobType;
import com.owera.xaps.dbi.JobParameter;
import com.owera.xaps.dbi.Parameter;
import com.owera.xaps.dbi.UnittypeParameter;
import com.owera.xaps.dbi.UnittypeParameterFlag;
import com.owera.xaps.dbi.UnittypeParameters;
import com.owera.xaps.dbi.tr069.TR069DMParameter;
import com.owera.xaps.dbi.tr069.TR069DMParameterMap;
import com.owera.xaps.dbi.util.ProvisioningMessage;
import com.owera.xaps.dbi.util.ProvisioningMessage.ErrorResponsibility;
import com.owera.xaps.dbi.util.ProvisioningMessage.ProvOutput;
import com.owera.xaps.dbi.util.ProvisioningMessage.ProvStatus;
import com.owera.xaps.dbi.util.ProvisioningMode;
import com.owera.xaps.dbi.util.SystemParameters;
import com.owera.xaps.tr069.CPEParameters;
import com.owera.xaps.tr069.DownloadLogicTR069;
import com.owera.xaps.tr069.HTTPReqResData;
import com.owera.xaps.tr069.SessionData;
import com.owera.xaps.tr069.background.ActiveDeviceDetectionTask;
import com.owera.xaps.tr069.decision.shelljob.ShellJobLogic;
import com.owera.xaps.tr069.exception.TR069DatabaseException;
import com.owera.xaps.tr069.exception.TR069Exception;
import com.owera.xaps.tr069.exception.TR069ExceptionShortMessage;
import com.owera.xaps.tr069.xml.ParameterList;
import com.owera.xaps.tr069.xml.ParameterValueStruct;
/**
* Decision is the main class in the decision package and it contains the core
* logic of what to-do after the initial IN-EM-GPV sequence is performed in the
* TR-069 conversation. At this point there are many options, all information
* about the xAPS database and the CPE has been gathered, and we must decide
* what the next step should be.
*
* The next method may be one out of three, in this priority:
*
* 1. DO (Download) 2. SPV (SetParameterValues) 3. EM (Empty)
*
* Which one to choose is decided in the constructor of this class. More details
* are explained in that comment.
*
*/
public class GPVDecision {
public static void process(HTTPReqResData reqRes) throws TR069Exception {
SessionData sessionData = reqRes.getSessionData();
ProvisioningMode mode = sessionData.getUnit().getProvisioningMode();
Log.debug(GPVDecision.class, "Mode was detected to be: " + mode.toString());
ProvisioningMessage pm = sessionData.getProvisioningMessage();
pm.setProvMode(mode);
boolean PIIsupport = supportPII(sessionData);
if (!PIIsupport) {
reqRes.getResponse().setMethod(TR069Method.EMPTY);
pm.setProvOutput(ProvOutput.EMPTY);
pm.setErrorMessage("The device does not support PII");
pm.setProvStatus(ProvStatus.ERROR);
pm.setErrorResponsibility(ErrorResponsibility.CLIENT);
} else {
if (mode == ProvisioningMode.REGULAR)
processPeriodic(reqRes);
// else if (mode == ProvisioningMode.INSPECTION)
// GPVDecisionInspection.processInspection(reqRes);
// else if (mode == ProvisioningMode.EXTRACTION)
// GPVDecisionExtraction.processExtraction(reqRes);
else if (mode == ProvisioningMode.READALL)
GPVDecisionExtraction.processExtraction(reqRes);
}
updateActiveDeviceMap(reqRes);
Log.debug(GPVDecision.class, "GPV-Decision is " + reqRes.getResponse().getMethod());
}
private static void updateActiveDeviceMap(HTTPReqResData reqRes) {
boolean updated = false;
SessionData sessionData = reqRes.getSessionData();
if (reqRes.getResponse().getMethod().equals(TR069Method.SET_PARAMETER_VALUES)) {
Long nextPII = null;
CPEParameters cpeParams = sessionData.getCpeParameters();
String PII = cpeParams.PERIODIC_INFORM_INTERVAL;
for (ParameterValueStruct pvs : sessionData.getToDB()) {
if (pvs.getName().equals(PII)) {
nextPII = Long.parseLong(pvs.getValue());
}
}
if (nextPII != null) {
updated = true;
ActiveDeviceDetectionTask.addActiveDevice(sessionData.getUnitId(), nextPII * 1000);
}
}
if (!updated)
ActiveDeviceDetectionTask.remove(sessionData.getUnitId());
}
@SuppressWarnings("unused")
private static void oppositePriorityProvisioning(HTTPReqResData reqRes) {
/*
* To accomplish opposite priority provisioning - we have to deal with some
* obstacles:
*
* - We must know when there are no more CONFIG-changes. This is usually
* true when no parameter will be transmitted to the CPE. However, a
* password can complicate this, if a device do not support ParameterKey
* feature and/or the passwords have not set the C-flag on the unittype
* parameter. This introduces some level of dependency both on the
* device-implementation and on the setup of the unittype.
*
* - We must know if reset/restart/download method needs to be run, before
* deciding the next periodic inform interval. If there is no such method
* "waiting" the next periodic inform interval will be calculated as usual.
* In other words, the service-window which those other methods might need
* will be ignored, since config has priority and is running in regular
* service window. This can in itself be an issue, since the other methods
* may never be run (if a service-window is short and one never hits that
* window). The question is if this in itself is so troubling that this
* whole idea must be abandoned. Perhaps the most reasonable solution is to
* remove service window from easy-provisioning altogether, and only use
* service window in jobs - making jobs more feature-rich compared to
* easy-provisioning. Service Windows never been used AFAIK - so this may be
* a fair trade. To accomplish this change, we need to change the job table
* - adding service-window there - which we cannot do in 2013R1. Thus we
* should wait with this until 2014R1.
*/
normalPriorityProvisioning(reqRes);
}
private static void normalPriorityProvisioning(HTTPReqResData reqRes) {
ServiceWindow serviceWindow = null;
SessionData sessionData = reqRes.getSessionData();
String reset = sessionData.getOweraParameters().getValue(SystemParameters.RESET);
String reboot = sessionData.getOweraParameters().getValue(SystemParameters.RESTART);
if (reset != null && reset.equals("1")) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.RESET);
serviceWindow = new ServiceWindow(sessionData, true);
if (serviceWindow.isWithin()) {
Util.resetReset(sessionData);
reqRes.getResponse().setMethod(TR069Method.FACTORY_RESET);
return;
} else
sessionData.getPIIDecision().setDisruptiveSW(serviceWindow);
} else if (reboot != null && reboot.equals("1")) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.REBOOT);
serviceWindow = new ServiceWindow(sessionData, true);
if (serviceWindow.isWithin()) {
Util.resetReboot(sessionData);
reqRes.getResponse().setMethod(TR069Method.REBOOT);
return;
} else
sessionData.getPIIDecision().setDisruptiveSW(serviceWindow);
} else if (DownloadLogicTR069.isSoftwareDownloadSetup(reqRes, null) && DownloadLogic.downloadAllowed(Module.TR069, null)) {
serviceWindow = new ServiceWindow(sessionData, true);
if (serviceWindow.isWithin()) {
reqRes.getResponse().setMethod(TR069Method.DOWNLOAD);
return;
} else
sessionData.getPIIDecision().setDisruptiveSW(serviceWindow);
} else if (DownloadLogicTR069.isScriptDownloadSetup(reqRes, null) && DownloadLogic.downloadAllowed(Module.TR069, null)) {
serviceWindow = new ServiceWindow(sessionData, true);
if (serviceWindow.isWithin()) {
reqRes.getResponse().setMethod(TR069Method.DOWNLOAD);
return;
} else
sessionData.getPIIDecision().setDisruptiveSW(serviceWindow);
} else {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.CONFIG);
serviceWindow = new ServiceWindow(sessionData, false);
if (serviceWindow.isWithin()) {
prepareSPV(sessionData);
if (sessionData.getToCPE().getParameterValueList().size() > 0)
reqRes.getResponse().setMethod(TR069Method.SET_PARAMETER_VALUES);
else
reqRes.getResponse().setMethod(TR069Method.EMPTY);
return;
}
}
prepareSPVLimited(reqRes);
reqRes.getResponse().setMethod(TR069Method.SET_PARAMETER_VALUES);
return;
}
private static void processPeriodic(HTTPReqResData reqRes) throws TR069Exception {
SessionData sessionData = reqRes.getSessionData();
UnitJob uj = null;
if (!sessionData.isJobUnderExecution()) {
// update unit-parameters with data from CPE, to get correct
// group-matching in job-search
// will not affect the comparison in populateToCollections()
updateUnitParameters(sessionData);
try {
uj = JobLogic.checkNewJob(Module.TR069, sessionData); // may find a new
// job
} catch (SQLException sqle) {
throw new TR069DatabaseException(sqle);
}
}
Job job = sessionData.getJob();
if (job == null) { // No job is present - process according to
// profile/unit-parameters
// String priority =
// sessionData.getOweraParameters().getValue(SystemParameters.PROVISIONING_PRIORITY);
// if (priority != null &&
// priority.equals("Config-Download-Reboot-Reset")) {
// oppositePriorityProvisioning(reqRes); // Not implemented - does normal
// priority-prov
// } else {
normalPriorityProvisioning(reqRes);
// }
} else {
jobProvisioning(reqRes, job, uj);
}
}
private static void jobProvisioning(HTTPReqResData reqRes, Job job, UnitJob uj) throws TR069Exception {
SessionData sessionData = reqRes.getSessionData();
sessionData.getProvisioningMessage().setJobId(job.getId());
JobType type = job.getFlags().getType();
if (type == JobType.RESET) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.RESET);
reqRes.getResponse().setMethod(TR069Method.FACTORY_RESET);
return;
} else if (type == JobType.RESTART) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.REBOOT);
reqRes.getResponse().setMethod(TR069Method.REBOOT);
return;
} else if (type == JobType.SOFTWARE) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.SOFTWARE);
if (!DownloadLogicTR069.isSoftwareDownloadSetup(reqRes, job))
throw new RuntimeException("Not possible to setup a Software Download job");
reqRes.getResponse().setMethod(TR069Method.DOWNLOAD);
return;
} else if (type == JobType.TR069_SCRIPT) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.SCRIPT);
if (!DownloadLogicTR069.isScriptDownloadSetup(reqRes, job))
throw new RuntimeException("Not possible to setup a Script Download job");
reqRes.getResponse().setMethod(TR069Method.DOWNLOAD);
return;
} else if (type == JobType.SHELL) {
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.SHELL);
ShellJobLogic.execute(sessionData, job, uj);
reqRes.getResponse().setMethod(TR069Method.SET_PARAMETER_VALUES);
return;
} else { // type == JobType.CONFIG
// The service-window is unimportant for next PII calculation, will
// be set to 31 no matter what, since a job is "in the process".
sessionData.getProvisioningMessage().setProvOutput(ProvOutput.CONFIG);
// ServiceWindow serviceWindow = new ServiceWindow(sessionData, false);
prepareSPVForConfigJob(sessionData);
reqRes.getResponse().setMethod(TR069Method.SET_PARAMETER_VALUES);
return;
}
}
private static boolean supportPII(SessionData sessionData) {
CPEParameters cpeParams = sessionData.getCpeParameters();
String PII = cpeParams.PERIODIC_INFORM_INTERVAL;
UnittypeParameters utps = sessionData.getUnittype().getUnittypeParameters();
if (utps.getByName(PII) != null && cpeParams.getValue(PII) != null) {
Log.debug(GPVDecision.class, "CPE supports PeriodicInformInterval");
return true;
} else if (utps.getByName(PII) == null) {
Log.error(GPVDecision.class, "The unittype does not contain PeriodicInformInterval, terminating the conversation.");
return false;
} else { // (cpeParams.getValue(PII) == null)
Log.error(GPVDecision.class, "The CPE did not return PeriodicInformInterval, terminating the conversation.");
return false;
}
}
private static void prepareSPVLimited(HTTPReqResData reqRes) {
SessionData sessionData = reqRes.getSessionData();
sessionData.setProvisioningAllowed(false);
sessionData.getProvisioningMessage().setProvStatus(ProvStatus.DELAYED);
CPEParameters cpeParams = sessionData.getCpeParameters();
String PII = cpeParams.PERIODIC_INFORM_INTERVAL;
ParameterValueStruct pvs = cpeParams.getPvs(PII);
ParameterList toCPE = new ParameterList();
long nextPII = sessionData.getPIIDecision().nextPII();
sessionData.getProvisioningMessage().setPeriodicInformInterval((int) nextPII);
// if (serviceWindow != null)
// nextPII = serviceWindow.nextPII();
pvs.setValue("" + nextPII);
pvs.setType("xsd:unsignedInt");
Log.debug(GPVDecision.class, "All previous CPE parameter changes are cancelled, will only set PeriodicInformInterval (" + pvs.getValue() + ") to CPE and ACS");
toCPE.addParameterValueStruct(pvs);
sessionData.setToCPE(toCPE);
sessionData.getToDB().add(new ParameterValueStruct(PII, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + PII + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
sessionData.getToDB().add(new ParameterValueStruct(SystemParameters.PERIODIC_INTERVAL, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + SystemParameters.PERIODIC_INTERVAL + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
// DBAccessSessionTR069 dbAccessSessionTR069 = new
// DBAccessSessionTR069(DBAccess.getDBI(), sessionData.getDbAccess());
DBAccessSessionTR069.writeUnitParams(sessionData);
}
private static void prepareSPVForConfigJob(SessionData sessionData) throws TR069Exception {
// populate to collections from job-params
// impl.
ParameterList toCPE = new ParameterList();
TR069DMParameterMap dataModel = null;
try {
dataModel = HTTPRequestProcessor.getTR069ParameterMap();
} catch (Exception e) {
throw new TR069Exception("TR069 Data model not found", TR069ExceptionShortMessage.MISC, e);
}
for (JobParameter jp : sessionData.getJobParams().values()) {
Parameter jup = jp.getParameter();
String jpName = jup.getUnittypeParameter().getName();
if (jpName.equals(SystemParameters.JOB_CURRENT) || jpName.equals(SystemParameters.JOB_HISTORY))
continue;
UnittypeParameterFlag upFlag = jup.getUnittypeParameter().getFlag();
String jpValue = jup.getValue();
// ParameterValueStruct jpPvs = new ParameterValueStruct(jpName, jpValue);
if (upFlag.isSystem() || upFlag.isReadOnly()) {
Log.debug(UnitJob.class, "Skipped " + jpName + " since it's a system/read-only parameter, cannot be set in the CPE");
} else {
Log.debug(UnitJob.class, "Added " + jpName + ", value:[" + jpValue + "] to session - will be asked for in GPV");
TR069DMParameter dmp = dataModel.getParameter(jpName);
if (dmp == null)
toCPE.addParameterValueStruct(new ParameterValueStruct(jpName, jpValue, "xsd:string"));
else
toCPE.addParameterValueStruct(new ParameterValueStruct(jpName, jpValue, dmp.getDatatype().getXsdType()));
}
}
sessionData.setToCPE(toCPE);
CPEParameters cpeParams = sessionData.getCpeParameters();
String PII = cpeParams.PERIODIC_INFORM_INTERVAL;
String nextPII = "" + sessionData.getPIIDecision().nextPII();
sessionData.getProvisioningMessage().setPeriodicInformInterval(new Integer(nextPII));
if (cpeParams.getValue(PII) != null && cpeParams.getValue(PII).equals(nextPII)) {
Log.debug(GPVDecision.class, "-No change " + PII + " CPE[" + PII + "] ACS[" + nextPII + "] Default action, the values should be equal");
} else {
sessionData.getToCPE().addOrChangeParameterValueStruct(PII, nextPII, "xsd:unsignedInt");
Log.debug(GPVDecision.class, "-ACS->CPE " + PII + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
sessionData.getToDB().add(new ParameterValueStruct(PII, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + PII + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
sessionData.getToDB().add(new ParameterValueStruct(SystemParameters.PERIODIC_INTERVAL, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + SystemParameters.PERIODIC_INTERVAL + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
}
DBAccessSessionTR069.writeUnitParams(sessionData);
}
private static void prepareSPV(SessionData sessionData) {
populateToCollections(sessionData);
CPEParameters cpeParams = sessionData.getCpeParameters();
String PII = cpeParams.PERIODIC_INFORM_INTERVAL;
String nextPII = "" + sessionData.getPIIDecision().nextPII();
// Cleanup after all jobs have been completed
String disruptiveJob = sessionData.getOweraParameters().getValue(SystemParameters.JOB_DISRUPTIVE);
if (disruptiveJob != null && disruptiveJob.equals("1")) {
Log.debug(GPVDecision.class, "No more jobs && disruptive flag set -> disruptive flag reset (to 0)");
ParameterValueStruct disruptivePvs = new ParameterValueStruct(SystemParameters.JOB_DISRUPTIVE, "0");
sessionData.getToDB().add(disruptivePvs);
}
sessionData.getProvisioningMessage().setPeriodicInformInterval(new Integer(nextPII));
if (cpeParams.getValue(PII) != null && cpeParams.getValue(PII).equals(nextPII)) {
Log.debug(GPVDecision.class, "-No change " + PII + " CPE[" + PII + "] ACS[" + nextPII + "] Default action, the values should be equal");
} else {
sessionData.getToCPE().addOrChangeParameterValueStruct(PII, nextPII, "xsd:unsignedInt");
Log.debug(GPVDecision.class, "-ACS->CPE " + PII + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
sessionData.getToDB().add(new ParameterValueStruct(PII, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + PII + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
sessionData.getToDB().add(new ParameterValueStruct(SystemParameters.PERIODIC_INTERVAL, "" + nextPII));
Log.debug(GPVDecision.class, "-ACS->ACS " + SystemParameters.PERIODIC_INTERVAL + " CPE[" + nextPII + "] ACS[" + nextPII + "] Decided by ACS");
}
DBAccessSessionTR069.writeUnitParams(sessionData);
}
// private static void sendSyslogMessage(SessionData sessionData) {
// try {
// InetAddress address =
// InetAddress.getByName(Properties.getSyslogServer(Module.TR069));
// DatagramSocket socket = new DatagramSocket();
// StringBuffer sb = new StringBuffer();
// sb.append("<133>Jan 1 00:00:00 cpe [" +
// sessionData.getOweraParameters().getValue(SystemParameters.MAC) +
// "]:TR-metrics:");
// for (ParameterValueStruct pvs : sessionData.getToSyslog()) {
// UnittypeParameters unittypeParameters =
// sessionData.getUnittype().getUnittypeParameters();
// UnittypeParameter utp = unittypeParameters.getByName(pvs.getName());
// sb.append(utp.getId() + "=" + pvs.getValue() + ",");
// }
// byte[] message = sb.toString().getBytes("UTF-8");
// DatagramPacket packet = new DatagramPacket(message, message.length);
// packet.setPort(Properties.getSyslogServerPort(Module.TR069));
// packet.setAddress(address);
// socket.send(packet);
// socket.close();
// } catch (Throwable t) {
// Log.warn(GPVDecision.class,
// "Transmission of metrics to syslog server failed:", t);
// }
//
// }
/**
* Loop through all parameters defined in the database, and see which ones are
* missing in the CPE. We only do this if the GPV has been run twice, clearly
* indicating that the first GPV resulted in FA, something that CAN happen
* because we ask for a parameter from the CPE which is not there. Usually
* this will happen because the firmware is no longer in sync with the
* unittype definition.
*/
private static void logMissingCPEParams(SessionData sessionData) {
boolean parameterMissing = false;
for (ParameterValueStruct pvsDB : sessionData.getFromDB().values()) {
boolean match = false;
for (ParameterValueStruct pvsCPE : sessionData.getFromCPE()) {
if (pvsDB.getName().equals(pvsCPE.getName())) {
match = true;
parameterMissing = true;
continue;
}
}
if (!match) {
String logMessage = "The parameter " + pvsDB.getName() + " is defined in the database,";
logMessage += "but does not exist in the CPE. Delete it from the unittype or update the firmware! ";
logMessage += "This situation will impact on the performance of the system.";
Log.warn(GPVDecision.class, logMessage);
}
}
if (parameterMissing)
Log.warn(GPVDecision.class, "GPV has been issued twice, but apparantly the reason for the failure of the first GPV-response is not due to missing parameters in the CPE.");
}
private static String msg(UnittypeParameter utp, String cpeValue, String acsValue, String action, String cause) {
if (utp.getFlag().isConfidential())
return "-" + String.format("%-15s", action) + utp.getName() + " CPE:[*****] ACS:[*****] Flags:[" + utp.getFlag().toString() + "] Cause:[" + cause + "]";
else
return "-" + String.format("%-15s", action) + utp.getName() + " CPE:[" + cpeValue + "] ACS:[" + acsValue + "] Flags:[" + utp.getFlag().toString() + "] Cause:[" + cause + "]";
}
private static void populateToCollections(SessionData sessionData) {
UnittypeParameters utps = sessionData.getUnittype().getUnittypeParameters();
ParameterList toCPE = new ParameterList();
List<ParameterValueStruct> toDB = new ArrayList<ParameterValueStruct>();
// List<ParameterValueStruct> toSyslog = new
// ArrayList<ParameterValueStruct>();
for (int i = 0; i < sessionData.getFromCPE().size(); i++) {
ParameterValueStruct pvsCPE = sessionData.getFromCPE().get(i);
ParameterValueStruct pvsDB = sessionData.getFromDB().get(pvsCPE.getName());
UnittypeParameter utp = utps.getByName(pvsCPE.getName());
String cpeV = pvsCPE.getValue();
String acsV = null;
if (pvsDB != null)
acsV = pvsDB.getValue();
if (utp == null) {
Log.debug(GPVDecision.class, "The parameter name " + pvsCPE.getName() + " was not recognized in ACS, could happen if a GPV on all params was issued.");
continue;
}
// if (utp.getFlag().isInspection())
// Log.warn(GPVDecision.class, msg(utp, cpeV, acsV, "Ignored",
// "Inspection-flag & mode is PERIODIC"));
// else
if (acsV != null && !acsV.equals("ExtraCPEParam") && !(acsV.equals(cpeV))) {
if (utp.getFlag().isReadWrite()) {
if (sessionData.getParameterKey().isEqual()) {
if (utp.getFlag().isConfidential()) {
String msg = msg(utp, cpeV, acsV, "No change", "Values differ & parameterkey is correct & param is confidential (C flag)");
Log.debug(GPVDecision.class, msg);
} else {
String unlc = utp.getName().toLowerCase();
String msg = null;
if (unlc.indexOf("password") > -1 || unlc.indexOf("secret") > -1 || unlc.indexOf("passphrase") > -1) {
msg = msg(utp, cpeV, acsV, "ACS->CPE",
"Values differ & parameterkey is correct -> parameter is probably a secret and should be set to confidential to avoid unnecessary prov. of secret");
} else {
msg = msg(utp, cpeV, acsV, "ACS->CPE",
"Values differ & parameterkey is correct -> parameter must have been changed on device OR should be set to confidential to avoid unnecessary write");
}
if (pvsDB != null)
pvsDB.setType(pvsCPE.getType());
toCPE.addParameterValueStruct(pvsDB);
Log.warn(GPVDecision.class, msg);
}
} else {
Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "ACS->CPE", "Param has ReadWrite-flag"));
if (pvsDB != null)
pvsDB.setType(pvsCPE.getType());
toCPE.addParameterValueStruct(pvsDB);
}
} else {
// if (utp.getFlag().isMonitored()) {
// if (sessionData.getJobParams() != null &&
// sessionData.getJobParams().get(utp.getName()) != null) {
// Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "CPE->SYS",
// "Param has ReadOnly- and Monitored-flag and is requested in a (monitor-)job"));
// toSyslog.add(pvsCPE);
// }
// if (utp.getFlag().isAlwaysRead()) {
// Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "CPE->ACS",
// "Param has ReadOnly-, Monitored- and AlwaysRead-flag"));
// toDB.add(pvsCPE);
// }
// } else {
Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "CPE->ACS", "Param has ReadOnly-flag"));
toDB.add(pvsCPE);
// }
}
} else if (pvsDB != null && pvsDB.getValue() == null && pvsCPE.getValue() != null && pvsCPE.getValue().length() > 0) {
Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "CPE->ACS", "Param new to ACS"));
toDB.add(pvsCPE);
} else if (acsV != null && acsV.equals("ExtraCPEParam")) {
Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "No change", "Ignore ExtraCPEParam - they're treated separately"));
} else {
Log.debug(GPVDecision.class, msg(utp, cpeV, acsV, "No change", "Default action, the values should be equal"));
}
}
// List<RequestResponseData> reqResList = sessionData.getReqResList();
String previousMethod = sessionData.getMethodBeforePreviousResponseMethod();
Log.debug(GPVDecision.class, "PreviousResponseMethod before deciding on log missing cpe params: " + previousMethod);
if (previousMethod.equals(TR069Method.GET_PARAMETER_VALUES))
logMissingCPEParams(sessionData);
sessionData.setToCPE(toCPE);
sessionData.setToDB(toDB);
// sessionData.setToSyslog(toSyslog);
Log.debug(GPVDecision.class, toCPE.getParameterValueList().size() + " params to CPE, " + toDB.size() + " params to ACS");
}
/*
* Make sure unit parameters accurately represents CPE parameters
*/
private static void updateUnitParameters(SessionData sessionData) {
if (sessionData.getUnit() != null && sessionData.getUnit().getUnitParameters() != null) {
Map<String, String> parameters = sessionData.getUnit().getParameters();
for (int i = 0; sessionData.getFromCPE() != null && i < sessionData.getFromCPE().size(); i++) {
ParameterValueStruct pvs = sessionData.getFromCPE().get(i);
if (pvs != null && pvs.getValue() != null)
parameters.put(pvs.getName(), pvs.getValue());
}
}
}
}