query customer and service from aai 47/14547/1
authorLuji7 <lu.ji3@zte.com.cn>
Fri, 22 Sep 2017 09:25:51 +0000 (17:25 +0800)
committerLuji7 <lu.ji3@zte.com.cn>
Fri, 22 Sep 2017 09:25:58 +0000 (17:25 +0800)
Change-Id: I70a04ae2b6834ffe5c1faa62a33dda4a88d81d77
Issue-Id: USECASEUI-36
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
21 files changed:
pom.xml
src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplate.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomer.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/exceptions/AAIException.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/SDCCatalogService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/consts/SDCConsts.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/exceptions/SDCCatalogException.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java [new file with mode: 0644]
src/main/java/org/onap/usecaseui/server/util/RestfulServices.java [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index fedfb8e..341cc60 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             <artifactId>jackson-annotations</artifactId>
             <version>${jackson.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.squareup.retrofit2</groupId>
+            <artifactId>retrofit</artifactId>
+            <version>2.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.retrofit2</groupId>
+            <artifactId>converter-jackson</artifactId>
+            <version>2.3.0</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplate.java b/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplate.java
new file mode 100644 (file)
index 0000000..bc23ac7
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.bean.lcm;
+
+public class ServiceTemplate {
+}
diff --git a/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java b/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java
new file mode 100644 (file)
index 0000000..a1b8d0e
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.controller.lcm;
+
+import org.onap.usecaseui.server.service.lcm.CustomerService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Controller
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class CustomerController {
+
+    @Resource(name="CustomerService")
+    private CustomerService customerService;
+
+    @ResponseBody
+    @RequestMapping(value = {"/lcm/customers"}, method = RequestMethod.GET , produces = "application/json")
+    public List<AAICustomer> getCustomers(HttpServletRequest request){
+        return customerService.listCustomer();
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java b/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java
new file mode 100644 (file)
index 0000000..3d51f64
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.controller.lcm;
+
+import org.onap.usecaseui.server.service.lcm.ServiceInstanceService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Controller
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class ServiceInstanceController {
+
+    private static final Logger logger = LoggerFactory.getLogger(ServiceInstanceController.class);
+
+    @Resource(name="ServiceInstanceService")
+    private ServiceInstanceService serviceInstanceService;
+
+    @ResponseBody
+    @RequestMapping(value = {"/lcm/service-instances"}, method = RequestMethod.GET , produces = "application/json")
+    public List<ServiceInstance> getCustomers(HttpServletRequest request){
+        String customerId = request.getParameter("customerId");
+        String serviceType = request.getParameter("serviceType");
+        logger.info(String.format(
+                "list service instances with [customerId=%s, serviceType=%s]",
+                customerId,
+                serviceType));
+
+        return serviceInstanceService.listServiceInstances(customerId, serviceType);
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java b/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java
new file mode 100644 (file)
index 0000000..53f77ee
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.controller.lcm;
+
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplate;
+import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Controller
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class ServiceTemplateController {
+
+    private static final Logger logger = LoggerFactory.getLogger(ServiceTemplateController.class);
+
+    @Resource(name="ServiceTemplateService")
+    private ServiceTemplateService serviceTemplateService;
+
+    @ResponseBody
+    @RequestMapping(value = {"/lcm/service-templates"}, method = RequestMethod.GET , produces = "application/json")
+    public List<ServiceTemplate> getServiceTemplates(HttpServletRequest request){
+        return serviceTemplateService.listDistributedServiceTemplate();
+    }
+
+
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java
new file mode 100644 (file)
index 0000000..9c65946
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm;
+
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+
+import java.util.List;
+
+public interface CustomerService {
+    List<AAICustomer> listCustomer();
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java
new file mode 100644 (file)
index 0000000..1775211
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm;
+
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
+
+import java.util.List;
+
+public interface ServiceInstanceService {
+
+    List<ServiceInstance> listServiceInstances(String customerId, String serviceType);
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java
new file mode 100644 (file)
index 0000000..ea2d818
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm;
+
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplate;
+
+import java.util.List;
+
+public interface ServiceTemplateService {
+
+    List<ServiceTemplate> listDistributedServiceTemplate();
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java
new file mode 100644 (file)
index 0000000..b4683b2
--- /dev/null
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.aai;
+
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Headers;
+import retrofit2.http.Path;
+
+import java.util.List;
+
+public interface AAIService {
+
+    @Headers({
+            "X-TransactionId: 7777",
+            "X-FromAppId: uui",
+            "Authorization: QUFJOkFBSQ=="
+    })
+    @GET("/api/aai-business/v11/customers")
+    Call<List<AAICustomer>> listCustomer();
+
+    @Headers({
+            "X-TransactionId: 7777",
+            "X-FromAppId: uui",
+            "Authorization: QUFJOkFBSQ=="
+    })
+    @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances")
+    Call<List<ServiceInstance>> listServiceInstances(@Path("global-customer-id") String customerId, @Path("service-type") String serviceType);
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomer.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomer.java
new file mode 100644 (file)
index 0000000..e113523
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AAICustomer {
+
+    private String globalCustomerId;
+
+    private String subscriberName;
+
+    private String subscriberType;
+
+    @JsonCreator
+    public AAICustomer(
+            @JsonProperty("global-customer-id") String globalCustomerId,
+            @JsonProperty("subscriber-name") String subscriberName,
+            @JsonProperty("subscriber-type") String subscriberType) {
+        this.globalCustomerId = globalCustomerId;
+        this.subscriberName = subscriberName;
+        this.subscriberType = subscriberType;
+    }
+
+    @JsonProperty("global-customer-id")
+    public String getGlobalCustomerId() {
+        return globalCustomerId;
+    }
+
+    @JsonProperty("subscriber-name")
+    public String getSubscriberName() {
+        return subscriberName;
+    }
+
+    @JsonProperty("subscriber-type")
+    public String getSubscriberType() {
+        return subscriberType;
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstance.java
new file mode 100644 (file)
index 0000000..5245d27
--- /dev/null
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceInstance {
+
+    private String globalCustomerId;
+
+    private String serviceType;
+
+    private String serviceInstanceId;
+
+    private String subscriberName;
+
+    private String subscriberType;
+
+    private String serviceInstanceName;
+
+    private String serviceInstanceLocationId;
+
+    @JsonCreator
+    public ServiceInstance(
+            @JsonProperty("global-customer-id") String globalCustomerId,
+            @JsonProperty("service-type") String serviceType,
+            @JsonProperty("service-instance-id") String serviceInstanceId,
+            @JsonProperty("subscriber-name") String subscriberName,
+            @JsonProperty("subscriber-type") String subscriberType,
+            @JsonProperty("service-instance-name") String serviceInstanceName,
+            @JsonProperty("service-instance-location-id") String serviceInstanceLocationId) {
+        this.globalCustomerId = globalCustomerId;
+        this.serviceType = serviceType;
+        this.serviceInstanceId = serviceInstanceId;
+        this.subscriberName = subscriberName;
+        this.subscriberType = subscriberType;
+        this.serviceInstanceName = serviceInstanceName;
+        this.serviceInstanceLocationId = serviceInstanceLocationId;
+    }
+
+    @JsonProperty("global-customer-id")
+    public String getGlobalCustomerId() {
+        return globalCustomerId;
+    }
+
+    @JsonProperty("service-type")
+    public String getServiceType() {
+        return serviceType;
+    }
+
+    @JsonProperty("service-instance-id")
+    public String getServiceInstanceId() {
+        return serviceInstanceId;
+    }
+
+    @JsonProperty("subscriber-name")
+    public String getSubscriberName() {
+        return subscriberName;
+    }
+
+    @JsonProperty("subscriber-type")
+    public String getSubscriberType() {
+        return subscriberType;
+    }
+
+    @JsonProperty("service-instance-name")
+    public String getServiceInstanceName() {
+        return serviceInstanceName;
+    }
+
+    @JsonProperty("service-instance-location-id")
+    public String getServiceInstanceLocationId() {
+        return serviceInstanceLocationId;
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/exceptions/AAIException.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/exceptions/AAIException.java
new file mode 100644 (file)
index 0000000..e7bc0d9
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.aai.exceptions;
+
+public class AAIException extends RuntimeException {
+
+    public AAIException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/SDCCatalogService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/SDCCatalogService.java
new file mode 100644 (file)
index 0000000..f6abba0
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.sdc;
+
+import okhttp3.ResponseBody;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Query;
+import retrofit2.http.Url;
+
+import java.util.List;
+
+public interface SDCCatalogService {
+
+    @GET("sdc/v1/catalog/services")
+    Call<List<SDCServiceTemplate>> listServices(@Query("category")String category, @Query("distributionStatus") String distributionStatus);
+
+    @GET
+    Call<ResponseBody> downloadCsar(@Url String fileUrl);
+
+    @GET("sdc/v1/catalog/resources")
+    Call<List<Vnf>> listResources(@Query("resourceType") String resourceType, @Query("distributionStatus") String distributionStatus);
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java
new file mode 100644 (file)
index 0000000..48da58a
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.sdc.bean;
+
+public class SDCServiceTemplate {
+
+
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/Vnf.java
new file mode 100644 (file)
index 0000000..8b98c71
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.sdc.bean;
+
+public class Vnf {
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/consts/SDCConsts.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/consts/SDCConsts.java
new file mode 100644 (file)
index 0000000..76914e4
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.sdc.consts;
+
+public class SDCConsts {
+
+    public static final String CATEGORY_E2E_SERVICE = "e2e";
+    public static final String CATEGORY_NS = "ns";
+    public static final String DISTRIBUTION_STATUS_DISTRIBUTED = "DISTRIBUTED";
+    public static final String RESOURCETYPE_VF = "VF";
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/exceptions/SDCCatalogException.java b/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/exceptions/SDCCatalogException.java
new file mode 100644 (file)
index 0000000..b099848
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.domain.sdc.exceptions;
+
+public class SDCCatalogException extends RuntimeException {
+
+    public SDCCatalogException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java
new file mode 100644 (file)
index 0000000..9332dcf
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.impl;
+
+import org.onap.usecaseui.server.service.lcm.CustomerService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.List;
+
+@Service("CustomerService")
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class DefaultCustomerService implements CustomerService {
+
+    private static final Logger logger = LoggerFactory.getLogger(DefaultCustomerService.class);
+
+    private AAIService aaiService;
+
+    public DefaultCustomerService() {
+        this(RestfulServices.create(AAIService.class));
+    }
+
+    public DefaultCustomerService(AAIService aaiService) {
+        this.aaiService = aaiService;
+    }
+
+    @Override
+    public List<AAICustomer> listCustomer() {
+        try {
+            return this.aaiService.listCustomer().execute().body();
+        } catch (IOException e) {
+            logger.error("list customers occur exception");
+            throw new AAIException("AAI is not available.", e);
+        }
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java
new file mode 100644 (file)
index 0000000..540a0da
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.impl;
+
+import org.onap.usecaseui.server.service.lcm.ServiceInstanceService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.util.List;
+
+@Service("ServiceInstanceService")
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class DefaultServiceInstanceService implements ServiceInstanceService {
+
+    private static final Logger logger = LoggerFactory.getLogger(DefaultServiceInstanceService.class);
+
+    private AAIService aaiService;
+
+    public DefaultServiceInstanceService() {
+        this(RestfulServices.create(AAIService.class));
+    }
+
+    public DefaultServiceInstanceService(AAIService aaiService) {
+        this.aaiService = aaiService;
+    }
+
+    @Override
+    public List<ServiceInstance> listServiceInstances(String customerId, String serviceType) {
+        try {
+            return aaiService.listServiceInstances(customerId, serviceType).execute().body();
+        } catch (IOException e) {
+            logger.error("list services instances occur exception");
+            throw new AAIException("AAI is not available.", e);
+        }
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java b/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
new file mode 100644 (file)
index 0000000..a5d90ed
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.service.lcm.impl;
+
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplate;
+import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+import java.io.IOException;
+import java.util.List;
+
+import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.CATEGORY_E2E_SERVICE;
+import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.DISTRIBUTION_STATUS_DISTRIBUTED;
+
+@Service("ServiceTemplateService")
+@Transactional
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class DefaultServiceTemplateService implements ServiceTemplateService {
+
+    private static final Logger logger = LoggerFactory.getLogger(DefaultServiceTemplateService.class);
+
+    private SDCCatalogService sdcCatalog;
+
+    public DefaultServiceTemplateService() {
+        this(RestfulServices.create(SDCCatalogService.class));
+    }
+
+    public DefaultServiceTemplateService(SDCCatalogService sdcCatalog) {
+        this.sdcCatalog = sdcCatalog;
+    }
+
+    @Override
+    public List<ServiceTemplate> listDistributedServiceTemplate() {
+        try {
+            List<SDCServiceTemplate> serviceTemplate = this.sdcCatalog.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body();
+            return translate(serviceTemplate);
+        } catch (IOException e) {
+            logger.error("Visit SDC Catalog occur exception");
+            logger.info("SDC Catalog Exception: ", e);
+            throw new SDCCatalogException("SDC Catalog is not available.", e);
+        }
+    }
+
+    private List<ServiceTemplate> translate(List<SDCServiceTemplate> serviceTemplate) {
+        return null;
+    }
+}
diff --git a/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java b/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java
new file mode 100644 (file)
index 0000000..c26aab6
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2016-2017 ZTE 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.usecaseui.server.util;
+
+import retrofit2.Retrofit;
+import retrofit2.converter.jackson.JacksonConverterFactory;
+
+public class RestfulServices {
+
+    public static <T> T create(Class<T> clazz) {
+        Retrofit retrofit = new Retrofit.Builder()
+                .baseUrl("http://localhost")
+                .addConverterFactory(JacksonConverterFactory.create())
+                .build();
+        return retrofit.create(clazz);
+    }
+}