use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class ExecuteChangesHandlerDto method getObjectDeltaXml.
public String getObjectDeltaXml() {
ObjectDeltaType objectDeltaType = taskDto.getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA, ObjectDeltaType.class);
if (objectDeltaType == null) {
return null;
}
PrismContext prismContext = MidPointApplication.get().getPrismContext();
try {
return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serializeAnyData(objectDeltaType, SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA));
} catch (SchemaException e) {
throw new SystemException("Couldn't serialize object delta: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class QueryBasedHandlerDto method getObjectQuery.
public String getObjectQuery() {
QueryType query = taskDto.getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.class);
if (query == null) {
return null;
}
PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
try {
return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serializeAnyData(query, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY));
} catch (SchemaException e) {
throw new SystemException("Couldn't serialize query: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TaskDto method getObjectQuery.
public String getObjectQuery() {
QueryType queryType = getExtensionPropertyRealValue(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.class);
PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
try {
return prismContext.xmlSerializer().serializeAnyData(queryType, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
} catch (SchemaException e) {
throw new SystemException("Couldn't serialize query: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class XNodeProcessorUtil method parseProtectedType.
public static <T> void parseProtectedType(ProtectedDataType<T> protectedType, MapXNode xmap, PrismContext prismContext, ParsingContext pc) throws SchemaException {
RootXNode xEncryptedData = xmap.getEntryAsRoot(ProtectedDataType.F_ENCRYPTED_DATA);
if (xEncryptedData != null) {
if (!(xEncryptedData.getSubnode() instanceof MapXNode)) {
throw new SchemaException("Cannot parse encryptedData from " + xEncryptedData);
}
EncryptedDataType encryptedDataType = prismContext.parserFor(xEncryptedData).context(pc).parseRealValue(EncryptedDataType.class);
protectedType.setEncryptedData(encryptedDataType);
} else {
// Check for legacy EncryptedData
RootXNode xLegacyEncryptedData = xmap.getEntryAsRoot(ProtectedDataType.F_XML_ENC_ENCRYPTED_DATA);
if (xLegacyEncryptedData != null) {
if (!(xLegacyEncryptedData.getSubnode() instanceof MapXNode)) {
throw new SchemaException("Cannot parse EncryptedData from " + xEncryptedData);
}
RootXNode xConvertedEncryptedData = (RootXNode) xLegacyEncryptedData.cloneTransformKeys(in -> {
String elementName = StringUtils.uncapitalize(in.getLocalPart());
if (elementName.equals("type")) {
return null;
}
return new QName(null, elementName);
});
EncryptedDataType encryptedDataType = prismContext.parserFor(xConvertedEncryptedData).context(pc).parseRealValue(EncryptedDataType.class);
protectedType.setEncryptedData(encryptedDataType);
if (protectedType instanceof ProtectedStringType) {
transformEncryptedValue(protectedType, prismContext);
}
}
}
RootXNode xHashedData = xmap.getEntryAsRoot(ProtectedDataType.F_HASHED_DATA);
if (xHashedData != null) {
if (!(xHashedData.getSubnode() instanceof MapXNode)) {
throw new SchemaException("Cannot parse hashedData from " + xHashedData);
}
HashedDataType hashedDataType = prismContext.parserFor(xHashedData).context(pc).parseRealValue(HashedDataType.class);
protectedType.setHashedData(hashedDataType);
}
// protected data empty..check for clear value
if (protectedType.isEmpty()) {
XNode xClearValue = xmap.get(ProtectedDataType.F_CLEAR_VALUE);
if (xClearValue == null) {
//TODO: try to use common namespace (only to be compatible with previous versions)
//FIXME maybe add some warning, info...
xClearValue = xmap.get(new QName(ProtectedDataType.F_CLEAR_VALUE.getLocalPart()));
}
if (xClearValue == null) {
return;
}
if (!(xClearValue instanceof PrimitiveXNode)) {
//this is maybe not good..
throw new SchemaException("Cannot parse clear value from " + xClearValue);
}
// TODO: clearValue
T clearValue = (T) ((PrimitiveXNode) xClearValue).getParsedValue(DOMUtil.XSD_STRING, String.class);
protectedType.setClearValue(clearValue);
}
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class ApprovalSchemaBuilder method cloneAndMergeStages.
private List<ApprovalStageDefinitionType> cloneAndMergeStages(List<Fragment> fragments) throws SchemaException {
if (fragments.size() == 1) {
return CloneUtil.cloneCollectionMembers(getStages(fragments.get(0).schema));
}
PrismContext prismContext = primaryChangeAspect.getChangeProcessor().getPrismContext();
ApprovalStageDefinitionType resultingStageDef = new ApprovalStageDefinitionType(prismContext);
fragments.sort((f1, f2) -> Comparator.nullsLast(Comparator.<Integer>naturalOrder()).compare(f1.compositionStrategy.getMergePriority(), f2.compositionStrategy.getMergePriority()));
for (Fragment fragment : fragments) {
mergeStageDefFromFragment(resultingStageDef, fragment);
}
return Collections.singletonList(resultingStageDef);
}
Aggregations