Fix license header violations in sal-rest-connector
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / 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.controller.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.controller.sal.rest.api.RestconfConstants;
15 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
16 import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
17
18 public class AbstractIdentifierAwareJaxRsProvider {
19
20     private static final String POST = "POST";
21
22     @Context
23     private UriInfo uriInfo;
24
25     @Context
26     private Request request;
27
28     protected final String getIdentifier() {
29         return uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
30     }
31
32     protected InstanceIdentifierContext<?> getInstanceIdentifierContext() {
33         return ControllerContext.getInstance().toInstanceIdentifier(getIdentifier());
34     }
35
36     protected UriInfo getUriInfo() {
37         return uriInfo;
38     }
39
40     protected boolean isPost() {
41         return POST.equals(request.getMethod());
42     }
43 }