Skip to content

Commit

Permalink
Merge pull request #51 from ammendonca/HWK-613
Browse files Browse the repository at this point in the history
Add support for Add Datasource operation
  • Loading branch information
mtho11 committed Oct 6, 2015
2 parents 860def0 + 2860c6b commit d8ac0af
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 0 deletions.
51 changes: 51 additions & 0 deletions dist/hawkular-ui-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ var hawkularRest;
var factory = {};
factory.Organization = $resource(prefix + '/hawkular/accounts/organizations/:id', { id: '@id' });
factory.Persona = $resource(prefix + '/hawkular/accounts/personas/:id', { id: '@id' });
factory.Role = $resource(prefix + '/hawkular/accounts/roles/:id', { id: '@id' });
factory.Permission = $resource(prefix + '/hawkular/accounts/permissions/:id', { id: '@id' });
factory.OrganizationMembership = $resource(prefix + '/hawkular/accounts/organizationMemberships/:organizationId', { organizationId: '@organizationId' });
factory.OrganizationInvitation = $resource(prefix + '/hawkular/accounts/invitations/:id', null, {
'update': { method: 'PUT' }
});
return factory;
}];
});
Expand Down Expand Up @@ -776,6 +782,28 @@ var hawkularRest;
}
}
},
{
prefix: 'AddDatasourceResponse=',
handle: function (addDatasourceResponse, binaryData) {
var message;
if (addDatasourceResponse.status === "OK") {
message =
addDatasourceResponse.message + '" on resource "' + addDatasourceResponse.resourcePath + '" with success.';
$rootScope.$broadcast('DatasourceAddSuccess', message);
}
else if (addDatasourceResponse.status === "ERROR") {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;
$rootScope.$broadcast('DatasourceAddError', message);
}
else {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;
$log.warn('Unexpected AddDatasourceOperationResponse: ', addDatasourceResponse);
$rootScope.$broadcast('DatasourceAddError', message);
}
}
},
{
prefix: 'ExportJdrResponse=',
handle: function (jdrResponse, binaryData) {
Expand Down Expand Up @@ -906,6 +934,29 @@ var hawkularRest;
$log.log('AddJDBCDriverRequest: ' + json);
ws.send(binaryblob);
};
factory.performAddDatasourceOperation = function (resourcePath, authToken, personaId, xaDatasource, datasourceName, jndiName, driverName, driverClass, connectionUrl, xaDataSourceClass, datasourceProperties, userName, password, securityDomain) {
var datasourceObject = {
resourcePath: resourcePath,
xaDatasource: xaDatasource,
datasourceName: datasourceName,
jndiName: jndiName,
driverName: driverName,
driverClass: driverClass,
connectionUrl: connectionUrl,
xaDataSourceClass: xaDataSourceClass,
datasourceProperties: datasourceProperties,
userName: userName,
password: password,
securityDomain: securityDomain,
authentication: {
token: authToken,
persona: personaId
}
};
var json = "AddDatasourceRequest=" + JSON.stringify(datasourceObject);
$log.log('AddDatasourceRequest: ' + json);
ws.send(json);
};
factory.performExportJDROperation = function (resourcePath, authToken, personaId) {
var operation = {
"resourcePath": resourcePath,
Expand Down
51 changes: 51 additions & 0 deletions dist/hawkular-ui-service.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ var hawkularRest;
var factory = {};
factory.Organization = $resource(prefix + '/hawkular/accounts/organizations/:id', { id: '@id' });
factory.Persona = $resource(prefix + '/hawkular/accounts/personas/:id', { id: '@id' });
factory.Role = $resource(prefix + '/hawkular/accounts/roles/:id', { id: '@id' });
factory.Permission = $resource(prefix + '/hawkular/accounts/permissions/:id', { id: '@id' });
factory.OrganizationMembership = $resource(prefix + '/hawkular/accounts/organizationMemberships/:organizationId', { organizationId: '@organizationId' });
factory.OrganizationInvitation = $resource(prefix + '/hawkular/accounts/invitations/:id', null, {
'update': { method: 'PUT' }
});
return factory;
}];
});
Expand Down Expand Up @@ -776,6 +782,28 @@ var hawkularRest;
}
}
},
{
prefix: 'AddDatasourceResponse=',
handle: function (addDatasourceResponse, binaryData) {
var message;
if (addDatasourceResponse.status === "OK") {
message =
addDatasourceResponse.message + '" on resource "' + addDatasourceResponse.resourcePath + '" with success.';
$rootScope.$broadcast('DatasourceAddSuccess', message);
}
else if (addDatasourceResponse.status === "ERROR") {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;
$rootScope.$broadcast('DatasourceAddError', message);
}
else {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;
$log.warn('Unexpected AddDatasourceOperationResponse: ', addDatasourceResponse);
$rootScope.$broadcast('DatasourceAddError', message);
}
}
},
{
prefix: 'ExportJdrResponse=',
handle: function (jdrResponse, binaryData) {
Expand Down Expand Up @@ -906,6 +934,29 @@ var hawkularRest;
$log.log('AddJDBCDriverRequest: ' + json);
ws.send(binaryblob);
};
factory.performAddDatasourceOperation = function (resourcePath, authToken, personaId, xaDatasource, datasourceName, jndiName, driverName, driverClass, connectionUrl, xaDataSourceClass, datasourceProperties, userName, password, securityDomain) {
var datasourceObject = {
resourcePath: resourcePath,
xaDatasource: xaDatasource,
datasourceName: datasourceName,
jndiName: jndiName,
driverName: driverName,
driverClass: driverClass,
connectionUrl: connectionUrl,
xaDataSourceClass: xaDataSourceClass,
datasourceProperties: datasourceProperties,
userName: userName,
password: password,
securityDomain: securityDomain,
authentication: {
token: authToken,
persona: personaId
}
};
var json = "AddDatasourceRequest=" + JSON.stringify(datasourceObject);
$log.log('AddDatasourceRequest: ' + json);
ws.send(json);
};
factory.performExportJDROperation = function (resourcePath, authToken, personaId) {
var operation = {
"resourcePath": resourcePath,
Expand Down
63 changes: 63 additions & 0 deletions src/rest/hawkRest-ops-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ module hawkularRest {
}
}
},
{
prefix: 'AddDatasourceResponse=',
handle: (addDatasourceResponse:IAddDatasourceResponse, binaryData:Blob) => {
let message;

if (addDatasourceResponse.status === "OK") {
message =
addDatasourceResponse.message + '" on resource "' + addDatasourceResponse.resourcePath + '" with success.';

$rootScope.$broadcast('DatasourceAddSuccess', message);

} else if (addDatasourceResponse.status === "ERROR") {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;

$rootScope.$broadcast('DatasourceAddError', message);
} else {
message = 'Add Datasource on resource "'
+ addDatasourceResponse.resourcePath + '" failed: ' + addDatasourceResponse.message;
$log.warn('Unexpected AddDatasourceOperationResponse: ', addDatasourceResponse);
$rootScope.$broadcast('DatasourceAddError', message);
}
}
},
{
prefix: 'ExportJdrResponse=',
handle: (jdrResponse:IExportJdrResponse, binaryData:Blob) => {
Expand Down Expand Up @@ -335,6 +359,45 @@ module hawkularRest {
ws.send(binaryblob);
};

factory.performAddDatasourceOperation = (resourcePath:string,
authToken:string,
personaId:string,
xaDatasource:string,
datasourceName:string,
jndiName:string,
driverName:string,
driverClass:string,
connectionUrl: string,
xaDataSourceClass:string, // optional
datasourceProperties:any, // optional
userName:string, // optional
password:string, // optional
securityDomain:string // optional
) => {
let datasourceObject:any = {
resourcePath,
xaDatasource,
datasourceName,
jndiName,
driverName,
driverClass,
connectionUrl,
xaDataSourceClass,
datasourceProperties,
userName,
password,
securityDomain,
authentication: {
token: authToken,
persona: personaId
}
};

let json = `AddDatasourceRequest=${JSON.stringify(datasourceObject)}`;
$log.log('AddDatasourceRequest: ' + json);
ws.send(json);
};

factory.performExportJDROperation = (resourcePath:string, authToken:string, personaId:string) => {
let operation = {
"resourcePath": resourcePath,
Expand Down

0 comments on commit d8ac0af

Please sign in to comment.