Skip to content

Commit

Permalink
fixed oracle polystring handling with nonascii orig value and null norm
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Sep 6, 2019
1 parent 503bcb1 commit 00f83d5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
Expand Up @@ -685,7 +685,7 @@ public static AuditEventRecord fromRepo(RAuditEventRecord repo, PrismContext pri
audit.addPropertyValue(rPropertyValue.getName(), rPropertyValue.getValue());
}
for (RAuditReferenceValue rRefValue : repo.getReferenceValues()) {
audit.addReferenceValue(rRefValue.getName(), rRefValue.fromRepo());
audit.addReferenceValue(rRefValue.getName(), rRefValue.fromRepo(prismContext));
}

audit.setRepoId(repo.getId());
Expand Down
Expand Up @@ -17,6 +17,7 @@
package com.evolveum.midpoint.repo.sql.data.audit;

import com.evolveum.midpoint.audit.api.AuditReferenceValue;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.repo.sql.data.InsertQueryBuilder;
import com.evolveum.midpoint.repo.sql.data.SingleSqlQuery;
Expand Down Expand Up @@ -180,8 +181,8 @@ public static SingleSqlQuery toRepo(Long recordId, String name, AuditReferenceVa
return queryBuilder.build();
}

public AuditReferenceValue fromRepo() {
return new AuditReferenceValue(oid, RUtil.stringToQName(type), RPolyString.fromRepo(targetName));
public AuditReferenceValue fromRepo(PrismContext prismContext) {
return new AuditReferenceValue(oid, RUtil.stringToQName(type), RPolyString.fromRepo(targetName, prismContext));
}

public static AuditReferenceValue fromRepo(ResultSet resultSet) throws SQLException {
Expand Down
Expand Up @@ -391,9 +391,9 @@ public static ObjectDeltaOperation fromRepo(RObjectDeltaOperation operation, Pri
OperationResultType resultType = prismContext.parserFor(xmlResult).parseRealValue(OperationResultType.class);
odo.setExecutionResult(OperationResult.createOperationResult(resultType));
}
odo.setObjectName(RPolyString.fromRepo(operation.getObjectName()));
odo.setObjectName(RPolyString.fromRepo(operation.getObjectName(), prismContext));
odo.setResourceOid(operation.getResourceOid());
odo.setResourceName(RPolyString.fromRepo(operation.getResourceName()));
odo.setResourceName(RPolyString.fromRepo(operation.getResourceName(), prismContext));
} catch (Exception ex) {
throw new DtoTranslationException(ex.getMessage(), ex);
}
Expand Down
Expand Up @@ -665,7 +665,7 @@ protected static <T extends ObjectType> void copyToJAXB(RObject<T> repo, ObjectT
Validate.notNull(repo, "Repo object must not be null.");
Validate.notNull(jaxb, "JAXB object must not be null.");

jaxb.setName(RPolyString.copyToJAXB(repo.getName()));
jaxb.setName(RPolyString.copyToJAXB(repo.getName(), prismContext));
jaxb.setOid(repo.getOid());
jaxb.setVersion(Integer.toString(repo.getVersion()));
jaxb.setLifecycleState(repo.getLifecycleState());
Expand Down
Expand Up @@ -98,7 +98,7 @@ public static void copyToJAXB(REmbeddedNamedReference repo, ObjectReferenceType
Validate.notNull(jaxb, "JAXB object must not be null.");
REmbeddedReference.copyToJAXB(repo, jaxb, prismContext);

jaxb.setTargetName(RPolyString.copyToJAXB(repo.getTargetName()));
jaxb.setTargetName(RPolyString.copyToJAXB(repo.getTargetName(), prismContext));
}

// public static void copyFromJAXB(ObjectReferenceType jaxb, REmbeddedNamedReference repo) {
Expand Down
Expand Up @@ -16,6 +16,7 @@

package com.evolveum.midpoint.repo.sql.data.common.embedded;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.repo.sql.query.definition.JaxbType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
Expand Down Expand Up @@ -108,23 +109,32 @@ public static RPolyString toRepo(PolyString string) {
return new RPolyString(string.getOrig(), string.getNorm());
}

public static PolyStringType copyToJAXB(RPolyString string) {
public static PolyStringType copyToJAXB(RPolyString string, PrismContext ctx) {
if (string == null) {
return null;
}

String orig = string.getOrig();
String norm = string.getNorm();

PolyStringType poly = new PolyStringType();
poly.setOrig(string.getOrig());
poly.setNorm(string.getNorm());
poly.setOrig(orig);

if (orig != null && norm == null) {
norm = ctx.getDefaultPolyStringNormalizer().normalize(orig);
poly.setNorm(norm);
} else {
poly.setNorm(norm);
}

return poly;
}

public static PolyString fromRepo(RPolyString string) {
public static PolyString fromRepo(RPolyString string, PrismContext prismContext) {
if (string == null) {
return null;
}

return new PolyString(string.getOrig(), string.getNorm());
return copyToJAXB(string, prismContext).toPolyString();
}
}
@@ -1,5 +1,6 @@
package com.evolveum.midpoint.repo.sql.data.common.other;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.repo.sql.data.common.RLookupTable;
import com.evolveum.midpoint.repo.sql.data.common.container.Container;
import com.evolveum.midpoint.repo.sql.data.common.embedded.RPolyString;
Expand Down Expand Up @@ -163,13 +164,13 @@ public int hashCode() {
return result;
}

public LookupTableRowType toJAXB() {
public LookupTableRowType toJAXB(PrismContext prismContext) {
LookupTableRowType row = new LookupTableRowType();
row.setId(Long.valueOf(id));
row.setKey(key);
row.setLastChangeTimestamp(lastChangeTimestamp);
row.setValue(value);
row.setLabel(RPolyString.copyToJAXB(label));
row.setLabel(RPolyString.copyToJAXB(label, prismContext));

return row;
}
Expand Down
Expand Up @@ -154,7 +154,7 @@ public void updateLookupTableData(Session session, String tableOid, Collection<?
QName name = ItemPath.toName(deltaPath.getSegment(2));

RLookupTableRow row = session.get(RLookupTableRow.class, new RContainerId(RUtil.toInteger(rowId), tableOid));
LookupTableRowType rowType = row.toJAXB();
LookupTableRowType rowType = row.toJAXB(prismContext);
delta.setParentPath(ItemPath.EMPTY_PATH);
delta.applyTo(rowType.asPrismContainerValue());
if (!QNameUtil.match(name, LookupTableRowType.F_LAST_CHANGE_TIMESTAMP)) {
Expand Down Expand Up @@ -228,7 +228,7 @@ public <T extends ObjectType> void updateLoadedLookupTable(PrismObject<T> object
LookupTableType lookup = (LookupTableType) object.asObjectable();
List<LookupTableRowType> jaxbRows = lookup.getRow();
for (RLookupTableRow row : rows) {
LookupTableRowType jaxbRow = row.toJAXB();
LookupTableRowType jaxbRow = row.toJAXB(prismContext);
jaxbRows.add(jaxbRow);
}
}
Expand Down

0 comments on commit 00f83d5

Please sign in to comment.