use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class SynchronizationUtils method isPolicyApplicable.
public static boolean isPolicyApplicable(QName objectClass, ShadowKindType kind, String intent, ObjectSynchronizationType synchronizationPolicy, PrismObject<ResourceType> resource) throws SchemaException {
List<QName> policyObjectClasses = synchronizationPolicy.getObjectClass();
if (policyObjectClasses == null || policyObjectClasses.isEmpty()) {
String policyIntent = synchronizationPolicy.getIntent();
ShadowKindType policyKind = synchronizationPolicy.getKind();
ObjectClassComplexTypeDefinition policyObjectClass = null;
RefinedResourceSchema schema = RefinedResourceSchemaImpl.getRefinedSchema(resource);
if (schema == null) {
throw new SchemaException("No schema defined in resource. Possible configuration problem?");
}
if (policyKind == null && policyIntent == null) {
policyObjectClass = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
}
if (policyKind != null) {
if (StringUtils.isEmpty(policyIntent)) {
policyObjectClass = schema.findDefaultObjectClassDefinition(policyKind);
} else {
policyObjectClass = schema.findObjectClassDefinition(policyKind, policyIntent);
}
}
if (policyObjectClass != null && !policyObjectClass.getTypeName().equals(objectClass)) {
return false;
}
}
if (policyObjectClasses != null && !policyObjectClasses.isEmpty()) {
if (!QNameUtil.contains(policyObjectClasses, objectClass)) {
return false;
}
}
// kind
ShadowKindType policyKind = synchronizationPolicy.getKind();
if (policyKind != null && kind != null && !policyKind.equals(kind)) {
return false;
}
// intent
// TODO is the intent always present in shadow at this time? [med]
String policyIntent = synchronizationPolicy.getIntent();
if (policyIntent != null && intent != null && !MiscSchemaUtil.equalsIntent(intent, policyIntent)) {
return false;
}
return true;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestRefinedSchema method testParseFromResourceSimple.
@Test
public void testParseFromResourceSimple() throws JAXBException, SchemaException, SAXException, IOException {
System.out.println("\n===[ testParseFromResourceSimple ]===\n");
// GIVEN
PrismContext prismContext = createInitializedPrismContext();
PrismObject<ResourceType> resource = prismContext.parseObject(RESOURCE_SIMPLE_FILE);
ResourceType resourceType = resource.asObjectable();
// WHEN
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext);
// THEN
assertNotNull("Refined schema is null", rSchema);
System.out.println("Refined schema");
System.out.println(rSchema.debugDump());
assertRefinedSchema(resourceType, rSchema, null, LayerType.SCHEMA, false);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class ExpressionHandlerImplTest method testEvaluateExpression.
@SuppressWarnings("unchecked")
@Test
public void testEvaluateExpression() throws Exception {
PrismObject<ShadowType> account = PrismTestUtil.parseObject(new File(TEST_FOLDER, "account.xml"));
ShadowType accountType = account.asObjectable();
PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(TEST_FOLDER_COMMON, "resource-dummy.xml"));
ResourceType resourceType = resource.asObjectable();
accountType.setResource(resourceType);
ObjectSynchronizationType synchronization = resourceType.getSynchronization().getObjectSynchronization().get(0);
for (ConditionalSearchFilterType filter : synchronization.getCorrelation()) {
MapXNode clauseXNode = filter.getFilterClauseXNode();
// key = q:equal, value = map (path + expression)
RootXNode expressionNode = ((MapXNode) clauseXNode.getSingleSubEntry("filter value").getValue()).getEntryAsRoot(new QName(SchemaConstants.NS_C, "expression"));
ExpressionType expression = PrismTestUtil.getPrismContext().parserFor(expressionNode).parseRealValue(ExpressionType.class);
LOGGER.debug("Expression: {}", SchemaDebugUtil.prettyPrint(expression));
OperationResult result = new OperationResult("testCorrelationRule");
String name = expressionHandler.evaluateExpression(accountType, expression, "test expression", null, result);
LOGGER.info(result.debugDump());
assertEquals("Wrong expression result", "hbarbossa", name);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestDependencies method initDummy.
private void initDummy(String name, Task initTask, OperationResult initResult) throws FileNotFoundException, ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ConnectException, SchemaViolationException, ConflictException, ExpressionEvaluationException {
String resourceOid = getDummyOid(name);
DummyResourceContoller resourceCtl = DummyResourceContoller.create(name.toUpperCase());
resourceCtl.extendSchemaPirate();
PrismObject<ResourceType> resource = importAndGetObjectFromFile(ResourceType.class, getDummFile(name), resourceOid, initTask, initResult);
resourceCtl.setResource(resource);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestExpressionFunctions method testgetResourceIcfConfigurationPropertyValueStringPort.
@Test
public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exception {
final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringPort";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
PrismObject<ResourceType> resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE);
// WHEN
int val = f.getResourceIcfConfigurationPropertyValue(resource.asObjectable(), "port");
// THEN
assertEquals("Wrong value of ICF configuration property", 10389, val);
}
Aggregations