76ffdb4689f7a5570f0e74aa0614047a120ba45e
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / netconf / sal / rest / impl / AbstractIdentifierAwareJaxRsProvider.java
1 /*
2  * Copyright (c) 2014, 2015 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
9 package org.opendaylight.netconf.sal.rest.impl;
10
11 import javax.ws.rs.core.Context;
12 import javax.ws.rs.core.Request;
13 import javax.ws.rs.core.UriInfo;
14 import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
15 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
16 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
17
18 /**
19  * JAX-RS Provider.
20  *
21  * @deprecated This class will be replaced by AbstractIdentifierAwareJaxRsProvider in restconf-nb-rfc8040
22  */
23 @Deprecated
24 public class AbstractIdentifierAwareJaxRsProvider {
25
26     private static final String POST = "POST";
27
28     @Context
29     private UriInfo uriInfo;
30
31     @Context
32     private Request request;
33
34     private final ControllerContext controllerContext;
35
36     protected AbstractIdentifierAwareJaxRsProvider(final ControllerContext controllerContext) {
37         this.controllerContext = controllerContext;
38     }
39
40     protected final String getIdentifier() {
41         return uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
42     }
43
44     protected InstanceIdentifierContext getInstanceIdentifierContext() {
45         return controllerContext.toInstanceIdentifier(getIdentifier());
46     }
47
48     protected UriInfo getUriInfo() {
49         return uriInfo;
50     }
51
52     protected boolean isPost() {
53         return POST.equals(request.getMethod());
54     }
55
56     protected ControllerContext getControllerContext() {
57         return controllerContext;
58     }
59
60     Request getRequest() {
61         return request;
62     }
63 }