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.RestConnectorProvider;
19 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
21 public class AbstractIdentifierAwareJaxRsProvider {
23 private static final String POST = "POST";
26 private UriInfo uriInfo;
29 private Request request;
31 protected final String getIdentifier() {
32 return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
35 protected InstanceIdentifierContext<?> getInstanceIdentifierContext() {
36 return ParserIdentifier.toInstanceIdentifier(
38 ControllerContext.getInstance().getGlobalSchema(),
39 Optional.of(RestConnectorProvider.getMountPointService()));
42 protected UriInfo getUriInfo() {
46 protected boolean isPost() {
47 return POST.equals(this.request.getMethod());
50 void setUriInfo(final UriInfo uriInfo) {
51 this.uriInfo = uriInfo;
54 void setRequest(final Request request) {
55 this.request = request;