|
5 | 5 | import edu.kit.datamanager.ro_crate.Crate; |
6 | 6 | import edu.kit.datamanager.ro_crate.entities.data.DataEntity; |
7 | 7 | import edu.kit.datamanager.ro_crate.objectmapper.MyObjectMapper; |
| 8 | +import edu.kit.datamanager.ro_crate.special.IdentifierUtils; |
8 | 9 | import org.apache.commons.io.FileUtils; |
9 | 10 | import org.slf4j.Logger; |
10 | 11 | import org.slf4j.LoggerFactory; |
@@ -64,16 +65,18 @@ public void save(Crate crate, String destination) throws IOException { |
64 | 65 | } |
65 | 66 | } |
66 | 67 | for (DataEntity dataEntity : crate.getAllDataEntities()) { |
67 | | - savetoFile(dataEntity, file); |
| 68 | + saveToFile(dataEntity, file); |
68 | 69 | } |
69 | 70 | } |
70 | 71 |
|
71 | | - private void savetoFile(DataEntity entity, File file) throws IOException { |
| 72 | + private void saveToFile(DataEntity entity, File file) throws IOException { |
72 | 73 | if (entity.getPath() != null) { |
| 74 | + String id = entity.getId(); |
| 75 | + String filename = IdentifierUtils.decode(id).orElse(id); |
73 | 76 | if (entity.getPath().toFile().isDirectory()) { |
74 | | - FileUtils.copyDirectory(entity.getPath().toFile(), file.toPath().resolve(entity.getId()).toFile()); |
| 77 | + FileUtils.copyDirectory(entity.getPath().toFile(), file.toPath().resolve(filename).toFile()); |
75 | 78 | } else { |
76 | | - FileUtils.copyFile(entity.getPath().toFile(), file.toPath().resolve(entity.getId()).toFile()); |
| 79 | + FileUtils.copyFile(entity.getPath().toFile(), file.toPath().resolve(filename).toFile()); |
77 | 80 | } |
78 | 81 | } |
79 | 82 | } |
|
0 commit comments