Priyanka B
Committed by Gerrit Code Review

[ONOS-4945] PCE Json fix

Change-Id: I701ed1044c603ea60becf8ba606098e4154a7733
Showing 19 changed files with 161 additions and 45 deletions
...@@ -68,11 +68,6 @@ ...@@ -68,11 +68,6 @@
68 <scope>test</scope> 68 <scope>test</scope>
69 </dependency> 69 </dependency>
70 <dependency> 70 <dependency>
71 - <groupId>org.easymock</groupId>
72 - <artifactId>easymock</artifactId>
73 - <scope>test</scope>
74 - </dependency>
75 - <dependency>
76 <groupId>org.onosproject</groupId> 71 <groupId>org.onosproject</groupId>
77 <artifactId>onlab-osgi</artifactId> 72 <artifactId>onlab-osgi</artifactId>
78 <classifier>tests</classifier> 73 <classifier>tests</classifier>
...@@ -90,11 +85,6 @@ ...@@ -90,11 +85,6 @@
90 <version>${project.version}</version> 85 <version>${project.version}</version>
91 </dependency> 86 </dependency>
92 <dependency> 87 <dependency>
93 - <groupId>org.onosproject</groupId>
94 - <artifactId>onlab-rest</artifactId>
95 - <version>${project.version}</version>
96 - </dependency>
97 - <dependency>
98 <groupId>javax.ws.rs</groupId> 88 <groupId>javax.ws.rs</groupId>
99 <artifactId>jsr311-api</artifactId> 89 <artifactId>jsr311-api</artifactId>
100 <version>1.1.1</version> 90 <version>1.1.1</version>
...@@ -108,31 +98,12 @@ ...@@ -108,31 +98,12 @@
108 <artifactId>jackson-annotations</artifactId> 98 <artifactId>jackson-annotations</artifactId>
109 </dependency> 99 </dependency>
110 <dependency> 100 <dependency>
111 - <groupId>org.glassfish.jersey.containers</groupId>
112 - <artifactId>jersey-container-servlet</artifactId>
113 - </dependency>
114 - <dependency>
115 - <groupId>org.glassfish.jersey.test-framework</groupId>
116 - <artifactId>jersey-test-framework-core</artifactId>
117 - <scope>test</scope>
118 - </dependency>
119 - <dependency>
120 - <groupId>org.glassfish.jersey.test-framework.providers</groupId>
121 - <artifactId>jersey-test-framework-provider-jetty</artifactId>
122 - <scope>test</scope>
123 - </dependency>
124 - <dependency>
125 <groupId>org.onosproject</groupId> 101 <groupId>org.onosproject</groupId>
126 <artifactId>onos-incubator-api</artifactId> 102 <artifactId>onos-incubator-api</artifactId>
127 <version>${project.version}</version> 103 <version>${project.version}</version>
128 </dependency> 104 </dependency>
129 <dependency> 105 <dependency>
130 <groupId>org.onosproject</groupId> 106 <groupId>org.onosproject</groupId>
131 - <artifactId>onlab-misc</artifactId>
132 - <version>${project.version}</version>
133 - </dependency>
134 - <dependency>
135 - <groupId>org.onosproject</groupId>
136 <artifactId>onos-app-pcep-api</artifactId> 107 <artifactId>onos-app-pcep-api</artifactId>
137 <version>${project.version}</version> 108 <version>${project.version}</version>
138 </dependency> 109 </dependency>
......
...@@ -247,13 +247,15 @@ public final class DefaultPcePath implements PcePath { ...@@ -247,13 +247,15 @@ 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 +
252 // Cost type 253 // Cost type
253 String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE); 254 String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE);
254 if (costType != null) { 255 if (costType != null) {
255 - this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(costType) - 1]); 256 + this.costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
256 } 257 }
258 +
257 // Bandwidth 259 // Bandwidth
258 String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH); 260 String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH);
259 if (bandwidth != null) { 261 if (bandwidth != null) {
......
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.7.0-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;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
32 <modules> 32 <modules>
33 <module>app</module> 33 <module>app</module>
34 <module>pceweb</module> 34 <module>pceweb</module>
35 + <module>pcerest</module>
35 </modules> 36 </modules>
36 37
37 </project> 38 </project>
......
...@@ -34,4 +34,5 @@ ...@@ -34,4 +34,5 @@
34 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact> 34 <artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
35 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact> 35 <artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
36 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact> 36 <artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
37 + <artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
37 </app> 38 </app>
......
...@@ -33,5 +33,6 @@ ...@@ -33,5 +33,6 @@
33 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle> 33 <bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
34 <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle> 34 <bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
35 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle> 35 <bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
36 + <bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
36 </feature> 37 </feature>
37 </features> 38 </features>
......
...@@ -90,6 +90,11 @@ ...@@ -90,6 +90,11 @@
90 </dependency> 90 </dependency>
91 <dependency> 91 <dependency>
92 <groupId>org.onosproject</groupId> 92 <groupId>org.onosproject</groupId>
93 + <artifactId>onos-app-pcerest</artifactId>
94 + <version>${project.version}</version>
95 + </dependency>
96 + <dependency>
97 + <groupId>org.onosproject</groupId>
93 <artifactId>onos-bgp-provider-topology</artifactId> 98 <artifactId>onos-bgp-provider-topology</artifactId>
94 <version>${project.version}</version> 99 <version>${project.version}</version>
95 </dependency> 100 </dependency>
......