diff --git a/designer/src/main/java/org/restcomm/connect/rvd/RvdConfiguration.java b/designer/src/main/java/org/restcomm/connect/rvd/RvdConfiguration.java index 83707ab..9af2cb5 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/RvdConfiguration.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/RvdConfiguration.java @@ -80,7 +80,7 @@ public class RvdConfiguration { private RvdConfig rvdConfig; // the configuration settings from rvd.xml private RestcommConfig restcommConfig; - private String contextRootPath; + private String contextRootPath; // e.g. a/path/ending/in/slash/ private URI restcommBaseUri; private Integer externalServiceTimeout; private Boolean videoSupport; @@ -93,13 +93,14 @@ public class RvdConfiguration { } public RvdConfiguration(ServletContext servletContext) { - contextRootPath = servletContext.getRealPath("/"); - logger.info("context root path is " + contextRootPath); - load(); + this(servletContext.getRealPath("/")); } public RvdConfiguration(String contextRootPath) { this.contextRootPath = contextRootPath; + // append trailing slash if not already there + if (this.contextRootPath != null && !this.contextRootPath.endsWith("/")) + this.contextRootPath += "/"; logger.info("context root path is " + contextRootPath); load(); } diff --git a/designer/src/main/webapp/app.js b/designer/src/main/webapp/app.js index 06f8181..afa0b0a 100644 --- a/designer/src/main/webapp/app.js +++ b/designer/src/main/webapp/app.js @@ -154,7 +154,8 @@ angular.element(document).ready(['$http',function ($http) { angular.module('Rvd').factory('RvdConfiguration', function () { return { projectsRootPath: '/restcomm-rvd/services/projects', - videoSupport: clientConfig.videoSupport + videoSupport: clientConfig.videoSupport, + restcommBaseUrl = 'http://192.168.2.2' } }); configPromise.resolve(clientConfig); diff --git a/designer/src/main/webapp/js/app/controllers/projectManager.js b/designer/src/main/webapp/js/app/controllers/projectManager.js index 5e5edc7..fd2ab5b 100644 --- a/designer/src/main/webapp/js/app/controllers/projectManager.js +++ b/designer/src/main/webapp/js/app/controllers/projectManager.js @@ -1,4 +1,4 @@ -App.controller('projectManagerCtrl', function ( $scope, $http, $location, $stateParams, $timeout, $upload, notifications, authentication, fileRetriever ) { +App.controller('projectManagerCtrl', function ( $scope, $http, $location, $stateParams, $timeout, $upload, notifications, authentication, fileRetriever, RvdConfiguration ) { var account = authentication.getAccount(); @@ -17,7 +17,7 @@ App.controller('projectManagerCtrl', function ( $scope, $http, $location, $state $scope.appItems = []; $scope.retrievingApps = true; $http({ - url: '/restcomm/2012-04-24/Accounts/' + account.sid + '/Applications.json', + url: RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/Accounts/' + account.sid + '/Applications.json', method: 'GET', headers: {Authorization: authentication.getAuthHeader()} }).success(function (data, status, headers, config) { diff --git a/designer/src/main/webapp/js/app/interceptors.js b/designer/src/main/webapp/js/app/interceptors.js index 42612df..96aefd2 100644 --- a/designer/src/main/webapp/js/app/interceptors.js +++ b/designer/src/main/webapp/js/app/interceptors.js @@ -38,7 +38,7 @@ angular.module('Rvd').config(['$httpProvider', function($httpProvider) { // injects authentication credentials when Restcomm authentication is used angular.module('Rvd').factory('RestcommAuthenticationInterceptor', function ($injector) { function request(config) { - return $injector.invoke(function ($state, authentication) { + return $injector.invoke(function ($state, authentication, RvdConfiguration) { if (config.url.startsWith('services/') || config.url.startsWith('/restcomm-rvd/services/')) { if (authentication.getAuthHeader()) { // if the request is targeted towards RVD add authorization header and there is no authorization header already @@ -47,7 +47,7 @@ angular.module('Rvd').factory('RestcommAuthenticationInterceptor', function ($in config.headers.Authorization = authentication.getAuthHeader(); } } else - if (config.url.startsWith('/restcomm/2012-04-24/')) { + if (config.url.startsWith(RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/')) { if (authentication.getAuthHeader()) { delete config.headers.authorization; // mind the case insensitivity of headers delete config.headers.Authorization; diff --git a/designer/src/main/webapp/js/app/services.js b/designer/src/main/webapp/js/app/services.js index 391173f..ec631ce 100644 --- a/designer/src/main/webapp/js/app/services.js +++ b/designer/src/main/webapp/js/app/services.js @@ -90,7 +90,7 @@ angular.module('Rvd').service('initializer',function (authentication, storage, }; }); -angular.module('Rvd').service('authentication', function ($http, $q, storage, $state, md5, $rootScope) { +angular.module('Rvd').service('authentication', function ($http, $q, storage, $state, md5, $rootScope, RvdConfiguration) { var authInfo = {}; var account = null; // if this is set it means that user logged in: authentication succeeded and account was retrieved @@ -138,7 +138,7 @@ angular.module('Rvd').service('authentication', function ($http, $q, storage, $s function restcommLogin(username,password) { var deferredLogin = $q.defer(); var authHeader = basicAuthHeader(username, password); - $http({method:'GET', url:'/restcomm/2012-04-24/Accounts.json/' + encodeURIComponent(username), headers: {Authorization: authHeader}}).then(function (response) { + $http({method:'GET', url: RvdConfiguration.restcommBaseUrl + '/restcomm/2012-04-24/Accounts.json/' + encodeURIComponent(username), headers: {Authorization: authHeader}}).then(function (response) { var acc = response.data; // store temporarily the account returned $http({method:'GET', url:'services/auth/keepalive', headers: {Authorization: "Basic " + btoa(acc.email_address + ":" +acc.auth_token)}}).then(function (response) { // ok, access to both restcomm and RVD is verified @@ -830,3 +830,4 @@ angular.module('Rvd').factory('fileRetriever', function (Blob, FileSaver, $http) download: download } }); +