Merge "BUG-633: allow overriding of channelFactory"
authorEd Warnicke <eaw@cisco.com>
Thu, 1 May 2014 16:36:16 +0000 (16:36 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 1 May 2014 16:36:16 +0000 (16:36 +0000)
26 files changed:
opendaylight/config/netty-config-api/src/main/yang/netty.yang
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleFieldSerializer.java
opendaylight/md-sal/compatibility/flow-management-compatibility/pom.xml
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend [deleted file]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend [deleted file]
opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowManagementReader.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend [deleted file]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyProvider.xtend
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyTransaction.xtend [deleted file]
opendaylight/md-sal/inventory-manager/pom.xml
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.java [new file with mode: 0644]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.xtend [deleted file]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.java [new file with mode: 0644]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.xtend [deleted file]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.java [new file with mode: 0644]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.xtend [deleted file]
opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/NodeChangeCommiter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java [new file with mode: 0644]
opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang [new file with mode: 0644]

index 7cac5ad5bc6202265be39f385b8749d61bc77e62..e274b058dccce43045ac6647d9c8775e65ceb78f 100644 (file)
@@ -49,4 +49,12 @@ module netty {
         base "config:service-type";
         config:java-class "io.netty.util.Timer";
     }
-}
\ No newline at end of file
+
+    identity channel-factory {
+        description
+            "Configuration wrapper around netty's channel factory";
+
+        base "config:service-type";
+        config:java-class "io.netty.bootstrap.ChannelFactory";
+    }
+}
index c0e3bc1ad84d6ab85b2010149b0286a01e440529..6211efe417973ee0f8faf637669e4f824a1df7f3 100644 (file)
@@ -16,7 +16,7 @@ public class ModuleFieldSerializer {
     public static String toString(ModuleField moduleField) {
         StringBuilder builder = new StringBuilder();
         builder.append("    ");
-        builder.append("protected final "
+        builder.append("public static final "
                 + JmxAttribute.class.getCanonicalName() + " "
                 + moduleField.getName() + "JmxAttribute = new "
                 + JmxAttribute.class.getCanonicalName() + "(\""
index 93ce0dd4f7161874ec6d7954e4a4729befdec461..7770c153498fe8a4491e81785236d3e2f21d25bd 100644 (file)
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.eclipse.xtend</groupId>
-      <artifactId>org.eclipse.xtend.lib</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>forwardingrulesmanager</artifactId>
           </instructions>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.eclipse.xtend</groupId>
-        <artifactId>xtend-maven-plugin</artifactId>
-      </plugin>
     </plugins>
   </build>
   <scm>
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/ConfigurationReader.java
new file mode 100644 (file)
index 0000000..411af28
--- /dev/null
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.frm.compatibility;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
+import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
+import org.opendaylight.controller.sal.compatibility.NodeMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.FlowsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigurationReader implements FlowManagementReader {
+
+    private final static Logger LOG = LoggerFactory.getLogger(ConfigurationReader.class);
+
+    private IForwardingRulesManager manager;
+
+    @Override
+    public Flows readAllFlows() {
+        List<FlowConfig> staticFlows = this.manager.getStaticFlows();
+        List<Flow> flowMap = new ArrayList<Flow>(staticFlows.size());
+
+        for (FlowConfig conf : staticFlows) {
+            flowMap.add(FlowConfigMapping.toConfigurationFlow(conf));
+        }
+        final FlowsBuilder flowsBuilder = new FlowsBuilder();
+        return (flowsBuilder.setFlow(flowMap)).build();
+    }
+
+    @Override
+    public Flow readFlow(final FlowKey key) {
+        try {
+            final FlowConfig flowConf =
+                    this.manager.getStaticFlow(String.valueOf(key.getId()), NodeMapping.toADNode(key.getNode()));
+            return FlowConfigMapping.toConfigurationFlow(flowConf);
+        } catch (Exception e) {
+            String errMsg = MessageFormat.format("readFlow by key {} fail", key);
+            LOG.error(errMsg, e);
+            throw new RuntimeException(errMsg, e);
+        }
+    }
+
+    public IForwardingRulesManager getManager() {
+        return this.manager;
+    }
+
+    public void setManager(final IForwardingRulesManager manager) {
+        this.manager = manager;
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.java
new file mode 100644 (file)
index 0000000..be3add1
--- /dev/null
@@ -0,0 +1,122 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.frm.compatibility;
+
+import java.util.Collections;
+
+import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
+import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
+import org.opendaylight.controller.md.sal.common.api.data.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
+import org.opendaylight.controller.sal.common.util.Arguments;
+import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
+
+public class FRMRuntimeDataProvider implements RuntimeDataProvider, DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject> {
+
+    private final static InstanceIdentifier<Flows> FLOWS_PATH = InstanceIdentifier.<Flows> builder(Flows.class).toInstance();
+
+    private final FlowManagementReader configuration = new ConfigurationReader();
+    private DataChangeListener<InstanceIdentifier<? extends DataObject>, DataObject> changeListener;
+    private DataProviderService dataService;
+    private IForwardingRulesManager manager;
+
+    public Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> init() {
+        return this.dataService.registerCommitHandler(FRMRuntimeDataProvider.FLOWS_PATH, this);
+    }
+
+    @Override
+    public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
+        return this.readFrom(this.configuration, path);
+    }
+
+    @Override
+    public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
+        return this.readFrom(this.configuration, path);
+    }
+
+    public DataObject readFrom(final FlowManagementReader store, final InstanceIdentifier<? extends DataObject> path) {
+        if (Objects.equal(FRMRuntimeDataProvider.FLOWS_PATH, path)) {
+            return store.readAllFlows();
+        }
+        if (FRMRuntimeDataProvider.FLOWS_PATH.contains(path)) {
+            return store.readFlow(this.toFlowKey(path));
+        }
+        return null;
+    }
+
+    @Override
+    public FlowCommitTransaction requestCommit(final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
+        return new FlowCommitTransaction(this, modification);
+    }
+
+    public FlowKey toFlowKey(final InstanceIdentifier<? extends DataObject> identifier) {
+        Preconditions.<InstanceIdentifier<? extends DataObject>> checkNotNull(identifier);
+
+        Iterable<PathArgument> path = identifier.getPathArguments();
+        PathArgument get = path.iterator().next();
+        final Identifier itemKey = Arguments.<IdentifiableItem> checkInstanceOf(get, IdentifiableItem.class).getKey();
+        return Arguments.<FlowKey> checkInstanceOf(itemKey, FlowKey.class);
+    }
+
+    public RpcResult<Void> finish(final FlowCommitTransaction transaction) {
+        Iterable<FlowConfig> toRemove = transaction.getToRemove();
+        for (final FlowConfig flow : toRemove) {
+            this.manager.removeStaticFlow(flow.getName(), flow.getNode());
+        }
+        Iterable<FlowConfig> toUpdate = transaction.getToUpdate();
+        for (final FlowConfig flow : toUpdate) {
+            this.manager.removeStaticFlow(flow.getName(), flow.getNode());
+            this.manager.addStaticFlow(flow);
+        }
+        return Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
+    }
+
+    public RpcResult<Void> rollback(final FlowCommitTransaction transaction) {
+        return null;
+    }
+
+    public DataProviderService getDataService() {
+        return this.dataService;
+    }
+
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+
+    public DataChangeListener<InstanceIdentifier<? extends DataObject>, DataObject> getChangeListener() {
+        return this.changeListener;
+    }
+
+    public void setChangeListener(final DataChangeListener<InstanceIdentifier<? extends DataObject>, DataObject> changeListener) {
+        this.changeListener = changeListener;
+    }
+
+    public IForwardingRulesManager getManager() {
+        return this.manager;
+    }
+
+    public void setManager(final IForwardingRulesManager manager) {
+        this.manager = manager;
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FRMRuntimeDataProvider.xtend
deleted file mode 100644 (file)
index 2d4e7d2..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.frm.compatibility
-
-import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeListener
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.FlowsBuilder
-import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager
-import static com.google.common.base.Preconditions.*;
-import static extension org.opendaylight.controller.md.frm.compatibility.FlowConfigMapping.*;
-import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*;
-import org.opendaylight.controller.sal.common.util.Arguments
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
-import org.opendaylight.yangtools.yang.common.RpcResult
-import org.opendaylight.controller.forwardingrulesmanager.FlowConfig
-import java.util.HashSet
-import org.opendaylight.controller.sal.common.util.Rpcs
-import java.util.Collections
-import org.opendaylight.yangtools.yang.common.RpcError
-
-class FRMRuntimeDataProvider implements RuntimeDataProvider, DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-
-    static val FLOWS_PATH = InstanceIdentifier.builder(Flows).toInstance;
-
-    @Property
-    var DataProviderService dataService;
-
-    @Property
-    var DataChangeListener changeListener;
-    
-    @Property
-    var IForwardingRulesManager manager;
-
-    FlowManagementReader configuration = new ConfigurationReader();
-
-    def init() {
-        //dataService.registerDataChangeListener(FLOWS_PATH, changeListener);
-        dataService.registerCommitHandler(FLOWS_PATH, this);
-    }
-
-    override readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
-        return readFrom(configuration, path);
-    }
-
-    override DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
-        return readFrom(configuration, path);
-    }
-
-    def DataObject readFrom(FlowManagementReader store, InstanceIdentifier<? extends DataObject> path) {
-        if (FLOWS_PATH == path) {
-            return store.readAllFlows();
-        }
-        if (FLOWS_PATH.contains(path)) {
-            return store.readFlow(path.toFlowKey());
-        }
-        return null;
-    }
-
-    override FlowCommitTransaction requestCommit(
-        DataModification modification) {
-        return new FlowCommitTransaction(this,modification);
-    }
-
-    def toFlowKey(InstanceIdentifier<? extends DataObject> identifier) {
-        checkNotNull(identifier)
-        val item = Arguments.checkInstanceOf(identifier.path.get(1),IdentifiableItem);
-        val key = Arguments.checkInstanceOf(item.key,FlowKey)
-        return key;
-    }
-    
-    def RpcResult<Void> finish(FlowCommitTransaction transaction) {
-        for(flw: transaction.toRemove) {
-            manager.removeStaticFlow(flw.name,flw.node)
-        }
-        
-        for(flw: transaction.toUpdate) {
-            manager.removeStaticFlow(flw.name,flw.node);
-            manager.addStaticFlow(flw);
-        }
-        
-        return Rpcs.<Void>getRpcResult(true,null,Collections.<RpcError>emptySet())
-    }
-    
-    def RpcResult<Void> rollback(FlowCommitTransaction transaction) {
-        // NOOP: We did not changed any state.
-    }
-
-}
-
-class ConfigurationReader implements FlowManagementReader {
-
-    @Property
-    var IForwardingRulesManager manager;
-
-    override Flows readAllFlows() {
-        val it = new FlowsBuilder();
-        flow = manager.staticFlows.map[
-            toConfigurationFlow();
-        ]
-        return it.build();
-    }
-
-    override readFlow(FlowKey key) {
-        val flowCfg = manager.getStaticFlow(String.valueOf(key.id), key.node.toADNode());
-        return flowCfg.toConfigurationFlow;
-    }
-}
-
-public static class FlowCommitTransaction implements DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> {
-
-    @Property
-    val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
-
-    @Property
-    val FRMRuntimeDataProvider flowManager;
-    
-    @Property
-    val toAdd = new HashSet<FlowConfig>();
-    
-    @Property
-    var Iterable<FlowConfig> toUpdate
-    
-    @Property
-    var Iterable<FlowConfig> toRemove
-    
-
-    new(FRMRuntimeDataProvider flowManager,DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        super();
-        _flowManager = flowManager;
-        _modification = modification;
-        processModification();
-    }
-
-    override finish() throws IllegalStateException {
-        return flowManager.finish(this);
-    }
-
-    override rollback() throws IllegalStateException
-{
-        return flowManager.rollback(this);
-    }
-
-    def processModification() {
-        val updated = modification.updatedConfigurationData.entrySet;
-        
-        val _toUpdate = updated.filter[key.isFlowPath].map[
-             return (value as Flow).toFlowConfig
-        ]
-        toUpdate = _toUpdate as Iterable<FlowConfig>
-        
-        
-        val _toRemove = modification.removedConfigurationData.filter[isFlowPath].map[
-             toFlowConfig
-        ]
-        toRemove = _toRemove as Iterable<FlowConfig>
-        
-    }
-}
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowCommitTransaction.java
new file mode 100644 (file)
index 0000000..bf0050d
--- /dev/null
@@ -0,0 +1,99 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.frm.compatibility;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class FlowCommitTransaction implements DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> {
+
+    private final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
+    private final HashSet<FlowConfig> toAdd = new HashSet<FlowConfig>();
+    private final FRMRuntimeDataProvider flowManager;
+    private Iterable<FlowConfig> toUpdate;
+    private Iterable<FlowConfig> toRemove;
+
+    public FlowCommitTransaction(
+            final FRMRuntimeDataProvider flowManager,
+            final DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
+        this.flowManager = flowManager;
+        this.modification = modification;
+        this.processModification();
+    }
+
+    @Override
+    public RpcResult<Void> finish() throws IllegalStateException {
+        return this.flowManager.finish(this);
+    }
+
+    @Override
+    public RpcResult<Void> rollback() throws IllegalStateException {
+        return this.flowManager.rollback(this);
+    }
+
+    public void processModification() {
+        final Set<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> updated =
+                this.modification.getUpdatedConfigurationData().entrySet();
+        final List<FlowConfig> forUpdate = new ArrayList<FlowConfig>(updated.size());
+
+        if (updated != null && !(updated.isEmpty())) {
+            for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : updated) {
+                if (FlowConfigMapping.isFlowPath(entry.getKey())) {
+                    forUpdate.add(FlowConfigMapping.toFlowConfig((Flow) entry.getValue()));
+                }
+            }
+        }
+        this.toUpdate = Collections.unmodifiableCollection(forUpdate);
+
+        final Set<InstanceIdentifier<? extends DataObject>> removedConfigurationData =
+                this.modification.getRemovedConfigurationData();
+        final List<FlowConfig> forRemove = new ArrayList<FlowConfig>(removedConfigurationData.size());
+
+        if (removedConfigurationData != null && !(removedConfigurationData.isEmpty())) {
+            for (InstanceIdentifier<? extends DataObject> data : removedConfigurationData) {
+                if (FlowConfigMapping.isFlowPath(data)) {
+                    forRemove.add(FlowConfigMapping.toFlowConfig(data));
+                }
+            }
+        }
+        this.toRemove = Collections.unmodifiableCollection(forRemove);
+    }
+
+    @Override
+    public DataModification<InstanceIdentifier<? extends DataObject>, DataObject> getModification() {
+        return this.modification;
+    }
+
+    public FRMRuntimeDataProvider getFlowManager() {
+        return this.flowManager;
+    }
+
+    public HashSet<FlowConfig> getToAdd() {
+        return this.toAdd;
+    }
+
+    public Iterable<FlowConfig> getToUpdate() {
+        return this.toUpdate;
+    }
+
+    public Iterable<FlowConfig> getToRemove() {
+        return this.toRemove;
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.java
new file mode 100644 (file)
index 0000000..58c60ec
--- /dev/null
@@ -0,0 +1,109 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.frm.compatibility;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+
+import org.opendaylight.controller.forwardingrulesmanager.FlowConfig;
+import org.opendaylight.controller.sal.compatibility.MDFlowMapping;
+import org.opendaylight.controller.sal.compatibility.NodeMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlowConfigMapping {
+
+    private final static Logger LOG = LoggerFactory.getLogger(FlowConfigMapping.class);
+
+    /* nodes/node/flow  -> 0 / 1 / 2  */
+    private static final int FLOW_KEY_IDENTIFIER_DEEP = 2;
+
+    public static Flow toConfigurationFlow(final FlowConfig sourceCfg) {
+        final FlowAdded source = MDFlowMapping.flowAdded(sourceCfg.getFlow());
+        final FlowBuilder flowBuilder = new FlowBuilder();
+        flowBuilder.setInstructions(source.getInstructions());
+        flowBuilder.setCookie(source.getCookie());
+        flowBuilder.setHardTimeout(source.getHardTimeout());
+        flowBuilder.setIdleTimeout(source.getIdleTimeout());
+        flowBuilder.setMatch(source.getMatch());
+        flowBuilder.setNode(source.getNode());
+
+        FlowKey flowKey =
+                new FlowKey(Long.valueOf(sourceCfg.getName()), flowBuilder.getNode());
+        flowBuilder.setKey(flowKey);
+        return flowBuilder.build();
+    }
+
+    public static FlowConfig toFlowConfig(final Flow sourceCfg) {
+        try {
+            final FlowConfig flowConfig = new FlowConfig();
+            flowConfig.setName(String.valueOf(sourceCfg.getId()));
+            flowConfig.setNode(NodeMapping.toADNode(sourceCfg.getNode()));
+            return flowConfig;
+        } catch (Exception e) {
+            String errMsg = MessageFormat.format("Convert from Flow {} to FlowConfig fail", sourceCfg);
+            LOG.error(errMsg, e);
+            throw new RuntimeException(errMsg, e);
+        }
+    }
+
+    public static FlowConfig toFlowConfig(final InstanceIdentifier<? extends Object> identifier) {
+        try {
+            PathArgument pathArg = FlowConfigMapping.getSecondPathArgumentFromPath(identifier);
+            if (pathArg != null) {
+                final FlowConfig flowConfig = new FlowConfig();
+                FlowKey key = ((IdentifiableItem<Flow, FlowKey>) pathArg).getKey();
+                flowConfig.setName(String.valueOf(key.getId()));
+                flowConfig.setNode(NodeMapping.toADNode(key.getNode()));
+                return flowConfig;
+            }
+            return null;
+        } catch (Exception e) {
+            String errMsg = MessageFormat.format("Convert from InstanceIdentifier {} to FlowConfig fail", identifier);
+            LOG.error(errMsg, e);
+            throw new RuntimeException(errMsg, e);
+        }
+    }
+
+    public static boolean isFlowPath(final InstanceIdentifier<? extends Object> path) {
+        PathArgument pathArg = FlowConfigMapping.getSecondPathArgumentFromPath(path);
+        if (pathArg == null) {
+            return false;
+        }
+        if (pathArg instanceof IdentifiableItem<?,?>) {
+            final Identifiable<?> key = ((IdentifiableItem<?, ? extends Identifiable<?>>) pathArg).getKey();
+            if ((key instanceof FlowKey)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static PathArgument getSecondPathArgumentFromPath(final InstanceIdentifier<? extends Object> path) {
+        if (path != null && path.getPathArguments() != null) {
+            Iterator<PathArgument> iterator = path.getPathArguments().iterator();
+            int deep = 0;
+            while (iterator.hasNext()) {
+                PathArgument pathArg = iterator.next();
+                if (deep == FlowConfigMapping.FLOW_KEY_IDENTIFIER_DEEP) {
+                    return pathArg;
+                }
+                deep++;
+            }
+        }
+        return null;
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend b/opendaylight/md-sal/compatibility/flow-management-compatibility/src/main/java/org/opendaylight/controller/md/frm/compatibility/FlowConfigMapping.xtend
deleted file mode 100644 (file)
index e15b3c6..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.frm.compatibility
-
-import org.opendaylight.controller.forwardingrulesmanager.FlowConfig
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder
-
-import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
-import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*
-import static org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.*
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
-import org.opendaylight.yangtools.yang.binding.Identifiable
-
-class FlowConfigMapping {
-
-    static def toConfigurationFlow(FlowConfig sourceCfg) {
-        val source = flowAdded(sourceCfg.flow);
-        val it = new FlowBuilder();
-        instructions = source.instructions;
-        cookie = source.cookie;
-        hardTimeout = source.hardTimeout
-        idleTimeout = source.idleTimeout
-        match = source.match
-        node = source.node
-        key = new FlowKey(Long.parseLong(sourceCfg.name),node);
-        return it.build();
-    }
-
-    static def toFlowConfig(Flow sourceCfg) {
-        val it = new FlowConfig;
-        name = String.valueOf(sourceCfg.id);
-        node = sourceCfg.node.toADNode();
-
-        return it
-    }
-
-    static def toFlowConfig(InstanceIdentifier<?> identifier) {
-        val it = new FlowConfig()
-        val FlowKey key = ((identifier.path.get(2) as IdentifiableItem<Flow,FlowKey>).key)
-        name = String.valueOf(key.id);
-        node = key.node.toADNode();
-
-        return it;
-    }
-
-    static def boolean isFlowPath(InstanceIdentifier<?> path) {
-        if(path.path.size < 2) return false;
-        if (path.path.get(2) instanceof IdentifiableItem<?,?>) {
-            val IdentifiableItem<?,? extends Identifiable<?>> item = path.path.get(2) as IdentifiableItem<?,? extends Identifiable<?>>;
-            val Identifiable<?> key = item.key;
-            if (key instanceof FlowKey) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.java
new file mode 100644 (file)
index 0000000..a35c3ed
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.compatibility.topology;
+
+import static org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.toAdEdge;
+import static org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.toTopoEdgeUpdate;
+
+import java.util.Map.Entry;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader;
+import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.topology.IPluginOutTopologyService;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TopologyCommitHandler implements DataChangeListener {
+    private static final Logger LOG = LoggerFactory.getLogger(TopologyCommitHandler.class);
+
+    private IPluginOutTopologyService topologyPublisher;
+
+    private final DataProviderService dataService;
+
+    public TopologyCommitHandler(final DataProviderService dataService, final IPluginOutTopologyService topologyPub) {
+        this.topologyPublisher = topologyPub;
+        this.dataService = dataService;
+    }
+
+    @Override
+    public void onDataChanged(final DataChangeEvent<InstanceIdentifier<?>, DataObject> modification) {
+        CopyOnWriteArrayList<TopoEdgeUpdate> msg = new CopyOnWriteArrayList<TopoEdgeUpdate>();
+        try {
+            TypeSafeDataReader reader = TypeSafeDataReader.forReader(dataService);
+            InstanceIdentifier<Topology> topologyPath = InstanceIdentifier.builder(NetworkTopology.class)
+                    .child(Topology.class, new TopologyKey(new TopologyId("flow:1"))).build();
+            Topology topology = reader.readOperationalData(topologyPath);
+
+            for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : modification
+                    .getCreatedOperationalData().entrySet()) {
+                if (entry.getValue() instanceof Link
+                        && modification.getCreatedOperationalData().containsKey(entry.getKey())) {
+                    msg.add(toTopoEdgeUpdate(toAdEdge((Link) entry.getValue(), topology), UpdateType.ADDED, reader));
+                }
+            }
+
+            for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : modification
+                    .getUpdatedOperationalData().entrySet()) {
+                if (entry.getValue() instanceof Link) {
+                    msg.add(toTopoEdgeUpdate(toAdEdge((Link) entry.getValue(), topology), UpdateType.CHANGED, reader));
+                }
+            }
+            for (InstanceIdentifier<? extends DataObject> path : modification.getRemovedOperationalData()) {
+                if (path.getTargetType() == Link.class) {
+                    Link link = (Link) modification.getOriginalOperationalData().get(path);
+                    msg.add(toTopoEdgeUpdate(toAdEdge(link, topology), UpdateType.CHANGED, reader));
+                }
+
+            }
+
+            if (topologyPublisher != null && msg != null && !msg.isEmpty()) {
+                topologyPublisher.edgeUpdate(msg);
+            }
+
+        } catch (Exception e) {
+            LOG.error("Exception caught", e);
+        }
+    }
+
+    protected IPluginOutTopologyService getTopologyPublisher() {
+        return topologyPublisher;
+    }
+
+    protected void setTopologyPublisher(final IPluginOutTopologyService topologyPublisher) {
+        this.topologyPublisher = topologyPublisher;
+    }
+
+}
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyCommitHandler.xtend
deleted file mode 100644 (file)
index fcf86f2..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.compatibility.topology
-
-import com.google.common.collect.FluentIterable
-import java.util.concurrent.CopyOnWriteArrayList
-import org.opendaylight.controller.md.sal.binding.util.TypeSafeDataReader
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.controller.sal.core.UpdateType
-import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
-import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import static extension org.opendaylight.controller.sal.compatibility.topology.TopologyMapping.*
-import org.slf4j.LoggerFactory
-
-class TopologyCommitHandler implements DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> {
-    static val LOG = LoggerFactory.getLogger(TopologyCommitHandler);
-    @Property
-    IPluginOutTopologyService topologyPublisher;
-    
-    @Property
-    DataProviderService dataService;
-    
-    new(DataProviderService dataService) {
-        _topologyPublisher = topologyPublisher
-        _dataService = dataService
-    }
-    
-    override requestCommit(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification) {
-        val msg = new CopyOnWriteArrayList<TopoEdgeUpdate>()
-        try {
-            val reader = TypeSafeDataReader.forReader(dataService)
-            val topologyPath = InstanceIdentifier.builder(NetworkTopology).child(Topology, new TopologyKey(new TopologyId("flow:1"))).toInstance
-            val topology = reader.readOperationalData(topologyPath)
-            val adds = FluentIterable.from(modification.createdOperationalData.entrySet)
-                .filter[value instanceof Link]
-                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED,reader)]
-                .toList
-            val updates = FluentIterable.from(modification.updatedOperationalData.entrySet)
-                .filter[!modification.createdOperationalData.containsKey(key) && (value instanceof Link)]
-                .transform[(value as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.ADDED,reader)] // Evidently the ADSAL does not expect edge 'CHANGED"
-                .toList
-            val removes = FluentIterable.from(modification.removedOperationalData)
-                .transform[reader.readOperationalData(it as InstanceIdentifier<DataObject>)]
-                .filter[it instanceof Link]
-                .transform[(it as Link).toAdEdge(topology).toTopoEdgeUpdate(UpdateType.REMOVED,reader)]
-                .toList
-            msg.addAll(adds)
-            msg.addAll(updates)
-            msg.addAll(removes)
-         } catch (Exception e) {
-            LOG.error("Exception caught",e)
-         }
-        return new TopologyTransaction(modification,topologyPublisher,dataService,msg)
-    }
-}
index 4aef75d9916565dc20c3c18a87149669116f4753..21f2b35f40a82c846df07e7ce05fab2ae540029c 100644 (file)
@@ -15,10 +15,10 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey
 import org.opendaylight.yangtools.yang.binding.DataObject
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link
 import org.slf4j.LoggerFactory
+import org.opendaylight.yangtools.concepts.ListenerRegistration
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener
 
 class TopologyProvider implements AutoCloseable{
     static val LOG = LoggerFactory.getLogger(TopologyProvider);
@@ -30,8 +30,9 @@ class TopologyProvider implements AutoCloseable{
     @Property
     DataProviderService dataService;
     
-    Registration<DataCommitHandler<InstanceIdentifier<? extends DataObject>,DataObject>> commitHandlerRegistration;
-
+    ListenerRegistration<DataChangeListener> listenerRegistration
+    
+    
     def void start() {
 
     }
@@ -40,18 +41,17 @@ class TopologyProvider implements AutoCloseable{
             LOG.error("dataService not set");
             return;
         }
-        commitHandler = new TopologyCommitHandler(dataService)
-        commitHandler.setTopologyPublisher(topologyPublisher)
+        commitHandler = new TopologyCommitHandler(dataService,topologyPublisher);
         val InstanceIdentifier<? extends DataObject> path = InstanceIdentifier.builder(NetworkTopology)
             .child(Topology,new TopologyKey(new TopologyId("flow:1")))
             .child(Link)
             .toInstance();
-        commitHandlerRegistration = dataService.registerCommitHandler(path,commitHandler);
+        listenerRegistration = dataService.registerDataChangeListener(path,commitHandler);
         LOG.info("TopologyProvider started")
     }
     
     override close() throws Exception {
-        commitHandlerRegistration.close
+        listenerRegistration.close
     }
     
     def setTopologyPublisher(IPluginOutTopologyService topologyPublisher) {
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyTransaction.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyTransaction.xtend
deleted file mode 100644 (file)
index 4de78ca..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.compatibility.topology
-
-import java.util.Collections
-import java.util.List
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
-import org.opendaylight.controller.md.sal.common.api.data.DataModification
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
-import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.common.RpcResult
-import org.slf4j.LoggerFactory
-
-class TopologyTransaction implements DataCommitTransaction<InstanceIdentifier<?extends DataObject>, DataObject> {
-    static val LOG = LoggerFactory.getLogger(TopologyTransaction);
-    @Property
-    val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
-    
-    @Property
-    IPluginOutTopologyService topologyPublisher;
-    
-    @Property
-    DataProviderService dataService;
-    @Property
-    List<TopoEdgeUpdate> edgeUpdates;
-    
-    new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,IPluginOutTopologyService topologyPublisher,
-        DataProviderService dataService,List<TopoEdgeUpdate> edgeUpdates) {
-        _modification = modification;
-        _topologyPublisher = topologyPublisher
-        _dataService = dataService
-        _edgeUpdates = edgeUpdates
-    }
-    override finish() throws IllegalStateException {
-        
-        if(topologyPublisher != null && _edgeUpdates != null && !edgeUpdates.empty) {
-            topologyPublisher.edgeUpdate(edgeUpdates)
-        }
-         
-         return new RpcResultTo()
-    }
-    
-    override getModification() {
-        return _modification;
-    }
-    
-    override rollback() throws IllegalStateException {
-        // NOOP
-    }
-}
-class RpcResultTo implements RpcResult<Void> {
-    
-    override getErrors() {
-        return Collections.emptySet
-    }
-    
-    override getResult() {
-        return null;
-    }
-    
-    override isSuccessful() {
-        return true;
-    }
-    
-}
index 40a79033a7d163f3e5ecdd520cc5f938715131aa..1706996ce4a301ef4564ac765032c608c39bea68 100644 (file)
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.eclipse.xtend</groupId>
-      <artifactId>org.eclipse.xtend.lib</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-binding-api</artifactId>
           </instructions>
         </configuration>
       </plugin>
-      <plugin>
-        <groupId>org.eclipse.xtend</groupId>
-        <artifactId>xtend-maven-plugin</artifactId>
-      </plugin>
     </plugins>
   </build>
   <scm>
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.java b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.java
new file mode 100644 (file)
index 0000000..7e4190f
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.inventory.manager;
+
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlowCapableInventoryProvider implements AutoCloseable {
+
+    private final static Logger LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider.class);
+
+    private DataProviderService dataService;
+    private NotificationProviderService notificationService;
+    private Registration<NotificationListener> listenerRegistration;
+    private final NodeChangeCommiter changeCommiter = new NodeChangeCommiter(FlowCapableInventoryProvider.this);
+
+    public void start() {
+        this.listenerRegistration = this.notificationService.registerNotificationListener(this.changeCommiter);
+        LOG.info("Flow Capable Inventory Provider started.");
+    }
+
+    protected DataModificationTransaction startChange() {
+        DataProviderService _dataService = this.dataService;
+        return _dataService.beginTransaction();
+    }
+
+    @Override
+    public void close() {
+        try {
+            LOG.info("Flow Capable Inventory Provider stopped.");
+            if (this.listenerRegistration != null) {
+                this.listenerRegistration.close();
+            }
+        } catch (Exception e) {
+            String errMsg = "Error by stop Flow Capable Inventory Provider.";
+            LOG.error(errMsg, e);
+            throw new RuntimeException(errMsg, e);
+        }
+    }
+
+    public DataProviderService getDataService() {
+        return this.dataService;
+    }
+
+    public void setDataService(final DataProviderService dataService) {
+        this.dataService = dataService;
+    }
+
+    public NotificationProviderService getNotificationService() {
+        return this.notificationService;
+    }
+
+    public void setNotificationService(
+            final NotificationProviderService notificationService) {
+        this.notificationService = notificationService;
+    }
+}
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.xtend b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/FlowCapableInventoryProvider.xtend
deleted file mode 100644 (file)
index ec8da86..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * 
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.inventory.manager
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.yangtools.concepts.Registration
-import org.opendaylight.yangtools.yang.binding.NotificationListener
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.DataObject
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey
-import static extension org.opendaylight.controller.md.inventory.manager.InventoryMapping.*
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
-import org.slf4j.LoggerFactory
-
-class FlowCapableInventoryProvider implements AutoCloseable {
-
-
-    static val LOG = LoggerFactory.getLogger(FlowCapableInventoryProvider);
-
-    @Property
-    DataProviderService dataService;
-
-    @Property
-    NotificationProviderService notificationService;
-    val NodeChangeCommiter changeCommiter = new NodeChangeCommiter(this);
-
-    Registration<NotificationListener> listenerRegistration
-
-    def void start() {
-        listenerRegistration = notificationService.registerNotificationListener(changeCommiter);
-        LOG.info("Flow Capable Inventory Provider started.");
-        
-    }
-
-    protected def startChange() {
-        return dataService.beginTransaction;
-    }
-
-    override close() {
-       LOG.info("Flow Capable Inventory Provider stopped.");
-        listenerRegistration?.close();
-    }
-    
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.java b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.java
new file mode 100644 (file)
index 0000000..6c06088
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.inventory.manager;
+
+import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.osgi.framework.BundleContext;
+
+public class InventoryActivator extends AbstractBindingAwareProvider {
+
+    private static FlowCapableInventoryProvider provider = new FlowCapableInventoryProvider();
+
+    @Override
+    public void onSessionInitiated(final ProviderContext session) {
+        DataProviderService salDataService = session.<DataProviderService> getSALService(DataProviderService.class);
+        NotificationProviderService salNotifiService =
+                session.<NotificationProviderService> getSALService(NotificationProviderService.class);
+        InventoryActivator.provider.setDataService(salDataService);
+        InventoryActivator.provider.setNotificationService(salNotifiService);
+        InventoryActivator.provider.start();
+    }
+
+    @Override
+    protected void stopImpl(final BundleContext context) {
+        InventoryActivator.provider.close();
+    }
+}
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.xtend b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryActivator.xtend
deleted file mode 100644 (file)
index 5d76924..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * 
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.inventory.manager
-
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
-import org.osgi.framework.BundleContext
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService
-
-class InventoryActivator extends AbstractBindingAwareProvider {
-
-    static var FlowCapableInventoryProvider provider = new FlowCapableInventoryProvider();
-
-    override onSessionInitiated(ProviderContext session) {
-        provider.dataService = session.getSALService(DataProviderService)
-        provider.notificationService = session.getSALService(NotificationProviderService)
-        provider.start();
-    }
-
-    override protected stopImpl(BundleContext context) {
-        provider.close();
-    }
-
-}
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.java b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.java
new file mode 100644 (file)
index 0000000..928ae76
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.inventory.manager;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector;
+
+public class InventoryMapping {
+
+    public static FlowCapableNodeConnector toInventoryAugment(final FlowNodeConnector updated) {
+        if ((updated instanceof FlowCapableNodeConnector)) {
+            return ((FlowCapableNodeConnector) updated);
+        }
+        final FlowCapableNodeConnectorBuilder builder = new FlowCapableNodeConnectorBuilder();
+        builder.setAdvertisedFeatures(updated.getAdvertisedFeatures());
+        builder.setConfiguration(updated.getConfiguration());
+        builder.setCurrentFeature(updated.getCurrentFeature());
+        builder.setCurrentSpeed(updated.getCurrentSpeed());
+        builder.setHardwareAddress(updated.getHardwareAddress());
+        builder.setMaximumSpeed(updated.getMaximumSpeed());
+        builder.setName(updated.getName());
+        builder.setPeerFeatures(updated.getPeerFeatures());
+        builder.setPortNumber(updated.getPortNumber());
+        builder.setState(updated.getState());
+        builder.setSupported(updated.getSupported());
+        return builder.build();
+    }
+
+    public static FlowCapableNode toInventoryAugment(final FlowNode source) {
+        if ((source instanceof FlowCapableNode)) {
+            return ((FlowCapableNode) source);
+        }
+        return (new FlowCapableNodeBuilder(source)).build();
+    }
+}
diff --git a/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.xtend b/opendaylight/md-sal/inventory-manager/src/main/java/org/opendaylight/controller/md/inventory/manager/InventoryMapping.xtend
deleted file mode 100644 (file)
index 6f1ef5e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * 
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.md.inventory.manager
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder
-
-class InventoryMapping {
-
-    static def FlowCapableNodeConnector toInventoryAugment(FlowNodeConnector updated) {
-        if (updated instanceof FlowCapableNodeConnector) {
-            return updated as FlowCapableNodeConnector;
-        }
-        val it = new FlowCapableNodeConnectorBuilder();
-        advertisedFeatures = updated.advertisedFeatures
-        configuration = updated.configuration
-        currentFeature = updated.currentFeature
-        currentSpeed = updated.currentSpeed
-        hardwareAddress = updated.hardwareAddress
-        maximumSpeed = updated.maximumSpeed
-        name = updated.name
-        peerFeatures = updated.peerFeatures
-        portNumber = updated.portNumber
-        state = updated.state
-        supported = updated.supported
-        return build();
-    }
-
-    static def FlowCapableNode toInventoryAugment(FlowNode source) {
-        if (source instanceof FlowCapableNode) {
-            return source as FlowCapableNode;
-        }
-        val it = new FlowCapableNodeBuilder(source);
-        return build();
-    }
-
-}
index ebb3de7dcae6d8380b1ad465a63e8900689740c1..03cdf973affae85e390c5b0cd07c445fb737a360 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeCon
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
@@ -39,8 +38,8 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Objects;
 
-@SuppressWarnings("all")
 public class NodeChangeCommiter implements OpendaylightInventoryListener {
+
     private final static Logger LOG = LoggerFactory.getLogger(NodeChangeCommiter.class);
 
     private final FlowCapableInventoryProvider manager;
@@ -75,7 +74,7 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener {
         final NodeConnectorRef ref = connector.getNodeConnectorRef();
         final FlowCapableNodeConnectorUpdated flowConnector = connector
                 .getAugmentation(FlowCapableNodeConnectorUpdated.class);
-        final DataModificationTransaction it = this.getManager().startChange();
+        final DataModificationTransaction it = this.manager.startChange();
         final NodeConnectorBuilder data = new NodeConnectorBuilder(connector);
         NodeConnectorId id = connector.getId();
         NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(id);
@@ -86,12 +85,9 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener {
             data.addAugmentation(FlowCapableNodeConnector.class, augment);
         }
         InstanceIdentifier<? extends Object> value = ref.getValue();
-        String string = value.toString();
-        String plus = ("updating node connector : " + string);
-        NodeChangeCommiter.LOG.debug(plus);
-        InstanceIdentifier<? extends Object> value1 = ref.getValue();
+        NodeChangeCommiter.LOG.debug("updating node connector : {}.", value);
         NodeConnector build = data.build();
-        it.putOperationalData((value1), build);
+        it.putOperationalData((value), build);
         Future<RpcResult<TransactionStatus>> commitResult = it.commit();
         try {
             commitResult.get();
@@ -105,14 +101,9 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener {
     public synchronized void onNodeRemoved(final NodeRemoved node) {
 
         final NodeRef ref = node.getNodeRef();
-        FlowCapableInventoryProvider manager = this.getManager();
-        final DataModificationTransaction it = manager.startChange();
-        InstanceIdentifier<? extends Object> value = ref.getValue();
-        String string = value.toString();
-        String plus = ("removing node : " + string);
-        NodeChangeCommiter.LOG.debug(plus);
-        InstanceIdentifier<? extends Object> value1 = ref.getValue();
-        it.removeOperationalData((value1));
+        final DataModificationTransaction it = this.manager.startChange();
+        NodeChangeCommiter.LOG.debug("removing node : {}", ref.getValue());
+        it.removeOperationalData((ref.getValue()));
         Future<RpcResult<TransactionStatus>> commitResult = it.commit();
         try {
             commitResult.get();
@@ -127,19 +118,15 @@ public class NodeChangeCommiter implements OpendaylightInventoryListener {
         final NodeRef ref = node.getNodeRef();
         final FlowCapableNodeUpdated flowNode = node
                 .<FlowCapableNodeUpdated> getAugmentation(FlowCapableNodeUpdated.class);
-        FlowCapableInventoryProvider manager = this.getManager();
-        final DataModificationTransaction it = manager.startChange();
-        NodeBuilder nodeBuilder = new NodeBuilder(node);
-        final NodeBuilder data = nodeBuilder;
-        NodeId id = node.getId();
-        NodeKey nodeKey = new NodeKey(id);
-        data.setKey(nodeKey);
+        final DataModificationTransaction it = this.manager.startChange();
+        final NodeBuilder nodeBuilder = new NodeBuilder(node);
+        nodeBuilder.setKey(new NodeKey(node.getId()));
         boolean equals = Objects.equal(flowNode, null);
         if (equals) {
             return;
         }
         final FlowCapableNode augment = InventoryMapping.toInventoryAugment(flowNode);
-        data.addAugmentation(FlowCapableNode.class, augment);
+        nodeBuilder.addAugmentation(FlowCapableNode.class, augment);
         InstanceIdentifier<? extends Object> value = ref.getValue();
         InstanceIdentifierBuilder<Node> builder = InstanceIdentifier.<Node> builder(((InstanceIdentifier<Node>) value));
         InstanceIdentifierBuilder<FlowCapableNode> augmentation = builder
index 85dc7118f4badad53ecdf8f568ff7ac6e916508b..7ea4d4e09fc1590557b339b65ce78a8fb54f25c6 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -39,6 +40,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMa
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.AugmentationSchemaProxy;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
@@ -514,7 +516,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper
             DataNodeContainerModificationStrategy<AugmentationSchema> {
 
         protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) {
-            super(schema, AugmentationNode.class);
+            super(createAugmentProxy(schema,resolved), AugmentationNode.class);
             // FIXME: Use resolved children instead of unresolved.
 
         }
@@ -734,4 +736,12 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper
 
     }
 
+    public static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) {
+        Set<DataSchemaNode> realChildSchemas = new HashSet<>();
+        for(DataSchemaNode augChild : schema.getChildNodes()) {
+            realChildSchemas.add(resolved.getDataChildByName(augChild.getQName()));
+        }
+        return new AugmentationSchemaProxy(schema, realChildSchemas);
+    }
+
 }
index a0bd99c5d2cc3dfc4b822125f43bdf104c8663ba..f1901d711259f1907aeb9f94817ffbf84694fffd 100644 (file)
@@ -588,7 +588,11 @@ class RestconfImpl implements RestconfService {
         }
         if (node instanceof CompositeNodeWrapper) {
             if ((node  as CompositeNodeWrapper).changeAllowed) {
-                normalizeNode(node as CompositeNodeWrapper, schema, null, mountPoint)
+                try {
+                    normalizeNode(node as CompositeNodeWrapper, schema, null, mountPoint)
+                } catch (NumberFormatException e) {
+                    throw new ResponseException(BAD_REQUEST,e.message)
+                }
             }
             return (node as CompositeNodeWrapper).unwrap()
         }
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/CodecsExceptionsCatchingTest.java
new file mode 100644 (file)
index 0000000..767aaf3
--- /dev/null
@@ -0,0 +1,59 @@
+package org.opendaylight.controller.sal.restconf.impl.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileNotFoundException;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.JerseyTest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
+import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
+import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
+import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
+import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+
+public class CodecsExceptionsCatchingTest extends JerseyTest {
+
+    private static RestconfImpl restConf;
+    private static ControllerContext controllerContext = ControllerContext.getInstance();
+
+    @BeforeClass
+    public static void init() throws FileNotFoundException {
+        restConf = RestconfImpl.getInstance();
+        controllerContext = ControllerContext.getInstance();
+        SchemaContext schemaContext = TestUtils.loadSchemaContext("/decoding-exception/yang");
+        controllerContext.setGlobalSchema(schemaContext);
+        restConf.setControllerContext(controllerContext);
+    }
+
+    @Override
+    protected Application configure() {
+        /* enable/disable Jersey logs to console */
+        // enable(TestProperties.LOG_TRAFFIC);
+        // enable(TestProperties.DUMP_ENTITY);
+        // enable(TestProperties.RECORD_LOG_LEVEL);
+        // set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
+        ResourceConfig resourceConfig = new ResourceConfig();
+        resourceConfig = resourceConfig.registerInstances(restConf, StructuredDataToXmlProvider.INSTANCE,
+                StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
+                JsonToCompositeNodeProvider.INSTANCE);
+        return resourceConfig;
+    }
+
+    @Test
+    public void StringToNumberConversionError() {
+        Response response = target("/config/number:cont").request(MediaType.APPLICATION_XML).put(
+                Entity.entity("<cont xmlns=\"number\"><lf>3f</lf></cont>", MediaType.APPLICATION_XML));
+        String exceptionMessage = response.readEntity(String.class);
+        assertTrue(exceptionMessage.contains("Incorrect lexical representation of Integer value: 3f"));
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/decoding-exception/yang/number.yang
new file mode 100644 (file)
index 0000000..c463882
--- /dev/null
@@ -0,0 +1,17 @@
+ module number {
+
+   namespace "number";
+   prefix "number";
+
+   revision 2014-04-24 {
+   }
+
+    
+
+    container cont {
+        leaf lf {
+            type uint8;
+        }
+        
+    }    
+ }