String maxConnectionsValue = message.getHeader(SCMPHeaderAttributeKey.MAX_CONNECTIONS);
ValidatorUtility.validateInt(1, maxConnectionsValue, maxSessions, SCMPError.HV_WRONG_MAX_CONNECTIONS);
int maxConnections = Integer.parseInt(maxConnectionsValue);
if (maxConnections == 1 && maxSessions != 1) {
// invalid configuration
throw new SCMPValidatorException(SCMPError.HV_WRONG_MAX_SESSIONS, "maxSessions must be 1 if maxConnections is 1");
}
// portNr - portNr >= 1 && portNr <= 0xFFFF mandatory
String portNr = message.getHeader(SCMPHeaderAttributeKey.PORT_NR);
ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, portNr, Constants.MAX_PORT_VALUE, SCMPError.HV_WRONG_PORTNR);
// keepAliveInterval mandatory
String kpi = message.getHeader(SCMPHeaderAttributeKey.KEEP_ALIVE_INTERVAL);
ValidatorUtility.validateInt(Constants.MIN_KPI_VALUE, kpi, Constants.MAX_KPI_VALUE,
SCMPError.HV_WRONG_KEEPALIVE_INTERVAL);
// checkRegistrationInterval mandatory
String cri = message.getHeader(SCMPHeaderAttributeKey.CHECK_REGISTRATION_INTERVAL);
ValidatorUtility.validateInt(Constants.MIN_CRI_VALUE, cri, Constants.MAX_CRI_VALUE,
SCMPError.HV_WRONG_CHECK_REGISTRATION_INTERVAL);
} catch (HasFaultResponseException ex) {
// needs to set message type at this point
ex.setMessageType(getKey());
throw ex;
} catch (Throwable th) {
LOGGER.error("validation error", th);
SCMPValidatorException validatorException = new SCMPValidatorException();
validatorException.setMessageType(getKey());
throw validatorException;
}
}