Import Permissions as last object

deploy_packages_to_gitea
Jens Pelzetter 2022-10-22 19:49:58 +02:00
parent 2333bbc35e
commit b2a6880d24
2 changed files with 18 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import org.libreccm.files.FileAccessException;
import org.libreccm.files.FileAlreadyExistsException; import org.libreccm.files.FileAlreadyExistsException;
import org.libreccm.files.FileDoesNotExistException; import org.libreccm.files.FileDoesNotExistException;
import org.libreccm.files.InsufficientPermissionsException; import org.libreccm.files.InsufficientPermissionsException;
import org.libreccm.security.Permission;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -229,6 +230,23 @@ public class ImportExport {
final List<EntityImExporterTreeNode> orderedNodes = treeManager final List<EntityImExporterTreeNode> orderedNodes = treeManager
.orderImExporters(tree); .orderImExporters(tree);
// Put the node for Permissions to the end of the list.
final EntityImExporterTreeNode permissionsNode = orderedNodes
.stream()
.filter(node -> node.getEntityImExporter().getEntityClass().equals(Permission.class))
.findAny()
.orElseThrow(
() -> new UnexpectedErrorException(
String.format(
"There should be an ImExporter in the tree for "
+ "%s, but it is not.",
Permission.class.getName()
)
)
);
orderedNodes.remove(permissionsNode);
orderedNodes.add(permissionsNode);
final ImportManifest manifest = createImportManifest(importName); final ImportManifest manifest = createImportManifest(importName);
final List<EntityImExporterTreeNode> importers = orderedNodes final List<EntityImExporterTreeNode> importers = orderedNodes

View File

@ -54,7 +54,6 @@ public class PermissionImExporter extends AbstractEntityImExporter<Permission> {
@Override @Override
protected Set<Class<? extends Exportable>> getRequiredEntities() { protected Set<Class<? extends Exportable>> getRequiredEntities() {
return Set.of( return Set.of(
CcmObject.class,
Role.class Role.class
); );
} }