Skip to content

Commit

Permalink
#707: Remove JSON format for object model definition
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Sep 18, 2019
1 parent a4f4c4e commit d7706ce
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 1,111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@
import java.util.ArrayList;
import java.util.List;

import org.eclipse.leshan.core.model.json.ObjectModelSerDes;
import org.eclipse.leshan.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eclipsesource.json.Json;
import com.eclipsesource.json.JsonValue;

public class ObjectLoader {

private static final Logger LOG = LoggerFactory.getLogger(ObjectLoader.class);
Expand Down Expand Up @@ -75,22 +71,6 @@ public static List<ObjectModel> loadDdfFile(InputStream input, String streamName
return ddfFileParser.parse(input, streamName);
}

/**
* Load object definitions from JSON stream.
*
* @param input An inputStream to a JSON stream.
*/
public static List<ObjectModel> loadJsonStream(InputStream input) {
try {
Reader reader = new InputStreamReader(input);
JsonValue json = Json.parse(reader);
return new ObjectModelSerDes().deserialize(json.asArray());
} catch (IOException e) {
LOG.error("Cannot load json model from inputstream");
}
return null;
}

/**
* Load object definition from DDF resources following rules of {@link Class#getResourceAsStream(String)}.
*
Expand Down Expand Up @@ -168,15 +148,6 @@ public static List<ObjectModel> loadObjectsFromDir(File modelsDir) {
e);
}

} else if (file.getName().endsWith(".json")) {
// from JSON file
LOG.debug("Loading object models from JSON file {}", file.getAbsolutePath());
try (FileInputStream input = new FileInputStream(file)) {
models.addAll(loadJsonStream(input));
} catch (IOException e) {
LOG.warn(MessageFormat.format("Unable to load object models for {0}", file.getAbsolutePath()),
e);
}
}
}
}
Expand Down

This file was deleted.

Loading

0 comments on commit d7706ce

Please sign in to comment.