Skip to content

Commit

Permalink
Merge pull request #69 from ammendonca/HAWKULAR-613
Browse files Browse the repository at this point in the history
Add support for Update Datasource operation
  • Loading branch information
mtho11 committed Nov 23, 2015
2 parents f308fa5 + cd6b7b2 commit 6e42ff1
Showing 1 changed file with 80 additions and 13 deletions.
93 changes: 80 additions & 13 deletions src/rest/hawkRest-ops-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ module hawkularRest {
message?: string;
}

interface IUpdateDatasourceResponse {
status: string;
resourcePath: string;
message?: string;
}

interface IRemoveDatasourceResponse {
resourcePath: string;
destinationSessionId: string;
Expand Down Expand Up @@ -189,6 +195,30 @@ module hawkularRest {
}
}
},
{
prefix: 'RemoveJdbcDriverResponse=',
handle: (removeJdbcDriverResponse: IRemoveJdbcDriverResponse) => {
let message;

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

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

} else if (removeJdbcDriverResponse.status === "ERROR") {
message = 'Remove JDBC Driver on resource "'
+ removeJdbcDriverResponse.resourcePath + '" failed: ' + removeJdbcDriverResponse.message;

$rootScope.$broadcast('JdbcDriverRemoveError', message);
} else {
message = 'Remove JDBC Driver on resource "'
+ removeJdbcDriverResponse.resourcePath + '" failed: ' + removeJdbcDriverResponse.message;
$log.warn('Unexpected RemoveJdbcDriverOperationResponse: ', removeJdbcDriverResponse);
$rootScope.$broadcast('JdbcDriverRemoveError', message);
}
}
},
{
prefix: 'AddDatasourceResponse=',
handle: (addDatasourceResponse:IAddDatasourceResponse, binaryData:Blob) => {
Expand All @@ -214,26 +244,26 @@ module hawkularRest {
}
},
{
prefix: 'RemoveJdbcDriverResponse=',
handle: (removeJdbcDriverResponse: IRemoveJdbcDriverResponse) => {
prefix: 'UpdateDatasourceResponse=',
handle: (updateDatasourceResponse:IUpdateDatasourceResponse, binaryData:Blob) => {
let message;

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

$rootScope.$broadcast('JdbcDriverRemoveSuccess', message);
$rootScope.$broadcast('DatasourceUpdateSuccess', message);

} else if (removeJdbcDriverResponse.status === "ERROR") {
message = 'Remove JDBC Driver on resource "'
+ removeJdbcDriverResponse.resourcePath + '" failed: ' + removeJdbcDriverResponse.message;
} else if (updateDatasourceResponse.status === "ERROR") {
message = 'Update Datasource on resource "'
+ updateDatasourceResponse.resourcePath + '" failed: ' + updateDatasourceResponse.message;

$rootScope.$broadcast('JdbcDriverRemoveError', message);
$rootScope.$broadcast('DatasourceUpdateError', message);
} else {
message = 'Remove JDBC Driver on resource "'
+ removeJdbcDriverResponse.resourcePath + '" failed: ' + removeJdbcDriverResponse.message;
$log.warn('Unexpected RemoveJdbcDriverOperationResponse: ', removeJdbcDriverResponse);
$rootScope.$broadcast('JdbcDriverRemoveError', message);
message = 'Update Datasource on resource "'
+ updateDatasourceResponse.resourcePath + '" failed: ' + updateDatasourceResponse.message;
$log.warn('Unexpected UpdateDatasourceOperationResponse: ', updateDatasourceResponse);
$rootScope.$broadcast('DatasourceUpdateError', message);
}
}
},
Expand Down Expand Up @@ -485,6 +515,43 @@ module hawkularRest {
ws.send(json);
};

factory.performUpdateDatasourceOperation = (resourcePath:string,
authToken:string,
personaId: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,
datasourceName,
jndiName,
driverName,
driverClass,
connectionUrl,
xaDataSourceClass,
datasourceProperties,
userName,
password,
securityDomain,
authentication: {
token: authToken,
persona: personaId
}
};

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

factory.performRemoveDatasourceOperation = (resourcePath:string,
authToken:string,
personaId:string
Expand Down

0 comments on commit 6e42ff1

Please sign in to comment.