[NO ISSUE][API] Add ensureOptionalParameters for extension

- user model changes: no
- storage format changes: no
- interface changes: no

Details:

Change-Id: Id7e9c5aa9c5a4356d1c7279f10c5602059f550f0
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/15227
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
index 5bcde3d..1ec7405 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCQueryServiceServlet.java
@@ -45,6 +45,7 @@
 import org.apache.asterix.translator.ResultProperties;
 import org.apache.asterix.translator.SessionOutput;
 import org.apache.hyracks.api.application.INCServiceContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.exceptions.Warning;
 import org.apache.hyracks.api.util.ExceptionUtils;
 import org.apache.hyracks.http.api.IChannelClosedHandler;
@@ -76,6 +77,7 @@
             QueryServiceRequestParameters param, RequestExecutionState executionState,
             Map<String, String> optionalParameters, Map<String, byte[]> statementParameters,
             ResponsePrinter responsePrinter, List<Warning> warnings) throws Exception {
+        ensureOptionalParameters(optionalParameters);
         // Running on NC -> send 'execute' message to CC
         INCServiceContext ncCtx = (INCServiceContext) serviceCtx;
         INCMessageBroker ncMb = (INCMessageBroker) ncCtx.getMessageBroker();
@@ -134,6 +136,10 @@
         buildResponseResults(responsePrinter, sessionOutput, responseMsg.getExecutionPlans(), warnings);
     }
 
+    protected void ensureOptionalParameters(Map<String, String> optionalParameters) throws HyracksDataException {
+
+    }
+
     protected ExecuteStatementRequestMessage createRequestMessage(IServletRequest request,
             IRequestReference requestReference, String statementsText, SessionOutput sessionOutput,
             ResultProperties resultProperties, QueryServiceRequestParameters param,
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCUdfApiServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCUdfApiServlet.java
index 8cf70b2..3d0f7fc 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCUdfApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/NCUdfApiServlet.java
@@ -295,8 +295,7 @@
         responseWriter.flush();
     }
 
-    protected boolean isRequestPermittedForWrite(IServletRequest request, IServletResponse response)
-            throws IOException {
+    protected boolean isRequestPermitted(IServletRequest request, IServletResponse response) throws IOException {
         if (!isRequestOnLoopback(request)) {
             rejectForbidden(response);
             return false;
@@ -322,14 +321,14 @@
 
     @Override
     protected void post(IServletRequest request, IServletResponse response) throws IOException {
-        if (isRequestPermittedForWrite(request, response)) {
+        if (isRequestPermitted(request, response)) {
             handleModification(request, response, LibraryOperation.UPSERT);
         }
     }
 
     @Override
     protected void delete(IServletRequest request, IServletResponse response) throws IOException {
-        if (isRequestPermittedForWrite(request, response)) {
+        if (isRequestPermitted(request, response)) {
             handleModification(request, response, LibraryOperation.DELETE);
         }
     }