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 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<classifier>tests</classifier>
......@@ -90,11 +85,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
......@@ -108,31 +98,12 @@
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcep-api</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -247,13 +247,15 @@ public final class DefaultPcePath implements PcePath {
// LSP type
String lspType = tunnel.annotations().value(PcepAnnotationKeys.LSP_SIG_TYPE);
if (lspType != null) {
this.lspType = LspType.values()[Integer.valueOf(lspType) - 1];
this.lspType = LspType.values()[LspType.valueOf(lspType).type()];
}
// Cost type
String costType = tunnel.annotations().value(PcepAnnotationKeys.COST_TYPE);
if (costType != null) {
this.costConstraint = CostConstraint.of(CostConstraint.Type.values()[Integer.valueOf(costType) - 1]);
this.costConstraint = CostConstraint.of(CostConstraint.Type.valueOf(costType));
}
// Bandwidth
String bandwidth = tunnel.annotations().value(PcepAnnotationKeys.BANDWIDTH);
if (bandwidth != null) {
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2016-2017 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-pce</artifactId>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-pcerest</artifactId>
<packaging>bundle</packaging>
<properties>
<web.context>/onos/pce</web.context>
<onos.app.name>org.onosproject.pcerest</onos.app.name>
<onos.app.title>PCE REST application</onos.app.title>
<onos.app.category>Utility</onos.app.category>
<onos.app.url>https://wiki.onosproject.org/display/ONOS/</onos.app.url>
<onos.app.readme>RESTCONF for PCE.</onos.app.readme>
</properties>
<description>PCE REST application</description>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-rest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pce</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_wab>src/main/resources/</_wab>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Import-Package>
*,org.glassfish.jersey.servlet
</Import-Package>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import static javax.ws.rs.core.Response.Status.OK;
import static org.onlab.util.Tools.nullIsNotFound;
......@@ -69,6 +69,7 @@ public class PcePathWebResource extends AbstractWebResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response queryAllPath() {
log.debug("Query all paths.");
Iterable<Tunnel> tunnels = get(PceService.class).queryAllPath();
......@@ -92,6 +93,7 @@ public class PcePathWebResource extends AbstractWebResource {
@GET
@Path("{path_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response queryPath(@PathParam("path_id") String id) {
log.debug("Query path by identifier {}.", id);
Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)),
......@@ -183,8 +185,10 @@ public class PcePathWebResource extends AbstractWebResource {
* @param id path id
* @return 200 OK, 404 if given identifier does not exist
*/
@Path("{path_id}")
@DELETE
@Path("{path_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response releasePath(@PathParam("path_id") String id) {
log.debug("Deletes path by identifier {}.", id);
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import org.onlab.rest.AbstractWebApplication;
......
......@@ -17,4 +17,5 @@
/**
* PCE rest application.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
......
......@@ -22,10 +22,10 @@
<servlet>
<servlet-name>JAX-RS Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.onosproject.pce.rest.PceWebApplication</param-value>
<param-value>org.onosproject.pcerest.PceWebApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.CodecService;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
......@@ -160,8 +160,8 @@ public class PcePathResourceTest extends PceResourceTest {
// Annotations
DefaultAnnotations.Builder builderAnn = DefaultAnnotations.builder();
builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "2");
builderAnn.set(PcepAnnotationKeys.COST_TYPE, "2");
builderAnn.set(PcepAnnotationKeys.LSP_SIG_TYPE, "WITH_SIGNALLING");
builderAnn.set(PcepAnnotationKeys.COST_TYPE, "COST");
builderAnn.set(PcepAnnotationKeys.BANDWIDTH, "200");
// Tunnel
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.rest;
package org.onosproject.pcerest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
......
......@@ -32,6 +32,7 @@
<modules>
<module>app</module>
<module>pceweb</module>
<module>pcerest</module>
</modules>
</project>
......
......@@ -34,4 +34,5 @@
<artifact>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pce/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pceweb/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pcerest/${project.version}</artifact>
</app>
......
......@@ -33,5 +33,6 @@
<bundle>mvn:${project.groupId}/onos-app-pceweb/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-packet/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgpcep-provider-flow/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcerest/${project.version}</bundle>
</feature>
</features>
......
......@@ -90,6 +90,11 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pcerest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-bgp-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
......