Bug 6664 - upgrade draft15 to draft16 - renaming
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / utils / patch / Draft16AbstractIdentifierAwareJaxRsProvider.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
9 package org.opendaylight.restconf.utils.patch;
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 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
18
19 public class Draft16AbstractIdentifierAwareJaxRsProvider {
20
21     private static final String POST = "POST";
22
23     @Context
24     private UriInfo uriInfo;
25
26     @Context
27     private Request request;
28
29     protected final String getIdentifier() {
30         return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
31     }
32
33     protected InstanceIdentifierContext<?> getInstanceIdentifierContext() {
34         return ParserIdentifier.toInstanceIdentifier(getIdentifier(),
35                 ControllerContext.getInstance().getGlobalSchema());
36     }
37
38     protected UriInfo getUriInfo() {
39         return this.uriInfo;
40     }
41
42     protected boolean isPost() {
43         return POST.equals(this.request.getMethod());
44     }
45 }