diff --git a/README.md b/README.md
index 6b980d9..051dd34 100644
--- a/README.md
+++ b/README.md
@@ -13,25 +13,11 @@ UoMs Management Module
#### Management
-
+
-
+
#### Converter
http://host:port/services/ts/codbex-uoms/api/converter.ts/CMT/DMT/50
-
-### Infrastructure
-
-#### Build
-
- docker build -t codbex-uoms:1.0.0 .
-
-#### Run
-
- docker run --name codbex-uoms -d -p 8080:8080 codbex-uoms:1.0.0
-
-#### Clean
-
- docker rm codbex-uoms
diff --git a/codbex-uoms/codbex-uoms.edm b/codbex-uoms/codbex-uoms.edm
index 56b6479..8b38911 100644
--- a/codbex-uoms/codbex-uoms.edm
+++ b/codbex-uoms/codbex-uoms.edm
@@ -1,11 +1,11 @@
-
+
-
+
@@ -25,5 +25,5 @@
-
+
\ No newline at end of file
diff --git a/codbex-uoms/codbex-uoms.gen b/codbex-uoms/codbex-uoms.gen
index 85467d2..ee746ad 100644
--- a/codbex-uoms/codbex-uoms.gen
+++ b/codbex-uoms/codbex-uoms.gen
@@ -1,17 +1,16 @@
{
"tablePrefix": "CODBEX_",
"brand": "codbex",
- "brandUrl": "https://codbex.com",
- "title": "Units of Measures Management Module",
- "description": "Managing units of measures data",
- "dataSource": "DefaultDB",
- "fileName": "codbex-uoms",
- "genFolderName": "codbex-uoms",
- "roles": [],
+ "brandUrl": "https://www.codbex.com/",
+ "title": "UoM Management Application",
+ "description": "Managing UoMs data",
"projectName": "codbex-uoms",
"workspaceName": "workspace",
"filePath": "codbex-uoms.model",
"templateId": "template-application-angular/template/template.js",
+ "fileName": "codbex-uoms",
+ "genFolderName": "codbex-uoms",
+ "dataSource": "DefaultDB",
"perspectives": {
"Dimensions": {
"views": [
@@ -57,6 +56,18 @@
"role": ""
}
},
+ "roles": [
+ {
+ "entityName": "Dimension",
+ "roleRead": "codbex-uoms.Dimensions.DimensionReadOnly",
+ "roleWrite": "codbex-uoms.Dimensions.DimensionFullAccess"
+ },
+ {
+ "entityName": "UoM",
+ "roleRead": "codbex-uoms.UnitsOfMeasures.UoMReadOnly",
+ "roleWrite": "codbex-uoms.UnitsOfMeasures.UoMFullAccess"
+ }
+ ],
"models": [
{
"properties": [
@@ -141,7 +152,7 @@
"dataName": "DIMENSION",
"dataQuery": "",
"description": "Manage entity Dimension",
- "generateDefaultRoles": "false",
+ "generateDefaultRoles": "true",
"generateReport": "false",
"icon": "cube",
"layoutType": "MANAGE",
@@ -155,6 +166,8 @@
"perspectiveName": "Dimensions",
"perspectiveOrder": "990",
"perspectiveRole": "",
+ "roleRead": "codbex-uoms.Dimensions.DimensionReadOnly",
+ "roleWrite": "codbex-uoms.Dimensions.DimensionFullAccess",
"title": "Dimension",
"tooltip": "Dimension",
"type": "SETTING",
@@ -399,7 +412,7 @@
"dataName": "UOM",
"dataQuery": "",
"description": "Manage entity UoM",
- "generateDefaultRoles": "false",
+ "generateDefaultRoles": "true",
"generateReport": "false",
"icon": "cubes",
"layoutType": "MANAGE_MASTER",
@@ -413,6 +426,8 @@
"perspectiveName": "UnitsOfMeasures",
"perspectiveOrder": "980",
"perspectiveRole": "",
+ "roleRead": "codbex-uoms.UnitsOfMeasures.UoMReadOnly",
+ "roleWrite": "codbex-uoms.UnitsOfMeasures.UoMFullAccess",
"title": "Unit of Measures",
"tooltip": "Unit of Measures",
"type": "SETTING",
diff --git a/codbex-uoms/codbex-uoms.model b/codbex-uoms/codbex-uoms.model
index ac4a627..a1111ba 100644
--- a/codbex-uoms/codbex-uoms.model
+++ b/codbex-uoms/codbex-uoms.model
@@ -50,7 +50,7 @@
"dataName": "DIMENSION",
"dataQuery": "",
"description": "Manage entity Dimension",
- "generateDefaultRoles": "false",
+ "generateDefaultRoles": "true",
"generateReport": "false",
"icon": "cube",
"layoutType": "MANAGE",
@@ -64,6 +64,8 @@
"perspectiveName": "Dimensions",
"perspectiveOrder": "990",
"perspectiveRole": "",
+ "roleRead": "codbex-uoms.Dimensions.DimensionReadOnly",
+ "roleWrite": "codbex-uoms.Dimensions.DimensionFullAccess",
"title": "Dimension",
"tooltip": "Dimension",
"type": "SETTING"
@@ -199,7 +201,7 @@
"dataName": "UOM",
"dataQuery": "",
"description": "Manage entity UoM",
- "generateDefaultRoles": "false",
+ "generateDefaultRoles": "true",
"generateReport": "false",
"icon": "cubes",
"layoutType": "MANAGE_MASTER",
@@ -213,6 +215,8 @@
"perspectiveName": "UnitsOfMeasures",
"perspectiveOrder": "980",
"perspectiveRole": "",
+ "roleRead": "codbex-uoms.UnitsOfMeasures.UoMReadOnly",
+ "roleWrite": "codbex-uoms.UnitsOfMeasures.UoMFullAccess",
"title": "Unit of Measures",
"tooltip": "Unit of Measures",
"type": "SETTING"
diff --git a/codbex-uoms/gen/codbex-uoms/api/Dimensions/DimensionService.ts b/codbex-uoms/gen/codbex-uoms/api/Dimensions/DimensionService.ts
index 24059a8..fc956ff 100644
--- a/codbex-uoms/gen/codbex-uoms/api/Dimensions/DimensionService.ts
+++ b/codbex-uoms/gen/codbex-uoms/api/Dimensions/DimensionService.ts
@@ -1,6 +1,8 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { DimensionRepository, DimensionEntityOptions } from "../../dao/Dimensions/DimensionRepository";
+import { user } from "sdk/security"
+import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
@@ -14,6 +16,7 @@ class DimensionService {
@Get("/")
public getAll(_: any, ctx: any) {
try {
+ this.checkPermissions("read");
const options: DimensionEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
@@ -28,6 +31,7 @@ class DimensionService {
@Post("/")
public create(entity: any) {
try {
+ this.checkPermissions("write");
this.validateEntity(entity);
entity.Id = this.repository.create(entity);
response.setHeader("Content-Location", "/services/ts/codbex-uoms/gen/codbex-uoms/api/Dimensions/DimensionService.ts/" + entity.Id);
@@ -41,6 +45,7 @@ class DimensionService {
@Get("/count")
public count() {
try {
+ this.checkPermissions("read");
return this.repository.count();
} catch (error: any) {
this.handleError(error);
@@ -50,6 +55,7 @@ class DimensionService {
@Post("/count")
public countWithFilter(filter: any) {
try {
+ this.checkPermissions("read");
return this.repository.count(filter);
} catch (error: any) {
this.handleError(error);
@@ -59,6 +65,7 @@ class DimensionService {
@Post("/search")
public search(filter: any) {
try {
+ this.checkPermissions("read");
return this.repository.findAll(filter);
} catch (error: any) {
this.handleError(error);
@@ -68,6 +75,7 @@ class DimensionService {
@Get("/:id")
public getById(_: any, ctx: any) {
try {
+ this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
if (entity) {
@@ -83,6 +91,7 @@ class DimensionService {
@Put("/:id")
public update(entity: any, ctx: any) {
try {
+ this.checkPermissions("write");
entity.Id = ctx.pathParameters.id;
this.validateEntity(entity);
this.repository.update(entity);
@@ -95,6 +104,7 @@ class DimensionService {
@Delete("/:id")
public deleteById(_: any, ctx: any) {
try {
+ this.checkPermissions("write");
const id = ctx.pathParameters.id;
const entity = this.repository.findById(id);
if (entity) {
@@ -118,6 +128,15 @@ class DimensionService {
}
}
+ private checkPermissions(operationType: string) {
+ if (operationType === "read" && !(user.isInRole("codbex-uoms.Dimensions.DimensionReadOnly") || user.isInRole("codbex-uoms.Dimensions.DimensionFullAccess"))) {
+ throw new ForbiddenError();
+ }
+ if (operationType === "write" && !user.isInRole("codbex-uoms.Dimensions.DimensionFullAccess")) {
+ throw new ForbiddenError();
+ }
+ }
+
private validateEntity(entity: any): void {
if (entity.SAP?.length > 20) {
throw new ValidationError(`The 'SAP' exceeds the maximum length of [20] characters`);
diff --git a/codbex-uoms/gen/codbex-uoms/api/UnitsOfMeasures/UoMService.ts b/codbex-uoms/gen/codbex-uoms/api/UnitsOfMeasures/UoMService.ts
index c571d26..5cc10ca 100644
--- a/codbex-uoms/gen/codbex-uoms/api/UnitsOfMeasures/UoMService.ts
+++ b/codbex-uoms/gen/codbex-uoms/api/UnitsOfMeasures/UoMService.ts
@@ -1,6 +1,8 @@
import { Controller, Get, Post, Put, Delete, response } from "sdk/http"
import { Extensions } from "sdk/extensions"
import { UoMRepository, UoMEntityOptions } from "../../dao/UnitsOfMeasures/UoMRepository";
+import { user } from "sdk/security"
+import { ForbiddenError } from "../utils/ForbiddenError";
import { ValidationError } from "../utils/ValidationError";
import { HttpUtils } from "../utils/HttpUtils";
@@ -14,6 +16,7 @@ class UoMService {
@Get("/")
public getAll(_: any, ctx: any) {
try {
+ this.checkPermissions("read");
const options: UoMEntityOptions = {
$limit: ctx.queryParameters["$limit"] ? parseInt(ctx.queryParameters["$limit"]) : undefined,
$offset: ctx.queryParameters["$offset"] ? parseInt(ctx.queryParameters["$offset"]) : undefined
@@ -28,6 +31,7 @@ class UoMService {
@Post("/")
public create(entity: any) {
try {
+ this.checkPermissions("write");
this.validateEntity(entity);
entity.Id = this.repository.create(entity);
response.setHeader("Content-Location", "/services/ts/codbex-uoms/gen/codbex-uoms/api/UnitsOfMeasures/UoMService.ts/" + entity.Id);
@@ -41,6 +45,7 @@ class UoMService {
@Get("/count")
public count() {
try {
+ this.checkPermissions("read");
return this.repository.count();
} catch (error: any) {
this.handleError(error);
@@ -50,6 +55,7 @@ class UoMService {
@Post("/count")
public countWithFilter(filter: any) {
try {
+ this.checkPermissions("read");
return this.repository.count(filter);
} catch (error: any) {
this.handleError(error);
@@ -59,6 +65,7 @@ class UoMService {
@Post("/search")
public search(filter: any) {
try {
+ this.checkPermissions("read");
return this.repository.findAll(filter);
} catch (error: any) {
this.handleError(error);
@@ -68,6 +75,7 @@ class UoMService {
@Get("/:id")
public getById(_: any, ctx: any) {
try {
+ this.checkPermissions("read");
const id = parseInt(ctx.pathParameters.id);
const entity = this.repository.findById(id);
if (entity) {
@@ -83,6 +91,7 @@ class UoMService {
@Put("/:id")
public update(entity: any, ctx: any) {
try {
+ this.checkPermissions("write");
entity.Id = ctx.pathParameters.id;
this.validateEntity(entity);
this.repository.update(entity);
@@ -95,6 +104,7 @@ class UoMService {
@Delete("/:id")
public deleteById(_: any, ctx: any) {
try {
+ this.checkPermissions("write");
const id = ctx.pathParameters.id;
const entity = this.repository.findById(id);
if (entity) {
@@ -118,6 +128,15 @@ class UoMService {
}
}
+ private checkPermissions(operationType: string) {
+ if (operationType === "read" && !(user.isInRole("codbex-uoms.UnitsOfMeasures.UoMReadOnly") || user.isInRole("codbex-uoms.UnitsOfMeasures.UoMFullAccess"))) {
+ throw new ForbiddenError();
+ }
+ if (operationType === "write" && !user.isInRole("codbex-uoms.UnitsOfMeasures.UoMFullAccess")) {
+ throw new ForbiddenError();
+ }
+ }
+
private validateEntity(entity: any): void {
if (entity.Name?.length > 100) {
throw new ValidationError(`The 'Name' exceeds the maximum length of [100] characters`);
diff --git a/codbex-uoms/gen/codbex-uoms/codbex-uoms.openapi b/codbex-uoms/gen/codbex-uoms/codbex-uoms.openapi
index 7f2b152..ddb3be3 100644
--- a/codbex-uoms/gen/codbex-uoms/codbex-uoms.openapi
+++ b/codbex-uoms/gen/codbex-uoms/codbex-uoms.openapi
@@ -1,8 +1,8 @@
openapi: 3.0.3
info:
- title: Units of Measures Management Module - OpenAPI 3.0
+ title: UoM Management Application - OpenAPI 3.0
version: 1.0.0
- description: Managing units of measures data
+ description: Managing UoMs data
externalDocs:
description: Find out more about Eclipse Dirigible
url: https://dirigible.io
diff --git a/codbex-uoms/gen/codbex-uoms/index.html b/codbex-uoms/gen/codbex-uoms/index.html
index c0caa0a..dcffded 100644
--- a/codbex-uoms/gen/codbex-uoms/index.html
+++ b/codbex-uoms/gen/codbex-uoms/index.html
@@ -36,9 +36,9 @@