Bug 6949 / Bug 6950 - Implementation of start-time and stop-time
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / common / wrapper / services / ServicesWrapperImpl.java
1 /*
2  * Copyright (c) 2016 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.restconf.common.wrapper.services;
9
10 import javax.ws.rs.Path;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.UriInfo;
13 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
14 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
15 import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
16 import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
17 import org.opendaylight.restconf.handlers.DOMDataBrokerHandler;
18 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
19 import org.opendaylight.restconf.handlers.NotificationServiceHandler;
20 import org.opendaylight.restconf.handlers.RpcServiceHandler;
21 import org.opendaylight.restconf.handlers.SchemaContextHandler;
22 import org.opendaylight.restconf.handlers.TransactionChainHandler;
23 import org.opendaylight.restconf.rest.services.api.BaseServicesWrapper;
24 import org.opendaylight.restconf.rest.services.api.RestconfModulesService;
25 import org.opendaylight.restconf.rest.services.api.RestconfOperationsService;
26 import org.opendaylight.restconf.rest.services.api.RestconfSchemaService;
27 import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
28 import org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceImpl;
29 import org.opendaylight.restconf.rest.services.impl.RestconfOperationsServiceImpl;
30 import org.opendaylight.restconf.rest.services.impl.RestconfSchemaServiceImpl;
31 import org.opendaylight.restconf.rest.services.impl.RestconfStreamsServiceImpl;
32 import org.opendaylight.restconf.restful.services.api.RestconfDataService;
33 import org.opendaylight.restconf.restful.services.api.RestconfInvokeOperationsService;
34 import org.opendaylight.restconf.restful.services.api.RestconfStreamsSubscriptionService;
35 import org.opendaylight.restconf.restful.services.api.TransactionServicesWrapper;
36 import org.opendaylight.restconf.restful.services.impl.RestconfDataServiceImpl;
37 import org.opendaylight.restconf.restful.services.impl.RestconfInvokeOperationsServiceImpl;
38 import org.opendaylight.restconf.restful.services.impl.RestconfStreamsSubscriptionServiceImpl;
39
40 /**
41  * Wrapper for services:
42  * <ul>
43  * <li>{@link BaseServicesWrapper}
44  * <li>{@link TransactionServicesWrapper}
45  * </ul>
46  *
47  */
48 @Path("/")
49 public class ServicesWrapperImpl implements BaseServicesWrapper, TransactionServicesWrapper {
50
51     private RestconfDataService delegRestconfDataService;
52     private RestconfInvokeOperationsService delegRestconfInvokeOpsService;
53     private RestconfStreamsSubscriptionService delegRestconfSubscrService;
54     private RestconfModulesService delegRestModService;
55     private RestconfOperationsService delegRestOpsService;
56     private RestconfStreamsService delegRestStrsService;
57     private RestconfSchemaService delegRestSchService;
58
59     private ServicesWrapperImpl() {
60     }
61
62     private static class InstanceHolder {
63         public static final ServicesWrapperImpl INSTANCE = new ServicesWrapperImpl();
64     }
65
66     public static ServicesWrapperImpl getInstance() {
67         return InstanceHolder.INSTANCE;
68     }
69
70     @Override
71     public NormalizedNodeContext getModules(final UriInfo uriInfo) {
72         return this.delegRestModService.getModules(uriInfo);
73     }
74
75     @Override
76     public NormalizedNodeContext getModules(final String identifier, final UriInfo uriInfo) {
77         return this.delegRestModService.getModules(identifier, uriInfo);
78     }
79
80     @Override
81     public NormalizedNodeContext getModule(final String identifier, final UriInfo uriInfo) {
82         return this.delegRestModService.getModule(identifier, uriInfo);
83     }
84
85     @Override
86     public NormalizedNodeContext getOperations(final UriInfo uriInfo) {
87         return this.delegRestOpsService.getOperations(uriInfo);
88     }
89
90     @Override
91     public NormalizedNodeContext getOperations(final String identifier, final UriInfo uriInfo) {
92         return this.delegRestOpsService.getOperations(identifier, uriInfo);
93     }
94
95     @Override
96     public NormalizedNodeContext getAvailableStreams(final UriInfo uriInfo) {
97         return this.delegRestStrsService.getAvailableStreams(uriInfo);
98     }
99
100     @Override
101     public SchemaExportContext getSchema(final String mountAndModuleId) {
102         return this.delegRestSchService.getSchema(mountAndModuleId);
103     }
104
105     @Override
106     public Response readData(final UriInfo uriInfo) {
107         return this.delegRestconfDataService.readData(uriInfo);
108     }
109
110     @Override
111     public Response readData(final String identifier, final UriInfo uriInfo) {
112         return this.delegRestconfDataService.readData(identifier, uriInfo);
113     }
114
115     @Override
116     public Response putData(final String identifier, final NormalizedNodeContext payload) {
117         return this.delegRestconfDataService.putData(identifier, payload);
118     }
119
120     @Override
121     public Response postData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
122         return this.delegRestconfDataService.postData(identifier, payload, uriInfo);
123     }
124
125     @Override
126     public Response postData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
127         return this.delegRestconfDataService.postData(payload, uriInfo);
128     }
129
130     @Override
131     public Response deleteData(final String identifier) {
132         return this.delegRestconfDataService.deleteData(identifier);
133     }
134
135     @Override
136     public PATCHStatusContext patchData(final String identifier, final PATCHContext context, final UriInfo uriInfo) {
137         return this.delegRestconfDataService.patchData(identifier, context, uriInfo);
138     }
139
140     @Override
141     public PATCHStatusContext patchData(final PATCHContext context, final UriInfo uriInfo) {
142         return this.delegRestconfDataService.patchData(context, uriInfo);
143     }
144
145     @Override
146     public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload,
147                                            final UriInfo uriInfo) {
148         return this.delegRestconfInvokeOpsService.invokeRpc(identifier, payload, uriInfo);
149     }
150
151     @Override
152     public NormalizedNodeContext subscribeToStream(final String identifier, final UriInfo uriInfo) {
153         return this.delegRestconfSubscrService.subscribeToStream(identifier, uriInfo);
154     }
155
156     public void setHandlers(final SchemaContextHandler schemaCtxHandler,
157                             final DOMMountPointServiceHandler domMountPointServiceHandler,
158                             final TransactionChainHandler transactionChainHandler,
159                             final DOMDataBrokerHandler domDataBrokerHandler,
160             final RpcServiceHandler rpcServiceHandler, final NotificationServiceHandler notificationServiceHandler) {
161         this.delegRestModService = new RestconfModulesServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
162         this.delegRestOpsService = new RestconfOperationsServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
163         this.delegRestSchService = new RestconfSchemaServiceImpl(schemaCtxHandler, domMountPointServiceHandler);
164         this.delegRestStrsService = new RestconfStreamsServiceImpl(schemaCtxHandler);
165         this.delegRestconfDataService = new RestconfDataServiceImpl(schemaCtxHandler, transactionChainHandler,
166                 domMountPointServiceHandler);
167         this.delegRestconfInvokeOpsService = new RestconfInvokeOperationsServiceImpl(rpcServiceHandler,
168                 schemaCtxHandler);
169         this.delegRestconfSubscrService =
170                 new RestconfStreamsSubscriptionServiceImpl(domDataBrokerHandler, notificationServiceHandler,
171                         schemaCtxHandler);
172     }
173 }