use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerSubscriptionActivityImpl method createUserDataAnswer.
public UserDataAnswer createUserDataAnswer(long resultCode, boolean isExperimentalResult) {
UserDataAnswer answer = null;
for (int index = 0; index < stateMessages.size(); index++) {
if (stateMessages.get(index).getCommand().getCode() == UserDataRequest.commandCode) {
UserDataRequest msg = (UserDataRequest) stateMessages.get(index);
answer = this.messageFactory.createUserDataAnswer(msg, resultCode, isExperimentalResult);
if (answer.getAuthSessionState() == null && this.authSessionState != null) {
answer.setAuthSessionState(this.authSessionState);
}
((DiameterShMessageImpl) answer).setData(msg);
break;
}
}
// answer.setSessionId(super.session.getSessionId());
return answer;
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShClientActivityImpl method sendUserDataRequest.
public void sendUserDataRequest(UserDataRequest message) throws IOException {
try {
DiameterMessageImpl msg = (DiameterMessageImpl) message;
this.clientSession.sendUserDataRequest(new UserDataRequestImpl((Request) msg.getGenericData()));
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
throw new IOException("Failed to send message, due to: " + e);
}
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShServerActivityAnswerCreationTest method testShServerSubscriptionActivityAnswerCreation.
@Test
public void testShServerSubscriptionActivityAnswerCreation() throws Exception {
ServerShSession session = new ShServerSessionImpl(new ShServerSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ServerShSessionListenerImpl());
DiameterMessageFactoryImpl msgFactory = new DiameterMessageFactoryImpl(session.getSessions().get(0), stack, null, null);
ShClientMessageFactoryImpl factory = new ShClientMessageFactoryImpl(session.getSessions().get(0), stack);
UserDataRequest udr = factory.createUserDataRequest();
net.java.slee.resource.diameter.sh.events.ProfileUpdateRequest pur = factory.createProfileUpdateRequest();
net.java.slee.resource.diameter.sh.events.SubscribeNotificationsRequest snr = factory.createSubscribeNotificationsRequest();
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(udr);
list.add(pur);
list.add(snr);
ShServerSubscriptionActivityImpl activity = new ShServerSubscriptionActivityImpl(new ShServerMessageFactoryImpl(msgFactory, session.getSessions().get(0), stack, diameterShAvpFactory), diameterShAvpFactory, session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
use of net.java.slee.resource.diameter.sh.events.UserDataRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method testMessageFactoryApplicationIdChangeUDR.
@Test
public void testMessageFactoryApplicationIdChangeUDR() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((ShClientMessageFactoryImpl) shClientFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Sh is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
UserDataRequest originalUDR = shClientFactory.createUserDataRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalUDR);
// now we switch..
originalUDR = null;
isVendor = !isVendor;
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
UserDataRequest changedUDR = shClientFactory.createUserDataRequest();
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedUDR);
// revert back to default
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Aggregations