BUG 274 REST response instead of NumberFormatException
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / topology / TopologyTransaction.xtend
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.compatibility.topology
9
10 import java.util.Collections
11 import java.util.List
12 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction
13 import org.opendaylight.controller.md.sal.common.api.data.DataModification
14 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
15 import org.opendaylight.controller.sal.topology.IPluginOutTopologyService
16 import org.opendaylight.controller.sal.topology.TopoEdgeUpdate
17 import org.opendaylight.yangtools.yang.binding.DataObject
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
19 import org.opendaylight.yangtools.yang.common.RpcResult
20 import org.slf4j.LoggerFactory
21
22 class TopologyTransaction implements DataCommitTransaction<InstanceIdentifier<?extends DataObject>, DataObject> {
23     static val LOG = LoggerFactory.getLogger(TopologyTransaction);
24     @Property
25     val DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification;
26     
27     @Property
28     IPluginOutTopologyService topologyPublisher;
29     
30     @Property
31     DataProviderService dataService;
32     @Property
33     List<TopoEdgeUpdate> edgeUpdates;
34     
35     new(DataModification<InstanceIdentifier<? extends DataObject>, DataObject> modification,IPluginOutTopologyService topologyPublisher,
36         DataProviderService dataService,List<TopoEdgeUpdate> edgeUpdates) {
37         _modification = modification;
38         _topologyPublisher = topologyPublisher
39         _dataService = dataService
40         _edgeUpdates = edgeUpdates
41     }
42     override finish() throws IllegalStateException {
43         
44         if(topologyPublisher != null && _edgeUpdates != null && !edgeUpdates.empty) {
45             topologyPublisher.edgeUpdate(edgeUpdates)
46         }
47          
48          return new RpcResultTo()
49     }
50     
51     override getModification() {
52         return _modification;
53     }
54     
55     override rollback() throws IllegalStateException {
56         // NOOP
57     }
58 }
59 class RpcResultTo implements RpcResult<Void> {
60     
61     override getErrors() {
62         return Collections.emptySet
63     }
64     
65     override getResult() {
66         return null;
67     }
68     
69     override isSuccessful() {
70         return true;
71     }
72     
73 }