mysql-connector-java to mariadb-java-client change 38/97038/1
authorDominik Mizyn <d.mizyn@samsung.com>
Mon, 14 Oct 2019 08:03:26 +0000 (10:03 +0200)
committerDominik Mizyn <d.mizyn@samsung.com>
Mon, 14 Oct 2019 08:03:35 +0000 (10:03 +0200)
plus changes in services and controllers

Issue-ID: PORTAL-710
Change-Id: I8f2a44e889ea39971693f8845efbb9cdff05e932
Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
14 files changed:
portal-BE/docker-compose.yml
portal-BE/pom.xml
portal-BE/src/main/java/org/onap/portal/dao/fn/FnRoleDao.java
portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnRole.java
portal-BE/src/main/java/org/onap/portal/domain/db/fn/FnUser.java
portal-BE/src/main/java/org/onap/portal/domain/dto/DomainVo.java
portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserAppCatalogRoles.java
portal-BE/src/main/java/org/onap/portal/domain/dto/ecomp/EPUserNotification.java
portal-BE/src/main/java/org/onap/portal/domain/dto/transport/EpNotificationItem.java
portal-BE/src/main/java/org/onap/portal/service/AdminRolesService.java
portal-BE/src/main/java/org/onap/portal/service/fn/FnRoleService.java
portal-BE/src/main/java/org/onap/portal/service/fn/FnUserService.java
portal-BE/src/main/java/org/onap/portal/utils/SystemType.java [new file with mode: 0644]
portal-BE/src/main/resources/application.properties

index e74888d..2293afb 100644 (file)
@@ -10,8 +10,8 @@ version: '3.1'
 
 services:
   portal-db:
-#    image: mariadb
-    image: mysql
+    image: mariadb
+#    image: mysql
     container_name: portal_mariaDB
     ports:
       - 3306:3306
index 8251dbf..13477b6 100644 (file)
                   <artifactId>h2</artifactId>
                   <scope>runtime</scope>
             </dependency>
-            <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
+            <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
             <dependency>
-                  <groupId>mysql</groupId>
-                  <artifactId>mysql-connector-java</artifactId>
-                  <version>8.0.17</version>
+                  <groupId>org.mariadb.jdbc</groupId>
+                  <artifactId>mariadb-java-client</artifactId>
+                  <version>2.5.0</version>
             </dependency>
             <!-- https://mvnrepository.com/artifact/org.glassfish/javax.el -->
             <dependency>
                   <artifactId>swagger-annotations</artifactId>
                   <version>1.5.20</version>
             </dependency>
+            <dependency>
+                  <groupId>org.apache.cxf</groupId>
+                  <artifactId>cxf-rt-rs-client</artifactId>
+                  <version>3.3.2</version>
+                  <scope>compile</scope>
+            </dependency>
       </dependencies>
       <properties>
             <docker.image.prefix>portal</docker.image.prefix>
index c7d1c0e..66f4758 100644 (file)
 
 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);
 }
index 20589b8..edd843a 100644 (file)
@@ -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"),
index ed79cb2..c5a9719 100644 (file)
@@ -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")
index a965c62..230da91 100644 (file)
@@ -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();
index c5fbd40..aa57cb8 100644 (file)
@@ -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;
+       }
 }
index 864db8b..88f2e4f 100644 (file)
@@ -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
index a3f8af6..59a577a 100644 (file)
@@ -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
index 88e379a..c2d88bc 100644 (file)
@@ -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;
index 539d4bd..45867b4 100644 (file)
 
 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;
+       }
 }
index 0565fc5..5c1c84b 100644 (file)
 
 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 (file)
index 0000000..fe7ff8f
--- /dev/null
@@ -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
+}
index 948ef96..6debc9a 100644 (file)
@@ -1,7 +1,7 @@
 server.port=8080
 
 spring.datasource.url=jdbc:mysql://portal-db:3306/testdb?createDatabaseIfNotExist=true&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
-spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
++spring.datasource.driverClassName=org.mariadb.jdbc.Driver
 spring.datasource.initialization-mode=always
 spring.session.jdbc.initialize-schema=always
 spring.datasource.continueOnError=true