From 68c0962794f50cc7bad44329c59cdb6bded8e983 Mon Sep 17 00:00:00 2001
From: Joze RIHTARSIC <joze.rihtarsic@ext.ec.europa.eu>
Date: Wed, 29 Aug 2018 09:02:45 +0200
Subject: [PATCH] Implementation of rest services for UI (servicegroup,
 servicemetadata, domains, users)

---
 pom.xml                                       |   1 +
 smp-parent-pom/pom.xml                        |  18 ++
 smp-server-library/pom.xml                    |  13 +
 .../smp/conversion/ServiceGroupConverter.java |  20 +-
 .../conversion/ServiceMetadataConverter.java  |  18 +-
 .../smp/data/dao/ui/UiDaoService.java         | 230 ++++++++++++++++++
 .../ec/edelivery/smp/data/ui/DomainRO.java    |  84 +++++++
 .../edelivery/smp/data/ui/ServiceGroupRO.java |  79 ++++++
 .../smp/data/ui/ServiceMetadataRO.java        |  86 +++++++
 .../edelivery/smp/data/ui/ServiceResult.java  |  60 +++++
 .../ec/edelivery/smp/data/ui/UserRO.java      |  64 +++++
 .../edelivery/smp/services/ServiceUIData.java | 111 +++++++++
 smp-webapp/pom.xml                            |   5 +
 .../edelivery/smp/config/DatabaseConfig.java  |   2 +-
 .../edelivery/smp/config/SmpWebAppConfig.java |   5 +-
 .../ec/edelivery/smp/ui/DomainResource.java   |  47 ++++
 .../smp/ui/ServiceGroupResource.java          |  49 ++++
 .../smp/ui/ServiceMetadataResource.java       |  48 ++++
 .../ec/edelivery/smp/ui/UserResource.java     |  47 ++++
 .../src/main/resources/spring-security.xml    |   2 +-
 .../mysql5innoDb-4.0.0-to-4.1.0.ddl           |   8 +-
 .../database-scripts/mysql5innoDb-4.1.0.ddl   |   9 +-
 .../database-scripts/oracle10g-4.1.0.ddl      |   2 +-
 .../ErrorMappingControllerAdviceTest.java     |   9 +-
 24 files changed, 982 insertions(+), 35 deletions(-)
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ui/UiDaoService.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceGroupRO.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceResult.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/UserRO.java
 create mode 100644 smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ServiceUIData.java
 create mode 100644 smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/DomainResource.java
 create mode 100644 smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java
 create mode 100644 smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceMetadataResource.java
 create mode 100644 smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java

diff --git a/pom.xml b/pom.xml
index fd0504644..c8b0edf36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,7 @@
     <modules>
         <module>smp-parent-pom</module>
         <module>smp-api</module>
+        <!-- module>smp-angular</module -->
         <module>smp-server-library</module>
         <module>smp-webapp</module>
     </modules>
diff --git a/smp-parent-pom/pom.xml b/smp-parent-pom/pom.xml
index 82e0e4217..5c12286fb 100644
--- a/smp-parent-pom/pom.xml
+++ b/smp-parent-pom/pom.xml
@@ -95,6 +95,7 @@
 		<lombok.version>1.16.16</lombok.version>
 		<xmlunit.version>2.5.1</xmlunit.version>
 		<hamcrest.version>2.0.0.0</hamcrest.version>
+		<jackson.version>2.9.2</jackson.version>
 
 		<!-- jacoco, sonar code coverage settings start -->
         <sonar.jacoco.reportPath>${maven.multiModuleProjectDirectory}/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
@@ -422,6 +423,23 @@
 				<version>${junit.version}</version>
 				<scope>test</scope>
 			</dependency>
+			<!-- Jackson-->
+			<dependency>
+				<groupId>com.fasterxml.jackson.core</groupId>
+				<artifactId>jackson-databind</artifactId>
+				<version>${jackson.version}</version>
+			</dependency>
+			<dependency>
+				<groupId>com.fasterxml.jackson.core</groupId>
+				<artifactId>jackson-core</artifactId>
+				<version>${jackson.version}</version>
+			</dependency>
+			<dependency>
+				<groupId>com.fasterxml.jackson.core</groupId>
+				<artifactId>jackson-annotations</artifactId>
+				<version>${jackson.version}</version>
+			</dependency>
+			<!-- End Jackson-->
 			<dependency>
 				<groupId>org.apache.commons</groupId>
 				<artifactId>commons-lang3</artifactId>
diff --git a/smp-server-library/pom.xml b/smp-server-library/pom.xml
index 06254dbba..77538b611 100644
--- a/smp-server-library/pom.xml
+++ b/smp-server-library/pom.xml
@@ -90,6 +90,19 @@
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-config</artifactId>
         </dependency>
+        <!-- Jackson-->
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-core</artifactId>
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
index f7ddf2b5f..c7e1b17a2 100644
--- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceGroupConverter.java
@@ -44,18 +44,18 @@ public class ServiceGroupConverter {
 
     private static final String PARSER_DISALLOW_DTD_PARSING_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
 
-    static Unmarshaller jaxbUnmarshaller;
-
-    private static Unmarshaller getUnmarshaller() throws JAXBException {
-        if(jaxbUnmarshaller != null) {
-            return jaxbUnmarshaller;
-        }
-
-        synchronized (ServiceGroupConverter.class) {
+    private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial( () -> {
+        try {
             JAXBContext jaxbContext = JAXBContext.newInstance(ServiceGroup.class);
-            jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-            return jaxbUnmarshaller;
+            return jaxbContext.createUnmarshaller();
+        }catch(JAXBException ex) {
+            throw new RuntimeException("Could not create ServiceGroup Unmarshaller!");
         }
+    } );
+
+
+    private static Unmarshaller getUnmarshaller() throws JAXBException {
+        return jaxbUnmarshaller.get();
     }
 
     public static ServiceGroup unmarshal(String serviceGroupXml) {
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverter.java
index 065c49f43..7be652de1 100644
--- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverter.java
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/ServiceMetadataConverter.java
@@ -46,17 +46,17 @@ public class ServiceMetadataConverter {
     private static final String DOC_SIGNED_SERVICE_METADATA_EMPTY = "<SignedServiceMetadata xmlns=\""+NS+"\"/>";
     private static final String PARSER_DISALLOW_DTD_PARSING_FEATURE = "http://apache.org/xml/features/disallow-doctype-decl";
 
-    static Unmarshaller jaxbUnmarshaller;
-
-    private static Unmarshaller getUnmarshaller() throws JAXBException {
-        if (jaxbUnmarshaller != null) {
-            return jaxbUnmarshaller;
-        }
-        synchronized (ServiceMetadataConverter.class) {
+    private static final ThreadLocal<Unmarshaller> jaxbUnmarshaller = ThreadLocal.withInitial( () -> {
+        try {
             JAXBContext jaxbContext = JAXBContext.newInstance(ServiceMetadata.class);
-            jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-            return jaxbUnmarshaller;
+            return jaxbContext.createUnmarshaller();
+        }catch(JAXBException ex) {
+            throw new RuntimeException("Could not create ServiceGroup Unmarshaller!");
         }
+    } );
+
+    private static Unmarshaller getUnmarshaller() throws JAXBException {
+        return jaxbUnmarshaller.get();
     }
 
     public static Document toSignedServiceMetadatadaDocument(String serviceMetadataXml)  {
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ui/UiDaoService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ui/UiDaoService.java
new file mode 100644
index 000000000..9f1c974bc
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ui/UiDaoService.java
@@ -0,0 +1,230 @@
+package eu.europa.ec.edelivery.smp.data.dao.ui;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+
+@Service
+public class UiDaoService {
+
+    @PersistenceContext
+    protected EntityManager memEManager;
+    private static final Logger LOG = LoggerFactory.getLogger(UiDaoService.class);
+
+    /**
+     *
+     * @param <T>
+     * @param type
+     * @param searchParams
+     * @param forCount
+     * @param sortField
+     * @param sortOrder
+     * @return
+     */
+    protected <T, D> CriteriaQuery createSearchCriteria(Class<T> type,
+                                                        Object searchParams, Class<D> filterType,
+                                                        boolean forCount, String sortField, String sortOrder) {
+        CriteriaBuilder cb = memEManager.getCriteriaBuilder();
+        CriteriaQuery cq = forCount ? cb.createQuery(Long.class
+        ) : cb.createQuery(
+                type);
+        Root<T> om = cq.from(filterType == null ? type : filterType);
+        if (forCount) {
+            cq.select(cb.count(om));
+        } else if (sortField != null) {
+            if (sortOrder != null && sortOrder.equalsIgnoreCase("desc")) {
+                cq.orderBy(cb.asc(om.get(sortField)));
+            } else {
+                cq.orderBy(cb.desc(om.get(sortField)));
+            }
+        } else {
+           // cq.orderBy(cb.desc(om.get("Id")));
+        }
+        List<Predicate> lstPredicate = new ArrayList<>();
+        // set order by
+        if (searchParams != null) {
+            Class cls = searchParams.getClass();
+            Method[] methodList = cls.getMethods();
+            for (Method m : methodList) {
+                // only getters (public, starts with get, no arguments)
+                String mName = m.getName();
+                if (Modifier.isPublic(m.getModifiers()) && m.getParameterCount() == 0
+                        && !m.getReturnType().equals(Void.TYPE)
+                        && (mName.startsWith("get") || mName.startsWith("is"))) {
+                    String fieldName = mName.substring(mName.startsWith("get") ? 3 : 2);
+                    // get returm parameter
+                    Object searchValue;
+                    try {
+                        searchValue = m.invoke(searchParams, new Object[]{});
+                    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                       // LOG.error(l, ex);
+                        continue;
+                    }
+
+                    if (searchValue == null) {
+                        continue;
+                    }
+
+                    if (fieldName.endsWith("List") && searchValue instanceof List) {
+                        String property = fieldName.substring(0, fieldName.lastIndexOf(
+                                "List"));
+                        if (!((List) searchValue).isEmpty()) {
+                            lstPredicate.add(om.get(property).in(
+                                    ((List) searchValue).toArray()));
+                        } else {
+                            lstPredicate.add(om.get(property).isNull());
+                        }
+                    } else {
+                        try {
+                            cls.getMethod("set" + fieldName, new Class[]{m.getReturnType()});
+                        } catch (NoSuchMethodException | SecurityException ex) {
+                            // method does not have setter // ignore other methods
+                            continue;
+                        }
+
+                        if (fieldName.endsWith("From") && searchValue instanceof Comparable) {
+                            lstPredicate.add(cb.greaterThanOrEqualTo(
+                                    om.get(fieldName.substring(0, fieldName.
+                                            lastIndexOf("From"))),
+                                    (Comparable) searchValue));
+                        } else if (fieldName.endsWith("To") && searchValue instanceof Comparable) {
+                            lstPredicate.add(cb.lessThan(
+                                    om.
+                                            get(fieldName.substring(0, fieldName.lastIndexOf(
+                                                    "To"))),
+                                    (Comparable) searchValue));
+                        } else if (searchValue instanceof String) {
+                            if (!((String) searchValue).isEmpty()) {
+                                lstPredicate.add(cb.equal(om.get(fieldName), searchValue));
+                            }
+                        } else if (searchValue instanceof BigInteger) {
+                            lstPredicate.add(cb.equal(om.get(fieldName), searchValue));
+                        } else {
+                            LOG.warn("Unknown search value type %s for method %s! "
+                                            + "Parameter is ignored!",
+                                    searchValue, fieldName);
+                        }
+                    }
+
+                }
+            }
+            if (!lstPredicate.isEmpty()) {
+                Predicate[] tblPredicate = lstPredicate.stream().toArray(
+                        Predicate[]::new);
+                cq.where(cb.and(tblPredicate));
+            }
+        }
+        return cq;
+    }
+
+
+    public <T> List<T> getDataList(Class<T> type, String hql,
+                                   Map<String, Object> params) {
+        TypedQuery<T> q = memEManager.createQuery(hql, type);
+        params.forEach((param, value) -> {
+            q.setParameter(param, value);
+        });
+        return q.getResultList();
+    }
+
+    /**
+     *
+     * @param <T>
+     * @param type
+     * @param startingAt
+     * @param maxResultCnt
+     * @param sortField
+     * @param sortOrder
+     * @param filters
+     * @return
+     */
+
+    public <T> List<T> getDataList(Class<T> type, int startingAt, int maxResultCnt,
+                                   String sortField,
+                                   String sortOrder, Object filters) {
+
+        return getDataList(type, startingAt, maxResultCnt, sortField, sortOrder,
+                filters, null);
+    }
+
+    /**
+     *
+     * @param <T>
+     * @param resultType
+     * @param startingAt
+     * @param maxResultCnt
+     * @param sortField
+     * @param sortOrder
+     * @param filters
+     * @param filterType
+     * @return
+     */
+    public <T, D> List<T> getDataList(Class<T> resultType, int startingAt,
+                                      int maxResultCnt,
+                                      String sortField,
+                                      String sortOrder, Object filters, Class<D> filterType) {
+
+        List<T> lstResult;
+        try {
+            CriteriaQuery<T> cq = createSearchCriteria(resultType, filters, filterType,
+                    false, sortField,
+                    sortOrder);
+            TypedQuery<T> q = memEManager.createQuery(cq);
+            if (maxResultCnt > 0) {
+                q.setMaxResults(maxResultCnt);
+            }
+            if (startingAt > 0) {
+                q.setFirstResult(startingAt);
+            }
+            lstResult = q.getResultList();
+        } catch (NoResultException ex) {
+            lstResult = new ArrayList<>();
+        }
+
+        return lstResult;
+    }
+
+    /**
+     *
+     * @param <T>
+     * @param type
+     * @param filters
+     * @return
+     */
+    public <T> long getDataListCount(Class<T> type, Object filters) {
+        CriteriaQuery<Long> cqCount = createSearchCriteria(type, filters, null, true,
+                null,
+                null);
+        Long res = memEManager.createQuery(cqCount).getSingleResult();
+        return res;
+    }
+
+    public <T> void persist(T entity){
+        memEManager.persist(entity);
+    }
+
+    public <T> void update(T entity){
+        memEManager.merge(entity);
+    }
+
+    public <T> void remove(T entity){
+        memEManager.remove(entity);
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java
new file mode 100644
index 000000000..2f21c65c0
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/DomainRO.java
@@ -0,0 +1,84 @@
+package eu.europa.ec.edelivery.smp.data.ui;
+
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+import static eu.europa.ec.edelivery.smp.data.model.CommonColumnsLengths.MAX_IDENTIFIER_VALUE_LENGTH;
+import static eu.europa.ec.edelivery.smp.data.model.CommonColumnsLengths.MAX_USERNAME_LENGTH;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@Entity
+@Table(name = "smp_domain")
+public class DomainRO implements Serializable {
+
+    @Id
+    @Column(name = "domainId")
+    private String domainId;
+    @Column(name = "bdmslClientCertHeader")
+    private String bdmslClientCertHeader;
+    @Column(name = "bdmslClientCertAlias")
+    private String bdmslClientCertAlias;
+    @Column(name = "bdmslSmpId")
+    private String bdmslSmpId;
+    @Column(name = "signatureCertAlias")
+    private String signatureCertAlias;
+
+
+    public DomainRO(){
+
+    }
+
+
+    public DomainRO(String domainId, String bdmslClientCertHeader, String bdmslClientCertAlias, String bdmslSmpId, String signatureCertAlias) {
+        this.domainId = domainId;
+        this.bdmslClientCertHeader = bdmslClientCertHeader;
+        this.bdmslClientCertAlias = bdmslClientCertAlias;
+        this.bdmslSmpId = bdmslSmpId;
+        this.signatureCertAlias = signatureCertAlias;
+    }
+
+    public String getDomainId() {
+        return domainId;
+    }
+
+    public void setDomainId(String domainId) {
+        this.domainId = domainId;
+    }
+
+    public String getBdmslClientCertHeader() {
+        return bdmslClientCertHeader;
+    }
+
+    public void setBdmslClientCertHeader(String bdmslClientCertHeader) {
+        this.bdmslClientCertHeader = bdmslClientCertHeader;
+    }
+
+    public String getBdmslClientCertAlias() {
+        return bdmslClientCertAlias;
+    }
+
+    public void setBdmslClientCertAlias(String bdmslClientCertAlias) {
+        this.bdmslClientCertAlias = bdmslClientCertAlias;
+    }
+
+    public String getBdmslSmpId() {
+        return bdmslSmpId;
+    }
+
+    public void setBdmslSmpId(String bdmslSmpId) {
+        this.bdmslSmpId = bdmslSmpId;
+    }
+
+    public String getSignatureCertAlias() {
+        return signatureCertAlias;
+    }
+
+    public void setSignatureCertAlias(String signatureCertAlias) {
+        this.signatureCertAlias = signatureCertAlias;
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceGroupRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceGroupRO.java
new file mode 100644
index 000000000..40a1513e1
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceGroupRO.java
@@ -0,0 +1,79 @@
+package eu.europa.ec.edelivery.smp.data.ui;
+
+
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@Entity
+@Table(name = "smp_service_group")
+public class ServiceGroupRO implements Serializable {
+
+
+    @EmbeddedId
+    ServiceGroupROId serviceGroupROId;
+
+    @Column(name = "domainId")
+    private String domain;
+
+    public ServiceGroupROId getServiceGroupROId() {
+        return serviceGroupROId;
+    }
+
+    public void setServiceGroupROId(ServiceGroupROId serviceGroupROId) {
+        this.serviceGroupROId = serviceGroupROId;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+
+
+    @Embeddable
+    @ToString
+    @EqualsAndHashCode
+    public static class ServiceGroupROId implements Serializable {
+        @Column(name = "businessIdentifier")
+        private String participantId;
+        @Column(name = "businessIdentifierScheme")
+        private String participantSchema;
+
+        public ServiceGroupROId(){
+
+        }
+
+        public ServiceGroupROId(String participantId, String participantSchema) {
+            this.participantId = participantId;
+            this.participantSchema = participantSchema;
+        }
+
+        public String getParticipantId() {
+            return participantId;
+        }
+
+        public void setParticipantId(String participantId) {
+            this.participantId = participantId;
+        }
+
+        public String getParticipantSchema() {
+            return participantSchema;
+        }
+
+        public void setParticipantSchema(String participanSchema) {
+            this.participantSchema = participanSchema;
+        }
+
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java
new file mode 100644
index 000000000..1259971a3
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java
@@ -0,0 +1,86 @@
+package eu.europa.ec.edelivery.smp.data.ui;
+
+
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@Entity
+@Table(name = "smp_service_metadata")
+public class ServiceMetadataRO implements Serializable {
+
+
+    @EmbeddedId
+    ServiceMetadataROId serviceMetadataROId;
+
+    public ServiceMetadataROId getServiceMetadataROId() {
+        return serviceMetadataROId;
+    }
+
+    public void setServiceMetadataROId(ServiceMetadataROId serviceMetadataROId) {
+        this.serviceMetadataROId = serviceMetadataROId;
+    }
+
+    @Embeddable
+    @ToString
+    @EqualsAndHashCode
+    public static class ServiceMetadataROId implements Serializable {
+        @Column(name = "businessIdentifier")
+        private String participantId;
+        @Column(name = "businessIdentifierScheme")
+        private String participantSchema;
+        @Column(name = "documentIdentifierScheme")
+        private String documentIdScheme;
+        @Column(name = "documentIdentifier")
+        private String documentIdValue;
+
+        public ServiceMetadataROId() {
+        }
+
+        public ServiceMetadataROId(String participantId, String participantSchema, String documentIdScheme, String documentIdValue) {
+            this.participantId = participantId;
+            this.participantSchema = participantSchema;
+            this.documentIdScheme = documentIdScheme;
+            this.documentIdValue = documentIdValue;
+        }
+
+        public String getParticipantId() {
+            return participantId;
+        }
+
+        public void setParticipantId(String participantId) {
+            this.participantId = participantId;
+        }
+
+        public String getParticipantSchema() {
+            return participantSchema;
+        }
+
+        public void setParticipantSchema(String participantSchema) {
+            this.participantSchema = participantSchema;
+        }
+
+        public String getDocumentIdScheme() {
+            return documentIdScheme;
+        }
+
+        public void setDocumentIdScheme(String documentIdScheme) {
+            this.documentIdScheme = documentIdScheme;
+        }
+
+        public String getDocumentIdValue() {
+            return documentIdValue;
+        }
+
+        public void setDocumentIdValue(String documentIdValue) {
+            this.documentIdValue = documentIdValue;
+        }
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceResult.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceResult.java
new file mode 100644
index 000000000..95214753d
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceResult.java
@@ -0,0 +1,60 @@
+package eu.europa.ec.edelivery.smp.data.ui;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+public class  ServiceResult<T> implements Serializable {
+
+    private Map<String, Object> filter; //NOSONAR
+    private List<T> serviceEntities;
+
+
+    private Long count;
+    private Integer page;
+    private Integer pageSize;
+
+    public Map<String, Object> getFilter() {
+        return filter;
+    }
+
+    public void setFilter(Map<String, Object> filter) {
+        this.filter = filter;
+    }
+
+    public List<T> getServiceEntities() {
+        if (serviceEntities == null) {
+            serviceEntities = new ArrayList<T>();
+        }
+        return serviceEntities;
+    }
+
+    public Long getCount() {
+        return count;
+    }
+
+    public void setCount(Long count) {
+        this.count = count;
+    }
+
+    public Integer getPage() {
+        return page;
+    }
+
+    public void setPage(Integer page) {
+        this.page = page;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/UserRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/UserRO.java
new file mode 100644
index 000000000..5dde5143d
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/UserRO.java
@@ -0,0 +1,64 @@
+package eu.europa.ec.edelivery.smp.data.ui;
+
+
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+import static eu.europa.ec.edelivery.smp.data.model.CommonColumnsLengths.MAX_USERNAME_LENGTH;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@Entity
+@Table(name = "smp_user")
+public class UserRO implements Serializable {
+
+
+
+    @Id
+    @Column(name = "username")
+    private String username;
+    @Column(name = "password")
+    private String password;
+    @Column(name = "isadmin")
+    private boolean isAdmin;
+
+    public UserRO(){
+
+    }
+
+    public UserRO(String username, String password, boolean isAdmin) {
+        this.username = username;
+        this.password = password;
+        this.isAdmin = isAdmin;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public boolean isAdmin() {
+        return isAdmin;
+    }
+
+    public void setAdmin(boolean admin) {
+        isAdmin = admin;
+    }
+}
diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ServiceUIData.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ServiceUIData.java
new file mode 100644
index 000000000..10fd1abd0
--- /dev/null
+++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ServiceUIData.java
@@ -0,0 +1,111 @@
+package eu.europa.ec.edelivery.smp.services;
+
+
+import eu.europa.ec.edelivery.smp.data.dao.ui.UiDaoService;
+import eu.europa.ec.edelivery.smp.data.ui.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class ServiceUIData {
+
+    @Autowired
+    private UiDaoService uiDaoService;
+
+    /**
+     *
+     * @param page
+     * @param pageSize
+     * @param sortField
+     * @param sortOrder
+     * @return
+     */
+
+    public ServiceResult<ServiceGroupRO> getServiceGroupList(int page, int pageSize,
+                                                  String sortField,
+                                                  String sortOrder) {
+
+        ServiceResult<ServiceGroupRO> sg = new  ServiceResult<>();
+
+        sg.setPage(page);
+        sg.setPageSize(pageSize);
+        long iCnt = uiDaoService.getDataListCount(ServiceGroupRO.class, null);
+        sg.setCount(iCnt);
+        if (iCnt > 0) {
+            List<ServiceGroupRO> lst = uiDaoService.getDataList(ServiceGroupRO.class, page * pageSize, pageSize, sortField, sortOrder, null);
+            sg.getServiceEntities().addAll(lst);
+        }
+        return sg;
+    }
+
+    /**
+     *
+     * @param page
+     * @param pageSize
+     * @param sortField
+     * @param sortOrder
+     * @return
+     */
+    public ServiceResult<UserRO> getUserList(int page, int pageSize,
+                                             String sortField,
+                                             String sortOrder) {
+
+        ServiceResult<UserRO> sg = new ServiceResult<>();
+        sg.setPage(page);
+        sg.setPageSize(pageSize);
+        long iCnt = uiDaoService.getDataListCount(UserRO.class, null);
+        sg.setCount(iCnt);
+        if (iCnt > 0) {
+
+            List<UserRO> lst = uiDaoService.getDataList(UserRO.class, page * pageSize, pageSize, sortField, sortOrder, null);
+            sg.getServiceEntities().addAll(lst);
+        }
+
+
+        return sg;
+    }
+
+    /**
+     *
+     * @param page
+     * @param pageSize
+     * @param sortField
+     * @param sortOrder
+     * @return
+     */
+    public ServiceResult<DomainRO> getDomainList(int page, int pageSize,
+                                                 String sortField,
+                                                 String sortOrder) {
+
+        ServiceResult<DomainRO> sg = new ServiceResult<>();
+        sg.setPage(page);
+        sg.setPageSize(pageSize);
+        long iCnt = uiDaoService.getDataListCount(DomainRO.class, null);
+        sg.setCount(iCnt);
+        if (iCnt > 0) {
+
+            List<DomainRO> lst = uiDaoService.getDataList(DomainRO.class, page * pageSize, pageSize, sortField, sortOrder, null);
+            sg.getServiceEntities().addAll(lst);
+        }
+        return sg;
+    }
+
+    public ServiceResult<ServiceMetadataRO> getServiceMetadataList(int page, int pageSize,
+                                                          String sortField,
+                                                          String sortOrder) {
+
+        ServiceResult<ServiceMetadataRO> sg = new ServiceResult<>();
+        sg.setPage(page);
+        sg.setPageSize(pageSize);
+        long iCnt = uiDaoService.getDataListCount(DomainRO.class, null);
+        sg.setCount(iCnt);
+        if (iCnt > 0) {
+            List<ServiceMetadataRO> lst = uiDaoService.getDataList(ServiceMetadataRO.class, page * pageSize, pageSize, sortField, sortOrder, null);
+            sg.getServiceEntities().addAll(lst);
+        }
+        return sg;
+    }
+
+}
diff --git a/smp-webapp/pom.xml b/smp-webapp/pom.xml
index 1fe05f656..be7cccd37 100644
--- a/smp-webapp/pom.xml
+++ b/smp-webapp/pom.xml
@@ -36,6 +36,11 @@
             <artifactId>smp-server-library</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>eu.europa.ec.edelivery</groupId>
+            <artifactId>smp-angular</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-webmvc</artifactId>
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/DatabaseConfig.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/DatabaseConfig.java
index 123c879bb..8bad930c5 100644
--- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/DatabaseConfig.java
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/DatabaseConfig.java
@@ -67,7 +67,7 @@ public class DatabaseConfig {
         LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
         lef.setDataSource(dataSource());
         lef.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
-        lef.setPackagesToScan("eu.europa.ec.edelivery.smp.data.model");
+        lef.setPackagesToScan("eu.europa.ec.edelivery.smp.data.model", "eu.europa.ec.edelivery.smp.data.ui");
         lef.setJpaProperties(prop);
         //lef.setPersistenceXmlLocation("classpath:META-INF/smp-persistence.xml");
         return lef;
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/SmpWebAppConfig.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/SmpWebAppConfig.java
index 25eec86d3..b067186cd 100644
--- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/SmpWebAppConfig.java
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/config/SmpWebAppConfig.java
@@ -19,6 +19,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
 import org.springframework.web.servlet.config.annotation.*;
 
+
 import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE;
 
 /**
@@ -28,7 +29,8 @@ import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE;
 @EnableWebMvc
 @ComponentScan(basePackages = {
         "eu.europa.ec.edelivery.smp.controllers",
-        "eu.europa.ec.edelivery.smp.validation"})
+        "eu.europa.ec.edelivery.smp.validation",
+        "eu.europa.ec.edelivery.smp.ui"})
 @Import({GlobalMethodSecurityConfig.class, ErrorMappingControllerAdvice.class})
 public class SmpWebAppConfig implements WebMvcConfigurer {
 
@@ -51,5 +53,4 @@ public class SmpWebAppConfig implements WebMvcConfigurer {
         //Default value (true) would break @PathVariable Identifiers containing dot character "."
         configurer.setUseSuffixPatternMatch(false);
     }
-
 }
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/DomainResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/DomainResource.java
new file mode 100644
index 000000000..6609c8f94
--- /dev/null
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/DomainResource.java
@@ -0,0 +1,47 @@
+package eu.europa.ec.edelivery.smp.ui;
+
+
+import eu.europa.ec.edelivery.smp.data.ui.DomainRO;
+import eu.europa.ec.edelivery.smp.data.ui.ServiceResult;
+import eu.europa.ec.edelivery.smp.services.ServiceUIData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@RestController
+@RequestMapping(value = "/ui/domain")
+public class DomainResource {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
+
+    @Autowired
+    private ServiceUIData serviceUIData;
+
+    @PostConstruct
+    protected void init() {
+
+    }
+
+    @PutMapping(produces = {"application/json"})
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.GET)
+    public ServiceResult<DomainRO> getServiceGroupList(
+            @RequestParam(value = "page", defaultValue = "0") int page,
+            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
+            @RequestParam(value = "orderBy", required = false) String orderBy,
+            @RequestParam(value = "orderType", defaultValue = "asc", required = false) String orderType,
+            @RequestParam(value = "user", required = false) String user
+            ) {
+
+
+        return serviceUIData.getDomainList(page,pageSize, orderBy, orderType );
+    }
+}
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java
new file mode 100644
index 000000000..679043d3f
--- /dev/null
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java
@@ -0,0 +1,49 @@
+package eu.europa.ec.edelivery.smp.ui;
+
+
+import eu.europa.ec.edelivery.smp.data.ui.ServiceGroupRO;
+import eu.europa.ec.edelivery.smp.data.ui.ServiceResult;
+import eu.europa.ec.edelivery.smp.services.ServiceUIData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@RestController
+@RequestMapping(value = "/ui/servicegroup")
+public class ServiceGroupResource {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceGroupResource.class);
+
+    @Autowired
+    private ServiceUIData serviceUIData;
+
+    @PostConstruct
+    protected void init() {
+
+    }
+
+    @PutMapping(produces = {"application/json"})
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.GET)
+    public  ServiceResult<ServiceGroupRO> getServiceGroupList(
+            @RequestParam(value = "page", defaultValue = "0") int page,
+            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
+            @RequestParam(value = "orderBy", required = false) String orderBy,
+            @RequestParam(value = "orderType", defaultValue = "asc", required = false) String orderType,
+            @RequestParam(value = "participantId", required = false) String participantId,
+            @RequestParam(value = "participantSchema", required = false) String participantSchema,
+            @RequestParam(value = "domain", required = false) String domainwe
+            ) {
+
+
+        return serviceUIData.getServiceGroupList(page,pageSize, orderBy, orderType );
+    }
+}
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceMetadataResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceMetadataResource.java
new file mode 100644
index 000000000..915408f05
--- /dev/null
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceMetadataResource.java
@@ -0,0 +1,48 @@
+package eu.europa.ec.edelivery.smp.ui;
+
+
+import eu.europa.ec.edelivery.smp.data.ui.ServiceMetadataRO;
+import eu.europa.ec.edelivery.smp.data.ui.ServiceResult;
+import eu.europa.ec.edelivery.smp.services.ServiceUIData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@RestController
+@RequestMapping(value = "/ui/servicemetadata")
+public class ServiceMetadataResource {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceMetadataResource.class);
+
+    @Autowired
+    private ServiceUIData serviceUIData;
+
+    @PostConstruct
+    protected void init() {
+
+    }
+
+    @PutMapping(produces = {"application/json"})
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.GET)
+    public  ServiceResult<ServiceMetadataRO> getServiceMetadataList(
+            @RequestParam(value = "page", defaultValue = "0") int page,
+            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
+            @RequestParam(value = "orderBy", required = false) String orderBy,
+            @RequestParam(value = "orderType", defaultValue = "asc", required = false) String orderType,
+            @RequestParam(value = "participantId", required = false) String participantId,
+            @RequestParam(value = "participantSchema", required = false) String participantSchema
+            ) {
+
+
+        return serviceUIData.getServiceMetadataList(page,pageSize, orderBy, orderType );
+    }
+}
diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java
new file mode 100644
index 000000000..0eea0022f
--- /dev/null
+++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java
@@ -0,0 +1,47 @@
+package eu.europa.ec.edelivery.smp.ui;
+
+
+import eu.europa.ec.edelivery.smp.data.ui.ServiceResult;
+import eu.europa.ec.edelivery.smp.data.ui.UserRO;
+import eu.europa.ec.edelivery.smp.services.ServiceUIData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.PostConstruct;
+
+/**
+ * @author Joze Rihtarsic
+ * @since 4.1
+ */
+
+@RestController
+@RequestMapping(value = "/ui/user")
+public class UserResource {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
+
+    @Autowired
+    private ServiceUIData serviceUIData;
+
+    @PostConstruct
+    protected void init() {
+
+    }
+
+    @PutMapping(produces = {"application/json"})
+    @ResponseBody
+    @RequestMapping(method = RequestMethod.GET)
+    public ServiceResult<UserRO> getUserist(
+            @RequestParam(value = "page", defaultValue = "0") int page,
+            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
+            @RequestParam(value = "orderBy", required = false) String orderBy,
+            @RequestParam(value = "orderType", defaultValue = "asc", required = false) String orderType,
+            @RequestParam(value = "user", required = false) String user
+            ) {
+
+
+        return  serviceUIData.getUserList(page,pageSize, orderBy, orderType );
+    }
+}
diff --git a/smp-webapp/src/main/resources/spring-security.xml b/smp-webapp/src/main/resources/spring-security.xml
index 3d9202216..1ebae2524 100644
--- a/smp-webapp/src/main/resources/spring-security.xml
+++ b/smp-webapp/src/main/resources/spring-security.xml
@@ -20,7 +20,7 @@
 
     <b:bean id="securityExceptionHandler" class="eu.europa.ec.edelivery.smp.error.SpringSecurityExceptionHandler"/>
 
-    <http>
+    <http >
         <csrf disabled="true"/>
         <http-basic entry-point-ref="securityExceptionHandler"/>
         <anonymous granted-authority="ROLE_ANONYMOUS"/>
diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.0.0-to-4.1.0.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.0.0-to-4.1.0.ddl
index 0f6e0cf55..2a1dbd415 100755
--- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.0.0-to-4.1.0.ddl
+++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.0.0-to-4.1.0.ddl
@@ -110,8 +110,12 @@ CREATE TABLE SMP_REV_INFO (
 ) ENGINE = InnoDB
   DEFAULT CHARSET = utf8;
 
-create table hibernate_sequence ( next_val bigint );
-create sequence hibernate_sequence;
 
 
+CREATE TABLE hibernate_sequence(
+    next_val BIGINT NOT NULL
+);
+
+INSERT INTO hibernate_sequence(next_val) values(1
+
 commit;
diff --git a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.1.0.ddl b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.1.0.ddl
index d43ddcead..e6077f440 100755
--- a/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.1.0.ddl
+++ b/smp-webapp/src/main/smp-setup/database-scripts/mysql5innoDb-4.1.0.ddl
@@ -201,7 +201,7 @@ CREATE TABLE SMP_REV_INFO (
   ID INT AUTO_INCREMENT NOT NULL,
   TIMESTAMP BIGINT NULL,
   REVISION_DATE timestamp NULL,
-  USER_NAME VARCHAR(255) NULL,
+  username VARCHAR(255) NULL,
   CONSTRAINT PK_SMP_REV_INFO PRIMARY KEY (ID)
 ) ENGINE = InnoDB
   DEFAULT CHARSET = utf8;
@@ -265,8 +265,11 @@ FOR EACH ROW
 
 DELIMITER ;
 
-create table hibernate_sequence ( next_val bigint );
-create sequence hibernate_sequence;
+create table hibernate_sequence(
+    next_val BIGINT NOT NULL
+);
+
+INSERT INTO hibernate_sequence(next_val) values(1);
 
 INSERT INTO smp_domain(domainId, bdmslSmpId) VALUES('domain1', 'DEFAULT-SMP-ID');
 -- default admin user with password "changeit"
diff --git a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-4.1.0.ddl b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-4.1.0.ddl
index 2bef81b21..c0960362d 100644
--- a/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-4.1.0.ddl
+++ b/smp-webapp/src/main/smp-setup/database-scripts/oracle10g-4.1.0.ddl
@@ -73,7 +73,7 @@ CREATE TABLE smp_ownership (
 INSERT INTO smp_domain(domainId, bdmslSmpId) VALUES('domain1', 'DEFAULT-SMP-ID');
 -- default admin user with password "changeit"
 INSERT INTO smp_user(username, password, isadmin) VALUES ('smp_admin', '$2a$10$SZXMo7K/wA.ULWxH7uximOxeNk4mf3zU6nxJx/2VfKA19QlqwSpNO', '1');
-
+commit;
 
 CREATE TABLE smp_domain_AUD (
   domainId              VARCHAR(50),
diff --git a/smp-webapp/src/test/java/eu/europa/ec/edelivery/smp/error/ErrorMappingControllerAdviceTest.java b/smp-webapp/src/test/java/eu/europa/ec/edelivery/smp/error/ErrorMappingControllerAdviceTest.java
index 1817c3411..f5b830d17 100644
--- a/smp-webapp/src/test/java/eu/europa/ec/edelivery/smp/error/ErrorMappingControllerAdviceTest.java
+++ b/smp-webapp/src/test/java/eu/europa/ec/edelivery/smp/error/ErrorMappingControllerAdviceTest.java
@@ -2,10 +2,7 @@ package eu.europa.ec.edelivery.smp.error;
 
 import ec.services.smp._1.ErrorResponse;
 import eu.europa.ec.edelivery.smp.error.exceptions.BadRequestException;
-import eu.europa.ec.edelivery.smp.exceptions.NotFoundException;
-import eu.europa.ec.edelivery.smp.exceptions.UnknownUserException;
-import eu.europa.ec.edelivery.smp.exceptions.WrongInputFieldException;
-import eu.europa.ec.edelivery.smp.exceptions.XmlParsingException;
+import eu.europa.ec.edelivery.smp.exceptions.*;
 import eu.europa.ec.smp.api.exceptions.MalformedIdentifierException;
 import eu.europa.ec.smp.api.exceptions.XmlInvalidAgainstSchemaException;
 import org.junit.Test;
@@ -97,10 +94,10 @@ public class ErrorMappingControllerAdviceTest {
 
     @Test
     public void handleInvalidOwnerException() {
-        ResponseEntity re = testIntance.handleUnknownUserException(new UnknownUserException("UnknownUserExceptionMessage"));
+        ResponseEntity re = testIntance.handleUnknownUserException(new InvalidOwnerException("InvalidOwnerExceptionMessage"));
 
         assertEquals(BAD_REQUEST, re.getStatusCode());
-        assertEquals(ErrorBusinessCode.USER_NOT_FOUND.toString(), ((ErrorResponse)re.getBody()).getBusinessCode());
+        assertEquals(ErrorBusinessCode.UNAUTHORIZED.toString(), ((ErrorResponse)re.getBody()).getBusinessCode());
     }
 
     @Test
-- 
GitLab