Fix remoteNotifier loop if pollEvent send error, append name to the getAttachement...
authorCharles du Jeu <charles.dujeu@gmail.com>
Thu, 7 May 2009 16:29:48 +0000 (16:29 +0000)
committerCharles du Jeu <charles.dujeu@gmail.com>
Thu, 7 May 2009 16:29:48 +0000 (16:29 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@2425 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

server/org.argeo.slc.ria/src/argeo-ria-lib/slc-web/class/org/argeo/slc/web/TestList.js
server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js
server/org.argeo.slc.ria/src/argeo-ria-src/class/org/argeo/ria/remote/RemoteNotifier.js

index 6204701924e3b95785ca2262f7ea239eb059df84..79fe698cd52a279ebbb67cfc5fda15f087fe8cdd 100644 (file)
@@ -180,7 +180,8 @@ qx.Class.define("org.argeo.slc.web.TestList",
                                        var split = commandId.split("__commandseparator__");\r
                                        var uuid = split[0];\r
                                        var contentType = split[1];\r
-                                       var url = org.argeo.slc.ria.SlcApi.buildGetAttachmentUrl(uuid, contentType);\r
+                                       var name = split[2];\r
+                                       var url = org.argeo.slc.ria.SlcApi.buildGetAttachmentUrl(uuid, contentType, name);\r
                                        var win = window.open(url);\r
                                },\r
                                selectionChange : function(viewId, xmlNodes){\r
@@ -194,12 +195,12 @@ qx.Class.define("org.argeo.slc.web.TestList",
                                                var submenus = [];\r
                                                for(var i=0;i<attachs.length;i++){\r
                                                        var uuid = org.argeo.ria.util.Element.getSingleNodeText(attachs[i], "slc:uuid");\r
-                                                       var contentType = org.argeo.ria.util.Element.getSingleNodeText(attachs[i], "slc:content-type");\r
+                                                       var contentType = (org.argeo.ria.util.Element.getSingleNodeText(attachs[i], "slc:content-type")||'');\r
                                                        var name = org.argeo.ria.util.Element.getSingleNodeText(attachs[i], "slc:name");\r
                                                        submenus.push({\r
                                                                label:name, \r
                                                                icon : 'resource/slc/mime-text-plain.png', \r
-                                                               commandId:uuid+'__commandseparator__'+contentType\r
+                                                               commandId:uuid+'__commandseparator__'+contentType+'__commandseparator__'+name\r
                                                        });\r
                                                }\r
                                                this.setMenu(submenus);\r
index 7009757a1857365293d0077aa2f0e2c4cdd77c30..d69830da20e692960bdd1b513f33be06aca711d5 100644 (file)
@@ -184,9 +184,9 @@ qx.Class.define("org.argeo.slc.ria.SlcApi",
                return request;\r
        },\r
 \r
-       buildGetAttachmentUrl : function(attachmentId, contentType){\r
+       buildGetAttachmentUrl : function(attachmentId, contentType, name){\r
                return org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT + "/" + org.argeo.slc.ria.SlcApi.GET_ATTACHEMENT_SERVICE\r
-                       + "?uuid=" + attachmentId + "&contentType=" + contentType;\r
+                       + "?uuid=" + attachmentId + "&contentType=" + contentType + "&name=" + name;\r
        },\r
        \r
        /**\r
index d5630b70dbd960b36c1d95471e5b72cd41839428..be97aee069b2a29d0b60a903a68c7845cae62cd5 100644 (file)
@@ -25,9 +25,13 @@ qx.Class.define("org.argeo.ria.remote.RemoteNotifier",
                eventXPath : {check : "String", init:"//event"},\r
                eventTypeXPath : {check : "String", init:"@type"},\r
                eventDataXPath : {check : "String", init:"@data"},\r
+               answerStatusXPath : {check : "String", init:"slc:execution-answer/slc:status"},\r
                timeout : {                     \r
                        init : 20000\r
                },\r
+               errorTimeout : {\r
+                       init : 5000\r
+               },\r
                interrupt : {\r
                        check : "Boolean",\r
                        init : false\r
@@ -60,10 +64,18 @@ qx.Class.define("org.argeo.ria.remote.RemoteNotifier",
                        req.setParameter("timeout", this.getTimeout());\r
                        req.setTimeout(this.getTimeout() + 5000);\r
                        req.addListener("completed", this._pollHandler, this);\r
+                       req.addListener("failed", this._errorHandler, this);\r
+                       req.addListener("timeout", this._errorHandler, this);\r
+                       req.addListener("aborted", this._errorHandler, this);\r
                        req.send();\r
                },\r
                _pollHandler : function(response){\r
                        // Parse response\r
+                       var status = org.argeo.ria.util.Element.getSingleNodeText(response.getContent(), this.getAnswerStatusXPath());\r
+                       if(status && status == "ERROR"){\r
+                               this._errorHandler();\r
+                               return;\r
+                       }\r
                        var messages = org.argeo.ria.util.Element.selectNodes(response.getContent(), this.getEventXPath());\r
                        if(messages){\r
                                for(var i=0;i<messages.length;i++){\r
@@ -78,6 +90,10 @@ qx.Class.define("org.argeo.ria.remote.RemoteNotifier",
                        }\r
                        this._poll();\r
                },\r
+               _errorHandler : function(){\r
+                       // Wait an try again later\r
+                       qx.event.Timer.once(this._poll, this, this.getErrorTimeout());\r
+               },\r
                _getRequest : function(service, method, type){\r
                        return new qx.io.remote.Request(\r
                                this.getUri()+service, \r