OSAM infra seed code - merge with osam-core side-by-side - fixed warnings in onap-enabler POMs

Change-Id: I0cd9ea39d4b7c1dc088ab0ecd6fb787c7f490e5e
Signed-off-by: Aharoni, Pavel (pa0916) <pavel.aharoni@intl.att.com>
diff --git a/osam-core/web/pom.xml b/osam-core/web/pom.xml
new file mode 100644
index 0000000..e8bd078
--- /dev/null
+++ b/osam-core/web/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--/*-

+        * ============LICENSE_START=======================================================

+        * OSAM Core

+        * ================================================================================

+        * Copyright (C) 2018 Netsia

+        * ================================================================================

+        * 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.

+        * ============LICENSE_END=========================================================

+        */-->

+

+<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">

+    <parent>

+        <artifactId>osam-core</artifactId>

+        <groupId>org.onap.osam</groupId>

+        <version>0.0.1-SNAPSHOT</version>

+    </parent>

+    <modelVersion>4.0.0</modelVersion>

+    <artifactId>web</artifactId>

+    <dependencies>

+        <dependency>

+            <groupId>org.onap.osam</groupId>

+            <artifactId>core</artifactId>

+            <version>${project.version}</version>

+        </dependency>

+        <dependency>

+            <groupId>org.springframework.boot</groupId>

+            <artifactId>spring-boot-starter-web</artifactId>

+        </dependency>

+        <dependency>

+            <groupId>io.springfox</groupId>

+            <artifactId>springfox-swagger-ui</artifactId>

+            <version>${swagger.version}</version>

+            <scope>compile</scope>

+        </dependency>

+        <dependency>

+            <groupId>io.springfox</groupId>

+            <artifactId>springfox-swagger2</artifactId>

+            <version>${swagger.version}</version>

+            <scope>compile</scope>

+        </dependency>

+    </dependencies>

+

+</project>
\ No newline at end of file
diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/AbstractController.java b/osam-core/web/src/main/java/org/onap/osam/controller/AbstractController.java
new file mode 100644
index 0000000..97bfa7c
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/AbstractController.java
@@ -0,0 +1,53 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import org.onap.osam.common.exception.BadFormatException;

+import org.onap.osam.common.exception.NotFoundException;

+import org.onap.osam.common.exception.UnknownTypeException;

+import org.slf4j.Logger;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+

+/**

+ * Created by cemturker on 30.09.2018.

+ */

+public abstract class AbstractController {

+

+    private Logger logger;

+

+    public AbstractController(Logger logger) {

+        this.logger = logger;

+    }

+

+    public <T>  ResponseEntity<T> proceedException(Exception e) {

+        if (e instanceof BadFormatException || e instanceof UnknownTypeException) {

+            return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();

+        } else if(e instanceof NotFoundException) {

+            return ResponseEntity.status(HttpStatus.NOT_FOUND).build();

+        } else {

+            logger.error("",e);

+            return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).build();

+        }

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java b/osam-core/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java
new file mode 100644
index 0000000..b4fbec0
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/AccessPodRestController.java
@@ -0,0 +1,97 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.dto.AccessPodDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.api.service.AccessPodService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.DeleteMapping;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.PostMapping;

+import org.springframework.web.bind.annotation.RequestBody;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 27.09.2018.

+ */

+@RestController

+@RequestMapping("/accessPod")

+@Slf4j

+public class AccessPodRestController extends AbstractController {

+

+    private AccessPodService accessPodService;

+

+    @Autowired

+    public AccessPodRestController(AccessPodService accessPodService) {

+        super(log);

+        this.accessPodService = accessPodService;

+    }

+

+    @GetMapping

+    public List<AccessPodDTO> getAccessPods(){

+        return DTOMapper.covertAccessPodsToDtos(accessPodService.getAll());

+    }

+

+    @PostMapping

+    public ResponseEntity<AccessPodDTO> postAccessPod(@RequestBody AccessPodDTO accessPodDTO){

+        try {

+            log.info("Post request for {} is received",accessPodDTO);

+            AccessPod accessPod = DTOMapper.covertDtoToAccessPod(accessPodDTO);

+            accessPod = accessPodService.addOrUpdate(accessPod);

+            return new ResponseEntity<>(DTOMapper.covertAccessPodToDto(accessPod),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("pnf/{pnfId}")

+    public ResponseEntity deleteAccessPodByPnfId(@PathVariable("pnfId") String pnfId) {

+        try{

+            this.accessPodService.removeByPnfId(pnfId);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+    @DeleteMapping("/{id}")

+    public ResponseEntity deleteAccessPod(@PathVariable("id") Long id) {

+        try {

+            this.accessPodService.removeById(id);

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+        return ResponseEntity.ok().build();

+    }

+

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/DeviceController.java b/osam-core/web/src/main/java/org/onap/osam/controller/DeviceController.java
new file mode 100644
index 0000000..026ec17
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/DeviceController.java
@@ -0,0 +1,136 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.dto.ChassisDTO;

+import org.onap.osam.dto.OLTChassisDTO;

+import org.onap.osam.dto.ONTDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.*;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.*;

+

+import java.util.List;

+import java.util.Map;

+

+/**

+ * Created by Zafer Kaban on 27.09.2018.

+ */

+@CrossOrigin

+@RestController

+@RequestMapping("/device")

+@Slf4j

+public class DeviceController extends AbstractController {

+

+    private DeviceService deviceService;

+

+    @Autowired

+    public DeviceController(DeviceService deviceService) {

+        super(log);

+        this.deviceService = deviceService;

+    }

+

+    @PostMapping("/chassis")

+    public ResponseEntity<ChassisDTO> postChassis(@RequestBody ChassisDTO chassisDTO){

+        try {

+            log.info("postChassis request is received {}",chassisDTO);

+            Chassis chassis = DTOMapper.convertToChassis(chassisDTO);

+            chassis = deviceService.addChassis(chassis);

+            return new ResponseEntity<>(DTOMapper.convertChassisToDTO(chassis),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @DeleteMapping("chassis/{clli}")

+    public ResponseEntity deleteChassisByClli(@PathVariable("clli") String clli) {

+        try{

+            this.deviceService.deleteChassisByClli(clli);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+

+    @PostMapping("/chassis/olt")

+    public ResponseEntity<OLTChassisDTO> postOLTChassis(@RequestBody OLTChassisDTO oltChassisDTO){

+        try {

+            Chassis chassis = this.deviceService.getChassisByClli(oltChassisDTO.getClli());

+            OLTSlot oltSlot = DTOMapper.convertToOLT(oltChassisDTO);

+            oltSlot.setChassis(chassis);

+            this.deviceService.addOLTSlot(oltSlot, chassis);

+            return new ResponseEntity<> (DTOMapper.convertFromOLT(oltSlot),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @PostMapping("/chassis/olt/ont")

+    public ResponseEntity<ONTDTO> postONTDevice(@RequestBody ONTDTO ontDTO){

+        try {

+            ONTDevice ont = deviceService.addONTDevice(ontDTO.getClli()

+                    ,ontDTO.getSlotNumber()

+                    ,ontDTO.getPortNumber()

+                    ,ontDTO.getSerialNumber());

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(ont),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+

+    }

+

+    @GetMapping("/chassis")

+    public ResponseEntity<List<ChassisDTO>> getAllChassis(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertChassisToDTO(deviceService.getAllChassis()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/chassis/olt")

+    public ResponseEntity<Map<String, List<OLTChassisDTO>>> getAllOLTDevices(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertFromOLT(deviceService.getAllOLTSlots()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/chassis/olt/ont")

+    public ResponseEntity<Map<String, List<ONTDTO>>> getAllONTDevices(){

+        try {

+            return new ResponseEntity<> (DTOMapper.convertFromONTDevice(deviceService.getAllONTDevices()), HttpStatus.OK);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/ServiceController.java b/osam-core/web/src/main/java/org/onap/osam/controller/ServiceController.java
new file mode 100644
index 0000000..d033a1a
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/ServiceController.java
@@ -0,0 +1,135 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.model.dao.SpeedProfile;

+import org.onap.osam.model.dao.TechnologyProfile;

+import org.onap.osam.api.service.BroadBandService;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.DeleteMapping;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.PostMapping;

+import org.springframework.web.bind.annotation.RequestBody;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 19.09.2018.

+ */

+@RestController

+@RequestMapping("/service")

+@Slf4j

+public class ServiceController extends AbstractController {

+

+    private BroadBandService broadBandService;

+

+    //TODOs add validations for post reqs...

+

+    @Autowired

+    public ServiceController(BroadBandService broadBandService){

+        super(log);

+        this.broadBandService = broadBandService;

+    }

+

+    @GetMapping("/speedProfile")

+    public ResponseEntity<List<SpeedProfile>> getSpeedProfiles() {

+        try{

+            return ResponseEntity.ok(this.broadBandService.getSpeedProfiles());

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/speedProfile/{id}")

+    public ResponseEntity<SpeedProfile> getSpeedProfile(@PathVariable("id") Long id) {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getSpeedProfile(id));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("/speedProfile/{id}")

+    public ResponseEntity deleteSpeedProfile(@PathVariable("id") Long id) {

+        try {

+            this.broadBandService.removeSpeedProfile(id);

+            return ResponseEntity.ok().build();

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @PostMapping("/speedProfile")

+    public ResponseEntity<SpeedProfile> createSpeedProfile(@RequestBody SpeedProfile speedProfile) {

+        try {

+            return new ResponseEntity<>(this.broadBandService.addSpeedProfile(speedProfile),

+                    HttpStatus.CREATED);

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+

+    }

+

+    @GetMapping("/technologyProfile")

+    public ResponseEntity<List<TechnologyProfile>> getTechnologyProfiles() {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getTechnologyProfiles());

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @GetMapping("/technologyProfile/{id}")

+    public ResponseEntity<TechnologyProfile> getTechnologyProfile(@PathVariable("id") Long id) {

+        try {

+            return ResponseEntity.ok(this.broadBandService.getTechnologyProfile(id));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+

+    @DeleteMapping("/technologyProfile/{id}")

+    public ResponseEntity deleteTechnologyProfile(@PathVariable("id") Long id) {

+        try {

+            this.broadBandService.removeSpeedProfile(id);

+            return ResponseEntity.ok().build();

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+

+    @PostMapping("/technologyProfile")

+    public ResponseEntity<TechnologyProfile> createTechnologyProfile(@RequestBody TechnologyProfile technologyProfile) {

+        try {

+            return new ResponseEntity<>(this.broadBandService.addTechnologyProfile(technologyProfile),HttpStatus.CREATED);

+        }catch (Exception e){

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/TopologyController.java b/osam-core/web/src/main/java/org/onap/osam/controller/TopologyController.java
new file mode 100644
index 0000000..6f760ee
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/TopologyController.java
@@ -0,0 +1,70 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller;

+

+import lombok.extern.slf4j.Slf4j;

+import org.onap.osam.api.service.AccessPodService;

+import org.onap.osam.api.service.DeviceService;

+import org.onap.osam.dto.AccessPodDTO;

+import org.onap.osam.helper.DTOMapper;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.model.dao.Chassis;

+import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.GetMapping;

+import org.springframework.web.bind.annotation.PathVariable;

+import org.springframework.web.bind.annotation.RequestMapping;

+import org.springframework.web.bind.annotation.RestController;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 03.10.2018.

+ */

+@RestController

+@RequestMapping("topology")

+@Slf4j

+public class TopologyController extends AbstractController {

+    private AccessPodService accessPodService;

+    private DeviceService deviceService;

+

+    @Autowired

+    public TopologyController(AccessPodService accessPodService,

+                              DeviceService deviceService) {

+        super(log);

+        this.accessPodService = accessPodService;

+        this.deviceService = deviceService;

+    }

+

+    @GetMapping("/accessPod/{pnfId}")

+    public ResponseEntity<AccessPodDTO> getTopologyWithPnfId(@PathVariable("pnfId") String pnfId) {

+        try{

+            log.info("GetTopology with pnfId:{} is received.",pnfId);

+            AccessPod accessPod = accessPodService.findByPnfId(pnfId);

+            List<Chassis> chassisList = deviceService.getByPnfId(pnfId);

+            return ResponseEntity.ok(DTOMapper.representTheAccessPod(chassisList,accessPod));

+        }catch (Exception e) {

+            return super.proceedException(e);

+        }

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java b/osam-core/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java
new file mode 100644
index 0000000..20a538c
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/controller/config/SwaggerConfig.java
@@ -0,0 +1,57 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.controller.config;

+

+import org.springframework.context.annotation.Bean;

+import org.springframework.context.annotation.Configuration;

+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

+import springfox.documentation.builders.PathSelectors;

+import springfox.documentation.builders.RequestHandlerSelectors;

+import springfox.documentation.spi.DocumentationType;

+import springfox.documentation.spring.web.plugins.Docket;

+import springfox.documentation.swagger2.annotations.EnableSwagger2;

+

+/**

+ * Created by cemturker on 04.10.2018.

+ */

+@Configuration

+@EnableSwagger2

+public class SwaggerConfig extends WebMvcConfigurationSupport {

+    @Bean

+    public Docket osamApi() {

+        return new Docket(DocumentationType.SWAGGER_2)

+                .select()                 .apis(RequestHandlerSelectors.any())

+                .paths(PathSelectors.any())

+                .build();

+    }

+

+    @Override

+    protected void addResourceHandlers(ResourceHandlerRegistry registry) {

+        registry.addResourceHandler("swagger-ui.html")

+                .addResourceLocations("classpath:/META-INF/resources/");

+

+        registry.addResourceHandler("/webjars/**")

+                .addResourceLocations("classpath:/META-INF/resources/webjars/");

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/dto/AccessPodDTO.java b/osam-core/web/src/main/java/org/onap/osam/dto/AccessPodDTO.java
new file mode 100644
index 0000000..52570c7
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/dto/AccessPodDTO.java
@@ -0,0 +1,69 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.dto;

+

+import com.fasterxml.jackson.annotation.JsonInclude;

+import com.fasterxml.jackson.annotation.JsonRootName;

+import lombok.AllArgsConstructor;

+import lombok.Getter;

+import lombok.NoArgsConstructor;

+import lombok.Setter;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 01.10.2018.

+ */

+@Getter

+@Setter

+@NoArgsConstructor

+@AllArgsConstructor

+@JsonRootName("AccessPod")

+@JsonInclude(JsonInclude.Include.NON_NULL)

+public class AccessPodDTO {

+    private Long id;

+    private String pnfId;

+    private String ip;

+    private String port;

+    private String coreIp;

+    private String corePort;

+    private String username;

+    private String password;

+    private List<ChassisDTO> chassises;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("AccessPodDTO{");

+        sb.append("id=").append(id);

+        sb.append(", pnfId='").append(pnfId).append('\'');

+        sb.append(", ip='").append(ip).append('\'');

+        sb.append(", port='").append(port).append('\'');

+        sb.append(", coreIp='").append(coreIp).append('\'');

+        sb.append(", corePort='").append(corePort).append('\'');

+        sb.append(", username='").append(username).append('\'');

+        sb.append(", password='").append(password).append('\'');

+        sb.append(", chassises=").append(chassises);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/dto/ChassisDTO.java b/osam-core/web/src/main/java/org/onap/osam/dto/ChassisDTO.java
new file mode 100644
index 0000000..96462cf
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/dto/ChassisDTO.java
@@ -0,0 +1,45 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.dto;

+

+import com.fasterxml.jackson.annotation.JsonInclude;

+import com.fasterxml.jackson.annotation.JsonRootName;

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.NoArgsConstructor;

+

+import java.util.List;

+

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@JsonRootName("Chassis")

+@JsonInclude(JsonInclude.Include.NON_NULL)

+public class ChassisDTO {

+    private Long id;

+    private String clli;

+    private String pnfId;

+    private int shelf;

+    private int rack;

+    private List<OLTChassisDTO> olts;

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/dto/OLTChassisDTO.java b/osam-core/web/src/main/java/org/onap/osam/dto/OLTChassisDTO.java
new file mode 100644
index 0000000..1937e35
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/dto/OLTChassisDTO.java
@@ -0,0 +1,47 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.dto;

+

+import com.fasterxml.jackson.annotation.JsonInclude;

+import com.fasterxml.jackson.annotation.JsonRootName;

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.NoArgsConstructor;

+

+import java.util.List;

+

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@JsonRootName("OLT")

+@JsonInclude(JsonInclude.Include.NON_NULL)

+public class OLTChassisDTO {

+    private String clli;

+    private String oltDriver;

+    private String oltType;

+    private int portNumber;

+    private String ipAddress;

+    private String name;

+    private List<OLTPortDTO> oltPorts;

+    private Long id;

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/dto/OLTPortDTO.java b/osam-core/web/src/main/java/org/onap/osam/dto/OLTPortDTO.java
new file mode 100644
index 0000000..1a376fa
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/dto/OLTPortDTO.java
@@ -0,0 +1,63 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.dto;

+

+import com.fasterxml.jackson.annotation.JsonInclude;

+import com.fasterxml.jackson.annotation.JsonRootName;

+import lombok.AllArgsConstructor;

+import lombok.Getter;

+import lombok.NoArgsConstructor;

+import lombok.Setter;

+import org.onap.osam.model.dao.ActivityState;

+import org.onap.osam.model.dao.AdminState;

+

+import java.util.List;

+

+/**

+ * Created by cemturker on 03.10.2018.

+ */

+@Getter

+@Setter

+@NoArgsConstructor

+@AllArgsConstructor

+@JsonRootName("OLTPort")

+@JsonInclude(JsonInclude.Include.NON_NULL)

+public class OLTPortDTO {

+    private Long id;

+    private Integer portNumber;

+    private ActivityState portAuthState;

+    private AdminState adminState;

+    private List<ONTDTO> ontDevices;

+

+    @Override

+    public String toString() {

+        final StringBuilder sb = new StringBuilder("OLTPortDTO{");

+        sb.append("id=").append(id);

+        sb.append(", portNumber=").append(portNumber);

+        sb.append(", portAuthState=").append(portAuthState);

+        sb.append(", adminState=").append(adminState);

+        sb.append(", ontDevices=").append(ontDevices);

+        sb.append('}');

+        return sb.toString();

+    }

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/dto/ONTDTO.java b/osam-core/web/src/main/java/org/onap/osam/dto/ONTDTO.java
new file mode 100644
index 0000000..d21d9e3
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/dto/ONTDTO.java
@@ -0,0 +1,43 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.dto;

+

+import com.fasterxml.jackson.annotation.JsonInclude;

+import com.fasterxml.jackson.annotation.JsonRootName;

+import lombok.AllArgsConstructor;

+import lombok.Data;

+import lombok.NoArgsConstructor;

+

+@Data

+@AllArgsConstructor

+@NoArgsConstructor

+@JsonRootName("ONTDevice")

+@JsonInclude(JsonInclude.Include.NON_NULL)

+public class ONTDTO {

+

+    private String clli;

+    private String serialNumber;

+    private int slotNumber;

+    private int portNumber;

+    private Long id;

+}

diff --git a/osam-core/web/src/main/java/org/onap/osam/helper/DTOMapper.java b/osam-core/web/src/main/java/org/onap/osam/helper/DTOMapper.java
new file mode 100644
index 0000000..3a8784f
--- /dev/null
+++ b/osam-core/web/src/main/java/org/onap/osam/helper/DTOMapper.java
@@ -0,0 +1,222 @@
+/*-

+ * ============LICENSE_START=======================================================

+ * OSAM Core

+ * ================================================================================

+ * Copyright (C) 2018 Netsia

+ * ================================================================================

+ * 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.

+ * ============LICENSE_END=========================================================

+ */

+

+

+

+package org.onap.osam.helper;

+

+import com.google.common.collect.Lists;

+import org.onap.osam.dto.AccessPodDTO;

+import org.onap.osam.dto.ChassisDTO;

+import org.onap.osam.dto.OLTChassisDTO;

+import org.onap.osam.dto.OLTPortDTO;

+import org.onap.osam.dto.ONTDTO;

+import org.onap.osam.model.dao.AccessPod;

+import org.onap.osam.model.dao.ActivityState;

+import org.onap.osam.model.dao.Chassis;

+import org.onap.osam.model.dao.OLTPort;

+import org.onap.osam.model.dao.OLTSlot;

+import org.onap.osam.model.dao.ONTDevice;

+import org.onap.osam.model.dao.OltDriver;

+import org.onap.osam.model.dao.OltType;

+

+import java.util.ArrayList;

+import java.util.List;

+import java.util.Map;

+import java.util.function.Function;

+import java.util.stream.Collectors;

+

+

+public final class DTOMapper {

+

+    private DTOMapper () {

+

+    }

+

+    public static Chassis convertToChassis (ChassisDTO chassisDTO) {

+        Chassis chassis = new Chassis();

+        chassis.setClli(chassisDTO.getClli());

+        chassis.setShelf(chassisDTO.getShelf());

+        chassis.setRack(chassisDTO.getRack());

+        chassis.setState(ActivityState.ACTIVE);

+        AccessPod accessPod = new AccessPod();

+        accessPod.setPnfId(chassisDTO.getPnfId());

+        chassis.setAccessPod(accessPod);

+        return chassis;

+    }

+

+

+

+

+    public static OLTSlot convertToOLT (OLTChassisDTO oltChassisDTO) {

+        OLTSlot oltSlot = new OLTSlot();

+        oltSlot.setIpAddress(oltChassisDTO.getIpAddress());

+        oltSlot.setPort(oltChassisDTO.getPortNumber());

+        oltSlot.setName(oltChassisDTO.getName());

+        oltSlot.setOltDriver(OltDriver.valueOf(oltChassisDTO.getOltDriver()));

+        oltSlot.setOltType(OltType.valueOf(oltChassisDTO.getOltType()));

+        return oltSlot;

+    }

+

+    public static ChassisDTO convertChassisToDTO(Chassis chassis) {

+        ChassisDTO chassisDTO = new ChassisDTO();

+        chassisDTO.setId(chassis.getId());

+        chassisDTO.setClli(chassis.getClli());

+        chassisDTO.setRack(chassis.getRack());

+        chassisDTO.setShelf(chassis.getShelf());

+        chassisDTO.setPnfId(chassis.getAccessPod().getPnfId());

+        return chassisDTO;

+    }

+

+    public static List<ChassisDTO> convertChassisToDTO(List<Chassis> chassises) {

+        return chassises.stream().map(x -> convertChassisToDTO(x)).collect(Collectors.toList());

+    }

+

+    public static Map<String, List<OLTChassisDTO>> convertFromOLT(List<OLTSlot> oltSlots){

+        return oltSlots.stream().map(x -> convertFromOLT(x)).collect(Collectors.toList()).stream().collect(Collectors.groupingBy(OLTChassisDTO::getClli));

+    }

+

+    public static OLTChassisDTO convertFromOLT (OLTSlot oltSlot) {

+        OLTChassisDTO oltChassisDTO = new OLTChassisDTO();

+        oltChassisDTO.setClli(oltSlot.getChassis().getClli());

+        oltChassisDTO.setIpAddress(oltSlot.getIpAddress());

+        oltChassisDTO.setName(oltSlot.getName());

+        oltChassisDTO.setOltDriver(oltSlot.getOltDriver().name());

+        oltChassisDTO.setOltType(oltSlot.getOltType().name());

+        oltChassisDTO.setPortNumber(oltSlot.getPort());

+        oltChassisDTO.setId(oltSlot.getId());

+        return oltChassisDTO;

+    }

+

+    public static ONTDTO convertFromONTDevice (ONTDevice ontDevice) {

+        ONTDTO ontdto = new ONTDTO();

+        ontdto.setSerialNumber(ontDevice.getSerialNumber());

+        ontdto.setPortNumber(ontDevice.getOLTPort().getPortNumber());

+        ontdto.setId(ontDevice.getId());

+        ontdto.setSlotNumber(ontDevice.getOLTPort().getOltSlot().getNumber());

+        ontdto.setClli(ontDevice.getOLTPort().getOltSlot().getChassis().getClli());

+        return ontdto;

+    }

+

+    public static Map<String, List<ONTDTO>> convertFromONTDevice(List<ONTDevice> ontDevices){

+        return ontDevices.stream().map(x -> convertFromONTDevice(x)).collect(Collectors.toList()).stream().collect(Collectors.groupingBy(ONTDTO::getClli));

+    }

+

+    public static AccessPod covertDtoToAccessPod(AccessPodDTO dto) {

+        //TODO validate..

+        AccessPod accessPod = new AccessPod();

+        accessPod.setPnfId(dto.getPnfId());

+        accessPod.setId(dto.getId());

+        accessPod.setCoreIp(dto.getCoreIp());

+        accessPod.setCorePort(dto.getCorePort());

+        accessPod.setUsername(dto.getUsername());

+        accessPod.setPassword(dto.getPassword());

+        accessPod.setIp(dto.getIp());

+        accessPod.setPort(dto.getPort());

+        return accessPod;

+    }

+

+    public static AccessPodDTO covertAccessPodToDto(AccessPod accessPod) {

+        //TODO validate..

+        AccessPodDTO dto = new AccessPodDTO();

+        dto.setPnfId(accessPod.getPnfId());

+        dto.setCoreIp(accessPod.getCoreIp());

+        dto.setCorePort(accessPod.getCorePort());

+        dto.setUsername(accessPod.getUsername());

+        dto.setPassword(accessPod.getPassword());

+        dto.setIp(accessPod.getIp());

+        dto.setId(accessPod.getId());

+        dto.setPort(accessPod.getPort());

+        return dto;

+    }

+

+    private static OLTPortDTO convertOLTPortToDTO(OLTPort oltPort) {

+        OLTPortDTO oltPortDTO = new OLTPortDTO();

+        oltPortDTO.setId(oltPort.getId());

+        oltPortDTO.setAdminState(oltPort.getAdminState());

+        oltPortDTO.setPortAuthState(oltPort.getPortAuthState());

+        oltPortDTO.setPortNumber(oltPort.getPortNumber());

+        return oltPortDTO;

+    }

+

+    public static List<AccessPodDTO> covertAccessPodsToDtos(List<AccessPod> accessPodList) {

+        //TODO validate..

+        List<AccessPodDTO> dtos = new ArrayList<>();

+        for (AccessPod accessPod : accessPodList) {

+            dtos.add(covertAccessPodToDto(accessPod));

+        }

+        return dtos;

+    }

+

+    public static AccessPodDTO representTheAccessPod(List<Chassis> chassisList, AccessPod accessPod) {

+        if (accessPod == null) {

+            return null;

+        }

+        AccessPodDTO accessPodDTO = covertAccessPodToDto(accessPod);

+        if (chassisList == null || chassisList.isEmpty()) {

+            return accessPodDTO;

+        }

+        List<ChassisDTO> chassisDTOS = new ArrayList<>();

+        accessPodDTO.setChassises(chassisDTOS);

+        for (Chassis chassis : chassisList) {

+            chassisDTOS.add(representTheChassis(chassis));

+        }

+        return accessPodDTO;

+    }

+

+    public static ChassisDTO representTheChassis(Chassis chassis) {

+        ChassisDTO chassisDTO = convertChassisToDTO(chassis);

+        if (chassis.getOltSlots() == null || chassis.getOltSlots().isEmpty()) {

+            return chassisDTO;

+        }

+        List<OLTChassisDTO> oltChassisDTOS = Lists.newArrayList();

+        chassisDTO.setOlts(oltChassisDTOS);

+        for (OLTSlot oltSlot : chassis.getOltSlots()) {

+            oltChassisDTOS.add(representTheOLTSlot(oltSlot));

+        }

+        return chassisDTO;

+    }

+

+    public static OLTChassisDTO representTheOLTSlot(OLTSlot oltSlot) {

+        OLTChassisDTO oltChassisDTO = convertFromOLT(oltSlot);

+        if (oltSlot.getOltPorts() == null || oltSlot.getOltPorts().isEmpty()) {

+            return oltChassisDTO;

+        }

+        List<OLTPortDTO> oltPortDTOS = Lists.newArrayList();

+        oltChassisDTO.setOltPorts(oltPortDTOS);

+        for (OLTPort oltPort : oltSlot.getOltPorts()) {

+            oltPortDTOS.add(representTheOLTPort(oltPort));

+        }

+        return oltChassisDTO;

+    }

+

+    public static OLTPortDTO representTheOLTPort(OLTPort oltPort) {

+        OLTPortDTO portDTO = convertOLTPortToDTO(oltPort);

+        if (oltPort.getOntDevices() == null || oltPort.getOntDevices().isEmpty()) {

+            return portDTO;

+        }

+        List<ONTDTO> ontdtos = Lists.newArrayList();

+        portDTO.setOntDevices(ontdtos);

+        for (ONTDevice ontDevice : oltPort.getOntDevices()) {

+            ontdtos.add(convertFromONTDevice(ontDevice));

+        }

+        return portDTO;

+    }

+}