/*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.openecomp.portalapp.portal.service;
import org.openecomp.portalapp.portal.domain.AppsResponse;
import org.openecomp.portalapp.portal.domain.EPApp;
import org.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.domain.EPUserAppRolesRequest;
+import org.openecomp.portalapp.portal.domain.EPUserAppRolesRequestDetail;
import org.openecomp.portalapp.portal.domain.EPUserAppsManualSortPreference;
import org.openecomp.portalapp.portal.domain.EPUserAppsSortPreference;
import org.openecomp.portalapp.portal.domain.EPWidgetsManualSortPreference;
ecompApp.setUebKey(app.getUebKey());
ecompApp.setUebSecret(app.getUebSecret());
ecompApp.setEnabled(app.getEnabled());
+ ecompApp.setCentralAuth(app.getCentralAuth());
+ ecompApp.setNameSpace(app.getNameSpace());
ecompApp.setRestrictedApp(app.isRestrictedApp());
ecompAppList.add(ecompApp);
}
@Override
public UserRoles getUserProfile(String loginId) {
- String format = "SELECT DISTINCT user.USER_ID, role.ROLE_ID, user.org_user_id, user.FIRST_NAME, user.LAST_NAME, role.ROLE_NAME FROM fn_user_role userrole "
- + "INNER JOIN fn_user user ON user.USER_ID = userrole.USER_ID "
- + "INNER JOIN fn_role role ON role.ROLE_ID = userrole.ROLE_ID "
- + "WHERE user.org_user_id = \"%s\" and (userrole.app_id = 1 or role.role_id = " + ACCOUNT_ADMIN_ROLE_ID
- + ") ";
- String sql = String.format(format, loginId);
- logQuery(sql);
+ final Map<String, String> params = new HashMap<>();
+ params.put("org_user_id", loginId);
@SuppressWarnings("unchecked")
- List<UserRole> userRoleList = dataAccessService.executeSQLQuery(sql, UserRole.class, null);
+ List<UserRole> userRoleList = dataAccessService.executeNamedQuery( "getUserRoles", params, null);
ArrayList<UserRoles> usersRolesList = aggregateUserProfileRowsResultsByRole(userRoleList);
if (usersRolesList == null || usersRolesList.size() < 1)
return null;
public List<LocalRole> getAppRoles(Long appId) {
String sql = "";
if (isRestrictedApp(appId)) {
- sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where ROLE_ID = '" + RESTRICTED_APP_ROLE_ID + "'";
- } else {
- sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where APP_ID = '" + appId + "'";
+ sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where UPPER(ACTIVE_YN) = 'Y' AND ROLE_ID = '" + RESTRICTED_APP_ROLE_ID + "'";
+ }else if(appId == 1){
+ sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where UPPER(ACTIVE_YN) = 'Y' AND APP_ID IS NULL";
+ }else{
+ sql = "SELECT ROLE_ID, ROLE_NAME from FN_ROLE where UPPER(ACTIVE_YN) = 'Y' AND APP_ID = '" + appId + "'";
}
logQuery(sql);
@SuppressWarnings("unchecked")
* (non-Javadoc)
*
* @see
- * org.openecomp.portalapp.portal.service.EPAppService#getAppCatalog(com.att
- * .fusionapp.ecomp.portal.domain.EPUser)
+ * org.openecomp.portalapp.portal.service.EPAppService#getAppCatalog(
+ * org.openecomp.portalapp.portal.domain.EPUser)
*/
@Override
public List<AppCatalogItem> getUserAppCatalog(EPUser user) {
return fieldsValidator;
}
+ @SuppressWarnings("unchecked")
@Override
public FieldsValidator deleteOnboardingApp(EPUser user, Long appid) {
FieldsValidator fieldsValidator = new FieldsValidator();
fieldsValidator.httpStatusCode = new Long(HttpServletResponse.SC_FORBIDDEN);
return fieldsValidator;
}
+ final Map<String, Long> params = new HashMap<>();
+ params.put("app_id", appid);
+ List<EPUserAppRolesRequest> EPUserAppRolesRequestList= new ArrayList<>();
+ EPUserAppRolesRequestList = dataAccessService.executeNamedQuery( "getRequestIdsForApp", params, null);
+ for(int i=0;i<EPUserAppRolesRequestList.size();i++)
+ {
+ dataAccessService.deleteDomainObjects(EPUserAppRolesRequestDetail.class , "req_id=" + EPUserAppRolesRequestList.get(i).getId(),null);
+
+ }
+
Boolean result = false;
Session localSession = null;
Transaction transaction = null;
logQuery(sql);
query = localSession.createSQLQuery(sql);
query.executeUpdate();
+
+
+ // Remove all roles, rolefunctions, appid records from ep_app_role_function
+ // that are associated with this app
+ sql = "DELETE FROM ep_app_role_function WHERE app_id='" + appid + "'";
+ logger.debug(EELFLoggerDelegate.debugLogger, "Executing query: " + sql);
+ query = localSession.createSQLQuery(sql);
+ query.executeUpdate();
+
+ //Remove all rolefunctions, appid records from ep_app_function
+ // that are associated with this app
+ sql = "DELETE FROM ep_app_function WHERE app_id='" + appid + "'";
+ logger.debug(EELFLoggerDelegate.debugLogger, "Executing query: " + sql);
+ query = localSession.createSQLQuery(sql);
+ query.executeUpdate();
// Remove all records from fn_user_role associated with this app
sql = "delete from fn_user_role where app_id='" + appid + "'";
transaction.commit();
result = true;
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "updateApp failed", e);
EcompPortalUtils.rollbackTransaction(transaction,
- "updateApp rollback, exception = " + EcompPortalUtils.getStackTrace(e));
+ "updateApp rollback, exception = " + e.toString());
} finally {
EcompPortalUtils.closeLocalSession(localSession, "updateApp");
}
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeUebRegisterOnboardingAppError, e);
EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeDaoSystemError, e);
EcompPortalUtils.rollbackTransaction(transaction,
- "updateApp rollback, exception = " + EcompPortalUtils.getStackTrace(e));
+ "updateApp rollback, exception = " + e.toString());
} finally {
EcompPortalUtils.closeLocalSession(localSession, "updateApp");
}
}
- public CambriaTopicManager getTopicManager(LinkedList<String> urlList, String key, String secret)
+ public CambriaTopicManager getTopicManager(List<String> urlList, String key, String secret)
throws GeneralSecurityException, Exception {
throw new Exception("This method can only be invoked from child class");
}
onboardingApp.uebTopicName = app.getUebTopicName();
onboardingApp.uebKey = app.getUebKey();
onboardingApp.uebSecret = app.getUebSecret();
+ onboardingApp.isCentralAuth = app.getCentralAuth();
+ onboardingApp.nameSpace = app.getNameSpace();
onboardingApp.setRestrictedApp(app.isRestrictedApp());
// if (app.getThumbnail() != null)
// onboardingApp.thumbnail = new
app.setUebTopicName(onboardingApp.uebTopicName);
app.setUebKey(onboardingApp.uebKey);
app.setUebSecret(onboardingApp.uebSecret);
+ app.setCentralAuth(onboardingApp.isCentralAuth);
+ app.setNameSpace(onboardingApp.nameSpace);
app.setRestrictedApp(onboardingApp.restrictedApp);
if (!StringUtils.isEmpty(onboardingApp.thumbnail)) {
logger.debug(EELFLoggerDelegate.debugLogger, "createAppFromOnboarding: onboarding thumbnail is NOT empty");
public List<EPApp> getUserRemoteApps(String id) {
throw new RuntimeException(" Cannot be called from parent class");
}
+
+ @Override
+ public UserRoles getUserProfileForLeftMenu(String loginId) {
+ final Map<String, String> params = new HashMap<>();
+ params.put("org_user_id", loginId);
+ @SuppressWarnings("unchecked")
+ List<UserRole> userRoleList = dataAccessService.executeNamedQuery( "getUserRolesForLeftMenu", params, null);
+ ArrayList<UserRoles> usersRolesList = aggregateUserProfileRowsResultsByRole(userRoleList);
+ if (usersRolesList == null || usersRolesList.size() < 1)
+ return null;
+
+ return usersRolesList.get(0);
+ }
+
+
+ @Override
+ public UserRoles getUserProfileNormalizedForLeftMenu(EPUser user) {
+ // Check database.
+ UserRoles userAndRoles = getUserProfileForLeftMenu(user.getLoginId());
+ // If no roles are defined, treat this user as a guest.
+ if (user.isGuest() || userAndRoles == null) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getUserProfileForLeftMenu: treating user {} as guest",
+ user.getLoginId());
+ UserRole userRole = new UserRole();
+ userRole.setUser_Id(user.getId());
+ userRole.setOrgUserId(user.getLoginId());
+ userRole.setFirstName(user.getFirstName());
+ userRole.setLastName(user.getLastName());
+ userRole.setRoleId(-1L);
+ userRole.setRoleName("Guest");
+ userRole.setUser_Id(-1L);
+ userAndRoles = new UserRoles(userRole);
+ }
+
+ return userAndRoles;
+ }
+
}