Skip to content

Commit 74cfa87

Browse files
authored
Remove obsolete code for the Liquibase LogHistoryService
Closes #41229 Signed-off-by: Martin Bartoš <[email protected]>
1 parent 6de8e2d commit 74cfa87

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/conn/CustomChangeLogHistoryService.java

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,12 @@
1616
*/
1717
package org.keycloak.connections.jpa.updater.liquibase.conn;
1818

19-
import org.keycloak.common.util.reflections.Reflections;
20-
import java.lang.reflect.Field;
21-
import java.text.DateFormat;
22-
import java.text.ParseException;
23-
import java.text.SimpleDateFormat;
24-
import java.time.LocalDateTime;
25-
import java.time.ZoneId;
26-
import java.util.ArrayList;
27-
import java.util.Collections;
28-
import java.util.Date;
29-
import java.util.List;
30-
import java.util.Map;
31-
import liquibase.ContextExpression;
32-
import liquibase.Labels;
33-
import liquibase.change.CheckSum;
3419
import liquibase.change.ColumnConfig;
35-
import liquibase.changelog.ChangeSet;
36-
import liquibase.changelog.RanChangeSet;
3720
import liquibase.changelog.StandardChangeLogHistoryService;
3821
import liquibase.database.Database;
3922
import liquibase.database.core.MySQLDatabase;
4023
import liquibase.exception.DatabaseException;
4124
import liquibase.executor.jvm.ChangelogJdbcMdcListener;
42-
import liquibase.logging.LogFactory;
4325
import liquibase.snapshot.InvalidExampleException;
4426
import liquibase.snapshot.SnapshotGeneratorFactory;
4527
import liquibase.statement.core.AddPrimaryKeyStatement;
@@ -53,7 +35,6 @@
5335
*/
5436
public class CustomChangeLogHistoryService extends StandardChangeLogHistoryService {
5537

56-
private List<RanChangeSet> ranChangeSetList;
5738
private boolean serviceInitialized;
5839

5940
@Override
@@ -74,68 +55,6 @@ public void init() throws DatabaseException {
7455
}
7556
}
7657

77-
@Override
78-
public List<RanChangeSet> getRanChangeSets() throws DatabaseException {
79-
if (this.ranChangeSetList == null) {
80-
String databaseChangeLogTableName = getDatabase().escapeTableName(getLiquibaseCatalogName(), getLiquibaseSchemaName(), getDatabaseChangeLogTableName());
81-
List<RanChangeSet> ranChangeSetList = new ArrayList<>();
82-
if (hasDatabaseChangeLogTable()) {
83-
LogFactory.getLogger().info("Reading from " + databaseChangeLogTableName);
84-
List<Map<String, ?>> results = queryDatabaseChangeLogTable(getDatabase());
85-
for (Map rs : results) {
86-
String fileName = rs.get("FILENAME").toString();
87-
String author = rs.get("AUTHOR").toString();
88-
String id = rs.get("ID").toString();
89-
String md5sum = rs.get("MD5SUM") == null || getDatabaseChecksumsCompatible() ? null : rs.get("MD5SUM").toString();
90-
String description = rs.get("DESCRIPTION") == null ? null : rs.get("DESCRIPTION").toString();
91-
String comments = rs.get("COMMENTS") == null ? null : rs.get("COMMENTS").toString();
92-
Object tmpDateExecuted = rs.get("DATEEXECUTED");
93-
Date dateExecuted = null;
94-
if (tmpDateExecuted instanceof Date) {
95-
dateExecuted = (Date) tmpDateExecuted;
96-
} else if (tmpDateExecuted instanceof LocalDateTime) {
97-
dateExecuted = Date.from(((LocalDateTime) tmpDateExecuted).atZone(ZoneId.systemDefault()).toInstant());
98-
} else {
99-
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
100-
try {
101-
dateExecuted = df.parse((String) tmpDateExecuted);
102-
} catch (ParseException e) {
103-
}
104-
}
105-
String tmpOrderExecuted = rs.get("ORDEREXECUTED").toString();
106-
Integer orderExecuted = (tmpOrderExecuted == null ? null : Integer.valueOf(tmpOrderExecuted));
107-
String tag = rs.get("TAG") == null ? null : rs.get("TAG").toString();
108-
String execType = rs.get("EXECTYPE") == null ? null : rs.get("EXECTYPE").toString();
109-
ContextExpression contexts = new ContextExpression((String) rs.get("CONTEXTS"));
110-
Labels labels = new Labels((String) rs.get("LABELS"));
111-
String deploymentId = (String) rs.get("DEPLOYMENT_ID");
112-
113-
try {
114-
RanChangeSet ranChangeSet = new RanChangeSet(fileName, id, author, CheckSum.parse(md5sum), dateExecuted, tag, ChangeSet.ExecType.valueOf(execType), description, comments, contexts, labels, deploymentId);
115-
ranChangeSet.setOrderExecuted(orderExecuted);
116-
ranChangeSetList.add(ranChangeSet);
117-
} catch (IllegalArgumentException e) {
118-
LogFactory.getLogger().severe("Unknown EXECTYPE from database: " + execType);
119-
throw e;
120-
}
121-
}
122-
}
123-
124-
this.ranChangeSetList = ranChangeSetList;
125-
}
126-
return Collections.unmodifiableList(ranChangeSetList);
127-
}
128-
129-
private boolean getDatabaseChecksumsCompatible() {
130-
Field f = Reflections.findDeclaredField(StandardChangeLogHistoryService.class, "databaseChecksumsCompatible");
131-
if (f != null) {
132-
f.setAccessible(true);
133-
Boolean databaseChecksumsCompatible = Reflections.getFieldValue(f, this, Boolean.class);
134-
return databaseChecksumsCompatible == null ? true : databaseChecksumsCompatible;
135-
}
136-
return true;
137-
}
138-
13958
@Override
14059
public int getPriority() {
14160
return super.getPriority() + 1; // Ensure bigger priority than StandardChangeLogHistoryService

0 commit comments

Comments
 (0)