Skip to content

Commit

Permalink
MODEXPW-488 - permissions-self-check
Browse files Browse the repository at this point in the history
  • Loading branch information
alekGbuz committed Sep 4, 2024
1 parent a3ab1b1 commit ca03968
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 104 deletions.
22 changes: 20 additions & 2 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"provides": [
{
"id": "bulk-edit",
"version": "4.0",
"version": "4.1",
"handlers": [
{
"methods": [ "POST" ],
Expand Down Expand Up @@ -273,6 +273,18 @@
"pathPattern": "/refresh-presigned-url",
"permissionsRequired": [ "refresh-presigned-url.get" ],
"modulePermissions": []
},
{
"methods": [ "GET" ],
"pathPattern": "/permissions-self-check",
"permissionsRequired": [ "permissions-self-check.get" ],
"permissionsDesired": [
"ui-inventory.instance.view",
"ui-inventory.holdings.create",
"ui-inventory.holdings.edit",
"ui-inventory.holdings.delete"
],
"modulePermissions": []
}
]
},
Expand Down Expand Up @@ -343,14 +355,20 @@
"displayName" : "Get refreshed presigned url for export file",
"description" : "Get refreshed presigned url for export file"
},
{
"permissionName" : "permissions-self-check.get",
"displayName" : "Set of desired permissions",
"description" : "Set of desired permissions"
},
{
"permissionName" : "bulk-edit.all",
"displayName" : "bulk-edit all",
"description" : "All permissions for bulk-edit module",
"subPermissions" : [
"bulk-edit.item.post",
"bulk-edit.start.item.post",
"bulk-edit.errors.collection.get"
"bulk-edit.errors.collection.get",
"permissions-self-check.get"
]
},
{
Expand Down
232 changes: 130 additions & 102 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
<refresh-presigned-url.yaml.file>
${project.basedir}/src/main/resources/swagger.api/refresh-presigned-url.yaml
</refresh-presigned-url.yaml.file>

<permissions-self-check.yaml.file>
${project.basedir}/src/main/resources/swagger.api/permissions-self-check.yaml
</permissions-self-check.yaml.file>
<folio-spring-base.version>8.1.0</folio-spring-base.version>
<folio-service-tools.version>3.1.0</folio-service-tools.version>
<folio-spring-cql.version>8.1.0</folio-spring-cql.version>
Expand Down Expand Up @@ -513,110 +515,136 @@
</configuration>
</execution>
<execution>
<id>bursar-export-worker-schedule-parameters</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${bursar-export.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>false</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<modelsToGenerate>ScheduleParameters</modelsToGenerate>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
<id>bursar-export-worker-schedule-parameters</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${bursar-export.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>false</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<modelsToGenerate>ScheduleParameters</modelsToGenerate>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
<execution>
<id>bulk-edit-worker</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${bulk-edit.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
<id>bulk-edit-worker</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${bulk-edit.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
<execution>
<id>refresh-presigned-url</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${refresh-presigned-url.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
<id>refresh-presigned-url</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${refresh-presigned-url.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
<execution>
<id>order-export-worker</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${order-export.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
<id>permissions-self-check</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${permissions-self-check.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>true</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
</configOptions>
</configuration>
</execution>
<execution>
<id>order-export-worker</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${order-export.yaml.file}</inputSpec>
<output>${project.build.directory}/generated-sources</output>
<generatorName>spring</generatorName>
<modelPackage>${project.groupId}.dew.domain.dto</modelPackage>
<generateApis>true</generateApis>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<generateModels>true</generateModels>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>true</generateModelDocumentation>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
<serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.folio.dew.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.folio.spring.FolioExecutionContext;
import org.folio.spring.integration.XOkapiHeaders;
import org.openapitools.api.PermissionsSelfCheckApi;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping
@Log4j2
@RequiredArgsConstructor
public class PermissionsSelfCheckController implements PermissionsSelfCheckApi {

private final FolioExecutionContext folioExecutionContext;

@Override
public ResponseEntity<List<String>> getDesiredPermissions() {
var okapiHeaders = folioExecutionContext.getOkapiHeaders();
var permissions = new ArrayList<>(okapiHeaders.get(XOkapiHeaders.PERMISSIONS));
return new ResponseEntity<>(permissions, HttpStatus.OK);
}
}
36 changes: 36 additions & 0 deletions src/main/resources/swagger.api/permissions-self-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
openapi: 3.0.0
info:
title: Refresh presigned url API
version: v1
paths:
/permissions-self-check:
get:
description: Get bulk edit desired permissions
operationId: getDesiredPermissions
responses:
'200':
description: List of actual desired permissions for current tenant
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/desiredPermission"
'404':
description: No found
content:
text/plain:
schema:
type: string
example: Desired permissions not found
'500':
description: Internal server errors, e.g. due to misconfiguration
content:
text/plain:
schema:
type: string
example: Internal server error
components:
schemas:
desiredPermission:
type: string

0 comments on commit ca03968

Please sign in to comment.