Bug 6848 - repackage providers for jersey+create xml
[netconf.git] / restconf / sal-rest-connector / 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.netconf.sal.restconf.impl.InstanceIdentifierContext;
17
18 /**
19  * @deprecated This class will be replaced by
20  *             {@link org.opendaylight.restconf.jersey.providers.AbstractIdentifierAwareJaxRsProvider}
21  */
22 @Deprecated
23 public class AbstractIdentifierAwareJaxRsProvider {
24
25     private static final String POST = "POST";
26
27     @Context
28     private UriInfo uriInfo;
29
30     @Context
31     private Request request;
32
33     protected final String getIdentifier() {
34         return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
35     }
36
37     protected InstanceIdentifierContext<?> getInstanceIdentifierContext() {
38         return ControllerContext.getInstance().toInstanceIdentifier(getIdentifier());
39     }
40
41     protected UriInfo getUriInfo() {
42         return this.uriInfo;
43     }
44
45     protected boolean isPost() {
46         return POST.equals(this.request.getMethod());
47     }
48
49     Request getRequest() {
50         return this.request;
51     }
52 }