</properties>
<dependencies>
- <!--
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
- -->
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
- <!--
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- -->
+
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
-<!--
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j2</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-tomcat</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
- <scope>provided</scope>
- </dependency>
- -->
+
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
+
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>2.6.1</version>
+ </dependency>
-<dependency>
- <groupId>ca.juliusdavies</groupId>
- <artifactId>not-yet-commons-ssl</artifactId>
- <version>0.3.11</version>
-</dependency>
</dependencies>
<build>
- <!--
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>0.7.9</version>
- </plugin>
- </plugins>
- </pluginManagement>
--->
+
<plugins>
- <!--
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <configuration>
- <includes>org.onap.vfc.nfvo.driver.vnfm.svnfm.*</includes>
- </configuration>
- <executions>
- <execution>
- <id>default-prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- <execution>
- <id>default-prepare-agent-integration</id>
- <goals>
- <goal>prepare-agent-integration</goal>
- </goals>
- </execution>
- <execution>
- <id>default-check</id>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- <execution>
- <id>default-report-integration</id>
- <goals>
- <goal>report-integration</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- -->
+
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
</plugin>
- <!--
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <id>default-integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- -->
</plugins>
</build>
- <!--
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>report</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-
- -->
+
</project>
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.ScaleType;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfcResourceInfoMapper;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmSubscriptionsMapper;
cbamRequest.setFilter(request.getFilter());
CBAMCreateSubscriptionResponse cbamResponse = cbamMgmr.createSubscription(cbamRequest);
driverResponse = responseConverter.queryRspConvert(cbamResponse);
- subscriptionsMapper.insert(cbamResponse.getId());
+ VnfmSubscriptionInfo subscriptionInfo = new VnfmSubscriptionInfo();
+ subscriptionInfo.setId(cbamResponse.getId());
+ subscriptionInfo.setDriverCallbackUrl(cbamResponse.getId());
+ subscriptionInfo.setNslcmCallbackUrl(request.getCallbackUri());
+ subscriptionsMapper.insert(subscriptionInfo);
} catch (Exception e) {
logger.error("error VnfmDriverMgmrImpl --> createSubscripiton. ", e);
throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500);
+++ /dev/null
-/*
-* Copyright 2016-2017, Nokia Corporation
-*
-* 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.
-*/
-
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean;
-
-import java.io.Serializable;
-
-//import javax.persistence.Column;
-//import javax.persistence.Entity;
-//import javax.persistence.GeneratedValue;
-//import javax.persistence.GenerationType;
-//import javax.persistence.Id;
-//import javax.persistence.Table;
-
-//@Entity
-//@Table(name="vnfm_resource_info")
-public class VnfmResourceInfo implements Serializable {
- private static final long serialVersionUID = -288015953900428312L;
-// @Id
-// @GeneratedValue(strategy = GenerationType.AUTO)
- private int id;
-
-// @Column(name = "type")
- private ResourceType type;
-
-// @Column(name = "resource_definition_id")
- private String resourceDefinitionId;
-
-// @Column(name = "vdu")
- private String vdu;
-
-// @Column(name = "status")
- private String status;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public ResourceType getType() {
- return type;
- }
-
- public void setType(ResourceType type) {
- this.type = type;
- }
-
- public String getResourceDefinitionId() {
- return resourceDefinitionId;
- }
-
- public void setResourceDefinitionId(String resourceDefinitionId) {
- this.resourceDefinitionId = resourceDefinitionId;
- }
-
- public String getVdu() {
- return vdu;
- }
-
- public void setVdu(String vdu) {
- this.vdu = vdu;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-}
// @Id
// @Column(name = "id")
private String id;
+
+ private String driverCallbackUrl;
+
+ private String nslcmCallbackUrl;
public static long getSerialversionuid() {
return serialVersionUID;
this.id = id;
}
- @Override
- public String toString() {
- return " VnfmSubscriptionInfo: [ " + super.toString() + ", id = " + id + "]";
+ public String getDriverCallbackUrl() {
+ return driverCallbackUrl;
+ }
+
+ public void setDriverCallbackUrl(String driverCallbackUrl) {
+ this.driverCallbackUrl = driverCallbackUrl;
+ }
+ public String getNslcmCallbackUrl() {
+ return nslcmCallbackUrl;
}
+ public void setNslcmCallbackUrl(String nslcmCallbackUrl) {
+ this.nslcmCallbackUrl = nslcmCallbackUrl;
+ }
+
+ @Override
+ public String toString() {
+ return " VnfmSubscriptionInfo: [ " + super.toString() + ", id = " + id + ", driverCallbackUrl = " + driverCallbackUrl +", nslcmCallbackUrl = " + nslcmCallbackUrl + "]";
+ }
}
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo;
@Mapper
@Select("SELECT * FROM vnfm_subscription_info")
@Results({
@Result(property = "id", column = "id"),
+ @Result(property = "driverCallbackUrl", column = "driver_callback_url"),
+ @Result(property = "nslcmCallbackUrl", column = "nslcm_callback_url")
})
List<VnfmSubscriptionInfo> getAll();
@Select("SELECT * FROM vnfm_subscription_info WHERE id = #{id}")
@Results({
@Result(property = "id", column = "id"),
+ @Result(property = "driverCallbackUrl", column = "driver_callback_url"),
+ @Result(property = "nslcmCallbackUrl", column = "nslcm_callback_url")
})
VnfmSubscriptionInfo findOne(String id);
-// @Insert("INSERT INTO vnfm_subscription_info(id) VALUES(#{id})")
-// void insert(VnfmJobExecutionInfo user);
+ @Insert("INSERT IGNORE INTO vnfm_subscription_info(id, driver_callback_url, nslcm_callback_url) VALUES(#{id}, #{driverCallbackUrl}, #{nslcmCallbackUrl})")
+ void insert(VnfmSubscriptionInfo info);
+
+ @Insert("update vnfm_subscription_info set driver_callback_url = #{driverCallbackUrl}, nslcm_callback_url = #{nslcmCallbackUrl}) WHERE id = #{id}")
+ void update(VnfmSubscriptionInfo info);
- @Insert("INSERT INTO vnfm_subscription_info(id) VALUES(#{id})")
- void insert(String id);
@Delete("DELETE FROM vnfm_subscription_info WHERE id =#{id}")
void delete(String id);
+++ /dev/null
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * 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.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository;
-
-public interface VnfmJobExecutionRepository //extends CrudRepository< VnfmJobExecutionInfo, Long>
-{
-
-}
+++ /dev/null
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * 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.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository;
-
-public interface VnfmResourceRepository //extends CrudRepository<VnfmResourceInfo, Integer>
-{
-
-}
+++ /dev/null
-/*
- * Copyright 2016-2017, Nokia Corporation
- *
- * 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.
- */
-package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository;
-
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo;
-//import org.springframework.data.repository.CrudRepository;
-
-public interface VnfmSubscriptionsRepository //extends CrudRepository<VnfmSubscriptionInfo, Integer>
-{
-
-}
@Bean
public static HttpClientBuilder createHttpClientBuilder() {
- org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol("https");
+// org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol("https");
SSLContext sslcontext = null;
try {
sslcontext = createIgnoreVerifySSL();
package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.controller;
+import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStreamReader;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.io.IOUtils;
+//import org.apache.commons.io.IOUtils;
+import com.alibaba.dubbo.common.utils.IOUtils;
import org.apache.http.HttpStatus;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
@Autowired
private VnfmDriverMgmrInf vnfmDriverMgmr;
- @Autowired
- private CbamMgmrInf cbamMgmr;
-
private Gson gson = new Gson();
@RequestMapping(value = "/swagger.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String apidoc() throws IOException {
// String client = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr();
ClassLoader classLoader = getClass().getClassLoader();
- return IOUtils.toString(classLoader.getResourceAsStream("swagger.json"));
+ return IOUtils.read(new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("swagger.json"))));
}
@RequestMapping(value = "/{vnfmId}/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
return null;
}
-// @RequestMapping(value = "/notifications", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
-// public CBAMVnfNotificationResponse notificationVnf(@RequestBody CBAMVnfNotificationRequest request, HttpServletResponse httpResponse) throws ClientProtocolException, Exception
@RequestMapping(value = "/notifications")
-// @ResponseBody
- public void notificationVnf(HttpServletRequest request, HttpServletResponse httpResponse)
+ public void notificationVnf(HttpServletRequest request, HttpServletResponse httpResponse) throws IOException
{
-// String jsonString = gson.toJson(request);
-// logger.info("notificationVnf request: bodyMessage is " + jsonString);
- logger.info("notificationVnf request: bodyMessage is " + request.getMethod() + ",");
+ logger.info("VnfmDriverController -> notificationVnf request: request method is " + request.getMethod() + ",");
try {
-// CBAMVnfNotificationResponse response = cbamMgmr.getNotification(request);
- httpResponse.setStatus(204);
-// logger.info("cbamController --> notificationVnf response is " + gson.toJson(response));
-// return response;
+ if("GET".equalsIgnoreCase(request.getMethod())) // this is for link test
+ {
+ httpResponse.setStatus(HttpStatus.SC_NO_CONTENT);
+ }
+ else if("POST".equalsIgnoreCase(request.getMethod()))
+ {
+ httpResponse.setStatus(HttpStatus.SC_NO_CONTENT);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
+ String bodyString = IOUtils.read(reader);
+ logger.info("VnfmDriverController -> notificationVnf request: bodyMessage is " + bodyString);
+ }
}
catch(VnfmDriverException e)
{
processControllerException(httpResponse, e);
}
-// return null;
}
private void processControllerException(HttpServletResponse httpResponse, VnfmDriverException e) {
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.ScaleType;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmSubscriptionsMapper;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException;
mockCbamResponse.setId("subscriptionId_001");
mockCbamResponse.setCallbackUrl("callbackUrl");
when(cbamMgmr.createSubscription(Mockito.any(CBAMCreateSubscriptionRequest.class))).thenReturn(mockCbamResponse);
- doNothing().when(subscriptionsMapper).insert(Mockito.anyString());
+ doNothing().when(subscriptionsMapper).insert(Mockito.any(VnfmSubscriptionInfo.class));
CreateSubscriptionRequest request = new CreateSubscriptionRequest();
CreateSubscriptionResponse response = vnfmDriverMgmr.createSubscription(request);
Assert.assertEquals("callbackUrl", response.getCallbackUri());
JSONObject jsonObj = new JSONObject(responseString);
Assert.assertEquals("jobId is ", mockResponse.getCallbackUri(), jsonObj.get("callbackUri"));
}
+
+ @Test
+ public void testNotificationVnfCreateSubscripitonPost() throws Exception {
+ CreateSubscriptionResponse mockResponse = new CreateSubscriptionResponse();
+ mockResponse.setCallbackUri("callbackUri");
+ String jsonString = "{\"callbackUri\":\"callbackUri\"," + "\"authentication\":{\"userName\":\"userName\",\"password\":\"password\",\"clientName\":\"clientName\"}}";
+
+ when(vnfmDriverMgmr.createSubscription(Mockito.any(CreateSubscriptionRequest.class))).thenReturn(mockResponse);
+
+ mockMvc.perform(
+ post("/api/nokiavnfmdriver/v1/notifications").
+ characterEncoding("UTF-8").
+ accept(MediaType.APPLICATION_JSON).
+ contentType(MediaType.APPLICATION_JSON).
+ content(jsonString))
+ .andDo(print())
+ .andExpect(status().isNoContent())
+ .andReturn().getResponse().getContentAsString();
+ }
+
+ @Test
+ public void testNotificationVnfCreateSubscripitonGet() throws Exception {
+ mockMvc.perform(
+ get("/api/nokiavnfmdriver/v1/notifications"))
+ .andDo(print())
+ .andExpect(status().isNoContent());
+ }
}