2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.asdc.client.test.rest;
\r
24 import javax.ws.rs.GET;
\r
25 import javax.ws.rs.Path;
\r
26 import javax.ws.rs.Produces;
\r
27 import javax.ws.rs.core.MediaType;
\r
28 import javax.ws.rs.core.Response;
\r
30 import org.openecomp.mso.asdc.client.ASDCController;
\r
31 import org.openecomp.mso.asdc.client.test.emulators.DistributionClientEmulator;
\r
32 import org.openecomp.mso.asdc.client.test.emulators.JsonNotificationData;
\r
33 import org.openecomp.mso.asdc.client.test.emulators.JsonStatusData;
\r
34 import org.openecomp.mso.asdc.installer.heat.ToscaResourceInstaller;
\r
35 import org.openecomp.mso.logger.MessageEnum;
\r
36 import org.openecomp.mso.logger.MsoLogger;
\r
39 * This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on jboss without the need to be connected
\r
40 * to the ASDC service broker. It starts the test at the treatNotification step and simulates both the notification step as well as the artifact download step.
\r
42 * i.e. http://localhost:8080/asdc/treatNotification/v1
\r
44 * i.e. http://localhost:8080/asdc/statusData/v1
\r
51 public class ASDCRestInterface {
\r
53 private static DistributionClientEmulator distributionClientEmulator;
\r
55 private static JsonNotificationData notifDataWithoutModuleInfo;
\r
57 private static JsonStatusData statusData;
\r
59 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
\r
62 @Path("/treatNotification/v1")
\r
63 @Produces(MediaType.APPLICATION_JSON)
\r
64 public Response invokeASDCService(String request) {
\r
67 distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
\r
68 notifDataWithoutModuleInfo = JsonNotificationData.instantiateNotifFromJsonFile("resource-examples/");
\r
70 ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
\r
71 LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "initASDC()");
\r
72 asdcController.initASDC();
\r
73 LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "treatNotification()");
\r
74 asdcController.treatNotification(notifDataWithoutModuleInfo);
\r
75 LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "closeASDC()");
\r
76 asdcController.closeASDC();
\r
77 }catch(Exception e){
\r
78 System.out.println("Error caught " + e.getMessage());
\r
79 LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION,
\r
80 "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in invokeASDCService", e);
\r
82 System.out.println("ASDC Updates are complete");
\r
83 LOGGER.info(MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "ASDC Updates Are Complete");
\r
89 @Path("/statusData/v1")
\r
90 @Produces(MediaType.APPLICATION_JSON)
\r
91 public Response invokeASDCStatusData(String request) {
\r
93 ToscaResourceInstaller toscaInstaller = new ToscaResourceInstaller();
\r
96 distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
\r
97 statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
\r
99 ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
\r
100 //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "initASDC()");
\r
101 asdcController.initASDC();
\r
102 //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "treatNotification()");
\r
103 toscaInstaller.installTheComponentStatus(statusData);
\r
104 //asdcController.treatNotification(notifDataWithoutModuleInfo);
\r
105 //LOGGER.info(MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, notifDataWithoutModuleInfo.getServiceUUID(), "ASDC", "closeASDC()");
\r
106 asdcController.closeASDC();
\r
107 }catch(Exception e){
\r
108 System.out.println("Error caught " + e.getMessage());
\r
109 LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION,
\r
110 "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in invokeASDCService", e);
\r
112 System.out.println("ASDC Updates are complete");
\r
113 LOGGER.info(MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, statusData.getDistributionID(), "ASDC", "ASDC Updates Are Complete");
\r