syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [3/3] syncope git commit: Do not report loggers used to support the Audit process
Date Fri, 05 Oct 2018 12:06:58 GMT
Do not report loggers used to support the Audit process


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/a69fe31a
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/a69fe31a
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/a69fe31a

Branch: refs/heads/2_0_X
Commit: a69fe31a721bea5f99d1355e2060f9668fe40392
Parents: 81b214a
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Oct 5 14:06:43 2018 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Oct 5 14:06:43 2018 +0200

----------------------------------------------------------------------
 .../apache/syncope/core/logic/LoggerLogic.java  | 43 ++++++++++++++------
 1 file changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/a69fe31a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
index 623d880..6843778 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/LoggerLogic.java
@@ -55,10 +55,12 @@ import org.apache.syncope.common.lib.types.AuditElements;
 import org.apache.syncope.common.lib.types.StandardEntitlement;
 import org.apache.syncope.core.logic.audit.AuditAppender;
 import org.apache.syncope.core.logic.init.LoggerLoader;
+import org.apache.syncope.core.persistence.api.dao.DomainDAO;
 import org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO;
 import org.apache.syncope.core.persistence.api.dao.LoggerDAO;
 import org.apache.syncope.core.persistence.api.dao.NotFoundException;
 import org.apache.syncope.core.persistence.api.dao.TaskDAO;
+import org.apache.syncope.core.persistence.api.entity.Domain;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.resource.ExternalResource;
 import org.apache.syncope.core.persistence.api.entity.Logger;
@@ -96,19 +98,10 @@ public class LoggerLogic extends AbstractTransactionalLogic<LoggerTO>
{
     private TaskDAO taskDAO;
 
     @Autowired
-    private EntityFactory entityFactory;
-
-    private List<LoggerTO> list(final LoggerType type) {
-        return CollectionUtils.collect(loggerDAO.findAll(type), new Transformer<Logger,
LoggerTO>() {
+    private DomainDAO domainDAO;
 
-            @Override
-            public LoggerTO transform(final Logger logger) {
-                LoggerTO loggerTO = new LoggerTO();
-                BeanUtils.copyProperties(logger, loggerTO);
-                return loggerTO;
-            }
-        }, new ArrayList<LoggerTO>());
-    }
+    @Autowired
+    private EntityFactory entityFactory;
 
     @PreAuthorize("hasRole('" + StandardEntitlement.LOG_LIST + "') and authentication.details.domain
== "
             + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
@@ -142,11 +135,35 @@ public class LoggerLogic extends AbstractTransactionalLogic<LoggerTO>
{
                 new ArrayList<LogStatementTO>());
     }
 
+    private List<LoggerTO> list(final LoggerType type) {
+        return CollectionUtils.collect(loggerDAO.findAll(type), new Transformer<Logger,
LoggerTO>() {
+
+            @Override
+            public LoggerTO transform(final Logger logger) {
+                LoggerTO loggerTO = new LoggerTO();
+                BeanUtils.copyProperties(logger, loggerTO);
+                return loggerTO;
+            }
+        }, new ArrayList<LoggerTO>());
+    }
+
     @PreAuthorize("hasRole('" + StandardEntitlement.LOG_LIST + "') and authentication.details.domain
== "
             + "T(org.apache.syncope.common.lib.SyncopeConstants).MASTER_DOMAIN")
     @Transactional(readOnly = true)
     public List<LoggerTO> listLogs() {
-        return list(LoggerType.LOG);
+        List<LoggerTO> logs = list(LoggerType.LOG);
+        CollectionUtils.filterInverse(logs, new Predicate<LoggerTO>() {
+
+            @Override
+            public boolean evaluate(final LoggerTO logger) {
+                boolean result = logger.getKey().startsWith(SyncopeConstants.MASTER_DOMAIN);
+                for (Domain domain : domainDAO.findAll()) {
+                    result |= logger.getKey().startsWith(domain.getKey());
+                }
+                return result;
+            }
+        });
+        return logs;
     }
 
     @PreAuthorize("hasRole('" + StandardEntitlement.AUDIT_LIST + "')")


Mime
View raw message