* ============LICENSE_START==========================================
* ONAP Portal
* ===================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.onap.portalsdk.core.service.AuditService;
+import org.onap.portalsdk.core.service.DataAccessService;
import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
private ApplicationsRestClientService applicationsRestClientService;
@Autowired
private AuditService auditService;
+ @Autowired
+ private DataAccessService dataAccessService;
private static final String FAILURE = "failure";
EcompPortalUtils.setBadPermissions(user, response, "getAppRolesForUser");
feErrorString = EcompPortalUtils.getFEErrorString(true, response.getStatus());
} else {
+ try {
+ if(orgUserId!=null) {
+ EPUser localUser = getUserInfo(orgUserId,applicationsRestClientService);
+ if(localUser !=null) {
+ if(localUser.isSystemUser()) {
+ isSystemUser = true;
+ }
+ }
+ }
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "isSystemUser update failed", e);
+ }
if ((!isSystemUser && EcompPortalUtils.legitimateUserId(orgUserId)) || isSystemUser) {
result = userRolesService.getAppRolesForUser(appid, orgUserId, extRequestValue, user);
logger.debug(EELFLoggerDelegate.debugLogger, "getAppRolesForUser: result {}, appId {}", result, appid);
}
return isSuperAdmin;
}
+
+ /**
+ *
+ * @param userId
+ * @param app
+ * @param applicationsRestClientService
+ * @return EPUser
+ * @throws HTTPException
+ */
+ protected EPUser getUserInfo(String userId, ApplicationsRestClientService applicationsRestClientService)
+ throws HTTPException {
+ @SuppressWarnings("unchecked")
+ List<EPUser> userList = (List<EPUser>) dataAccessService
+ .executeQuery("from EPUser where orgUserId='" + userId + "'", null);
+ if (userList != null && !userList.isEmpty())
+ return userList.get(0);
+ else
+ return null;
+ }
}