import com.google.common.base.Preconditions;
import com.google.gson.stream.JsonReader;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
-import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
public GnpyResult(String gnpyResponseString) throws Exception {
- // try {
- // Optional<DataObject> dataObject;
// Create the schema context
final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
Iterable<? extends YangModuleInfo> moduleInfos;
NoPathCase noPathCase = (NoPathCase) response.getResponseType();
String noPathType = noPathCase.getNoPath().getNoPath();
LOG.info("GNPy: No path - {}",noPathType);
- if (((noPathType == "NO_FEASIBLE_BAUDRATE_WITH_SPACING") && (noPathType == "NO_FEASIBLE_MODE"))
- && ((noPathType == "MODE_NOT_FEASIBLE") && (noPathType == "NO_SPECTRUM"))) {
+ if (((noPathType.equals("NO_FEASIBLE_BAUDRATE_WITH_SPACING"))
+ && (noPathType.equals("NO_FEASIBLE_MODE"))) && ((noPathType.equals("MODE_NOT_FEASIBLE"))
+ && (noPathType.equals("NO_SPECTRUM")))) {
List<PathMetric> pathMetricList = noPathCase.getNoPath().getPathProperties().getPathMetric();
LOG.info("GNPy : path is not feasible : {}", noPathType);
for (PathMetric pathMetric : pathMetricList) {
NormalizedNodeResult result = new NormalizedNodeResult();
SchemaContext schemaContext = getSchemaContext(objectClass);
try (NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result);
- JsonParserStream jsonParser = JsonParserStream.create(streamWriter, schemaContext, schemaContext);) {
+ JsonParserStream jsonParser = JsonParserStream.create(streamWriter,
+ JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02.getShared(schemaContext),
+ schemaContext);) {
LOG.debug("GNPy: the path to the reader {}", reader.getPath());
LOG.debug("GNPy: the reader {}", reader.toString());
LOG.debug("GNPy: the jsonParser class {} // jsonParser to string {}", jsonParser.getClass(),
return schemaContext;
}
- private String readResultFromFile(String fileName) {
- BufferedReader br = null;
- FileReader fr = null;
- StringBuilder sb = new StringBuilder();
- String gnpyResponse;
-
- try {
- fr = new FileReader(fileName);
- br = new BufferedReader(fr);
- String currentLine;
- while ((currentLine = br.readLine()) != null) {
- LOG.info(currentLine);
- sb.append(currentLine);
- }
- fr.close();
- } catch (IOException e) {
- LOG.warn("GNPy: exception {} occured during the reading of results", e.getMessage());
- }
- gnpyResponse = sb.toString();
- return gnpyResponse;
- }
-
/**
* Transforms the given input {@link NormalizedNode} into the given
* {@link DataObject}.
}
return Optional.ofNullable((T) bindingNodeEntry.getValue());
}
+
+ public Response getResponse() {
+ return response;
+ }
}