FIX: Manage Permissions Catalog

This commit is contained in:
Victor Radael
2022-09-28 16:58:52 -03:00
parent a28781423c
commit d42584fcfc
5 changed files with 37 additions and 25 deletions
+13 -2
View File
@@ -55,8 +55,19 @@ export class CatalogController {
@User() user: RequestUser,
@Body() body,
) {
const response = await this.catalogService.managePermissions(body, user);
return { message: { id, body } };
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
const response = await this.catalogService.managePermissions(
{ ...body, id },
metadata,
);
return { data_asset: JSON.parse(response.data_asset) };
}
@Get('all')
+15 -14
View File
@@ -3,7 +3,12 @@ import { ReadService } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { Messages } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { WriteService } from '@dadosfera/protospack-v2/dist/lib/Catalog';
import { Inject, OnModuleInit } from '@nestjs/common';
import {
HttpException,
HttpStatus,
Inject,
OnModuleInit,
} from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices';
import axios from 'axios';
import { lastValueFrom } from 'rxjs';
@@ -47,21 +52,17 @@ class CatalogService implements OnModuleInit {
}
async managePermissions(data: Messages.ManagePermissionRequest, metadata) {
this.logger.info('CatalogService - getAllOpenSearchDashboard');
this.logger.info('CatalogService - Manage Data assets permissions');
const response = await lastValueFrom(
return lastValueFrom(
this.catalogWriteService.ManagePermission(data, metadata),
)
.then((res) => {
this.logger.info('Done');
return res;
})
.catch((err) => {
this.logger.error(err.message);
throw new Error(err);
});
return { data_assets: response };
).catch((err) => {
console.log(err.details);
throw new HttpException(
err.details,
err.code === 6 ? HttpStatus.CONFLICT : 404,
);
});
}
async catalogAll(body) {