Forum Post: Jsdosession Service Already Loaded Error

  • Thread starter Thread starter riche
  • Start date Start date
Status
Not open for further replies.
R

riche

Guest
In my mobile app, I have a drawer on my login page that allows the user to set the server to connect to. All works well except in one situation. If I log in, then decide to logout, then change the settings (which are saved to local storage), then try to log in again, it logs in, but the add catalog throws and error. Error: Error processing catalog ' servername.mydomain.com:8980/.../MyAppService.json' . A service named 'MyAppService' was already loaded. I'm using an angularjs factory as an authentication service and have the jsdosession as a property of it and I am currently just using anonymous security. var factory = { loginPath: '/login', user: { isAuthenticated: false, roles: null }, serverName: jsdoSettings.serverName, serverPort: jsdoSettings.port, serverSecure: jsdoSettings.secured, jsdosession: createSession() }; function createSession() { // this will just set the authenticationModel to "ANONYMOUS" if it is bland or undefined progress.util.jsdoSettingsProcessor(jsdoSettings); if (!jsdoSettings.authenticationModel) { console.log("Warning: jsdoSettings.authenticationModel not specified. Default is ANONYMOUS"); } else { if (jsdoSettings.serviceURI) { return new progress.data.JSDOSession(jsdoSettings); } else { console.log("Error: jsdoSettings.serviceURI must be specified."); } } return null; } Here are the login and logout functions: factory.login = function (username, password) { var loggedIn = false; var deferred = $q.defer(); try { // factory.jsdosession = null; // factory.jsdosession = createSession(); factory.jsdosession.login(username, password).done( function (jsdosession, result, info) { try { console.log("login promise done"); factory.jsdosession.addCatalog(jsdoSettings.catalogURIs).done( function (jsdosession, result, details) { console.log("Add catalog promise done"); loggedIn = true; changeAuth(loggedIn); deferred.resolve(loggedIn); }).fail(function (jsdosession, result, details) { console.log("add catalog promise failed"); addCatalogErrorFn(jsdosession, progress.data.Session.GENERAL_FAILURE, details); deferred.reject(loggedIn); }); } catch (ex) { console.log("undknown error in add catalog"); details = [{ "catalogURI": jsdoSettings.catalogURIs, errorObject: ex }]; addCatalogErrorFn(jsdosession, progress.data.Session.GENERAL_FAILURE, details); deferred.reject(false); } }).fail(function (jsdosession, result, info) { console.log("login promise failed"); loginErrorFn(jsdosession, result, info); deferred.reject(false); }); // end promise.fail } catch (ex) { loginErrorFn(jsdosession, progress.data.Session.GENERAL_FAILURE, { errorObject: ex }); deferred.reject(false); } return deferred.promise; }; factory.logout = function () { var promise, loggedIn = true, deferred = $q.defer(); try { promise = factory.jsdosession.logout(); promise.done(function (jsdosession, result, info) { console.log("logout promise done"); //vm.options.performLogout = false; loggedIn = false; deferred.resolve(true); }); promise.fail(function (jsdosession, result, info) { logoutErrorFn(jsdosession, result, info); deferred.reject(false); }); } catch (ex) { logoutErrorFn(factory.jsdosession, progress.data.Session.GENERAL_FAILURE, { errorObject: ex }); deferred.reject(false); } changeAuth(loggedIn); return deferred.promise; }; And here is what I do when they change the settings (which will only happen when they are logged out. factory.SaveServerSetup = function () { jsdoSettings.SetServerInfo(factory.serverName, factory.serverPort, factory.serverSecure); factory.jsdosession = createSession(); }; So, I am trying to just create a new JSDOSession object. I then click on the login button and it calls login, the login function is successful, but it fails on the addCatalog function stating the before-metioned error. Is there something wrong in my setup or a bug in the progress.all.js or something else going on here? Thanks

Continue reading...
 
Status
Not open for further replies.
Back
Top