Browse Source

Merge pull request #2302 in CORE/base-third from feature/10.0 to bugfix/10.0

* commit '04f518520021ae2336a4e7f6d5181a023ebc02d8': (23 commits)
  KERNEL-7725 feat: websocket提供全局拦截器
  DEC-17989 itext XXE安全漏洞修复,参考 930a1c81f8
  DEC-17833 fix: CBB独立发布 third打包脚本修改 withCBB写反了
  DEC-17833 feat: CBB独立发布 third打包脚本修改
  DEC-17833 feat: CBB独立发布 third打包脚本修改
  DEC-17833 fix: CBB独立发布 third打包脚本修改 withCBB写反了
  DEC-17833 feat: CBB独立发布 third打包脚本修改
  DEC-17833 feat: CBB独立发布 third打包脚本修改
  REPORT-50649 导出-生僻字导出问题 Excel导出
  无jira任务 docs: 补充readme
  无jira任务 chore: 解决bugfix合并到feature的冲突
  KERNEL-6189 fix: 修复third打包脚本
  KERNEL-6189 chore: feature分支fine-third打包加入CBB
  KERNEL-6151 fix: fine-third打包脚本修改
  KERNEL-6151 feat: fine-third适配fine-essential并加入打包
  KERNEL-5583 feat: 升级spring到4.3.29RELEASE
  DEC-14578 feat: hibernate二级缓存卡顿
  DEC-14578 feat: hibernate自动删除旧唯一键
  DEC-14578 feat: 使hibernate支持主键的自动更新
  DEC-14578 feat: 去掉无用的jetbrain.NotNull依赖, 拆分Utils方法
  ...
bugfix/10.0
superman 4 years ago
parent
commit
8543bef69f
  1. 2
      base-third-project/base-third-step8/pom.xml
  2. 2
      fine-bouncycastle/readme.md
  3. 5
      fine-ehcache/src/main/java/com/fr/third/net/sf/ehcache/pool/builtin-sizeof.filter
  4. 5
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java
  5. 16
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/MySQLDialect.java
  6. 5
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/DefaultUniqueDelegate.java
  7. 23
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/MySQLUniqueDelegate.java
  8. 20
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/IndexInformationImpl.java
  9. 18
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java
  10. 2
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/spi/IndexInformation.java
  11. 104
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java
  12. 3
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java
  13. 3
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java
  14. 63
      fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardPrimaryKeyExporter.java
  15. 18
      fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/SafeEmptyEntityResolver.java
  16. 2
      fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/pdf/XfaForm.java
  17. 2
      fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/xml/xmp/XmpReader.java
  18. 18
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/SafeEmptyEntityResolver.java
  19. 2
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/pdf/XfaForm.java
  20. 2
      fine-itext/src/main/java/com/fr/third/v2/lowagie/text/xml/xmp/XmpReader.java
  21. 16
      fine-poi/src/main/java/com/fr/third/v2/org/apache/poi/xssf/streaming/SheetDataWriter.java
  22. 46
      fine-poi/src/main/java/com/fr/third/v2/org/apache/xmlbeans/impl/store/Saver.java
  23. 34
      fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java
  24. 27
      fine-socketio/src/main/java/com/fr/third/socketio/listener/interceptor/EventInterceptor.java
  25. 23
      fine-socketio/src/main/java/com/fr/third/socketio/listener/interceptor/Interceptor.java
  26. 53
      fine-socketio/src/main/java/com/fr/third/socketio/namespace/Namespace.java

2
base-third-project/base-third-step8/pom.xml

@ -7,7 +7,7 @@
<parent>
<groupId>com.fr.third</groupId>
<artifactId>base-third</artifactId>
<version>${revision}</version>
<version>10.0-FEATURE-SNAPSHOT</version>
</parent>
<artifactId>step8</artifactId>

2
fine-bouncycastle/readme.md

@ -0,0 +1,2 @@
版本:1.64<br>
源码:https://www.bouncycastle.org/latest_releases.html<br>

5
fine-ehcache/src/main/java/com/fr/third/net/sf/ehcache/pool/builtin-sizeof.filter vendored

@ -22,6 +22,11 @@ com.fr.third.org.hibernate.cache.spi.QueryKey.tenantIdentifier
com.fr.third.org.hibernate.engine.spi.TypedValue.type
com.fr.third.org.hibernate.engine.spi.TypedValue.entityMode
# Hibernate 5.x Second Level Entity/Collection Caching
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.type
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.entityOrRoleName
com.fr.third.org.hibernate.cache.internal.CacheKeyImplementation.tenantId
# This TC internal field is shared amongst all clustered entries
org.terracotta.cache.serialization.SerializedEntry.tcClazz
com.tc.object.TCObjectSelfImpl.tcClazz

5
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/Dialect.java

@ -2099,6 +2099,11 @@ public abstract class Dialect implements ConversionContext {
return " add constraint " + constraintName + " primary key ";
}
public String getDropPrimaryKeyConstraintString(String constraintName) {
return " drop constraint " + constraintName;
}
/**
* Does the database/driver have bug in deleting rows that refer to other rows being deleted in the same query?
*

16
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/MySQLDialect.java

@ -22,6 +22,8 @@ import com.fr.third.org.hibernate.dialect.identity.MySQLIdentityColumnSupport;
import com.fr.third.org.hibernate.dialect.pagination.AbstractLimitHandler;
import com.fr.third.org.hibernate.dialect.pagination.LimitHandler;
import com.fr.third.org.hibernate.dialect.pagination.LimitHelper;
import com.fr.third.org.hibernate.dialect.unique.MySQLUniqueDelegate;
import com.fr.third.org.hibernate.dialect.unique.UniqueDelegate;
import com.fr.third.org.hibernate.engine.spi.RowSelection;
import com.fr.third.org.hibernate.exception.LockAcquisitionException;
import com.fr.third.org.hibernate.exception.LockTimeoutException;
@ -43,6 +45,8 @@ import com.fr.third.org.hibernate.type.StandardBasicTypes;
@SuppressWarnings("deprecation")
public class MySQLDialect extends Dialect {
private final UniqueDelegate uniqueDelegate;
private static final LimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
@Override
public String processSql(String sql, RowSelection selection) {
@ -196,6 +200,8 @@ public class MySQLDialect extends Dialect {
getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
uniqueDelegate = new MySQLUniqueDelegate( this );
}
protected void registerVarcharTypes() {
@ -234,6 +240,11 @@ public class MySQLDialect extends Dialect {
);
}
@Override
public String getDropPrimaryKeyConstraintString(String constraintName) {
return " drop primary key ";
}
@Override
public boolean supportsLimit() {
return true;
@ -422,6 +433,11 @@ public class MySQLDialect extends Dialect {
return ps.getResultSet();
}
@Override
public UniqueDelegate getUniqueDelegate() {
return uniqueDelegate;
}
@Override
public boolean supportsRowValueConstructorSyntax() {
return true;

5
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/DefaultUniqueDelegate.java

@ -85,7 +85,7 @@ public class DefaultUniqueDelegate implements UniqueDelegate {
final StringBuilder buf = new StringBuilder( "alter table " );
buf.append( tableName );
buf.append(" drop constraint " );
buf.append(getDropUnique());
if ( dialect.supportsIfExistsBeforeConstraintName() ) {
buf.append( "if exists " );
}
@ -96,4 +96,7 @@ public class DefaultUniqueDelegate implements UniqueDelegate {
return buf.toString();
}
protected String getDropUnique(){
return " drop constraint ";
}
}

23
fine-hibernate/src/main/java/com/fr/third/org/hibernate/dialect/unique/MySQLUniqueDelegate.java

@ -0,0 +1,23 @@
package com.fr.third.org.hibernate.dialect.unique;
import com.fr.third.org.hibernate.dialect.Dialect;
/**
* @author Andrea Boriero
*/
public class MySQLUniqueDelegate extends DefaultUniqueDelegate {
/**
* Constructs MySQLUniqueDelegate
*
* @param dialect The dialect for which we are handling unique constraints
*/
public MySQLUniqueDelegate(Dialect dialect) {
super( dialect );
}
@Override
protected String getDropUnique() {
return " drop index ";
}
}

20
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/IndexInformationImpl.java

@ -21,12 +21,19 @@ import com.fr.third.org.hibernate.tool.schema.spi.SchemaManagementException;
public class IndexInformationImpl implements IndexInformation {
private final Identifier indexIdentifier;
private final List<ColumnInformation> columnList;
private boolean unique;
public IndexInformationImpl(Identifier indexIdentifier, List<ColumnInformation> columnList) {
this.indexIdentifier = indexIdentifier;
this.columnList = columnList;
}
public IndexInformationImpl(Identifier indexIdentifier, List<ColumnInformation> columnList, boolean unique) {
this.indexIdentifier = indexIdentifier;
this.columnList = columnList;
this.unique = unique;
}
@Override
public Identifier getIndexIdentifier() {
return indexIdentifier;
@ -37,6 +44,11 @@ public class IndexInformationImpl implements IndexInformation {
return columnList;
}
@Override
public boolean isUnique() {
return unique;
}
public static Builder builder(Identifier indexIdentifier) {
return new Builder( indexIdentifier );
}
@ -44,6 +56,7 @@ public class IndexInformationImpl implements IndexInformation {
public static class Builder {
private final Identifier indexIdentifier;
private final List<ColumnInformation> columnList = new ArrayList<ColumnInformation>();
private boolean unique;
public Builder(Identifier indexIdentifier) {
this.indexIdentifier = indexIdentifier;
@ -54,13 +67,18 @@ public class IndexInformationImpl implements IndexInformation {
return this;
}
public Builder setUnique(boolean unique) {
this.unique = unique;
return this;
}
public IndexInformationImpl build() {
if ( columnList.isEmpty() ) {
throw new SchemaManagementException(
"Attempt to resolve JDBC metadata failed to find columns for index [" + indexIdentifier.getText() + "]"
);
}
return new IndexInformationImpl( indexIdentifier, Collections.unmodifiableList( columnList ) );
return new IndexInformationImpl( indexIdentifier, Collections.unmodifiableList( columnList ), unique);
}
}
}

18
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/internal/InformationExtractorJdbcDatabaseMetaDataImpl.java

@ -710,6 +710,24 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
}
try {
//处理唯一键
ResultSet uniqueKeyResult = extractionContext.getJdbcDatabaseMetaData().getIndexInfo(catalogFilter, schemaFilter, tableName.getTableName().getText(), true, true);
try {
while (uniqueKeyResult.next()) {
if ( uniqueKeyResult.getShort("TYPE") == DatabaseMetaData.tableIndexStatistic ) {
continue;
}
final Identifier indexIdentifier = DatabaseIdentifier.toIdentifier(uniqueKeyResult.getString("INDEX_NAME"));
IndexInformationImpl.Builder builder = builders.get( indexIdentifier );
if ( builder == null ) {
builder = IndexInformationImpl.builder( indexIdentifier ).setUnique(true);
builders.put( indexIdentifier, builder );
}
}
} finally {
uniqueKeyResult.close();
}
ResultSet resultSet = extractionContext.getJdbcDatabaseMetaData().getIndexInfo(
catalogFilter,
schemaFilter,

2
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/extract/spi/IndexInformation.java

@ -30,4 +30,6 @@ public interface IndexInformation {
* @return The columns
*/
public List<ColumnInformation> getIndexedColumns();
boolean isUnique();
}

104
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java

@ -6,12 +6,6 @@
*/
package com.fr.third.org.hibernate.tool.schema.internal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.fr.third.org.hibernate.boot.Metadata;
import com.fr.third.org.hibernate.boot.model.naming.Identifier;
import com.fr.third.org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
@ -26,17 +20,21 @@ import com.fr.third.org.hibernate.engine.config.spi.StandardConverters;
import com.fr.third.org.hibernate.engine.jdbc.internal.FormatStyle;
import com.fr.third.org.hibernate.engine.jdbc.internal.Formatter;
import com.fr.third.org.hibernate.internal.util.StringHelper;
import com.fr.third.org.hibernate.mapping.Column;
import com.fr.third.org.hibernate.mapping.Constraint;
import com.fr.third.org.hibernate.mapping.ForeignKey;
import com.fr.third.org.hibernate.mapping.Index;
import com.fr.third.org.hibernate.mapping.PrimaryKey;
import com.fr.third.org.hibernate.mapping.Table;
import com.fr.third.org.hibernate.mapping.UniqueKey;
import com.fr.third.org.hibernate.resource.transaction.spi.DdlTransactionIsolator;
import com.fr.third.org.hibernate.tool.hbm2ddl.UniqueConstraintSchemaUpdateStrategy;
import com.fr.third.org.hibernate.tool.schema.extract.spi.ColumnInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.DatabaseInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.ForeignKeyInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.IndexInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.NameSpaceTablesInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.PrimaryKeyInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.SequenceInformation;
import com.fr.third.org.hibernate.tool.schema.extract.spi.TableInformation;
import com.fr.third.org.hibernate.tool.schema.internal.exec.GenerationTarget;
@ -48,9 +46,15 @@ import com.fr.third.org.hibernate.tool.schema.spi.SchemaFilter;
import com.fr.third.org.hibernate.tool.schema.spi.SchemaManagementException;
import com.fr.third.org.hibernate.tool.schema.spi.SchemaMigrator;
import com.fr.third.org.hibernate.tool.schema.spi.TargetDescriptor;
import com.fr.third.org.jboss.logging.Logger;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.fr.third.org.hibernate.cfg.AvailableSettings.UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY;
/**
@ -355,6 +359,29 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
if ( uniqueConstraintStrategy != UniqueConstraintSchemaUpdateStrategy.SKIP ) {
final Exporter<Constraint> exporter = dialect.getUniqueKeyExporter();
Set<Identifier> identifiers = getUniqueKeyIdentifiers(table);
if (tableInfo != null) {
for (IndexInformation indexInfo : tableInfo.getIndexes()) {
if (!indexInfo.isUnique() || indexInfo.getIndexIdentifier().equals(tableInfo.getPrimaryKey().getPrimaryKeyIdentifier())) {
continue;
}
//如果旧的唯一键已经不存在, 则删除
if (!identifiers.contains(indexInfo.getIndexIdentifier())) {
log.warn("delete unique key not existed in entity: " + indexInfo.getIndexIdentifier().getText());
UniqueKey old = new UniqueKey();
old.setTable(table);
old.setName(indexInfo.getIndexIdentifier().getText());
applySqlStrings(
true,
exporter.getSqlDropStrings(old, metadata),
formatter,
options,
targets
);
}
}
}
final Iterator ukItr = table.getUniqueKeyIterator();
while ( ukItr.hasNext() ) {
final UniqueKey uniqueKey = (UniqueKey) ukItr.next();
@ -388,6 +415,18 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
}
}
private Set<Identifier> getUniqueKeyIdentifiers(Table table) {
Set<Identifier> identifiers = new HashSet<>();
Iterator<UniqueKey> uniqueKeys = table.getUniqueKeyIterator();
while (uniqueKeys.hasNext()) {
UniqueKey uniqueKey = uniqueKeys.next();
if (StringHelper.isNotEmpty(uniqueKey.getName())) {
identifiers.add(Identifier.toIdentifier(uniqueKey.getName()));
}
}
return identifiers;
}
private UniqueConstraintSchemaUpdateStrategy determineUniqueConstraintSchemaUpdateStrategy(Metadata metadata) {
final ConfigurationService cfgService = ((MetadataImplementor) metadata).getMetadataBuildingOptions()
.getServiceRegistry()
@ -446,6 +485,57 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator {
return tableInformation.getForeignKey( Identifier.toIdentifier( foreignKey.getName() ) );
}
protected void applyPrimaryKey(
Table table,
TableInformation tableInfo,
Dialect dialect,
Metadata metadata,
Formatter formatter,
ExecutionOptions options,
GenerationTarget... targets) {
try {
PrimaryKey primaryKey = table.getPrimaryKey();
if (primaryKey == null) {
return;
}
Exporter<PrimaryKey> exporter = new StandardPrimaryKeyExporter(dialect);
PrimaryKeyInformation existedPrimaryKeyInfo = tableInfo.getPrimaryKey();
if (existedPrimaryKeyInfo == null) {
applySqlStrings(true, exporter.getSqlCreateStrings(primaryKey, metadata), formatter, options, targets);
} else if (!columnEquals(table.getPrimaryKey().getColumns(), existedPrimaryKeyInfo.getColumns())) {
//主键列不匹配, 先删再增
PrimaryKey deletedKey = copyPrimaryKey(tableInfo.getPrimaryKey().getPrimaryKeyIdentifier().getText(), table);
applySqlStrings(true, exporter.getSqlDropStrings(deletedKey, metadata), formatter, options, targets);
applySqlStrings(true, exporter.getSqlCreateStrings(primaryKey, metadata), formatter, options, targets);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
private PrimaryKey copyPrimaryKey(String newName, Table table) {
PrimaryKey copy = new PrimaryKey(table);
copy.setName(newName);
return copy;
}
private boolean columnEquals(List<Column> columns, Iterable<ColumnInformation> iterator) {
int count = 0;
Set<String> names = new HashSet<String>();
for (Column column: columns) {
names.add(column.getName().toLowerCase());
}
for (ColumnInformation columnInformation : iterator) {
String name = columnInformation.getColumnIdentifier().getText();
if (!names.contains(name.toLowerCase())) {
return false;
}
count++;
}
return count == columns.size();
}
protected void checkExportIdentifier(Exportable exportable, Set<String> exportIdentifiers) {
final String exportIdentifier = exportable.getExportIdentifier();
if ( exportIdentifiers.contains( exportIdentifier ) ) {

3
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java

@ -83,6 +83,9 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator {
if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) {
applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets );
applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets );
if (tableInformation != null) {
applyPrimaryKey(table, tableInformation, dialect, metadata, formatter, options, targets);
}
}
}
}

3
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java

@ -83,6 +83,9 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator {
if ( tableInformation == null || ( tableInformation != null && tableInformation.isPhysicalTable() ) ) {
applyIndexes( table, tableInformation, dialect, metadata, formatter, options, targets );
applyUniqueKeys( table, tableInformation, dialect, metadata, formatter, options, targets );
if (tableInformation != null) {
applyPrimaryKey(table, tableInformation, dialect, metadata, formatter, options, targets);
}
}
}
}

63
fine-hibernate/src/main/java/com/fr/third/org/hibernate/tool/schema/internal/StandardPrimaryKeyExporter.java

@ -0,0 +1,63 @@
package com.fr.third.org.hibernate.tool.schema.internal;
import com.fr.third.org.hibernate.boot.Metadata;
import com.fr.third.org.hibernate.dialect.Dialect;
import com.fr.third.org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import com.fr.third.org.hibernate.mapping.Column;
import com.fr.third.org.hibernate.mapping.PrimaryKey;
import com.fr.third.org.hibernate.tool.schema.spi.Exporter;
import java.util.Iterator;
/**
* @author Elijah
* @version 10.5
* Created by Elijah on 2020/9/30
*/
public class StandardPrimaryKeyExporter implements Exporter<PrimaryKey> {
private Dialect dialect;
public StandardPrimaryKeyExporter(Dialect dialect) {
this.dialect = dialect;
}
@Override
public String[] getSqlCreateStrings(PrimaryKey primaryKey, Metadata metadata) {
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
primaryKey.getTable().getQualifiedTableName(),
dialect
);
final String constraintName = dialect.quote( primaryKey.getName() );
return new String[]{ "alter table " + tableName + dialect.getAddPrimaryKeyConstraintString(constraintName) + " " + columnsToString( primaryKey ) };
}
protected String columnsToString(PrimaryKey primaryKey) {
final StringBuilder sb = new StringBuilder();
sb.append( " (" );
final Iterator<Column> columnIterator = primaryKey.columnIterator();
while ( columnIterator.hasNext() ) {
final Column column = columnIterator.next();
sb.append( column.getQuotedName( dialect ) );
if ( columnIterator.hasNext() ) {
sb.append( ", " );
}
}
return sb.append( ')' ).toString();
}
@Override
public String[] getSqlDropStrings(PrimaryKey primaryKey, Metadata metadata) {
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format(
primaryKey.getTable().getQualifiedTableName(),
dialect
);
final StringBuilder buf = new StringBuilder( "alter table " );
buf.append( tableName );
buf.append(dialect.getDropPrimaryKeyConstraintString(dialect.quote( primaryKey.getName())));
return new String[] { buf.toString() };
}
}

18
fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/SafeEmptyEntityResolver.java

@ -0,0 +1,18 @@
package com.fr.third.com.lowagie.text;
import java.io.IOException;
import java.io.StringReader;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* @author Hugh.C
* @version 1.0
* Created by Hugh.C on 2021/4/26
*/
public class SafeEmptyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
}

2
fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/pdf/XfaForm.java

@ -49,6 +49,7 @@
package com.fr.third.com.lowagie.text.pdf;
import com.fr.third.com.lowagie.text.SafeEmptyEntityResolver;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -140,6 +141,7 @@ public class XfaForm {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
domDocument = db.parse(new ByteArrayInputStream(bout.toByteArray()));
extractNodes();
}

2
fine-itext-old/src/main/java/com/fr/third/com/lowagie/text/xml/xmp/XmpReader.java

@ -46,6 +46,7 @@
*/
package com.fr.third.com.lowagie.text.xml.xmp;
import com.fr.third.com.lowagie.text.SafeEmptyEntityResolver;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -85,6 +86,7 @@ public class XmpReader {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
domDocument = db.parse(bais);
} catch (ParserConfigurationException e) {

18
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/SafeEmptyEntityResolver.java

@ -0,0 +1,18 @@
package com.fr.third.v2.lowagie.text;
import java.io.IOException;
import java.io.StringReader;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* @author Hugh.C
* @version 1.0
* Created by Hugh.C on 2021/4/26
*/
public class SafeEmptyEntityResolver implements EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
return new InputSource(new StringReader(""));
}
}

2
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/pdf/XfaForm.java

@ -49,6 +49,7 @@
package com.fr.third.v2.lowagie.text.pdf;
import com.fr.third.v2.lowagie.text.SafeEmptyEntityResolver;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -140,6 +141,7 @@ public class XfaForm {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
domDocument = db.parse(new ByteArrayInputStream(bout.toByteArray()));
extractNodes();
}

2
fine-itext/src/main/java/com/fr/third/v2/lowagie/text/xml/xmp/XmpReader.java

@ -46,6 +46,7 @@
*/
package com.fr.third.v2.lowagie.text.xml.xmp;
import com.fr.third.v2.lowagie.text.SafeEmptyEntityResolver;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -85,6 +86,7 @@ public class XmpReader {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
db.setEntityResolver(new SafeEmptyEntityResolver());
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
domDocument = db.parse(bais);
} catch (ParserConfigurationException e) {

16
fine-poi/src/main/java/com/fr/third/v2/org/apache/poi/xssf/streaming/SheetDataWriter.java

@ -377,14 +377,22 @@ public class SheetDataWriter {
default:
// YK: XmlBeans silently replaces all ISO control characters ( < 32) with question marks.
// the same rule applies to unicode surrogates and "not a character" symbols.
if( c < ' ' || Character.isLowSurrogate(c) || Character.isHighSurrogate(c) ||
('\uFFFE' <= c && c <= '\uFFFF')) {
// Excel SXSSF deals with special chars.
// https://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java?r1=1791720&r2=1800705&pathrev=1800705&diff_format=f
if (replaceWithQuestionMark(c)) {
if (counter > last) {
sb.append(chars, last, counter - last);
}
sb.append('?');
last = counter + 1;
}
else if (Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) {
if (counter > last) {
sb.append(chars, last, counter - last);
}
sb.append(c);
last = counter + 1;
}
else if (c > 127) {
if (counter > last) {
sb.append(chars, last, counter - last);
@ -412,4 +420,8 @@ public class SheetDataWriter {
_out.close();
return _fd.delete();
}
private boolean replaceWithQuestionMark(char c) {
return c < ' ' || '\uFFFE' <= c;
}
}

46
fine-poi/src/main/java/com/fr/third/v2/org/apache/xmlbeans/impl/store/Saver.java

@ -273,6 +273,23 @@ abstract class Saver
end.toEnd();
}
/**
* Test if a character is valid in xml character content. See
* http://www.w3.org/TR/REC-xml#NT-Char
* Excel XSSF deals with special chars.
* https://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Saver.java?r1=1025773&r2=1832298&pathrev=1832298&diff_format=h
*/
static boolean isBadChar ( char ch )
{
return ! (
Character.isHighSurrogate(ch) ||
Character.isLowSurrogate(ch) ||
(ch >= 0x20 && ch <= 0xD7FF) ||
(ch >= 0xE000 && ch <= 0xFFFD) ||
(ch == 0x9) || (ch == 0xA) || (ch == 0xD)
);
}
protected boolean saveNamespacesFirst ( )
{
return _saveNamespacesFirst;
@ -1548,21 +1565,6 @@ abstract class Saver
}
}
/**
* Test if a character is valid in xml character content. See
* http://www.w3.org/TR/REC-xml#NT-Char
*/
private boolean isBadChar ( char ch )
{
return ! (
(ch >= 0x20 && ch <= 0xD7FF ) ||
(ch >= 0xE000 && ch <= 0xFFFD) ||
(ch >= 0x10000 && ch <= 0x10FFFF) ||
(ch == 0x9) || (ch == 0xA) || (ch == 0xD)
);
}
/**
* Test if a character is to be replaced with an escaped value
*/
@ -2187,20 +2189,6 @@ abstract class Saver
}
}
/**
* Test if a character is valid in xml character content. See
* http://www.w3.org/TR/REC-xml#NT-Char
*/
private boolean isBadChar ( char ch )
{
return ! (
(ch >= 0x20 && ch <= 0xD7FF ) ||
(ch >= 0xE000 && ch <= 0xFFFD) ||
(ch >= 0x10000 && ch <= 0x10FFFF) ||
(ch == 0x9) || (ch == 0xA) || (ch == 0xD)
);
}
private void emitLiteral ( String literal )
{
// TODO: systemId production http://www.w3.org/TR/REC-xml/#NT-SystemLiteral

34
fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java

@ -17,11 +17,14 @@ package com.fr.third.socketio;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.fr.third.socketio.handler.SuccessAuthorizationListener;
import com.fr.third.socketio.listener.DefaultExceptionListener;
import com.fr.third.socketio.listener.ExceptionListener;
import com.fr.third.socketio.listener.interceptor.EventInterceptor;
import com.fr.third.socketio.listener.interceptor.Interceptor;
import com.fr.third.socketio.protocol.JsonSupport;
import com.fr.third.socketio.store.MemoryStoreFactory;
import com.fr.third.socketio.store.RedissonStoreFactory;
@ -91,6 +94,10 @@ public class Configuration {
private String accessControlAllowHeaders = null;
private List<Interceptor> connectInterceptors = Collections.emptyList();
private List<Interceptor> disconnectInterceptors = Collections.emptyList();
private List<EventInterceptor> eventInterceptors = Collections.emptyList();
public Configuration() {
}
@ -159,6 +166,9 @@ public class Configuration {
setRandomSession(conf.randomSession);
setAccessControlAllowHeaders(conf.getAccessControlAllowHeaders());
setConnectInterceptors(conf.getConnectInterceptors().toArray(new Interceptor[0]));
setDisconnectInterceptors(conf.getDisconnectInterceptors().toArray(new Interceptor[0]));
setEventInterceptors(conf.getEventInterceptors().toArray(new EventInterceptor[0]));
}
public JsonSupport getJsonSupport() {
@ -596,4 +606,28 @@ public class Configuration {
public void setAccessControlAllowHeaders(String accessControlAllowHeaders) {
this.accessControlAllowHeaders = accessControlAllowHeaders;
}
public List<Interceptor> getConnectInterceptors() {
return connectInterceptors;
}
public void setConnectInterceptors(Interceptor[] connectInterceptors) {
this.connectInterceptors = Arrays.asList(connectInterceptors);
}
public List<Interceptor> getDisconnectInterceptors() {
return disconnectInterceptors;
}
public void setDisconnectInterceptors(Interceptor[] disconnectInterceptors) {
this.disconnectInterceptors = Arrays.asList(disconnectInterceptors);
}
public List<EventInterceptor> getEventInterceptors() {
return eventInterceptors;
}
public void setEventInterceptors(EventInterceptor[] eventInterceptors) {
this.eventInterceptors = Arrays.asList(eventInterceptors);
}
}

27
fine-socketio/src/main/java/com/fr/third/socketio/listener/interceptor/EventInterceptor.java

@ -0,0 +1,27 @@
package com.fr.third.socketio.listener.interceptor;
import com.fr.third.socketio.AckRequest;
import com.fr.third.socketio.SocketIOClient;
import java.util.List;
/**
* Desc
*
* @author Elijah
* created on 2021-04-26
*/
public interface EventInterceptor extends Interceptor {
default void before(SocketIOClient client, List<Object> params, AckRequest ackRequest){
before(client);
}
default void after(SocketIOClient client, List<Object> params, AckRequest ackRequest){
after(client);
}
default boolean accept(String eventName, SocketIOClient client, List<Object> param){
return accept(client);
}
}

23
fine-socketio/src/main/java/com/fr/third/socketio/listener/interceptor/Interceptor.java

@ -0,0 +1,23 @@
package com.fr.third.socketio.listener.interceptor;
import com.fr.third.socketio.SocketIOClient;
/**
* Desc
*
* @author Elijah
* created on 2021-05-06
*/
public interface Interceptor {
default void before(SocketIOClient client){
}
default void after(SocketIOClient client){
}
default boolean accept(SocketIOClient client){
return true;
}
}

53
fine-socketio/src/main/java/com/fr/third/socketio/namespace/Namespace.java

@ -34,6 +34,8 @@ import com.fr.third.socketio.MultiTypeArgs;
import com.fr.third.socketio.SocketIOClient;
import com.fr.third.socketio.SocketIONamespace;
import com.fr.third.socketio.annotation.ScannerEngine;
import com.fr.third.socketio.listener.interceptor.EventInterceptor;
import com.fr.third.socketio.listener.interceptor.Interceptor;
import com.fr.third.socketio.protocol.JsonSupport;
import com.fr.third.socketio.protocol.Packet;
import com.fr.third.socketio.store.StoreFactory;
@ -74,6 +76,7 @@ public class Namespace implements SocketIONamespace {
private final JsonSupport jsonSupport;
private final StoreFactory storeFactory;
private final ExceptionListener exceptionListener;
private final Configuration configuration;
public Namespace(String name, Configuration configuration) {
super();
@ -82,6 +85,7 @@ public class Namespace implements SocketIONamespace {
this.storeFactory = configuration.getStoreFactory();
this.exceptionListener = configuration.getExceptionListener();
this.ackMode = configuration.getAckMode();
this.configuration = configuration;
}
public void addClient(SocketIOClient client) {
@ -137,7 +141,16 @@ public class Namespace implements SocketIONamespace {
if (entry == null) {
return;
}
for (EventInterceptor eventInterceptor: configuration.getEventInterceptors()) {
try {
//不影响后续执行
if (eventInterceptor.accept(eventName, client, args)) {
eventInterceptor.before(client, args, ackRequest);
}
} catch (Exception e) {
exceptionListener.onEventException(e, args, client);
}
}
try {
Queue<DataListener> listeners = entry.getListeners();
for (DataListener dataListener : listeners) {
@ -149,6 +162,17 @@ public class Namespace implements SocketIONamespace {
if (ackMode == AckMode.AUTO_SUCCESS_ONLY) {
return;
}
} finally {
for (EventInterceptor eventInterceptor: configuration.getEventInterceptors()) {
try {
//不影响后续执行
if (eventInterceptor.accept(eventName, client, args)) {
eventInterceptor.after(client, args, ackRequest);
}
} catch (Exception e) {
exceptionListener.onEventException(e, args, client);
}
}
}
sendAck(ackRequest);
@ -190,12 +214,15 @@ public class Namespace implements SocketIONamespace {
}
clientRooms.remove(client.getSessionId());
callInterceptor(client, false, true);
try {
for (DisconnectListener listener : disconnectListeners) {
listener.onDisconnect(client);
}
} catch (Exception e) {
exceptionListener.onDisconnectException(e, client);
} finally {
callInterceptor(client, false, false);
}
}
@ -208,15 +235,39 @@ public class Namespace implements SocketIONamespace {
join(getName(), client.getSessionId());
storeFactory.pubSubStore().publish(PubSubType.JOIN, new JoinLeaveMessage(client.getSessionId(), getName(), getName()));
callInterceptor(client, true, true);
try {
for (ConnectListener listener : connectListeners) {
listener.onConnect(client);
}
} catch (Exception e) {
exceptionListener.onConnectException(e, client);
} finally {
callInterceptor(client, true, false);
}
}
private void callInterceptor(SocketIOClient client, boolean connect, boolean before) {
List<Interceptor> interceptors = connect ? configuration.getConnectInterceptors() : configuration.getDisconnectInterceptors();
for (Interceptor interceptor: interceptors) {
try{
if (interceptor.accept(client)) {
if (before) {
interceptor.before(client);
} else {
interceptor.after(client);
}
}
} catch (Exception e) {
if (connect) {
exceptionListener.onConnectException(e, client);
} else {
exceptionListener.onDisconnectException(e, client);
}
}
}
}
@Override
public void addPingListener(PingListener listener) {
pingListeners.add(listener);

Loading…
Cancel
Save