12
12
import edu .kit .datamanager .ro_crate .entities .data .RootDataEntity ;
13
13
import edu .kit .datamanager .ro_crate .special .JsonUtilFunctions ;
14
14
import static edu .kit .datamanager .ro_crate .special .UriUtil .decode ;
15
+ import static edu .kit .datamanager .ro_crate .special .UriUtil .isUrl ;
16
+
15
17
import edu .kit .datamanager .ro_crate .validation .JsonSchemaValidation ;
16
18
import edu .kit .datamanager .ro_crate .validation .Validator ;
17
19
@@ -92,17 +94,18 @@ public RoCrate readCrate(String location) {
92
94
// if the id is in the root hasPart list, we know this entity is a data entity
93
95
RootDataEntity root = crate .getRootDataEntity ();
94
96
if (root != null && root .hasInHasPart (node .get (PROP_ID ).asText ())) {
97
+ // data entity
98
+ DataEntity .DataEntityBuilder dataEntity = new DataEntity .DataEntityBuilder ()
99
+ .setAll (node .deepCopy ());
100
+
101
+ // Handle data entities with corresponding file
95
102
File loc = checkFolderHasFile (node .get (PROP_ID ).asText (), files );
96
103
if (loc != null ) {
97
104
usedFiles .add (loc .getPath ());
98
-
99
- // data entity
100
- DataEntity dataEntity = new DataEntity .DataEntityBuilder ()
101
- .setAll (node .deepCopy ())
102
- .addContent (loc .toPath (), loc .getName ())
103
- .build ();
104
- crate .addDataEntity (dataEntity , false );
105
+ dataEntity .addContent (loc .toPath (), loc .getName ());
105
106
}
107
+
108
+ crate .addDataEntity (dataEntity .build (), false );
106
109
} else {
107
110
// contextual entity
108
111
crate .addContextualEntity (
@@ -124,6 +127,7 @@ public RoCrate readCrate(String location) {
124
127
}
125
128
126
129
protected File checkFolderHasFile (String id , File file ) {
130
+ if (isUrl (id )) return null ;
127
131
Path path = file .toPath ().resolve (decode (id ).get ());
128
132
if (path .toFile ().exists ()) {
129
133
return path .toFile ();
0 commit comments