File tree 2 files changed +21
-8
lines changed
src/main/java/edu/kit/datamanager/ro_crate 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 40
40
*/
41
41
public class RoCrate implements Crate {
42
42
43
- private final CratePayload roCratePayload ;
44
- private CrateMetadataContext metadataContext ;
45
- private CratePreview roCratePreview ;
46
- private RootDataEntity rootDataEntity ;
47
- private ContextualEntity jsonDescriptor ;
43
+ protected final CratePayload roCratePayload ;
44
+ protected CrateMetadataContext metadataContext ;
45
+ protected CratePreview roCratePreview ;
46
+ protected RootDataEntity rootDataEntity ;
47
+ protected ContextualEntity jsonDescriptor ;
48
48
49
- private Collection <File > untrackedFiles ;
49
+ protected Collection <File > untrackedFiles ;
50
50
51
51
@ Override
52
52
public CratePreview getPreview () {
Original file line number Diff line number Diff line change 31
31
*/
32
32
public class RoCrateReader {
33
33
34
+ /**
35
+ * This is a private inner class that shall not be exposed.
36
+ * **Do not make it public or protected.** It serves only the
37
+ * purpose of unsafe operations while reading a crate and
38
+ * may be specific to this implementation.
39
+ */
40
+ private static class RoCrateUnsafe extends RoCrate {
41
+ public void addDataEntityWithoutRootHasPart (DataEntity entity ) {
42
+ this .metadataContext .checkEntity (entity );
43
+ this .roCratePayload .addDataEntity (entity );
44
+ }
45
+ }
46
+
34
47
/**
35
48
* If the number of JSON entities in the crate is larger than this number,
36
49
* parallelization will be used.
@@ -78,7 +91,7 @@ public RoCrate readCrate(String location) {
78
91
JsonNode context = metadataJson .get (PROP_CONTEXT );
79
92
80
93
CrateMetadataContext crateContext = new RoCrateMetadataContext (context );
81
- RoCrate crate = new RoCrate ();
94
+ RoCrateUnsafe crate = new RoCrateUnsafe ();
82
95
crate .setMetadataContext (crateContext );
83
96
JsonNode graph = metadataJson .get (PROP_GRAPH );
84
97
@@ -101,7 +114,7 @@ public RoCrate readCrate(String location) {
101
114
.setId (file .getName ());
102
115
});
103
116
104
- crate .addDataEntity (dataEntity .build ());
117
+ crate .addDataEntityWithoutRootHasPart (dataEntity .build ());
105
118
} else {
106
119
// contextual entity
107
120
crate .addContextualEntity (
You can’t perform that action at this time.
0 commit comments