Skip to content

Restcomm 1512 - Extensions API changes needed for FAC#2757

Merged
gvagenas merged 5 commits intomasterfrom
restcomm-1512
Jan 19, 2018
Merged

Restcomm 1512 - Extensions API changes needed for FAC#2757
gvagenas merged 5 commits intomasterfrom
restcomm-1512

Conversation

@gvagenas
Copy link
Copy Markdown
Contributor

Changes needed to the Extensions API to support Feature Access Control feature

* @return ExtensionResponse see ExtensionResponse
*/
ExtensionResponse preInboundAction(SipServletRequest request);
ExtensionResponse preInboundAction(IExtensionRequest extensionRequest);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the idea of being independent to underlying framework (servlet,akka), so good choice on having our own request. It would be still a good idea to be able to recover ref to original framework objects using generic container of objects, so extension impl may use them if required. I noticed in the "init" method we still inject a ServletContext, so the extension is still tied to specific ServletAPI. not sure if is time to have an specific ExtensionContext as well, and pass it as part of the request...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExtensionContext sounds a good idea @jaimecasero. Not sure also if its the proper time to do it.
I think that since now the team will be more familiar with the Extensions API, for the next task we can plan and estimate enhancements like the one you suggest

}

public ExtensionResponse executePreInboundAction(final IExtensionRequest er, List<RestcommExtensionGeneric> extensions) {
ExtensionResponse response = new ExtensionResponse();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of this default response?, how do we detect if this response is coming from an actual extension or not? maybe the empty response is good enough for the framework, just wondering...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero The ExtensionResponse object will be set by each extension. The response holds an object that can be used to pass data from one extension back to RC, such as custom headers, custom proxy headers etc.

Currently, we don't use the post-*-action methods so we just create a response object and return it.

The idea for the post-*-action is to use them for maintenance and logistic, such as update logs, update db, notify services (charging) etc.....

return response;
}

public ExtensionResponse executePostInboundAction(final IExtensionRequest er, List<RestcommExtensionGeneric> extensions) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this extension API is starting to feel very specific ,with many variants of same purpose. Not sure if we could push all this executePre/PostXAction methods into the request interface, so the request tells the type of exec point X by a using a getter in the req interface... I think we could have a single pre and post methods...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero we can discuss pros/cons about this for the next Extensions API enhancements

ExtensionController ec = ExtensionController.getInstance();
ApiRequest apiRequest = new ApiRequest(sid.toString(), data, ApiRequest.Type.CREATE_SUBACCOUNT);

if (executePostApiAction(apiRequest)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really post,or should be pre?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero good catch, this must be pre. I will fix that

call.tell(new Hangup(errMsg), source);
return;
}
ec.executePostOutboundAction(er, extensions);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we delay the invocation of PostAction to when the ASR is actually executed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero, in general, the post action should be executed after the pre action.

At the point of your comment, the call is already answered and maybe had already executed some RCML verbs, the interpreter started executions of the gather verb with asr which account was not permitted and thus interpreter hangup the call. I think this is the proper place for post action method.

final NotificationsDao notifications = storage.getNotificationsDao();
final Notification notification = notification(WARNING_NOTIFICATION, 11001, "Outbound SMS is now allowed");
notifications.addNotification(notification);
fsm.transition(message, finished);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we covering postaction invocation later as part of FSM?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero no, I missed the post action and I will add it now

}
final NotificationsDao notifications = storage.getNotificationsDao();
final Notification notification = notification(WARNING_NOTIFICATION, 11001, "Outbound SMS is now allowed");
notifications.addNotification(notification);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we covering postaction invocation as part of fsm lateR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero no, I missed the post action and I will add it now

sendNotification(errMsg, 11001, "warning", true);
final SipServletResponse resp = request.createResponse(SC_FORBIDDEN, "Inbound USSD session is not Allowed");
resp.send();
ec.executePostOutboundAction(far, extensions);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we invoking postAction here if feature isAllowed in the other branch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero we need to invoke post action in any case, I will fix that

+ " is not Allowed";
sendNotification(errMsg, 11001, "warning", true);
final SipServletResponse resp = request.createResponse(SC_FORBIDDEN, "Call not allowed");
resp.send();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we cover postAction in this execution point (for both allowed and notAllowed options)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaimecasero I missed that, I will fix this

@maria-farooq
Copy link
Copy Markdown

maria-farooq commented Jan 16, 2018

my comment on the topic is related to RestcommExtensionGeneric.java I think for me

postApiAction
postInboundAction
postOutboundAction
preApiAction
preInboundAction
preOutboundAction

are same method and should have similar approach on applying a sequence of extensions to a given Action/Request regardless of it being pre or post, inbound or out bound, api request or any-other request

@gvagenas
Copy link
Copy Markdown
Contributor Author

@maria-farooq @jaimecasero about your comments on improvements for Extensions API, I think those should definitely be discussed but are out of the scope of this feature and this sprint.

Any changes in the API will have an impact on existing extensions. As I suggested earlier, we should record any suggestion, discuss them and in the next sprints plan them

@@ -0,0 +1,14 @@
package org.restcomm.connect.extension.api;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add copyright statement in begenning of this file?

@@ -0,0 +1,79 @@
package org.restcomm.connect.telephony.api;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl we adde copyright statement in begening of this file

@gvagenas gvagenas merged commit b7874f6 into master Jan 19, 2018
@gvagenas gvagenas deleted the restcomm-1512 branch January 19, 2018 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants