2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.restconf.jersey.providers;
11 import com.google.common.base.Optional;
12 import javax.ws.rs.core.Context;
13 import javax.ws.rs.core.Request;
14 import javax.ws.rs.core.UriInfo;
15 import org.opendaylight.netconf.sal.rest.api.RestconfConstants;
16 import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
17 import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
18 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
20 public class AbstractIdentifierAwareJaxRsProvider {
22 private static final String POST = "POST";
25 private UriInfo uriInfo;
28 private Request request;
30 protected final String getIdentifier() {
31 return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
34 protected InstanceIdentifierContext<?> getInstanceIdentifierContext() {
35 return ParserIdentifier.toInstanceIdentifier(getIdentifier(),
36 ControllerContext.getInstance().getGlobalSchema(), Optional.absent());
39 protected UriInfo getUriInfo() {
43 protected boolean isPost() {
44 return POST.equals(this.request.getMethod());
47 void setUriInfo(final UriInfo uriInfo) {
48 this.uriInfo = uriInfo;
51 void setRequest(final Request request) {
52 this.request = request;