summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunder Tattavarada <statta@research.att.com>2020-08-04 17:40:58 +0000
committerGerrit Code Review <gerrit@onap.org>2020-08-04 17:40:58 +0000
commit0ee99992f35411273073c19e22367b641869d651 (patch)
tree5cb7081b956d35d1bed83b663a04dcd73c9b086b
parent3f22ef1f00477e4d697b0df5c6e2c8f81ea18fa2 (diff)
parent9c9f8c9643dcd6ccda3b765111a1b278267393c3 (diff)
Merge "Fix NPE & other issues"
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java7
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java34
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java35
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java9
4 files changed, 39 insertions, 46 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
index 6a581c19..0f6f3cea 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
@@ -151,9 +151,6 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
logger.debug(EELFLoggerDelegate.debugLogger, "Client Initialized");
-
-
-
}
@SuppressWarnings("unchecked")
@@ -178,7 +175,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
if (cres.getEntity() != null) {
try {
String str = (cres).readEntity(String.class);
- if (t.getClass().getName().equals(String.class.getName())) {
+ if (t.getClass().isAssignableFrom(String.class)) {
t = (T) str;
} else {
@@ -233,7 +230,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
try {
String str = (cres).readEntity(String.class);
- if (t.getClass().getName().equals(String.class.getName())) {
+ if (t.getClass().isAssignableFrom(String.class)) {
t = (T) str;
} else {
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
index c1ca8735..675cfe14 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
@@ -57,17 +57,17 @@ public class SchedulerUtil {
public static GetTimeSlotsWrapper getTimeSlotsWrapResponse (GetTimeSlotsRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
}
GetTimeSlotsWrapper w = new GetTimeSlotsWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
return (w);
@@ -75,19 +75,19 @@ public class SchedulerUtil {
public static PostSubmitVnfChangeTimeSlotsWrapper postSubmitNewVnfWrapResponse (PostSubmitVnfChangeRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
String uuid = "";
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
uuid = rs.getUUID();
}
PostSubmitVnfChangeTimeSlotsWrapper w = new PostSubmitVnfChangeTimeSlotsWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
w.setUuid(uuid);
@@ -96,19 +96,19 @@ public class SchedulerUtil {
public static PostCreateNewVnfWrapper postCreateNewVnfWrapResponse (PostCreateNewVnfRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
String uuid = "";
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
uuid = rs.getUUID();
}
PostCreateNewVnfWrapper w = new PostCreateNewVnfWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
w.setUuid(uuid);
@@ -121,14 +121,14 @@ public class SchedulerUtil {
ObjectMapper mapper = new ObjectMapper();
String r_json_str = "";
if ( t != null ) {
- try {
- r_json_str = mapper.writeValueAsString(t);
- }
- catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- DateUtil.getDateFormat().format(new Date()) + "<== " + methodName + " Unable " + "to "
- + "parse object as json");
- }
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException j) {
+ logger.debug(
+ EELFLoggerDelegate.debugLogger, DateUtil.getDateFormat().format(new Date())
+ + "<== " + methodName + " Unable " + "to " + "parse object as json",
+ j);
+ }
}
return (r_json_str);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
index 75919eee..f120c4f0 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
@@ -63,24 +63,21 @@ public class SchedulerAuxRestInt {
*
* @param r the r
*/
- public void logRequest ( RequestDetails r ) {
- SimpleDateFormat dateFormat = DateUtil.getDateFormat();
- String methodName = "logRequest";
- ObjectMapper mapper = new ObjectMapper();
- String r_json_str = "";
- if ( r != null ) {
- r_json_str = r.toString();
- try {
- r_json_str = mapper.writeValueAsString(r);
- }
- catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " "
- + "Unable to "
- + "parse request as json");
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Request="
- + "(" +
- r_json_str + ")");
+ public void logRequest(RequestDetails r) {
+ SimpleDateFormat dateFormat = DateUtil.getDateFormat();
+ String methodName = "logRequest";
+ ObjectMapper mapper = new ObjectMapper();
+ String rJsonStr = "";
+ if (r != null) {
+ rJsonStr = r.toString();
+ try {
+ rJsonStr = mapper.writeValueAsString(r);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException j) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " " + "Unable to " + "parse request as json", j);
+ }
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " Request=" + "(" + rJsonStr + ")");
}
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
index 5d38317a..4adf1fdb 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
@@ -62,6 +62,9 @@ import org.onap.portalsdk.core.service.DataAccessService;
public class EPRoleServiceImpl implements EPRoleService {
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPRoleServiceImpl.class);
+ private static final String GET_APP_ROLE_SQL_FORMAT =
+ "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s";
+
@Autowired
private DataAccessService dataAccessService;
@@ -123,10 +126,6 @@ public class EPRoleServiceImpl implements EPRoleService {
return (EPRole) getDataAccessService().getDomainObject(EPRole.class, id, null);
}
- // TODO: refactor
- private static final String GET_APP_ROLE_SQL_FORMAT =
- "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s";
-
@SuppressWarnings("unchecked")
public EPRole getRole(Long appId, Long appRoleid) {
if (appId == null || appRoleid == null) {
@@ -185,7 +184,7 @@ public class EPRoleServiceImpl implements EPRoleService {
if (roles != null) {
return roles.get(0);
}
- } else if (resultsCount == 1) {
+ } else if (roles!=null && resultsCount == 1) {
return roles.get(0);
}
return null;