X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FRestCodec.java;h=45f3f7f30bd3de9b29117e27b50767ae7e5c5166;hp=450ba02b56071412d8aff89030db7b221a128605;hb=54bed4dd6dfbada9a8e2ddf70ca84952aec3f55a;hpb=d2aed692dab458282c37d42b13a16cff743d598e diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java index 450ba02b56..45f3f7f30b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestCodec.java @@ -19,16 +19,16 @@ public class RestCodec { private RestCodec() { } - + public static final Codec from(TypeDefinition typeDefinition) { return new ObjectCodec(typeDefinition); } - + @SuppressWarnings("rawtypes") public static final class ObjectCodec implements Codec { private final Logger logger = LoggerFactory.getLogger(RestCodec.class); - + public static final Codec IDENTITYREF_DEFAULT_CODEC = new IdentityrefCodecImpl(); public static final Codec LEAFREF_DEFAULT_CODEC = new LeafrefCodecImpl(); @@ -37,7 +37,7 @@ public class RestCodec { private ObjectCodec(TypeDefinition typeDefinition) { type = RestUtil.resolveBaseTypeFrom(typeDefinition); } - + @SuppressWarnings("unchecked") @Override public Object deserialize(Object input) { @@ -47,16 +47,21 @@ public class RestCodec { } else if (type instanceof LeafrefTypeDefinition) { return LEAFREF_DEFAULT_CODEC.deserialize(input); } else { - TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec.from(type); + TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec + .from(type); if (typeAwarecodec != null) { return typeAwarecodec.deserialize(String.valueOf(input)); } else { - logger.debug("Codec for type \"" + type.getQName().getLocalName() + "\" is not implemented yet."); + logger.debug("Codec for type \"" + type.getQName().getLocalName() + + "\" is not implemented yet."); return null; } } - } catch (ClassCastException e) { // TODO remove this catch when everyone use codecs - logger.error("ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), e); + } catch (ClassCastException e) { // TODO remove this catch when + // everyone use codecs + logger.error( + "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), + e); return input; } } @@ -70,22 +75,27 @@ public class RestCodec { } else if (type instanceof LeafrefTypeDefinition) { return LEAFREF_DEFAULT_CODEC.serialize(input); } else { - TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec.from(type); + TypeDefinitionAwareCodec> typeAwarecodec = TypeDefinitionAwareCodec + .from(type); if (typeAwarecodec != null) { return typeAwarecodec.serialize(input); } else { - logger.debug("Codec for type \"" + type.getQName().getLocalName() + "\" is not implemented yet."); + logger.debug("Codec for type \"" + type.getQName().getLocalName() + + "\" is not implemented yet."); return null; } } - } catch (ClassCastException e) { // TODO remove this catch when everyone use codecs - logger.error("ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), e); + } catch (ClassCastException e) { // TODO remove this catch when + // everyone use codecs + logger.error( + "ClassCastException was thrown when codec is invoked with parameter " + String.valueOf(input), + e); return input; } } - + } - + public static class IdentityrefCodecImpl implements IdentityrefCodec { @Override @@ -97,7 +107,7 @@ public class RestCodec { public QName deserialize(IdentityValuesDTO data) { IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); String namespace = valueWithNamespace.getNamespace(); - URI validNamespace = ControllerContext.getInstance().findNamespaceByModule(namespace); + URI validNamespace = ControllerContext.getInstance().findNamespaceByModuleName(namespace); if (validNamespace == null) { validNamespace = URI.create(namespace); } @@ -105,7 +115,7 @@ public class RestCodec { } } - + public static class LeafrefCodecImpl implements LeafrefCodec { @Override @@ -117,7 +127,7 @@ public class RestCodec { public Object deserialize(String data) { return data; } - + } - + }