diff options
author | mukesh.paliwal1@huawei.com <mukesh.paliwal1@huawei.com> | 2020-04-14 20:32:47 +0530 |
---|---|---|
committer | Mukesh Paliwal <mukesh.paliwal1@huawei.com> | 2020-04-15 04:52:16 +0000 |
commit | 9626403987d46efe32e4480d31b35b89e014a00f (patch) | |
tree | 3ef299fbea6c4e03c21b112d64992fefe7487733 | |
parent | 500e05183bbc4a77bdc1afc09c9e50c70a546d3b (diff) |
vnf and uni id is not filtering for Service topology - Resource file reading issue
Issue-ID: USECASEUI-427
Signed-off-by: mukesh.paliwal1@huawei.com <mukesh.paliwal1@huawei.com>
Change-Id: I0b35862f862fed8d4204dd59fae1c3f38058f260
5 files changed, 31 insertions, 40 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/customer/impl/CcvpnCustomerServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/customer/impl/CcvpnCustomerServiceImpl.java index 4fa79ade..cb4a44b8 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/customer/impl/CcvpnCustomerServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/customer/impl/CcvpnCustomerServiceImpl.java @@ -34,6 +34,8 @@ import org.onap.usecaseui.server.util.RestfulServices; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import retrofit2.Response; @@ -140,17 +142,14 @@ public class CcvpnCustomerServiceImpl implements CcvpnCustomerService { } public ModelConfig readFile() { - JSONParser parser = new JSONParser(); - ClassLoader classLoader = new CcvpnCustomerServiceImpl().getClass().getClassLoader(); - File file = new File(classLoader.getResource("modelconfig.json").getFile()); ObjectMapper mapper = new ObjectMapper(); try { - Object object = parser.parse(new FileReader(file)); - ModelConfig modelInformation = mapper.readValue(object.toString(), new TypeReference<ModelConfig>() { - }); + Resource resource = new ClassPathResource("modelconfig.json"); + ModelConfig modelInformation = mapper.readValue(resource.getInputStream(), ModelConfig.class); + logger.info("subscriber id is: {}.", modelInformation.getSubscriberId()); return modelInformation; - } catch (ParseException | IOException ex) { - logger.error("Exception occured while reading configuration file:" + ex); + } catch (IOException ex) { + logger.error("Exception occured while reading configuration file: {}", ex); return null; } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceQryServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceQryServiceImpl.java index c62cf232..d20959ca 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceQryServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceQryServiceImpl.java @@ -35,6 +35,8 @@ import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import org.springframework.stereotype.Service; import retrofit2.Response; @@ -103,17 +105,14 @@ public class SotnServiceQryServiceImpl implements SotnServiceQryService { } public ModelConfig readFile() { - JSONParser parser = new JSONParser(); - ClassLoader classLoader = new SotnServiceQryServiceImpl().getClass().getClassLoader(); - File file = new File(classLoader.getResource("modelconfig.json").getFile()); ObjectMapper mapper = new ObjectMapper(); try { - Object object = parser.parse(new FileReader(file)); - ModelConfig modelInformation = mapper.readValue(object.toString(), new TypeReference<ModelConfig>() { - }); + Resource resource = new ClassPathResource("modelconfig.json"); + ModelConfig modelInformation = mapper.readValue(resource.getInputStream(), ModelConfig.class); + logger.info("subscriber id is: {}.", modelInformation.getSubscriberId()); return modelInformation; - } catch (ParseException | IOException ex) { - logger.error("Exception occured while reading configuration file:" + ex); + } catch (IOException ex) { + logger.error("Exception occured while reading configuration file: {}", ex); return null; } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceTemplateServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceTemplateServiceImpl.java index 2ce2cb24..780dc1ab 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceTemplateServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/SotnServiceTemplateServiceImpl.java @@ -41,6 +41,8 @@ import org.onap.usecaseui.server.bean.activateEdge.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import retrofit2.Response; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.RelationshipData; @@ -80,35 +82,26 @@ public class SotnServiceTemplateServiceImpl implements SotnServiceTemplateServic } public ModelConfig readFile() { - JSONParser parser = new JSONParser(); - ClassLoader classLoader = new SotnServiceQryServiceImpl().getClass().getClassLoader(); - File file = new File(classLoader.getResource("modelconfig.json").getFile()); ObjectMapper mapper = new ObjectMapper(); - try { - Object object = parser.parse(new FileReader(file)); - ModelConfig modelInformation = mapper.readValue(object.toString(), new TypeReference<ModelConfig>() { - }); - + Resource resource = new ClassPathResource("modelconfig.json"); + ModelConfig modelInformation = mapper.readValue(resource.getInputStream(), ModelConfig.class); + logger.info("subscriber id is: {}.", modelInformation.getSubscriberId()); return modelInformation; - } catch (ParseException | IOException ex) { - logger.error("Exception occured while reading configuration file:" + ex); + } catch (IOException ex) { + logger.error("Exception occured while reading configuration file: {}", ex); return null; } } - public ModelConfig readFile_unni(){ - JSONParser parser = new JSONParser(); - ClassLoader classLoader = new SotnServiceQryServiceImpl().getClass().getClassLoader(); - File file = new File(classLoader.getResource("modelconfigunni.json").getFile()); - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { - Object object = parser.parse(new FileReader(file)); - ModelConfig modelInformation = mapper.readValue(object.toString(), new TypeReference<ModelConfig>() { - }); + Resource resource = new ClassPathResource("modelconfigunni.json"); + ModelConfig modelInformation = mapper.readValue(resource.getInputStream(), ModelConfig.class); + logger.info("subscriber id is: {}.", modelInformation.getSubscriberId()); return modelInformation; - } catch (ParseException | IOException ex) { - // logger.error("Exception occured while reading configuration file:" + ex); + } catch (IOException ex) { + logger.error("Exception occured while reading configuration file: {}", ex); return null; } } @@ -154,7 +147,6 @@ public class SotnServiceTemplateServiceImpl implements SotnServiceTemplateServic logger.info("SO instantiate SOTN service has finished"); if (sotnserviceresponse.isSuccessful()) { logger.info("SO instantiate SOTN service is successful"); - result=sotnserviceresponse.body().getService(); return sotnserviceresponse.body(); } else { logger.error(String.format("Can not instantiate SOTN service[code=%s, message=%s]", sotnserviceresponse.code(), sotnserviceresponse.message())); @@ -857,6 +849,7 @@ public class SotnServiceTemplateServiceImpl implements SotnServiceTemplateServic edges.add(getEdge(uniInfo.getId(), unipinterface.getId())); } catch (Exception e) { + logger.info("Exception:"+e.getMessage()); } } diff --git a/server/src/main/resources/modelconfig.json b/server/src/main/resources/modelconfig.json index d2dfafc1..9e305998 100644 --- a/server/src/main/resources/modelconfig.json +++ b/server/src/main/resources/modelconfig.json @@ -1,5 +1,5 @@ { - "subscriberId":"ISAAC", + "subscriberId":"SOTN-CUST", "subscriptionType":"SOTN", "status":1, "modelInformation":[ diff --git a/server/src/main/resources/modelconfigunni.json b/server/src/main/resources/modelconfigunni.json index 7c8abe76..26aed2b2 100644 --- a/server/src/main/resources/modelconfigunni.json +++ b/server/src/main/resources/modelconfigunni.json @@ -1,5 +1,5 @@ { - "subscriberId":"ISAAC_1", + "subscriberId":"SOTN-001", "subscriptionType":"SOTN", "serviceInvariantUuid":"5c13f3fb-2744-4635-9f1f-c59c92dc8f70", "serviceUuid":"3a76b1f5-fb0d-4b6b-82d5-0e8a4ebc3838", @@ -38,4 +38,4 @@ } } ] -}
\ No newline at end of file +} |