protected PrismObject<ShadowType> repoAddShadowFromFile(File file, OperationResult parentResult)
throws SchemaException, ObjectAlreadyExistsException, EncryptionException, IOException {
OperationResult result = parentResult.createSubresult(AbstractIntegrationTest.class.getName()
+ ".repoAddShadowFromFile");
result.addParam("file", file.getPath());
LOGGER.debug("addShadowFromFile: {}", file);
PrismObject<ShadowType> object = prismContext.parseObject(file);
PrismContainer<Containerable> attrCont = object.findContainer(ShadowType.F_ATTRIBUTES);
for (PrismProperty<?> attr: attrCont.getValue().getProperties()) {
if (attr.getDefinition() == null) {
ResourceAttributeDefinition<String> attrDef = ObjectFactory.createResourceAttributeDefinition(attr.getElementName(),
DOMUtil.XSD_STRING, prismContext);
attr.setDefinition((PrismPropertyDefinition) attrDef);
}
}
addBasicMetadata(object);
LOGGER.trace("Adding object:\n{}", object.debugDump());
repoAddObject(object, "from file "+file, result);
result.recordSuccess();
return object;
}