You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/08/04 12:01:47 UTC
[3/3] syncope git commit: [SYNCOPE-916] Restoring table filter
[SYNCOPE-916] Restoring table filter
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/ef7fc474
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/ef7fc474
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/ef7fc474
Branch: refs/heads/master
Commit: ef7fc474457444f822bfb29842e7767a20356a36
Parents: f17d110
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Thu Aug 4 14:01:35 2016 +0200
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Thu Aug 4 14:01:35 2016 +0200
----------------------------------------------------------------------
.../syncope/core/logic/ConfigurationLogic.java | 11 ++++-
.../api/content/ContentExporter.java | 2 +-
.../jpa/content/XMLContentExporter.java | 44 +++++++++++++++-----
3 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/ef7fc474/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java
index 98e1032..b6c31b4 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java
@@ -31,6 +31,7 @@ import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr;
import org.apache.syncope.core.provisioning.api.data.ConfigurationDataBinder;
+import org.apache.syncope.core.workflow.api.AnyObjectWorkflowAdapter;
import org.apache.syncope.core.workflow.api.GroupWorkflowAdapter;
import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
import org.springframework.beans.factory.annotation.Autowired;
@@ -59,6 +60,9 @@ public class ConfigurationLogic extends AbstractTransactionalLogic<AttrTO> {
@Autowired
private GroupWorkflowAdapter gwfAdapter;
+ @Autowired
+ private AnyObjectWorkflowAdapter awfAdapter;
+
@PreAuthorize("hasRole('" + StandardEntitlement.CONFIGURATION_DELETE + "')")
public void delete(final String schema) {
CPlainAttr conf = confDAO.find(schema);
@@ -106,7 +110,12 @@ public class ConfigurationLogic extends AbstractTransactionalLogic<AttrTO> {
@Transactional(readOnly = true)
public void export(final OutputStream os) {
try {
- exporter.export(AuthContextUtils.getDomain(), os, uwfAdapter.getPrefix(), gwfAdapter.getPrefix());
+ exporter.export(
+ AuthContextUtils.getDomain(),
+ os,
+ uwfAdapter.getPrefix(),
+ gwfAdapter.getPrefix(),
+ awfAdapter.getPrefix());
LOG.debug("Database content successfully exported");
} catch (Exception e) {
LOG.error("While exporting database content", e);
http://git-wip-us.apache.org/repos/asf/syncope/blob/ef7fc474/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/content/ContentExporter.java
----------------------------------------------------------------------
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/content/ContentExporter.java b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/content/ContentExporter.java
index 5ed50df..4b2cf10 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/content/ContentExporter.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/content/ContentExporter.java
@@ -24,6 +24,6 @@ import org.xml.sax.SAXException;
public interface ContentExporter {
- void export(String domain, OutputStream output, String uwfPrefix, String rwfPrefix)
+ void export(String domain, OutputStream output, String uwfPrefix, String gwfPrefix, String awfPrefix)
throws SAXException, TransformerConfigurationException;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/ef7fc474/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
index 4f7c3a4..7618e1b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/XMLContentExporter.java
@@ -47,6 +47,8 @@ import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
+import org.apache.commons.collections4.IterableUtils;
+import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.SyncopeConstants;
@@ -79,13 +81,13 @@ import org.xml.sax.helpers.AttributesImpl;
@Component
public class XMLContentExporter extends AbstractContentDealer implements ContentExporter {
- protected static final Set<String> TABLE_PREFIXES_TO_BE_EXCLUDED =
- new HashSet<>(Arrays.asList(new String[] {
- "QRTZ_", "LOGGING", JPAReportExec.TABLE, JPATaskExec.TABLE,
- JPAUser.TABLE, JPAUPlainAttr.TABLE, JPAUPlainAttrValue.TABLE, JPAUPlainAttrUniqueValue.TABLE,
- JPAAnyObject.TABLE, JPAAPlainAttr.TABLE, JPAAPlainAttrValue.TABLE, JPAAPlainAttrUniqueValue.TABLE,
- JPAARelationship.TABLE, JPAAMembership.TABLE, JPAURelationship.TABLE, JPAUMembership.TABLE
- }));
+ protected static final Set<String> TABLE_PREFIXES_TO_BE_EXCLUDED = new HashSet<>(Arrays.asList(new String[] {
+ "QRTZ_", "LOGGING", JPAReportExec.TABLE, JPATaskExec.TABLE,
+ JPAUser.TABLE, JPAUPlainAttr.TABLE, JPAUPlainAttrValue.TABLE, JPAUPlainAttrUniqueValue.TABLE,
+ JPAURelationship.TABLE, JPAUMembership.TABLE,
+ JPAAnyObject.TABLE, JPAAPlainAttr.TABLE, JPAAPlainAttrValue.TABLE, JPAAPlainAttrUniqueValue.TABLE,
+ JPAARelationship.TABLE, JPAAMembership.TABLE
+ }));
protected static final Map<String, String> TABLES_TO_BE_FILTERED =
Collections.singletonMap("TASK", "DTYPE <> 'PropagationTask'");
@@ -93,6 +95,16 @@ public class XMLContentExporter extends AbstractContentDealer implements Content
protected static final Map<String, Set<String>> COLUMNS_TO_BE_NULLIFIED =
Collections.singletonMap("SYNCOPEGROUP", Collections.singleton("USEROWNER_ID"));
+ private boolean isTableAllowed(final String tableName) {
+ return IterableUtils.matchesAll(TABLE_PREFIXES_TO_BE_EXCLUDED, new Predicate<String>() {
+
+ @Override
+ public boolean evaluate(final String prefix) {
+ return !tableName.toUpperCase().startsWith(prefix.toUpperCase());
+ }
+ });
+ }
+
private List<String> sortByForeignKeys(final String dbSchema, final Connection conn, final Set<String> tableNames)
throws SQLException {
@@ -304,14 +316,22 @@ public class XMLContentExporter extends AbstractContentDealer implements Content
}
@Override
- public void export(final String domain, final OutputStream os, final String uwfPrefix, final String rwfPrefix)
+ public void export(
+ final String domain,
+ final OutputStream os,
+ final String uwfPrefix,
+ final String gwfPrefix,
+ final String awfPrefix)
throws SAXException, TransformerConfigurationException {
if (StringUtils.isNotBlank(uwfPrefix)) {
TABLE_PREFIXES_TO_BE_EXCLUDED.add(uwfPrefix);
}
- if (StringUtils.isNotBlank(rwfPrefix)) {
- TABLE_PREFIXES_TO_BE_EXCLUDED.add(rwfPrefix);
+ if (StringUtils.isNotBlank(gwfPrefix)) {
+ TABLE_PREFIXES_TO_BE_EXCLUDED.add(gwfPrefix);
+ }
+ if (StringUtils.isNotBlank(awfPrefix)) {
+ TABLE_PREFIXES_TO_BE_EXCLUDED.add(awfPrefix);
}
StreamResult streamResult = new StreamResult(os);
@@ -346,7 +366,9 @@ public class XMLContentExporter extends AbstractContentDealer implements Content
while (rs.next()) {
String tableName = rs.getString("TABLE_NAME");
LOG.debug("Found table {}", tableName);
- tableNames.add(tableName);
+ if (isTableAllowed(tableName)) {
+ tableNames.add(tableName);
+ }
}
LOG.debug("Tables to be exported {}", tableNames);