Hi Sajith,
Simply wrapping sendRedirect, in a try/catch gives me error.
Sample snippet is as below.
try {
> var hasMultiple =
> recoveryManager.hasMultiplePasswordRecoveryEnabled();
> if (!hasMultiple) {//when multiple recovery options are not enabled
>
> if
> (recoveryManager.isPasswordRecoveryOptionEnabled("notification-based")) {
>
> //TODO invoke password recovery via email
> sendRedirect(env.contextPath +
> '/recovery/password-complete?username=' + username);
>
> } else if
> (recoveryManager.isPasswordRecoveryOptionEnabled("security-question-based"))
> {
>
> sendRedirect(env.contextPath +
> '/recovery/security-questions?username=' + username);
> }
> //TODO decide what, when non of the options are enabled
} else {
> var questions = recoveryManager.getUserQuestions(userId);
> if (!questions.success) {
> sendError(500, "something.wrong.error");
> //TODO
> }
> return {
> hasMultipleOptions: hasMultiple,
> hasUserQuestions: questions.data.length > 0,
> userQuestions: questions.data
> };
> }
> } catch (e) {
> Log.error("Errror", e)
>
sendError(500, "something.wrong.error");
> }
>
On Wed, Feb 1, 2017 at 7:10 PM, SajithAR Ariyarathna <[email protected]>
wrote:
> Hi Ayesha,
>
> Observing below error when sendRedirect is used within a try.
>>
> Can you point the source where this is hapenning.
>
> Thanks.
>
> On Wed, Feb 1, 2017 at 6:57 PM, SajithAR Ariyarathna <[email protected]>
> wrote:
>
>> Hi Manu,
>>
>> Maybe if extend PageRedirectException from Throwable instead Exception
>>> it'll work
>>>
>> This wouldn't work as Nashorn JS try-catch is equivalent to Java, which
>> mean that it catches Throwable.
>>
>> Thanks.
>>
>> On Wed, Feb 1, 2017 at 6:54 PM, Manuranga Perera <[email protected]> wrote:
>>
>>> @UUF team,
>>>
>>> Maybe if extend PageRedirectException from Throwable instead Exception
>>> it'll work. If not we will have to do what J2EE does, that is, even after
>>> sendRedirect the code runs, but no output.
>>>
>>> On Wed, Feb 1, 2017 at 12:43 PM, Ayesha Dissanayaka <[email protected]>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> Observing below error when sendRedirect is used within a try.
>>>>
>>>> ...org.wso2.carbon.uuf.exception.PageRedirectException: Redirecting to
>>>> '/user-portal/recovery/password-complete?username=admin'.
>>>> at org.wso2.carbon.uuf.core.API.sendRedirect(API.java:144)
>>>> at jdk.nashorn.internal.scripts.Script$Recompilation$96$721A$pa
>>>> ssword_options$cu1$restOf.onGet(/home/ayesha/WORK/IS/SOURCE/
>>>> product-is/product/working/wso2is-6.0.0-SNAPSHOT/deployment/uufapps/
>>>> org.wso2.carbon.iam.user-portal/components/root/page
>>>> s/recovery/password-options.js:38)
>>>> at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(Scrip
>>>> tFunctionData.java:639)
>>>> at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFun
>>>> ction.java:494)
>>>> at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRunti
>>>> me.java:393)
>>>> at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(Scri
>>>> ptObjectMirror.java:199)
>>>> at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(Nas
>>>> hornScriptEngine.java:383)
>>>> at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction
>>>> (NashornScriptEngine.java:190)
>>>> at org.wso2.carbon.uuf.renderablecreator.hbs.impl.JsExecutable.
>>>> execute(JsExecutable.java:133)
>>>> at org.wso2.carbon.uuf.renderablecreator.hbs.impl.MutableJsExec
>>>> utable.execute(MutableJsExecutable.java:43)
>>>> at org.wso2.carbon.uuf.renderablecreator.hbs.impl.HbsPageRender
>>>> able.execute(HbsPageRenderable.java:124)
>>>> at org.wso2.carbon.uuf.renderablecreator.hbs.impl.HbsPageRender
>>>> able.render(HbsPageRenderable.java:75)
>>>> at org.wso2.carbon.uuf.core.Page.render(Page.java:61)
>>>> at org.wso2.carbon.uuf.core.Component.renderPage(Component.java
>>>> :117)
>>>> at org.wso2.carbon.uuf.core.App.renderPageUri(App.java:176)
>>>> at org.wso2.carbon.uuf.core.App.renderPage(App.java:126)
>>>> at org.wso2.carbon.uuf.internal.RequestDispatcher.servePageOrFr
>>>> agment(RequestDispatcher.java:94)
>>>> at org.wso2.carbon.uuf.internal.RequestDispatcher.serve(Request
>>>> Dispatcher.java:67)
>>>> at org.wso2.carbon.uuf.internal.UUFServer.serve(UUFServer.java:175)
>>>> at org.wso2.carbon.uuf.httpconnector.msf4j.UUFMicroservice.getI
>>>> mpl(UUFMicroservice.java:56)
>>>> at org.wso2.carbon.uuf.httpconnector.msf4j.UUFMicroservice.get(
>>>> UUFMicroservice.java:48)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>>>> ssorImpl.java:62)
>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>>>> thodAccessorImpl.java:43)
>>>> at java.lang.reflect.Method.invoke(Method.java:498)
>>>> at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMet
>>>> hodInfo.java:132)
>>>> at org.wso2.msf4j.internal.MSF4JMessageProcessor.dispatchMethod
>>>> (MSF4JMessageProcessor.java:130)
>>>> at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JM
>>>> essageProcessor.java:72)
>>>> at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDisp
>>>> atchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoo
>>>> lDispatchingSourceHandler.java:125)
>>>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>>>> Executor.java:1142)
>>>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>>> lExecutor.java:617)
>>>> at java.lang.Thread.run(Thread.java:745)
>>>>
>>>> Created [1] to track this.
>>>>
>>>> [1] https://github.com/wso2/carbon-uuf/issues/182
>>>>
>>>> Thanks!
>>>> -Ayesha
>>>>
>>>> --
>>>> *Ayesha Dissanayaka*
>>>> Software Engineer,
>>>> WSO2, Inc : http://wso2.com
>>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
>>>> 20, Palmgrove Avenue, Colombo 3
>>>> E-Mail: [email protected] <[email protected]>
>>>>
>>>
>>>
>>>
>>> --
>>> With regards,
>>> *Manu*ranga Perera.
>>>
>>> phone : 071 7 70 20 50
>>> mail : [email protected]
>>>
>>
>>
>>
>> --
>> Sajith Janaprasad Ariyarathna
>> Software Engineer; WSO2, Inc.; http://wso2.com/
>> <https://wso2.com/signature>
>>
>
>
>
> --
> Sajith Janaprasad Ariyarathna
> Software Engineer; WSO2, Inc.; http://wso2.com/
> <https://wso2.com/signature>
>
--
*Ayesha Dissanayaka*
Software Engineer,
WSO2, Inc : http://wso2.com
<http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
20, Palmgrove Avenue, Colombo 3
E-Mail: [email protected] <[email protected]>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev