@@ -51,7 +51,7 @@ public ResourceTypeAdapter(SpaceWrapper spaceWrapper, Map<String, Class<?>> cust
5151 this .httpScheme = httpScheme ;
5252 }
5353
54- @ Override public CDAResource deserialize (JsonElement jsonElement , Type type ,
54+ public CDAResource deserialize (JsonElement jsonElement , Type type ,
5555 JsonDeserializationContext context ) throws JsonParseException {
5656 CDAResource result = null ;
5757 JsonObject sys = jsonElement .getAsJsonObject ().getAsJsonObject ("sys" );
@@ -103,20 +103,26 @@ private CDAAsset deserializeAsset(JsonElement jsonElement, JsonDeserializationCo
103103 JsonObject sys ) {
104104 CDAAsset result = new CDAAsset ();
105105 setBaseFields (result , sys , jsonElement , context );
106- Map fileMap = (Map ) result .getFields ().get ("file" );
107- String defaultLocale = spaceWrapper .get ().getDefaultLocale ();
108106
109- if (fileMap .containsKey (defaultLocale )) {
110- Object map = fileMap .get (defaultLocale );
107+ Map fields = result .getFields ();
108+ if (fields != null ) {
109+ Map fileMap = (Map ) fields .get ("file" );
110+ if (fileMap != null ) {
111+ String defaultLocale = spaceWrapper .get ().getDefaultLocale ();
111112
112- if (map instanceof Map ) {
113- fileMap = (Map ) map ;
113+ if (fileMap .containsKey (defaultLocale )) {
114+ Object map = fileMap .get (defaultLocale );
115+
116+ if (map instanceof Map ) {
117+ fileMap = (Map ) map ;
118+ }
119+ }
120+
121+ result .setUrl (String .format ("%s:%s" , httpScheme , fileMap .get ("url" )));
122+ result .setMimeType ((String ) fileMap .get ("contentType" ));
114123 }
115124 }
116125
117- result .setUrl (String .format ("%s:%s" , httpScheme , fileMap .get ("url" )));
118- result .setMimeType ((String ) fileMap .get ("contentType" ));
119-
120126 return result ;
121127 }
122128
0 commit comments