Cleanup: Remove passing around of DataPersistenceProvider
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / main / java / org / opendaylight / controller / sal / rest / impl / AbstractIdentifierAwareJaxRsProvider.java
1 package org.opendaylight.controller.sal.rest.impl;
2
3 import com.google.common.base.Optional;
4 import javax.ws.rs.core.Context;
5 import javax.ws.rs.core.Request;
6 import javax.ws.rs.core.UriInfo;
7 import org.opendaylight.controller.sal.rest.api.RestconfConstants;
8 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
9 import org.opendaylight.controller.sal.restconf.impl.InstanceIdentifierContext;
10
11 public class AbstractIdentifierAwareJaxRsProvider {
12
13     private static final String POST = "POST";
14
15     @Context
16     private UriInfo uriInfo;
17
18     @Context
19     private Request request;
20
21     protected final String getIdentifier() {
22         return uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER);
23     }
24
25     protected final Optional<InstanceIdentifierContext> getIdentifierWithSchema() {
26         return Optional.of(getInstanceIdentifierContext());
27     }
28
29     protected InstanceIdentifierContext getInstanceIdentifierContext() {
30         return ControllerContext.getInstance().toInstanceIdentifier(getIdentifier());
31     }
32
33     protected UriInfo getUriInfo() {
34         return uriInfo;
35     }
36
37     protected boolean isPost() {
38         return POST.equals(request.getMethod());
39     }
40 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.