Split Restconf implementations (draft02 and RFC) - Prepare modules
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / restful / utils / RestconfStreamsConstants.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 package org.opendaylight.restconf.restful.utils;
9
10 import com.google.common.collect.ImmutableSet;
11 import java.net.URI;
12 import java.text.ParseException;
13 import java.util.Date;
14 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
17 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
18 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
19 import org.opendaylight.restconf.utils.RestconfConstants;
20 import org.opendaylight.restconf.utils.parser.builder.ParserBuilderConstants;
21 import org.opendaylight.yangtools.yang.common.QName;
22 import org.opendaylight.yangtools.yang.common.QNameModule;
23 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 /**
29  * Constants for streams.
30  *
31  */
32 public final class RestconfStreamsConstants {
33
34     private static final Logger LOG = LoggerFactory.getLogger(RestconfStreamsConstants.class);
35
36     public static final String SAL_REMOTE_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote";
37
38     public static final String DATASTORE_PARAM_NAME = "datastore";
39
40     private static final URI NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT = URI.create("urn:sal:restconf:event:subscription");
41
42     public static final QNameModule SAL_REMOTE_AUGMENT;
43
44     static {
45         final Date eventSubscriptionAugRevision;
46         try {
47             eventSubscriptionAugRevision = SimpleDateFormatUtil.getRevisionFormat().parse("2014-07-08");
48         } catch (final ParseException e) {
49             final String errMsg = "It wasn't possible to convert revision date of sal-remote-augment to date";
50             LOG.debug(errMsg);
51             throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
52         }
53         SAL_REMOTE_AUGMENT = QNameModule.create(NAMESPACE_EVENT_SUBSCRIPTION_AUGMENT, eventSubscriptionAugRevision)
54                 .intern();
55     }
56
57     public static final AugmentationIdentifier SAL_REMOTE_AUG_IDENTIFIER = new AugmentationIdentifier(
58         ImmutableSet.of(QName.create(SAL_REMOTE_AUGMENT, "scope"), QName.create(SAL_REMOTE_AUGMENT, "datastore"),
59             QName.create(SAL_REMOTE_AUGMENT, "notification-output-type")));
60
61     public static final DataChangeScope DEFAULT_SCOPE = DataChangeScope.BASE;
62
63     public static final LogicalDatastoreType DEFAULT_DS = LogicalDatastoreType.CONFIGURATION;
64
65     public static final String SCOPE_PARAM_NAME = "scope";
66
67     public static final char EQUAL = ParserBuilderConstants.Deserializer.EQUAL;
68
69     public static final String DS_URI = RestconfConstants.SLASH + DATASTORE_PARAM_NAME + EQUAL;
70
71     public static final String SCOPE_URI = RestconfConstants.SLASH + SCOPE_PARAM_NAME + EQUAL;
72
73     public static final int NOTIFICATION_PORT = 8181;
74
75     public static final String SCHEMA_SUBSCIBRE_URI = "ws";
76
77     public static final CharSequence DATA_SUBSCR = "data-change-event-subscription";
78     public static final CharSequence CREATE_DATA_SUBSCR = "create-" + DATA_SUBSCR;
79
80     public static final CharSequence NOTIFICATION_STREAM = "notification-stream";
81     public static final CharSequence CREATE_NOTIFICATION_STREAM = "create-" + NOTIFICATION_STREAM;
82
83     public static final String STREAMS_PATH = "ietf-restconf-monitoring:restconf-state/streams";
84     public static final String STREAM_PATH_PART = "/stream=";
85     public static final String STREAM_PATH = STREAMS_PATH + STREAM_PATH_PART;
86     public static final String STREAM_ACCESS_PATH_PART = "/access=";
87     public static final String STREAM_LOCATION_PATH_PART = "/location";
88
89     private RestconfStreamsConstants() {
90         throw new UnsupportedOperationException("Util class.");
91     }
92
93 }