Skip to content

Commit

Permalink
MID-6732: fix, introduced useZipAudit repo config flag, true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Dec 3, 2020
1 parent abba82d commit 29be424
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Expand Up @@ -564,7 +564,8 @@ public void execute(Connection connection) throws SQLException {

SingleSqlQuery deltaQuery;
try {
deltaQuery = RObjectDeltaOperation.toRepo(id, delta, getPrismContext());
deltaQuery = RObjectDeltaOperation.toRepo(id, delta, getPrismContext(),
getConfiguration().isUseZipAudit());
deltaBatchQuery.addQueryForBatch(deltaQuery);
} catch (DtoTranslationException e) {
baseHelper.handleGeneralCheckedException(e, localSession, null);
Expand Down
Expand Up @@ -272,6 +272,7 @@ public static IncompatibleSchemaAction fromValue(String text) {
public static final String PROPERTY_JDBC_URL = "jdbcUrl";
public static final String PROPERTY_DATASOURCE = "dataSource";
public static final String PROPERTY_USE_ZIP = "useZip";
public static final String PROPERTY_USE_ZIP_AUDIT = "useZipAudit";
public static final String PROPERTY_MIN_POOL_SIZE = "minPoolSize";
public static final String PROPERTY_MAX_POOL_SIZE = "maxPoolSize";
public static final String PROPERTY_MAX_LIFETIME = "maxLifetime";
Expand Down Expand Up @@ -353,6 +354,7 @@ public static IncompatibleSchemaAction fromValue(String text) {
private final Long maxLifetime;
private final Long idleTimeout;
private final boolean useZip;
private final boolean useZipAudit;

private TransactionIsolation defaultTransactionIsolation;
private boolean defaultLockForUpdateViaHibernate;
Expand Down Expand Up @@ -468,6 +470,7 @@ public SqlRepositoryConfiguration(Configuration configuration) {
idleTimeout = configuration.getLong(PROPERTY_IDLE_TIMEOUT, null);

useZip = configuration.getBoolean(PROPERTY_USE_ZIP, false);
useZipAudit = configuration.getBoolean(PROPERTY_USE_ZIP_AUDIT, true);

// requires asServer, baseDir, fileName, port
jdbcUrl = configuration.getString(PROPERTY_JDBC_URL, embedded ? getDefaultEmbeddedJdbcUrl() : null);
Expand Down Expand Up @@ -896,6 +899,10 @@ public boolean isUseZip() {
return useZip;
}

public boolean isUseZipAudit() {
return useZipAudit;
}

public boolean isIgnoreOrgClosure() {
return ignoreOrgClosure;
}
Expand Down
Expand Up @@ -299,7 +299,7 @@ public static RObjectDeltaOperation toRepo(RAuditEventRecord record, ObjectDelta
}

public static SingleSqlQuery toRepo(Long recordId, ObjectDeltaOperation operation,
PrismContext prismContext) throws DtoTranslationException {
PrismContext prismContext, boolean useZipAudit) throws DtoTranslationException {

InsertQueryBuilder queryBuilder = new InsertQueryBuilder(TABLE_NAME);
queryBuilder.addParameter(COLUMN_RECORD_ID, recordId, true);
Expand All @@ -310,7 +310,7 @@ public static SingleSqlQuery toRepo(Long recordId, ObjectDeltaOperation operatio
ObjectDelta delta = operation.getObjectDelta();

String xmlDelta = DeltaConvertor.toObjectDeltaTypeXml(delta, DeltaConversionOptions.createSerializeReferenceNames());
deltaData = RUtil.getByteArrayFromXml(xmlDelta, true);
deltaData = RUtil.getByteArrayFromXml(xmlDelta, useZipAudit);
queryBuilder.addParameter(DELTA_COLUMN_NAME, deltaData);
queryBuilder.addParameter(DELTA_OID_COLUMN_NAME, delta.getOid());
queryBuilder.addParameter(DELTA_TYPE_COLUMN_NAME, RUtil.getRepoEnumValue(delta.getChangeType(), RChangeType.class));
Expand All @@ -329,7 +329,7 @@ public static SingleSqlQuery toRepo(Long recordId, ObjectDeltaOperation operatio
queryBuilder.addParameter(STATUS_COLUMN_NAME, RUtil.getRepoEnumValue(jaxb.getStatus(), ROperationResultStatus.class));
try {
String full = prismContext.xmlSerializer().serializeRealValue(jaxb, SchemaConstantsGenerated.C_OPERATION_RESULT);
fullResultData = RUtil.getByteArrayFromXml(full, true);
fullResultData = RUtil.getByteArrayFromXml(full, useZipAudit);
queryBuilder.addParameter(FULL_RESULT_COLUMN_NAME, fullResultData);
} catch (Exception ex) {
throw new DtoTranslationException(ex.getMessage(), ex);
Expand Down

0 comments on commit 29be424

Please sign in to comment.