summaryrefslogtreecommitdiffstats
path: root/portal-BE/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'portal-BE/src/main/java')
-rw-r--r--portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java5
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java2
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java2
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java6
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java10
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java3
-rw-r--r--portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java3
-rw-r--r--portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java1
-rw-r--r--portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java26
-rw-r--r--portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java20
-rw-r--r--portal-BE/src/main/java/org/onap/portal/utils/SystemType.java44
11 files changed, 107 insertions, 15 deletions
diff --git a/portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java
index c7d1c0e3..66f4758c 100644
--- a/portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java
+++ b/portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java
@@ -40,8 +40,11 @@
package org.onap.portal.dao.fn;
+import java.util.List;
import org.onap.portal.domain.db.fn.FnRole;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@@ -49,4 +52,6 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface FnRoleDao extends JpaRepository<FnRole, Long> {
+ @Query
+ List<FnRole> retrieveAppRoleByAppRoleIdAndByAppId(final @Param("appId") Long appId, final @Param("appRoleId") Long appRoleId);
}
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java
index 20589b8d..edd843ac 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java
@@ -102,7 +102,7 @@ CREATE TABLE `fn_role` (
query = "FROM FnRole where role_id =:roleId and app_id is null"),
@NamedQuery(
name = "FnRole.retrieveAppRoleByAppRoleIdAndByAppId",
- query = "FROM FnRole where app_role_id =:appRoleId and app_id =:appId"),
+ query = "FROM FnRole where appRoleId =:appRoleId and appId =:appId"),
@NamedQuery(
name = "FnRole.retrieveAppRoleByRoleIdAndAppId",
query = "FROM FnRole where role_id =:roleId and app_id =:appId"),
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java
index ed79cb2c..c5a97195 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java
@@ -342,7 +342,7 @@ public class FnUser extends DomainVo implements UserDetails, Serializable {
@SafeHtml
private String siloStatus;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
- @JoinColumn(name = "language_id", nullable = false, columnDefinition = "int(11) DEFAULT 1")
+ @JoinColumn(name = "language_id", nullable = false, columnDefinition = "bigint DEFAULT 1")
@NotNull(message = "languageId must not be null")
private FnLanguage languageId;
@Column(name = "is_guest", nullable = false, columnDefinition = "bit DEFAULT 0")
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java
index a965c62d..230da910 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java
@@ -76,7 +76,11 @@ public class DomainVo extends FusionVo implements Serializable, Cloneable, Compa
protected Serializable auditUserId;
protected Set auditTrail = null;
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DomainVo.class);
-
+
+ public DomainVo(Long id) {
+ this.id = id;
+ }
+
@Override
public int compareTo(Object obj) {
Long c1 = this.getId();
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java
index c5fbd40d..aa57cb83 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java
@@ -57,10 +57,16 @@ import org.onap.portal.domain.dto.DomainVo;
public class EPUserAppCatalogRoles extends DomainVo {
private static final long serialVersionUID = -5259869298825093816L;
-
private Long requestedRoleId;
- private String rolename;
+ private String roleName;
private String requestStatus;
private Long appId;
+ public EPUserAppCatalogRoles(Long reqId, Long requestedRoleId, String roleName, String requestStatus, Long appId) {
+ super(reqId);
+ this.requestedRoleId = requestedRoleId;
+ this.roleName = roleName;
+ this.requestStatus = requestStatus;
+ this.appId = appId;
+ }
}
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java
index 864db8bc..88f2e4f0 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java
@@ -45,7 +45,8 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import org.onap.portal.domain.dto.DomainVo;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+
@Getter
@Setter
diff --git a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java
index a3f8af6e..59a577ae 100644
--- a/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java
+++ b/portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java
@@ -53,7 +53,8 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.SafeHtml;
-import org.onap.portal.domain.dto.DomainVo;
+import org.onap.portalsdk.core.domain.support.DomainVo;
+
@Getter
@Setter
diff --git a/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java b/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java
index 88e379ab..c2d88bc1 100644
--- a/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java
+++ b/portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java
@@ -47,7 +47,6 @@ import javax.persistence.EntityManager;
import org.onap.portal.domain.db.fn.FnRole;
import org.onap.portal.domain.db.fn.FnUser;
import org.onap.portal.domain.db.fn.FnUserRole;
-import org.onap.portal.domain.dto.ecomp.UserRole;
import org.onap.portal.logging.format.EPAppMessagesEnum;
import org.onap.portal.logging.logic.EPLogUtil;
import org.onap.portal.service.fn.FnUserRoleService;
diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java
index 539d4bdc..45867b42 100644
--- a/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java
+++ b/portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java
@@ -40,9 +40,13 @@
package org.onap.portal.service.fn;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import javax.persistence.EntityExistsException;
import org.onap.portal.dao.fn.FnRoleDao;
import org.onap.portal.domain.db.fn.FnRole;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -50,6 +54,9 @@ import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class FnRoleService {
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnRoleService.class);
+
+
private final FnRoleDao fnRoleDao;
@Autowired
@@ -57,7 +64,24 @@ public class FnRoleService {
this.fnRoleDao = fnRoleDao;
}
- public FnRole getById(final Long id){
+ public FnRole getById(final Long id) {
return fnRoleDao.findById(id).orElseThrow(EntityExistsException::new);
}
+
+ public FnRole getRole(final Long appId, final Long appRoleId) {
+
+ String sql = "SELECT * FROM fn_role where APP_ID = :appId AND APP_ROLE_ID = :appRoleId";
+
+ List<FnRole> roles = Optional.of(fnRoleDao.retrieveAppRoleByAppRoleIdAndByAppId(appId, appRoleId)).orElse(new ArrayList<>());
+ if (!roles.isEmpty()) {
+ logger.error(EELFLoggerDelegate.errorLogger,
+ String.format(
+ "search by appId=%s, appRoleid=%s should have returned 0 or 1 results. Got %d. This is an internal server error.",
+ appId, appRoleId, roles.size()));
+ logger.error(EELFLoggerDelegate.errorLogger,
+ "Trying to recover from duplicates by returning the first search result. This issue should be treated, it is probably not critical because duplicate roles should be similar.");
+ return roles.get(0);
+ }
+ return null;
+ }
}
diff --git a/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java b/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java
index 0565fc5d..5c1c84b5 100644
--- a/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java
+++ b/portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java
@@ -40,12 +40,18 @@
package org.onap.portal.service.fn;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import org.onap.portal.controller.UserRolesController;
import org.onap.portal.dao.fn.FnUserDao;
import org.onap.portal.domain.db.fn.FnUser;
+import org.onap.portal.domain.dto.transport.UserWithNameSurnameTitle;
+import org.onap.portal.utils.EcompPortalUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.security.core.userdetails.UserDetailsService;
@@ -58,6 +64,8 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class FnUserService implements UserDetailsService {
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FnUserService.class);
+
private FnUserDao fnUserDao;
@Autowired
@@ -83,20 +91,20 @@ public class FnUserService implements UserDetailsService {
return Optional.of(fnUserDao.getOne(id));
}
- List<FnUser> getUserWithOrgUserId(final String orgUserIdValue){
+ List<FnUser> getUserWithOrgUserId(final String orgUserIdValue) {
return fnUserDao.getUserWithOrgUserId(orgUserIdValue).orElse(new ArrayList<>());
}
- List<FnUser> getUsersByOrgIds(final List<String> orgIds){
+ List<FnUser> getUsersByOrgIds(final List<String> orgIds) {
return fnUserDao.getUsersByOrgIds(orgIds).orElse(new ArrayList<>());
}
- List<FnUser> getActiveUsers(){
+ List<FnUser> getActiveUsers() {
return fnUserDao.getActiveUsers().orElse(new ArrayList<>());
}
- public void deleteUser(final FnUser fnUser){
+ public void deleteUser(final FnUser fnUser) {
fnUserDao.delete(fnUser);
}
@@ -104,7 +112,7 @@ public class FnUserService implements UserDetailsService {
return fnUserDao.existsById(userId);
}
- public List<FnUser> findAll(){
+ public List<FnUser> findAll() {
return fnUserDao.findAll();
}
-}
+ } \ No newline at end of file
diff --git a/portal-BE/src/main/java/org/onap/portal/utils/SystemType.java b/portal-BE/src/main/java/org/onap/portal/utils/SystemType.java
new file mode 100644
index 00000000..fe7ff8f2
--- /dev/null
+++ b/portal-BE/src/main/java/org/onap/portal/utils/SystemType.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 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
+ *
+ * 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============================================
+ *
+ *
+ */
+package org.onap.portal.utils;
+
+public enum SystemType {
+
+ APPLICATION,
+// SYSTEM
+}