X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FControllerContext.xtend;h=065d01e8e9405058f563189e6f5117d30eed4857;hb=0d7444fae6e9873e7af11a762aeb59d833d18573;hp=c1ee611e07c77241b1346f0683387d503111e1e9;hpb=1d86c5cf27410934076c10eaa74f4bab4418215c;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend index c1ee611e07..065d01e8e9 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.xtend @@ -9,7 +9,6 @@ import java.util.HashMap import java.util.List import java.util.Map import java.util.concurrent.ConcurrentHashMap -import javax.ws.rs.WebApplicationException import javax.ws.rs.core.Response import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener import org.opendaylight.controller.sal.rest.impl.RestconfProvider @@ -46,7 +45,7 @@ class ControllerContext implements SchemaServiceListener { private new() { - if (INSTANCE != null) { + if (INSTANCE !== null) { throw new IllegalStateException("Already instantiated"); } } @@ -56,9 +55,8 @@ class ControllerContext implements SchemaServiceListener { } private def void checkPreconditions() { - if (schemas == null) { - throw new WebApplicationException(Response.status(Response.Status.SERVICE_UNAVAILABLE) - .entity(RestconfProvider::NOT_INITALIZED_MSG).build()) + if (schemas === null) { + throw new ResponseException(Response.Status.SERVICE_UNAVAILABLE, RestconfProvider::NOT_INITALIZED_MSG) } } @@ -72,7 +70,7 @@ class ControllerContext implements SchemaServiceListener { pathArgs.remove(0) } val schemaNode = ret.collectPathArguments(pathArgs, restconfInstance.findModule); - if (schemaNode == null) { + if (schemaNode === null) { return null } new InstanceIdWithSchemaNode(ret.toInstance, schemaNode) @@ -92,7 +90,7 @@ class ControllerContext implements SchemaServiceListener { private def getLatestModule(SchemaContext schema, String moduleName) { checkNotNull(schema) - checkArgument(moduleName != null && !moduleName.empty) + checkArgument(moduleName !== null && !moduleName.empty) val modules = schema.modules.filter[m|m.name == moduleName] var latestModule = modules.head for (module : modules) { @@ -134,9 +132,9 @@ class ControllerContext implements SchemaServiceListener { def CharSequence toRestconfIdentifier(QName qname) { checkPreconditions var module = uriToModuleName.get(qname.namespace) - if (module == null) { + if (module === null) { val moduleSchema = schemas.findModuleByNamespaceAndRevision(qname.namespace, qname.revision); - if(moduleSchema == null) throw new IllegalArgumentException() + if(moduleSchema === null) throw new IllegalArgumentException() uriToModuleName.put(qname.namespace, moduleSchema.name) module = moduleSchema.name; } @@ -189,13 +187,16 @@ class ControllerContext implements SchemaServiceListener { } private def toUriString(Object object) { - if(object == null) return ""; + if(object === null) return ""; return URLEncoder.encode(object.toString) } private def DataSchemaNode collectPathArguments(InstanceIdentifierBuilder builder, List strings, DataNodeContainer parentNode) { checkNotNull(strings) + if (parentNode === null) { + return null; + } if (strings.empty) { return parentNode as DataSchemaNode; } @@ -203,14 +204,14 @@ class ControllerContext implements SchemaServiceListener { val nodeName = nodeRef.toNodeName(); val targetNode = parentNode.getDataChildByName(nodeName); - if (targetNode == null) { + if (targetNode === null) { val children = parentNode.childNodes for (child : children) { if (child instanceof ChoiceNode) { val choice = child as ChoiceNode for (caze : choice.cases) { val result = builder.collectPathArguments(strings, caze as DataNodeContainer); - if (result != null) + if (result !== null) return result } }