Skip to content

Commit

Permalink
https://github.com/metadatacenter/cedar-project/issues/1198
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila L. Egyedi committed Nov 8, 2023
1 parent 6267489 commit 0b2352e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.metadatacenter.server.security.KeycloakUtilInfo;
import org.metadatacenter.server.security.KeycloakUtils;

import java.security.KeyStore;
import java.security.KeyStoreException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

import org.keycloak.representations.idm.UserRepresentation;
import org.metadatacenter.bridge.CedarDataServices;
import org.metadatacenter.config.BlueprintUserProfile;
import org.metadatacenter.config.CedarConfig;
import org.metadatacenter.exception.security.CedarAccessException;
import org.metadatacenter.rest.context.CedarRequestContext;
import org.metadatacenter.rest.context.CedarRequestContextFactory;
import org.metadatacenter.server.*;
import org.metadatacenter.server.security.model.user.CedarSuperRole;
import org.metadatacenter.server.security.model.user.CedarUser;
import org.metadatacenter.server.security.model.user.CedarUserApiKey;
import org.metadatacenter.server.security.util.CedarUserUtil;
import org.metadatacenter.server.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.time.LocalDateTime;
import java.util.List;

public abstract class AbstractNeo4JAccessTask extends AbstractKeycloakReadingTask {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/metadatacenter/admin/task/ImpexExportAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,19 @@ public int execute() {


out.info("Exporting users");
Path userExportPath = Paths.get(exportDir).resolve("users");
Path exportPath = Paths.get(exportDir);
Path userExportPath = exportPath.resolve("users");
serializeUsers(userExportPath);

out.info("Exporting groups");
Path groupExportPath = Paths.get(exportDir).resolve("groups");
Path groupExportPath = exportPath.resolve("groups");
serializeGroups(groupExportPath);

String rootPath = neo4jFolderSession.getRootPath();
FolderServerFolder rootFolder = neo4jFolderSession.findFolderByPath(rootPath);

out.info("Exporting resources");
Path resourceExportPath = Paths.get(exportDir).resolve("resources");
Path resourceExportPath = exportPath.resolve("resources");
walkFolder(resourceExportPath, rootFolder, 0);

return 0;
Expand All @@ -149,8 +150,7 @@ public int execute() {

private int walkFolder(Path path, FileSystemResource node, int idx) {
idx++;
if (node instanceof FolderServerFolder) {
FolderServerFolder folder = (FolderServerFolder) node;
if (node instanceof FolderServerFolder folder) {
Path candidateFolder = serializeFolder(path, folder, idx);
List<FileSystemResource> folderContents = neo4jFolderSession.findFolderContentsFiltered(folder.getResourceId(), resourceTypeList,
ResourceVersionFilter.ALL, ResourcePublicationStatusFilter.ALL, EXPORT_MAX_COUNT, 0, sortList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.metadatacenter.admin.task.importexport.ImportExportConstants;
import org.metadatacenter.bridge.CedarDataServices;
import org.metadatacenter.config.MongoConfig;
import org.metadatacenter.id.CedarResourceId;
import org.metadatacenter.id.CedarUntypedResourceId;
import org.metadatacenter.model.CedarResourceType;
import org.metadatacenter.model.RelationLabel;
Expand Down Expand Up @@ -116,7 +115,8 @@ public int execute() {
deleteAllMongoData();

out.info("Importing users into Mongo");
Path userImportPath = Paths.get(importDir).resolve("users");
Path importPath = Paths.get(importDir);
Path userImportPath = importPath.resolve("users");
processFolder(userImportPath, this::importUserIntoMongo);

out.info("Deleting everything from Neo4J");
Expand All @@ -128,11 +128,11 @@ public int execute() {
processFolder(userImportPath, this::importUserIntoNeo);

out.info("Importing groups");
Path groupImportPath = Paths.get(importDir).resolve("groups");
Path groupImportPath = importPath.resolve("groups");
processFolder(groupImportPath, this::importGroup);

out.info("Importing resources");
Path resourceImportPath = Paths.get(importDir).resolve("resources");
Path resourceImportPath = importPath.resolve("resources");
processFolder(resourceImportPath, this::importResource);

return 0;
Expand Down

0 comments on commit 0b2352e

Please sign in to comment.