aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java124
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java16
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java4
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java2
8 files changed, 77 insertions, 77 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
index 8cdeaaa9e1..cd6522b487 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
@@ -428,45 +428,46 @@ public class CatalogDbAdapterRest {
QueryVfModule qryResp;
int respStatus = HttpStatus.SC_OK;
List<VfModuleCustomization> ret = null;
- CatalogDatabase db = CatalogDatabase.getInstance();
-
- try{
- if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
- LOGGER.debug ("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
- VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
- if(vfModule != null){
- ret = new ArrayList<>(1);
- ret.add(vfModule);
- }
- }else{
- throw(new Exception("Incoming parameter is null or blank"));
- }
- if(ret == null || ret.isEmpty()){
- LOGGER.debug ("vfModules not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryVfModule();
- }else{
- LOGGER.debug ("vfModules found");
- qryResp = new QueryVfModule(ret);
- LOGGER.debug ("vfModules query Results is: "+ qryResp);
- LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
- }
- LOGGER.debug ("Query vfModules exit");
- return Response
- .status(respStatus)
- .entity(qryResp.JSON2(false, false))
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }catch(Exception e){
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }finally {
- db.close();
- }
+
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
+ LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
+ VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
+ if (vfModule != null) {
+ ret = new ArrayList<>(1);
+ ret.add(vfModule);
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ if (ret == null || ret.isEmpty()) {
+ LOGGER.debug("vfModules not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryVfModule();
+ } else {
+ LOGGER.debug("vfModules found");
+ qryResp = new QueryVfModule(ret);
+ LOGGER.debug("vfModules query Results is: " + qryResp);
+ LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false));
+ }
+ LOGGER.debug("Query vfModules exit");
+ return Response
+ .status(respStatus)
+ .entity(qryResp.JSON2(false, false))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ",
+ e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
}
/**
@@ -482,37 +483,36 @@ public class CatalogDbAdapterRest {
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response ServiceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
int respStatus = HttpStatus.SC_OK;
- CatalogDatabase db = CatalogDatabase.getInstance();
String entity = "";
- try{
- if(smUuid != null && !"".equals(smUuid)){
- LOGGER.debug ("Query Csar by service model uuid: " + smUuid);
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
+ if (smUuid != null && !"".equals(smUuid)) {
+ LOGGER.debug("Query Csar by service model uuid: " + smUuid);
ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid);
- if(toscaCsar != null){
+ if (toscaCsar != null) {
QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
entity = serviceCsar.JSON2(false, false);
- }
- else{
+ } else {
respStatus = HttpStatus.SC_NOT_FOUND;
}
- }else{
- throw(new Exception("Incoming parameter is null or blank"));
- }
- LOGGER.debug ("Query Csar exit");
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ LOGGER.debug("Query Csar exit");
return Response
- .status(respStatus)
- .entity(entity)
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }catch(Exception e){
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }finally {
- db.close();
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
}
}
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
index 31a58329d6..31594905fd 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java
@@ -70,7 +70,7 @@ public class CatalogDbAdapterRestClassTest {
*
*/
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("ciVFOnboarded-FNAT-aab06c41 1");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
index 33f5553115..ae5e663777 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java
@@ -114,7 +114,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -154,7 +154,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setVnfResourceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -198,7 +198,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<VnfResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
@@ -242,7 +242,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -282,7 +282,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -322,7 +322,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
ArrayList<NetworkResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -367,7 +367,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<AllottedResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
@@ -409,7 +409,7 @@ public class CatalogDbAdapterRestHttpTest {
try {
List<AllottedResourceCustomization> paramList;
// set up mock return value
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
index 31e828d19a..ee2c8db577 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java
@@ -49,7 +49,7 @@ public class CatalogQueryTest {
CatalogQuery mockCatalogQuery = Mockito.mock(CatalogQuery.class);
Mockito.doCallRealMethod().when(mockCatalogQuery).setTemplate(Mockito.anyString(), Mockito.anyMapOf(String.class, String.class));
- Map<String,String> valueMap = new HashMap<String,String>();
+ Map<String,String> valueMap = new HashMap<>();
valueMap.put("somekey", "somevalue");
String ret = mockCatalogQuery.setTemplate("<somekey>", valueMap);
@@ -60,7 +60,7 @@ public class CatalogQueryTest {
@Test
public void smartToJson_Test()
{
- List<VnfResourceCustomization> paramList = new ArrayList<VnfResourceCustomization>();
+ List<VnfResourceCustomization> paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
d1.setModelInstanceName("RG_6-26_mog11 0");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
index 71352b5272..0d86a6cf10 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java
@@ -43,7 +43,7 @@ public class QueryAllottedResourceCustomizationTest {
public void JSON2_Test()
{
List<AllottedResourceCustomization> paramList;
- paramList = new ArrayList<AllottedResourceCustomization>();
+ paramList = new ArrayList<>();
AllottedResourceCustomization d1 = new AllottedResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391");
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
index dfbc2dc384..3a767a8609 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java
@@ -47,7 +47,7 @@ public class QueryServiceMarcoHolderTest {
svc.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9");
svc.setModelName("Testing Model One");
ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
index b237dbe0a8..1c855eaa72 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java
@@ -45,7 +45,7 @@ public class QueryServiceNetworksTest {
public void JSON2_Test()
{
ArrayList<NetworkResourceCustomization> paramList;
- paramList = new ArrayList<NetworkResourceCustomization>();
+ paramList = new ArrayList<>();
NetworkResourceCustomization d1 = new NetworkResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
paramList.add(d1);
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
index 262fe06988..8c8fc967da 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java
@@ -44,7 +44,7 @@ public class QueryServiceVnfsTest {
public void JSON2_Test()
{
List<VnfResourceCustomization> paramList;
- paramList = new ArrayList<VnfResourceCustomization>();
+ paramList = new ArrayList<>();
VnfResourceCustomization d1 = new VnfResourceCustomization();
d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");