Priyanka B
Committed by Gerrit Code Review

[ONOS-4945] PCE Json fix

Change-Id: I7f2545931dd3c57762985c122748d8c35233b0a7
Showing 19 changed files with 159 additions and 45 deletions
...@@ -69,11 +69,6 @@ ...@@ -69,11 +69,6 @@
69 <scope>test</scope> 69 <scope>test</scope>
70 </dependency> 70 </dependency>
71 <dependency> 71 <dependency>
72 - <groupId>org.easymock</groupId>
73 - <artifactId>easymock</artifactId>
74 - <scope>test</scope>
75 - </dependency>
76 - <dependency>
77 <groupId>org.onosproject</groupId> 72 <groupId>org.onosproject</groupId>
78 <artifactId>onlab-osgi</artifactId> 73 <artifactId>onlab-osgi</artifactId>
79 <classifier>tests</classifier> 74 <classifier>tests</classifier>
...@@ -91,11 +86,6 @@ ...@@ -91,11 +86,6 @@
91 <version>${project.version}</version> 86 <version>${project.version}</version>
92 </dependency> 87 </dependency>
93 <dependency> 88 <dependency>
94 - <groupId>org.onosproject</groupId>
95 - <artifactId>onlab-rest</artifactId>
96 - <version>${project.version}</version>
97 - </dependency>
98 - <dependency>
99 <groupId>javax.ws.rs</groupId> 89 <groupId>javax.ws.rs</groupId>
100 <artifactId>jsr311-api</artifactId> 90 <artifactId>jsr311-api</artifactId>
101 <version>1.1.1</version> 91 <version>1.1.1</version>
...@@ -109,31 +99,12 @@ ...@@ -109,31 +99,12 @@
109 <artifactId>jackson-annotations</artifactId> 99 <artifactId>jackson-annotations</artifactId>
110 </dependency> 100 </dependency>
111 <dependency> 101 <dependency>
112 - <groupId>org.glassfish.jersey.containers</groupId>
113 - <artifactId>jersey-container-servlet</artifactId>
114 - </dependency>
115 - <dependency>
116 - <groupId>org.glassfish.jersey.test-framework</groupId>
117 - <artifactId>jersey-test-framework-core</artifactId>
118 - <scope>test</scope>
119 - </dependency>
120 - <dependency>
121 - <groupId>org.glassfish.jersey.test-framework.providers</groupId>
122 - <artifactId>jersey-test-framework-provider-jetty</artifactId>
123 - <scope>test</scope>
124 - </dependency>
125 - <dependency>
126 <groupId>org.onosproject</groupId> 102 <groupId>org.onosproject</groupId>
127 <artifactId>onos-incubator-api</artifactId> 103 <artifactId>onos-incubator-api</artifactId>
128 <version>${project.version}</version> 104 <version>${project.version}</version>
129 </dependency> 105 </dependency>
130 <dependency> 106 <dependency>
131 <groupId>org.onosproject</groupId> 107 <groupId>org.onosproject</groupId>
132 - <artifactId>onlab-misc</artifactId>
133 - <version>${project.version}</version>
134 - </dependency>
135 - <dependency>
136 - <groupId>org.onosproject</groupId>
137 <artifactId>onos-app-pcep-api</artifactId> 108 <artifactId>onos-app-pcep-api</artifactId>
138 <version>${project.version}</version> 109 <version>${project.version}</version>
139 </dependency> 110 </dependency>
......
...@@ -247,12 +247,12 @@ public final class DefaultPcePath implements PcePath { ...@@ -247,12 +247,12 @@ public final class DefaultPcePath implements PcePath {
247 // LSP type 247 // LSP type
248 String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE); 248 String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE);
249 if (lspType != null) { 249 if (lspType != null) {
250 - this.lspType = LspType.values()[Integer.valueOf(lspType) - 1]; 250 + this.lspType = LspType.values()[LspType.valueOf(lspType).type()];
251 } 251 }
252 // Cost type 252 // Cost type
253 String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE); 253 String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE);
254 if (costType != null) { 254 if (costType != null) {
255 - this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(costType) - 1]); 255 + this.costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
256 } 256 }
257 // Bandwidth 257 // Bandwidth
258 String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH); 258 String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH);
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016-2017 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +<project xmlns="http://maven.apache.org/POM/4.0.0"
18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20 + <modelVersion>4.0.0</modelVersion>
21 +
22 + <parent>
23 + <groupId>org.onosproject</groupId>
24 + <artifactId>onos-pce</artifactId>
25 + <version>1.6.1-SNAPSHOT</version>
26 + <relativePath>../pom.xml</relativePath>
27 + </parent>
28 +
29 + <artifactId>onos-app-pcerest</artifactId>
30 + <packaging>bundle</packaging>
31 + <properties>
32 + <web.context>/onos/pce</web.context>
33 + <onos.app.name>org.onosproject.pcerest</onos.app.name>
34 + <onos.app.title>PCE REST application</onos.app.title>
35 + <onos.app.category>Utility</onos.app.category>
36 + <onos.app.url>https://wiki.onosproject.org/display/ONOS/</onos.app.url>
37 + <onos.app.readme>RESTCONF for PCE.</onos.app.readme>
38 + </properties>
39 + <description>PCE REST application</description>
40 +
41 + <dependencies>
42 + <dependency>
43 + <groupId>javax.ws.rs</groupId>
44 + <artifactId>javax.ws.rs-api</artifactId>
45 + <version>2.0.1</version>
46 + </dependency>
47 + <dependency>
48 + <groupId>org.onosproject</groupId>
49 + <artifactId>onlab-junit</artifactId>
50 + <scope>test</scope>
51 + </dependency>
52 + <dependency>
53 + <groupId>org.onosproject</groupId>
54 + <artifactId>onos-core-serializers</artifactId>
55 + <version>${project.version}</version>
56 + </dependency>
57 + <dependency>
58 + <groupId>org.easymock</groupId>
59 + <artifactId>easymock</artifactId>
60 + <scope>test</scope>
61 + </dependency>
62 + <dependency>
63 + <groupId>org.onosproject</groupId>
64 + <artifactId>onlab-junit</artifactId>
65 + <scope>test</scope>
66 + </dependency>
67 + <dependency>
68 + <groupId>org.onosproject</groupId>
69 + <artifactId>onlab-osgi</artifactId>
70 + <classifier>tests</classifier>
71 + <scope>test</scope>
72 + </dependency>
73 + <dependency>
74 + <groupId>org.onosproject</groupId>
75 + <artifactId>onlab-misc</artifactId>
76 + <version>${project.version}</version>
77 + </dependency>
78 + <dependency>
79 + <groupId>org.glassfish.jersey.containers</groupId>
80 + <artifactId>jersey-container-servlet</artifactId>
81 + </dependency>
82 + <dependency>
83 + <groupId>org.glassfish.jersey.test-framework</groupId>
84 + <artifactId>jersey-test-framework-core</artifactId>
85 + <scope>test</scope>
86 + </dependency>
87 + <dependency>
88 + <groupId>org.glassfish.jersey.test-framework.providers</groupId>
89 + <artifactId>jersey-test-framework-provider-jetty</artifactId>
90 + <scope>test</scope>
91 + </dependency>
92 + <dependency>
93 + <groupId>org.onosproject</groupId>
94 + <artifactId>onlab-rest</artifactId>
95 + <version>${project.version}</version>
96 + </dependency>
97 + <dependency>
98 + <groupId>org.onosproject</groupId>
99 + <artifactId>onos-incubator-api</artifactId>
100 + <version>${project.version}</version>
101 + </dependency>
102 + <dependency>
103 + <groupId>org.onosproject</groupId>
104 + <artifactId>onos-app-pce</artifactId>
105 + <version>${project.version}</version>
106 + </dependency>
107 +
108 + </dependencies>
109 + <build>
110 + <plugins>
111 + <plugin>
112 + <groupId>org.apache.felix</groupId>
113 + <artifactId>maven-bundle-plugin</artifactId>
114 + <extensions>true</extensions>
115 + <configuration>
116 + <instructions>
117 + <_wab>src/main/resources/</_wab>
118 + <Bundle-SymbolicName>
119 + ${project.groupId}.${project.artifactId}
120 + </Bundle-SymbolicName>
121 + <Import-Package>
122 + *,org.glassfish.jersey.servlet
123 + </Import-Package>
124 + <Web-ContextPath>${web.context}</Web-ContextPath>
125 + </instructions>
126 + </configuration>
127 + </plugin>
128 + </plugins>
129 + </build>
130 +</project>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import org.apache.felix.scr.annotations.Activate; 18 import org.apache.felix.scr.annotations.Activate;
19 import org.apache.felix.scr.annotations.Component; 19 import org.apache.felix.scr.annotations.Component;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import static com.google.common.base.Preconditions.checkNotNull; 18 import static com.google.common.base.Preconditions.checkNotNull;
19 19
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import static javax.ws.rs.core.Response.Status.OK; 18 import static javax.ws.rs.core.Response.Status.OK;
19 import static org.onlab.util.Tools.nullIsNotFound; 19 import static org.onlab.util.Tools.nullIsNotFound;
...@@ -69,6 +69,7 @@ public class PcePathWebResource extends AbstractWebResource { ...@@ -69,6 +69,7 @@ public class PcePathWebResource extends AbstractWebResource {
69 */ 69 */
70 @GET 70 @GET
71 @Produces(MediaType.APPLICATION_JSON) 71 @Produces(MediaType.APPLICATION_JSON)
72 + @Consumes(MediaType.APPLICATION_JSON)
72 public Response queryAllPath() { 73 public Response queryAllPath() {
73 log.debug("Query all paths."); 74 log.debug("Query all paths.");
74 Iterable<Tunnel> tunnels = get(PceService.class).queryAllPath(); 75 Iterable<Tunnel> tunnels = get(PceService.class).queryAllPath();
...@@ -92,6 +93,7 @@ public class PcePathWebResource extends AbstractWebResource { ...@@ -92,6 +93,7 @@ public class PcePathWebResource extends AbstractWebResource {
92 @GET 93 @GET
93 @Path("{path_id}") 94 @Path("{path_id}")
94 @Produces(MediaType.APPLICATION_JSON) 95 @Produces(MediaType.APPLICATION_JSON)
96 + @Consumes(MediaType.APPLICATION_JSON)
95 public Response queryPath(@PathParam("path_id") String id) { 97 public Response queryPath(@PathParam("path_id") String id) {
96 log.debug("Query path by identifier {}.", id); 98 log.debug("Query path by identifier {}.", id);
97 Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)), 99 Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)),
...@@ -183,8 +185,10 @@ public class PcePathWebResource extends AbstractWebResource { ...@@ -183,8 +185,10 @@ public class PcePathWebResource extends AbstractWebResource {
183 * @param id path id 185 * @param id path id
184 * @return 200 OK, 404 if given identifier does not exist 186 * @return 200 OK, 404 if given identifier does not exist
185 */ 187 */
186 - @Path("{path_id}")
187 @DELETE 188 @DELETE
189 + @Path("{path_id}")
190 + @Produces(MediaType.APPLICATION_JSON)
191 + @Consumes(MediaType.APPLICATION_JSON)
188 public Response releasePath(@PathParam("path_id") String id) { 192 public Response releasePath(@PathParam("path_id") String id) {
189 log.debug("Deletes path by identifier {}.", id); 193 log.debug("Deletes path by identifier {}.", id);
190 194
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.pce.rest; 17 +package org.onosproject.pcerest;
18 18
19 import org.onlab.rest.AbstractWebApplication; 19 import org.onlab.rest.AbstractWebApplication;
20 20
......
...@@ -17,4 +17,5 @@ ...@@ -17,4 +17,5 @@
17 /** 17 /**
18 * PCE rest application. 18 * PCE rest application.
19 */ 19 */
20 -package org.onosproject.pce.rest; 20 +
21 +package org.onosproject.pcerest;
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
22 22
23 <servlet> 23 <servlet>
24 <servlet-name>JAX-RS Service</servlet-name> 24 <servlet-name>JAX-RS Service</servlet-name>
25 - <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 25 + <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
26 <init-param> 26 <init-param>
27 <param-name>javax.ws.rs.Application</param-name> 27 <param-name>javax.ws.rs.Application</param-name>
28 - <param-value>org.onosproject.pce.rest.PceWebApplication</param-value> 28 + <param-value>org.onosproject.pcerest.PceWebApplication</param-value>
29 </init-param> 29 </init-param>
30 <load-on-startup>1</load-on-startup> 30 <load-on-startup>1</load-on-startup>
31 </servlet> 31 </servlet>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import org.onosproject.codec.CodecContext; 18 import org.onosproject.codec.CodecContext;
19 import org.onosproject.codec.CodecService; 19 import org.onosproject.codec.CodecService;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import static org.hamcrest.MatcherAssert.assertThat; 18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is; 19 import static org.hamcrest.Matchers.is;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import static org.easymock.EasyMock.anyObject; 18 import static org.easymock.EasyMock.anyObject;
19 import static org.easymock.EasyMock.createMock; 19 import static org.easymock.EasyMock.createMock;
...@@ -160,8 +160,8 @@ public class PcePathResourceTest extends PceResourceTest { ...@@ -160,8 +160,8 @@ public class PcePathResourceTest extends PceResourceTest {
160 160
161 // Annotations 161 // Annotations
162 DefaultAnnotations.Builder builderAnn = DefaultAnnotations.builder(); 162 DefaultAnnotations.Builder builderAnn = DefaultAnnotations.builder();
163 - builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "2"); 163 + builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "WITH_SIGNALLING");
164 - builderAnn.set(PcepAnnotationKeys.COST_TYPE, "2"); 164 + builderAnn.set(PcepAnnotationKeys.COST_TYPE, "COST");
165 builderAnn.set(PcepAnnotationKeys.BANDWIDTH, "200"); 165 builderAnn.set(PcepAnnotationKeys.BANDWIDTH, "200");
166 166
167 // Tunnel 167 // Tunnel
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.pce.rest; 16 +package org.onosproject.pcerest;
17 17
18 import org.glassfish.jersey.server.ResourceConfig; 18 import org.glassfish.jersey.server.ResourceConfig;
19 import org.glassfish.jersey.test.JerseyTest; 19 import org.glassfish.jersey.test.JerseyTest;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
33 <modules> 33 <modules>
34 <module>app</module> 34 <module>app</module>
35 <module>pceweb</module> 35 <module>pceweb</module>
36 + <module>pcerest</module>
36 </modules> 37 </modules>
37 38
38 </project> 39 </project>
......
...@@ -35,4 +35,5 @@ ...@@ -35,4 +35,5 @@
35 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact> 35 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
36 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact> 36 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
37 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact> 37 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
38 + <artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
38 </app> 39 </app>
......
...@@ -34,5 +34,6 @@ ...@@ -34,5 +34,6 @@
34 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle> 34 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
35 <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle> 35 <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
36 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle> 36 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
37 + <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
37 </feature> 38 </feature>
38 </features> 39 </features>
......
...@@ -91,6 +91,11 @@ ...@@ -91,6 +91,11 @@
91 </dependency> 91 </dependency>
92 <dependency> 92 <dependency>
93 <groupId>org.onosproject</groupId> 93 <groupId>org.onosproject</groupId>
94 + <artifactId>onos-app-pcerest</artifactId>
95 + <version>${project.version}</version>
96 + </dependency>
97 + <dependency>
98 + <groupId>org.onosproject</groupId>
94 <artifactId>onos-bgp-provider-topology</artifactId> 99 <artifactId>onos-bgp-provider-topology</artifactId>
95 <version>${project.version}</version> 100 <version>${project.version}</version>
96 </dependency> 101 </dependency>
......