Author: uncled
Date: Tue May 26 11:45:14 2009
New Revision: 778662

URL: http://svn.apache.org/viewvc?rev=778662&view=rev
Log:
CMIS-15 mildly improved error handling for js client

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/cmisclient.js
    incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/index.html

Modified: 
incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/cmisclient.js
URL: 
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/cmisclient.js?rev=778662&r1=778661&r2=778662&view=diff
==============================================================================
--- 
incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/cmisclient.js 
(original)
+++ 
incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/cmisclient.js 
Tue May 26 11:45:14 2009
@@ -19,12 +19,12 @@
  *     The CMIS javascript client gives access to a CMIS document management 
system
  *     from client-side java script code.         
  *      
- * @version $Rev: $, $Date: 2007-03-27 16:30:52 +0200 (Tue, 27 Mar 2007) $
  */
 
 CMISClient = function (url) {
        this.CMIS_SERVICE_URL=url;
        this.info = this.getRepositoryInfo();
+       this.connected = this.info?true:false;
 }
 
 CMISClient.NAME_OF_THIS_FILE = "cmisclient.js";
@@ -103,6 +103,7 @@
        }
        return (obj);
 }
+
 /** Processes an Atom entry into a usable js object */
 CMISClient.processEntry = function(node) {
        var entry=new Object();
@@ -134,6 +135,11 @@
                url=this.info.collections["rootchildren"];
        }
        var htcon=this.httpGet(url);
+       this.lastHttpStatus = htcon.status;
+       if (htcon.status != 200) {
+               return null;
+       }
+       
        var doc=htcon.responseXML;
        var flatres=CMISClient.flatten(doc);
 
@@ -168,6 +174,13 @@
 /** This method reads the repository Info */
 CMISClient.prototype.getRepositoryInfo = function() {
        var htcon=this.httpGet(this.CMIS_SERVICE_URL);
+       this.lastHttpStatus = htcon.status;
+       
+       /* could not connect */
+       if (htcon.status != 200) { 
+               return null;
+               }
+               
        var doc=htcon.responseXML;
        var flatres=CMISClient.flatten(doc);
        var res=new Object();

Modified: 
incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/index.html
URL: 
http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/index.html?rev=778662&r1=778661&r2=778662&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/index.html 
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jsclient/webroot/index.html 
Tue May 26 11:45:14 2009
@@ -34,12 +34,16 @@
        /* instantiate cmisclient */
        var cmisclient= new CMISClient(cmisurl);
 
-       /* get root folder */
-       var rootfolder=cmisclient.getFolder("/");
+       if (cmisclient.connected) {
+               /* get root folder */
+               var rootfolder=cmisclient.getFolder("/");
 
-       /* start traversal */
-       traverse(cmisclient, rootfolder);
+               /* start traversal */
+               traverse(cmisclient, rootfolder);
+       } else {
+               alert ("Could not connect to the repository at: "+cmisurl+" ("+ 
cmisclient.lastHttpStatus +")");
        }
+}
 </script>
 <style>
 </style>


Reply via email to