diff --git a/Kitodo-DataManagement/src/main/resources/db/migration/V2_132__Add_permission_to_use_mass_import.sql b/Kitodo-DataManagement/src/main/resources/db/migration/V2_132__Add_permission_to_use_mass_import.sql new file mode 100644 index 00000000000..a787659a700 --- /dev/null +++ b/Kitodo-DataManagement/src/main/resources/db/migration/V2_132__Add_permission_to_use_mass_import.sql @@ -0,0 +1,17 @@ +-- +-- (c) Kitodo. Key to digital objects e. V. +-- +-- This file is part of the Kitodo project. +-- +-- It is licensed under GNU General Public License version 3 or later. +-- +-- For the full copyright and license information, please read the +-- GPL3-License.txt file that was distributed with this source code. +-- + +SET SQL_SAFE_UPDATES = 0; + +-- add authorities/permission for using mass import feature +INSERT IGNORE INTO authority (title) VALUES ('useMassImport_clientAssignable'); + +SET SQL_SAFE_UPDATES = 1; diff --git a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java index bdcbe2e794f..bcf619eb78a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java +++ b/Kitodo/src/main/java/org/kitodo/production/controller/SecurityAccessController.java @@ -499,7 +499,7 @@ public boolean hasAuthorityToUnassignTasks() { /** * Check if the current user has the authority to upload media in metadataeditor. * - * @return true if the current user has the authority to to upload media in metadataeditor + * @return true if the current user has the authority to upload media in metadataeditor */ public boolean hasAuthorityToUploadMedia() { return securityAccessService.hasAuthorityToUploadMedia(); @@ -1067,7 +1067,7 @@ public boolean hasAuthorityToOpenMetadataEditor() { /** * Check if the current user has the authority to delete media in metadata editor. * - * @return true if the current user has the authority to to delete media in metadata editor + * @return true if the current user has the authority to delete media in metadata editor */ public boolean hasAuthorityToDeleteMedia() { return securityAccessService.hasAuthorityToDeleteMedia(); @@ -1117,4 +1117,13 @@ public boolean hasAuthorityToAssignImportConfigurationToClient() { public boolean hasAuthorityToLinkToProcessesOfUnassignedProjects() { return securityAccessService.hasAuthorityToLinkToProcessesOfUnassignedProjects(); } + + /** + * Check if the current user has the permission to create processes and use the mass import feature. + * + * @return true if the current user has the permission to create processes and use the mass import feature. + */ + public boolean hasAuthorityToMassImportProcesses() { + return securityAccessService.hasAuthorityToUseMassImport() && securityAccessService.hasAuthorityToAddProcess(); + } } diff --git a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java index a2721d7e1fa..545942b67a4 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/security/SecurityAccessService.java @@ -1104,4 +1104,13 @@ public boolean hasAuthorityToAssignImportConfigurationToClient() { public boolean hasAuthorityToLinkToProcessesOfUnassignedProjects() { return hasAnyAuthorityForClient("linkToProcessesOfUnassignedProjects"); } + + /** + * Check if the current user has the permission to use the mass import feature. + * + * @return true if the current use has the permission to use the mass import feature + */ + public boolean hasAuthorityToUseMassImport() { + return hasAnyAuthorityForClient("useMassImport"); + } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 691ee725cbc..fe2485120bf 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -1308,6 +1308,7 @@ renameMediaForProcessesConfirmMessage=Die Mediendateien von {0} Vorg\u00E4ngen w resetWorkflow=Workflow zur\u00FCcksetzen runKitodoScript=KitodoScript ausf\u00FChren linkToProcessesOfUnassignedProjects=Verkn\u00FCpfungen mit Vorg\u00E4ngen nicht-zugewiesener Projekte erstellen +useMassImport=Massenimport nutzen viewAllAuthorities=Alle Berechtigungen anzeigen viewAllBatches=Alle Batches anzeigen diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 9d4db78f416..3dd2a0a7bc4 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -1309,6 +1309,7 @@ renameMediaThread=Rename media renameMediaForProcessesConfirmMessage=The media files of {0} processes will be renamed according to their order in the individual processes. This change cannot be reverted. Do you want to continue? runKitodoScript=Execute KitodoScript linkToProcessesOfUnassignedProjects=Link to processes of unassigned projects +useMassImport=Use mass import viewAllAuthorities=View all authorities viewAllBatches=View all batches diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/projects/projectList.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/projects/projectList.xhtml index 0732f390d3d..00221954550 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/projects/projectList.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/projects/projectList.xhtml @@ -137,7 +137,7 @@ + rendered="#{SecurityAccessController.hasAuthorityToMassImportProcesses()}"> diff --git a/Kitodo/src/main/webapp/pages/massImport.xhtml b/Kitodo/src/main/webapp/pages/massImport.xhtml index 8daea698c5d..4ffad8770c1 100644 --- a/Kitodo/src/main/webapp/pages/massImport.xhtml +++ b/Kitodo/src/main/webapp/pages/massImport.xhtml @@ -58,7 +58,7 @@ + rendered="#{SecurityAccessController.hasAuthorityToMassImportProcesses()}"> diff --git a/Kitodo/src/test/java/org/kitodo/MockDatabase.java b/Kitodo/src/test/java/org/kitodo/MockDatabase.java index e5763fa0c58..d1b86a20688 100644 --- a/Kitodo/src/test/java/org/kitodo/MockDatabase.java +++ b/Kitodo/src/test/java/org/kitodo/MockDatabase.java @@ -452,6 +452,9 @@ public static void insertAuthorities() throws DAOException { // Assign import configurations to clients authorities.add(new Authority("assignImportConfigurationToClient" + GLOBAL_ASSIGNABLE)); + // Use mass import + authorities.add(new Authority("useMassImport" + CLIENT_ASSIGNABLE)); + for (Authority authority : authorities) { ServiceManager.getAuthorityService().saveToDatabase(authority); } @@ -1540,6 +1543,9 @@ private static void insertRoles() throws DAOException { firstRole.getAuthorities().add(allAuthorities.get(i)); } + firstRole.getAuthorities().add(ServiceManager.getAuthorityService() + .getByTitle("useMassImport" + CLIENT_ASSIGNABLE)); + ServiceManager.getRoleService().saveToDatabase(firstRole); Role secondRole = new Role(); diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/AuthorityServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/AuthorityServiceIT.java index aae27b7f1e2..3f3abfa14ee 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/AuthorityServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/AuthorityServiceIT.java @@ -27,7 +27,7 @@ public class AuthorityServiceIT { private static final AuthorityService authorityService = ServiceManager.getAuthorityService(); - private static final int EXPECTED_AUTHORITIES_COUNT = 100; + private static final int EXPECTED_AUTHORITIES_COUNT = 101; @BeforeAll public static void prepareDatabase() throws Exception { @@ -79,6 +79,6 @@ public void shouldNotSaveAlreadyExistingAuthorities() { @Test public void shouldGetAllClientAssignableAuthorities() throws DAOException { List authorities = authorityService.getAllAssignableToClients(); - assertEquals(72, authorities.size(), "Client assignable authorities were not found database!"); + assertEquals(73, authorities.size(), "Client assignable authorities were not found database!"); } } diff --git a/Kitodo/src/test/java/org/kitodo/production/services/data/RoleServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/data/RoleServiceIT.java index d88b9b6c97d..790081ec8f3 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/data/RoleServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/data/RoleServiceIT.java @@ -127,7 +127,7 @@ public void shouldRemoveRoleButNotUser() throws Exception { public void shouldGetAuthorizationsAsString() throws Exception { Role role = roleService.getById(1); int actual = roleService.getAuthorizationsAsString(role).size(); - int expected = 34; + int expected = 35; assertEquals(expected, actual, "Number of authority strings doesn't match!"); } diff --git a/Kitodo/src/test/java/org/kitodo/production/services/security/SecurityAccessServiceIT.java b/Kitodo/src/test/java/org/kitodo/production/services/security/SecurityAccessServiceIT.java index 7b4b27aee87..e15a895f881 100644 --- a/Kitodo/src/test/java/org/kitodo/production/services/security/SecurityAccessServiceIT.java +++ b/Kitodo/src/test/java/org/kitodo/production/services/security/SecurityAccessServiceIT.java @@ -53,7 +53,7 @@ public void shouldGetAuthorities() throws DAOException { SecurityTestUtils.addUserDataToSecurityContext(user, 1); Collection authorities = SecurityContextHolder.getContext().getAuthentication() .getAuthorities(); - assertEquals(172, authorities.size(), "Security context holder does not hold the corresponding authorities"); + assertEquals(174, authorities.size(), "Security context holder does not hold the corresponding authorities"); } @Test