use of org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentRequestImpl in project jain-slee.diameter by RestComm.
the class CxDxMessageFactoryImpl method createCxDxMessage.
/**
* Creates a CxDx Message with specified command-code and avps filled. If a header is present an answer will be created, if not
* it will generate a request.
*
* @param diameterHeader
* @param avps
* @param _commandCode
* @param appId
* @return
* @throws InternalException
*/
DiameterMessage createCxDxMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws InternalException {
boolean creatingRequest = diameterHeader == null;
Message msg = null;
if (!creatingRequest) {
Message raw = createMessage(diameterHeader, avps, 0, appId);
raw.setProxiable(diameterHeader.isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = raw;
} else {
Message raw = createMessage(diameterHeader, avps, _commandCode, appId);
raw.setProxiable(true);
raw.setRequest(true);
msg = raw;
}
int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
DiameterMessage diamMessage = null;
switch(commandCode) {
case LocationInfoRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new LocationInfoRequestImpl(msg) : new LocationInfoAnswerImpl(msg);
break;
case MultimediaAuthenticationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new MultimediaAuthenticationRequestImpl(msg) : new MultimediaAuthenticationAnswerImpl(msg);
break;
case PushProfileRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new PushProfileRequestImpl(msg) : new PushProfileAnswerImpl(msg);
break;
case RegistrationTerminationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new RegistrationTerminationRequestImpl(msg) : new RegistrationTerminationAnswerImpl(msg);
break;
case ServerAssignmentRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new ServerAssignmentRequestImpl(msg) : new ServerAssignmentAnswerImpl(msg);
break;
case UserAuthorizationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new UserAuthorizationRequestImpl(msg) : new UserAuthorizationAnswerImpl(msg);
break;
default:
diamMessage = new ExtensionDiameterMessageImpl(msg);
}
if (!diamMessage.hasSessionId() && session != null) {
diamMessage.setSessionId(session.getSessionId());
}
return diamMessage;
}
use of org.mobicents.slee.resource.diameter.cxdx.events.ServerAssignmentRequestImpl in project jain-slee.diameter by RestComm.
the class DiameterCxDxResourceAdaptor method createEvent.
/**
* Create Event object from a JDiameter message (request or answer)
*
* @return a DiameterMessage object wrapping the request/answer
* @throws OperationNotSupportedException
*/
private DiameterMessage createEvent(Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
boolean isRequest = message.isRequest();
switch(commandCode) {
case // UAR/UAA
UserAuthorizationRequest.COMMAND_CODE:
return isRequest ? new UserAuthorizationRequestImpl(message) : new UserAuthorizationAnswerImpl(message);
case // SAR/SAA
ServerAssignmentRequest.COMMAND_CODE:
return isRequest ? new ServerAssignmentRequestImpl(message) : new ServerAssignmentAnswerImpl(message);
case // LIR/LIA
LocationInfoRequest.COMMAND_CODE:
return isRequest ? new LocationInfoRequestImpl(message) : new LocationInfoAnswerImpl(message);
case // MAR/MAA
MultimediaAuthenticationRequest.COMMAND_CODE:
return isRequest ? new MultimediaAuthenticationRequestImpl(message) : new MultimediaAuthenticationAnswerImpl(message);
case // RTR/RTA
RegistrationTerminationRequest.COMMAND_CODE:
return isRequest ? new RegistrationTerminationRequestImpl(message) : new RegistrationTerminationAnswerImpl(message);
case // MAR/MAA
PushProfileRequest.COMMAND_CODE:
return isRequest ? new PushProfileRequestImpl(message) : new PushProfileAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
Aggregations