Skip to content

Commit

Permalink
#736 reuse more code across both WSDL and WADL
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Nov 21, 2013
1 parent b02713e commit f7ac5ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
28 changes: 27 additions & 1 deletion hawtio-web/src/main/webapp/app/api/js/apiHelpers.ts
@@ -1,6 +1,8 @@
module API {

var log:Logging.Logger = Logger.get("API");
export var log:Logging.Logger = Logger.get("API");

export var wadlNamespace = "http://schemas.xmlsoap.org/wsdl/";

/**
* Loads the XML for the given url if its defined or ignore if not valid
Expand Down Expand Up @@ -40,6 +42,30 @@ module API {
return answer;
}

export function initScope($scope, $location, jolokia) {
var search = $location.search();
$scope.url = search["wadl"];
$scope.container = search["container"];
$scope.objectName = search["objectName"];

if ($scope.container && $scope.objectName) {
Fabric.containerJolokia(jolokia, $scope.container, (remoteJolokia) => {
$scope.remoteJolokia = remoteJolokia;
if (remoteJolokia) {
API.loadJsonSchema(remoteJolokia, $scope.objectName, (jsonSchema) => {
log.info("Got JSON Schema: " + JSON.stringify(jsonSchema, null, " "));
$scope.jsonSchema = jsonSchema;
})
} else {
log.info("No Remote Jolokia!");
}
});
} else {
log.info("No container or objectName");
}
log.info("container: " + $scope.container + " objectName: " + $scope.objectName + " url: " + $scope.url);
}

/**
* Loads the JSON schema from a given CXF endpoint mbean
*/
Expand Down
27 changes: 1 addition & 26 deletions hawtio-web/src/main/webapp/app/api/js/wadl.ts
Expand Up @@ -2,32 +2,7 @@ module API {

export function WadlViewController($scope, $location, jolokia) {

var search = $location.search();
$scope.url = search["wadl"];
$scope.container = search["container"];
$scope.objectName = search["objectName"];

if ($scope.container && $scope.objectName) {
Fabric.containerJolokia(jolokia, $scope.container, (remoteJolokia) => {
$scope.remoteJolokia = remoteJolokia;
if (remoteJolokia) {
API.loadJsonSchema(remoteJolokia, $scope.objectName, (jsonSchema) => {
log.info("Got JSON Schema: " + JSON.stringify(jsonSchema, null, " "));
$scope.jsonSchema = jsonSchema;
})
} else {
log.info("No Remote Jolokia!");
}
});
} else {
log.info("No container or objectName");
}

var log:Logging.Logger = Logger.get("API3");

log.info("container: " + $scope.container + " objectName: " + $scope.objectName + " url: " + $scope.url);

var wadlNamespace = "http://schemas.xmlsoap.org/wsdl/";
API.initScope($scope, $location, jolokia);

loadXml($scope.url, onWsdl);

Expand Down
8 changes: 1 addition & 7 deletions hawtio-web/src/main/webapp/app/api/js/wsdl.ts
Expand Up @@ -2,16 +2,11 @@ module API {

export function WsdlViewController($scope, $location, jolokia) {

var search = $location.search();
$scope.url = search["wsdl"];
$scope.container = search["container"];
$scope.objectName = search["objectName"];
API.initScope($scope, $location, jolokia);

var log:Logging.Logger = Logger.get("API");
var wsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";

log.info("container: " + $scope.container + " objectName: " + $scope.objectName + " url: " + $scope.url);

loadXml($scope.url, onWsdl);

function onWsdl(response) {
Expand Down Expand Up @@ -59,6 +54,5 @@ module API {
});
Core.$apply($scope);
}

}
}

0 comments on commit f7ac5ca

Please sign in to comment.