Skip to content

Commit

Permalink
fixed create backup command.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Dec 20, 2024
1 parent 860d2d5 commit 55a2346
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Class<CreateBackupOwlFileAction> getActionClass() {
@NotNull
@Override
public CreateBackupOwlFileResponse execute(@NotNull CreateBackupOwlFileAction action, @NotNull ExecutionContext executionContext) {
projectBackupManager.createBackup();
return new CreateBackupOwlFileResponse();
String backupFileLocation = projectBackupManager.createBackup();
return new CreateBackupOwlFileResponse(backupFileLocation);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package edu.stanford.protege.webprotege.project;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import edu.stanford.protege.webprotege.common.Response;
import edu.stanford.protege.webprotege.dispatch.Result;

import static edu.stanford.protege.webprotege.project.CreateBackupOwlFileAction.CHANNEL;

@JsonTypeName(CHANNEL)
public record CreateBackupOwlFileResponse() implements Result, Response {
public record CreateBackupOwlFileResponse(@JsonProperty("owlFileBackupLocation") String owlFileBackupLocation) implements Result, Response {
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ProjectBackupManager(ProjectDirectoryProvider projectDirectoryProvider, P
this.backupDirectoryProvider = backupDirectoryProvider;
}

public void createBackup() {
public String createBackup() {
String currentDate = LocalDate.now().toString();
Path sourcePath = new File(projectDirectoryProvider.get().getAbsolutePath()+ "/change-data/change-data.binary").toPath();
Path targetDir = new File(backupDirectoryProvider.get().getAbsolutePath() + "/" + currentDate).toPath();
Expand All @@ -37,8 +37,10 @@ public void createBackup() {
}

Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
return targetPath.toAbsolutePath().toString();
} catch (IOException e) {
LOGGER.error("Error saving the backup file occurred", e);
throw new RuntimeException("Error saving the backup file occurred", e);
}
}

Expand Down

0 comments on commit 55a2346

Please sign in to comment.