From 5188ea0ab226ce6e7fa3b1ecb8e29ebb9e05bbfd Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 5 Feb 2016 13:46:41 +0100 Subject: [PATCH 1/5] Fixing repo impl tests. --- .../src/test/resources/basic/objects.xml | 14 +++++++------- .../src/test/resources/cert/cert-campaign-1.xml | 14 +++++++------- .../src/test/resources/cert/cert-campaign-2.xml | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/repo/repo-sql-impl-test/src/test/resources/basic/objects.xml b/repo/repo-sql-impl-test/src/test/resources/basic/objects.xml index d2759b9d606..3e36133deec 100644 --- a/repo/repo-sql-impl-test/src/test/resources/basic/objects.xml +++ b/repo/repo-sql-impl-test/src/test/resources/basic/objects.xml @@ -1414,7 +1414,7 @@ notDecided 2015-12-04T01:10:20.032+01:00 - notDecided + notDecided 1 @@ -1435,7 +1435,7 @@ accept 2015-12-04T01:04:06.385+01:00 - accept + accept 1 @@ -1456,7 +1456,7 @@ noResponse 2015-12-04T01:10:08.670+01:00 - noResponse + noResponse 1 @@ -1477,7 +1477,7 @@ revoke 2015-12-04T01:10:13.814+01:00 - revoke + revoke 1 @@ -1518,7 +1518,7 @@ revoke 2015-12-04T01:10:14.614+01:00 - revoke + revoke 1 @@ -1539,7 +1539,7 @@ reduce 2015-12-04T01:10:15.375+01:00 - reduce + reduce 1 @@ -1560,7 +1560,7 @@ revoke 2015-12-04T01:10:16.136+01:00 - revoke + revoke 1 diff --git a/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-1.xml b/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-1.xml index d889471b1f1..0f81457f6dc 100644 --- a/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-1.xml +++ b/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-1.xml @@ -87,7 +87,7 @@ noResponse 2015-12-04T01:10:20.032+01:00 - notDecided + notDecided 1 @@ -109,7 +109,7 @@ accept 2015-12-04T01:04:06.385+01:00 - accept + accept 1 @@ -129,7 +129,7 @@ - noResponse + noResponse 1 @@ -152,7 +152,7 @@ revoke 2015-12-04T01:10:13.814+01:00 - revoke + revoke 1 @@ -195,7 +195,7 @@ revoke 2015-12-04T01:10:14.614+01:00 - revoke + revoke 1 @@ -222,7 +222,7 @@ - reduce + reduce 1 @@ -251,7 +251,7 @@ accept 2015-12-04T01:15:00.000+01:00 - revoke + revoke 1 diff --git a/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-2.xml b/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-2.xml index 685d8cbe207..f89679b680b 100644 --- a/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-2.xml +++ b/repo/repo-sql-impl-test/src/test/resources/cert/cert-campaign-2.xml @@ -67,7 +67,7 @@ accept 2015-12-04T01:10:20.032+01:00 - accept + accept 1 From dfd65093c3e90a1c473f7a1b6364d83f6ff3990c Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 5 Feb 2016 15:05:13 +0100 Subject: [PATCH 2/5] Support for base context searches for connectors that support object hierarchies (such as LDAP) --- ...CompositeRefinedObjectClassDefinition.java | 9 +- .../LayerRefinedObjectClassDefinition.java | 7 +- .../RefinedObjectClassDefinition.java | 13 +- .../ObjectClassComplexTypeDefinition.java | 15 +- .../processor/ResourceAttributeContainer.java | 11 +- .../ResourceAttributeContainerDefinition.java | 9 +- .../ResourceObjectIdentification.java | 52 +++- .../midpoint/schema/util/ObjectQueryUtil.java | 44 ++-- .../midpoint/schema/util/ShadowUtil.java | 20 +- .../xml/ns/public/common/common-3.xsd | 11 +- .../impl/EntitlementConverter.java | 10 +- .../impl/ResourceObjectConverter.java | 9 +- .../impl/ResourceObjectReferenceResolver.java | 79 +++++- .../provisioning/impl/ShadowCache.java | 37 ++- .../provisioning/impl/ShadowManager.java | 2 +- .../ucf/impl/ConnectorInstanceIcfImpl.java | 13 +- .../test/impl/AbstractOpenDJTest.java | 6 +- .../provisioning/test/impl/TestDummy.java | 44 +++- .../provisioning/test/impl/TestOpenDJ.java | 227 ++++++++++++++++-- .../provisioning/test/ucf/TestUcfOpenDj.java | 6 +- .../impl/opendj/group-specialists.xml | 33 +++ .../test/resources/object/resource-opendj.xml | 42 +++- .../midpoint/testing/story/TestUnix.java | 104 +++++++- .../test/resources/unix/resource-opendj.xml | 18 ++ 24 files changed, 712 insertions(+), 109 deletions(-) create mode 100644 provisioning/provisioning-impl/src/test/resources/impl/opendj/group-specialists.xml diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java index 6fa390e2edd..912195c2540 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Evolveum + * Copyright (c) 2015-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,13 +158,20 @@ public RefinedAttributeDefinition getDisplayNameAttribute() { return structuralObjectClassDefinition.getDisplayNameAttribute(); } + @Override public Collection> getIdentifiers() { return structuralObjectClassDefinition.getIdentifiers(); } + @Override public Collection> getSecondaryIdentifiers() { return structuralObjectClassDefinition.getSecondaryIdentifiers(); } + + @Override + public Collection> getAllIdentifiers() { + return structuralObjectClassDefinition.getAllIdentifiers(); + } public boolean isAuxiliary() { return structuralObjectClassDefinition.isAuxiliary(); diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinition.java index a8dc5248e70..607039f55a7 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,6 +205,11 @@ public void setDisplayNameAttribute(QName displayName) { public Collection> getIdentifiers() { return substituteLayerRefinedAttributeDefinitionCollection(refinedObjectClassDefinition.getIdentifiers()); } + + @Override + public Collection> getAllIdentifiers() { + return substituteLayerRefinedAttributeDefinitionCollection(refinedObjectClassDefinition.getAllIdentifiers()); + } @Override public D findItemDefinition(QName name, Class clazz) { diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java index 5516874260e..d6e4ab3fc53 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -200,6 +200,17 @@ public Collection> getSecondaryIdentifie } return secondaryIdentifiers; } + + public Collection> getAllIdentifiers() { + Collection> allIdentifiers = new ArrayList<>(); + if (identifiers != null) { + allIdentifiers.addAll((Collection)getIdentifiers()); + } + if (secondaryIdentifiers != null) { + allIdentifiers.addAll((Collection)getSecondaryIdentifiers()); + } + return allIdentifiers; + } private Collection> createIdentifiersCollection() { return new ArrayList<>(); diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java index 3a0e8806c43..0f24f2e0e1f 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java @@ -58,7 +58,7 @@ public Collection getAttributeDefinitions } /** - * Returns the definition of identifier attributes of a resource object. + * Returns the definition of primary identifier attributes of a resource object. * * May return empty set if there are no identifier attributes. Must not * return null. @@ -71,6 +71,7 @@ public Collection getAttributeDefinitions * @throws IllegalStateException * if there is no definition for the referenced attributed */ + // TODO: rename to getPrimaryIdentifiers public Collection getIdentifiers() { if (identifiers == null) { identifiers = new ArrayList(1); @@ -78,6 +79,7 @@ public Collection getIdentifiers() { return identifiers; } + // TODO: rename to isPrimaryIdentifier public boolean isIdentifier(QName attrName) { for (ResourceAttributeDefinition idDef: getIdentifiers()) { if (idDef.getName().equals(attrName)) { @@ -118,6 +120,17 @@ public boolean isSecondaryIdentifier(QName attrName) { return false; } + public Collection getAllIdentifiers() { + Collection allIdentifiers = new ArrayList<>(); + if (identifiers != null) { + allIdentifiers.addAll((Collection)getIdentifiers()); + } + if (secondaryIdentifiers != null) { + allIdentifiers.addAll((Collection)getSecondaryIdentifiers()); + } + return allIdentifiers; + } + /** * Returns the definition of description attribute of a resource object. * diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java index 4fb837b95d4..65db6aaf9dc 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ public void add(ResourceAttribute attribute) throws SchemaException { } /** - * Returns a (single) identifier. + * Returns a (single) primary identifier. * * This method returns a property that acts as an (primary) identifier for * the resource object. Primary identifiers are used to access the resource @@ -113,7 +113,7 @@ public PrismProperty getIdentifier() { } /** - * Returns identifiers. + * Returns primary identifiers. * * This method returns properties that act as (primary) identifiers for the * resource object. Primary identifiers are used to access the resource @@ -129,6 +129,7 @@ public PrismProperty getIdentifier() { * * @return set of identifier properties */ + // TODO: rename to getPrimaryIdentifiers public Collection> getIdentifiers() { return extractAttributesByDefinitions(getDefinition().getIdentifiers()); } @@ -178,6 +179,10 @@ public PrismProperty getSecondaryIdentifier() { public Collection> getSecondaryIdentifiers() { return extractAttributesByDefinitions(getDefinition().getSecondaryIdentifiers()); } + + public Collection> getAllIdentifiers() { + return extractAttributesByDefinitions(getDefinition().getAllIdentifiers()); + } private Collection> extractAttributesByDefinitions(Collection definitions) { Collection> attributes = new ArrayList>(definitions.size()); diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainerDefinition.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainerDefinition.java index 14ccb17551a..781cc3c899f 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainerDefinition.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainerDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public ObjectClassComplexTypeDefinition getComplexTypeDefinition() { } /** - * Returns the definition of identifier attributes of a resource object. + * Returns the definition of primary identifier attributes of a resource object. * * May return empty set if there are no identifier attributes. Must not * return null. @@ -85,6 +85,7 @@ public ObjectClassComplexTypeDefinition getComplexTypeDefinition() { * @throws IllegalStateException * if there is no definition for the referenced attributed */ + // TODO: rename to getPrimaryIdentifiers public Collection getIdentifiers() { return getComplexTypeDefinition().getIdentifiers(); } @@ -107,6 +108,10 @@ public Collection getIdentifiers() { public Collection getSecondaryIdentifiers() { return getComplexTypeDefinition().getSecondaryIdentifiers(); } + + public Collection getAllIdentifiers() { + return getComplexTypeDefinition().getAllIdentifiers(); + } /** * Returns the definition of description attribute of a resource object. diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceObjectIdentification.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceObjectIdentification.java index 9740a88e19a..eaa233667db 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceObjectIdentification.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceObjectIdentification.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Evolveum + * Copyright (c) 2015-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import java.util.Collection; import com.evolveum.midpoint.util.PrettyPrinter; +import com.evolveum.midpoint.util.exception.SchemaException; /** * @author semancik @@ -26,17 +27,46 @@ public class ResourceObjectIdentification { private ObjectClassComplexTypeDefinition objectClassDefinition; - private Collection> identifiers; + private Collection> primaryIdentifiers; + private Collection> secondaryIdentifiers; // TODO: identification strategy - public ResourceObjectIdentification(ObjectClassComplexTypeDefinition objectClassDefinition, Collection> identifiers) { + public ResourceObjectIdentification(ObjectClassComplexTypeDefinition objectClassDefinition, + Collection> primaryIdentifiers, + Collection> secondaryIdentifiers) { this.objectClassDefinition = objectClassDefinition; - this.identifiers = identifiers; + this.primaryIdentifiers = primaryIdentifiers; + this.secondaryIdentifiers = secondaryIdentifiers; } - public Collection> getIdentifiers() { - return identifiers; + public Collection> getPrimaryIdentifiers() { + return primaryIdentifiers; } + + public ResourceAttribute getPrimaryIdentifier() throws SchemaException { + if (primaryIdentifiers == null || primaryIdentifiers.isEmpty()) { + return null; + } + if (primaryIdentifiers.size() > 1) { + throw new SchemaException("More than one primary identifier in "+this); + } + return primaryIdentifiers.iterator().next(); + } + + public Collection> getSecondaryIdentifiers() { + return secondaryIdentifiers; + } + + public ResourceAttribute getSecondaryIdentifier() throws SchemaException { + if (secondaryIdentifiers == null || secondaryIdentifiers.isEmpty()) { + return null; + } + if (secondaryIdentifiers.size() > 1) { + throw new SchemaException("More than one secondary identifier in "+this); + } + return secondaryIdentifiers.iterator().next(); + } + public ObjectClassComplexTypeDefinition getObjectClassDefinition() { return objectClassDefinition; @@ -46,7 +76,7 @@ public ObjectClassComplexTypeDefinition getObjectClassDefinition() { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((identifiers == null) ? 0 : identifiers.hashCode()); + result = prime * result + ((primaryIdentifiers == null) ? 0 : primaryIdentifiers.hashCode()); result = prime * result + ((objectClassDefinition == null) ? 0 : objectClassDefinition.hashCode()); return result; } @@ -60,10 +90,10 @@ public boolean equals(Object obj) { if (getClass() != obj.getClass()) return false; ResourceObjectIdentification other = (ResourceObjectIdentification) obj; - if (identifiers == null) { - if (other.identifiers != null) + if (primaryIdentifiers == null) { + if (other.primaryIdentifiers != null) return false; - } else if (!identifiers.equals(other.identifiers)) + } else if (!primaryIdentifiers.equals(other.primaryIdentifiers)) return false; if (objectClassDefinition == null) { if (other.objectClassDefinition != null) @@ -76,7 +106,7 @@ public boolean equals(Object obj) { @Override public String toString() { return "ResourceObjectIdentification(" + PrettyPrinter.prettyPrint(objectClassDefinition.getTypeName()) - + ": " + identifiers + ")"; + + ": primary=" + primaryIdentifiers + ", secondary=" + secondaryIdentifiers + ")"; } } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ObjectQueryUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ObjectQueryUtil.java index cbdb2a67cec..e5e7fd86877 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ObjectQueryUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ObjectQueryUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,37 +16,30 @@ package com.evolveum.midpoint.schema.util; -import java.util.ArrayList; import java.util.List; import javax.xml.namespace.QName; +import org.apache.commons.lang.Validate; +import org.apache.commons.lang.mutable.MutableBoolean; + +import com.evolveum.midpoint.prism.ItemDefinition; +import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismPropertyValue; import com.evolveum.midpoint.prism.PrismReferenceValue; import com.evolveum.midpoint.prism.PrismValue; import com.evolveum.midpoint.prism.match.PolyStringNormMatchingRule; import com.evolveum.midpoint.prism.match.PolyStringOrigMatchingRule; - import com.evolveum.midpoint.prism.path.ItemPath; +import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.polystring.PolyStringNormalizer; import com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer; -import com.evolveum.midpoint.prism.query.NaryLogicalFilter; -import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.mutable.MutableBoolean; - -import com.evolveum.midpoint.prism.ItemDefinition; -import com.evolveum.midpoint.prism.PrismContext; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.prism.polystring.PolyString; import com.evolveum.midpoint.prism.query.AllFilter; import com.evolveum.midpoint.prism.query.AndFilter; import com.evolveum.midpoint.prism.query.EqualFilter; -import com.evolveum.midpoint.prism.query.InOidFilter; -import com.evolveum.midpoint.prism.query.LogicalFilter; +import com.evolveum.midpoint.prism.query.NaryLogicalFilter; import com.evolveum.midpoint.prism.query.NoneFilter; -import com.evolveum.midpoint.prism.query.UndefinedFilter; import com.evolveum.midpoint.prism.query.NotFilter; import com.evolveum.midpoint.prism.query.ObjectFilter; import com.evolveum.midpoint.prism.query.ObjectQuery; @@ -54,12 +47,14 @@ import com.evolveum.midpoint.prism.query.OrgFilter; import com.evolveum.midpoint.prism.query.RefFilter; import com.evolveum.midpoint.prism.query.TypeFilter; +import com.evolveum.midpoint.prism.query.UndefinedFilter; import com.evolveum.midpoint.prism.query.ValueFilter; import com.evolveum.midpoint.prism.query.Visitor; +import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.prism.xml.ns._public.query_3.QueryType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @@ -128,6 +123,21 @@ public static ObjectFilter createResourceAndObjectClassFilter(String resourceOid createObjectClassFilter(objectClass, prismContext)); return and; } + + public static ObjectQuery createResourceAndKindIntent(String resourceOid, ShadowKindType kind, String intent, PrismContext prismContext) throws SchemaException { + return ObjectQuery.createObjectQuery(createResourceAndKindIntentFilter(resourceOid, kind, intent, prismContext)); + } + + public static ObjectFilter createResourceAndKindIntentFilter(String resourceOid, ShadowKindType kind, String intent, PrismContext prismContext) throws SchemaException { + Validate.notNull(resourceOid, "Resource where to search must not be null."); + Validate.notNull(kind, "Kind to search must not be null."); + Validate.notNull(prismContext, "Prism context must not be null."); + AndFilter and = AndFilter.createAnd( + createResourceFilter(resourceOid, prismContext), + EqualFilter.createEqual(ShadowType.F_KIND, ShadowType.class, prismContext, null, kind), + EqualFilter.createEqual(ShadowType.F_INTENT, ShadowType.class, prismContext, null, intent)); + return and; + } public static ObjectQuery createResourceQuery(String resourceOid, PrismContext prismContext) throws SchemaException { Validate.notNull(resourceOid, "Resource where to search must not be null."); diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java index 1b3e3a9c96e..f6827b3cc11 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/util/ShadowUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceAttributeContainer; import com.evolveum.midpoint.schema.processor.ResourceAttributeContainerDefinition; +import com.evolveum.midpoint.schema.processor.ResourceObjectIdentification; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.util.MiscUtil; import com.evolveum.midpoint.util.QNameUtil; @@ -54,6 +55,7 @@ public static Collection> getIdentifiers(ShadowType shadowT return getIdentifiers(shadowType.asPrismObject()); } + // TODO: rename to getPrimaryIdentifiers public static Collection> getIdentifiers(PrismObject shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { @@ -81,7 +83,7 @@ public static ResourceAttribute getSecondaryIdentifier(ObjectClassComplexType } ResourceAttribute secondaryIdentifier = null; for (ResourceAttribute identifier: identifiers) { - if (identifier.getDefinition().isIdentifier(objectClassDefinition)) { + if (identifier.getDefinition().isSecondaryIdentifier(objectClassDefinition)) { if (secondaryIdentifier != null) { throw new SchemaException("More than one secondary identifier in "+objectClassDefinition); } @@ -91,6 +93,14 @@ public static ResourceAttribute getSecondaryIdentifier(ObjectClassComplexType return secondaryIdentifier; } + public static Collection> getAllIdentifiers(PrismObject shadow) { + ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); + if (attributesContainer == null) { + return null; + } + return attributesContainer.getAllIdentifiers(); + } + public static ResourceAttribute getNamingAttribute(ShadowType shadow){ return getNamingAttribute(shadow.asPrismObject()); } @@ -578,4 +588,10 @@ public static String determineShadowStringName(PrismObjec // return // attributesContainer.getNamingAttribute().getValue().getValue(); } + + public static ResourceObjectIdentification getResourceObjectIdentification( + PrismObject shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { + return new ResourceObjectIdentification(objectClassDefinition, + ShadowUtil.getIdentifiers(shadow), ShadowUtil.getSecondaryIdentifiers(shadow)); + } } diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-3.xsd index 852770f8f12..477e70203df 100644 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-3.xsd @@ -4426,12 +4426,19 @@ + + + + Specifies the object class of the referenced object. + This clause for objectClass may be omitted if it can be determined by other means. + + + The filter used to look for the object. This filter does NOT need to contain - clauses for resource. This will be automatically added by midpoint. In some situation also - the clause for objectClass may be omitted (if it can be determined by other means). + clauses for resource. This will be automatically added by midpoint. diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/EntitlementConverter.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/EntitlementConverter.java index 08dc2e83f0d..081a0930c53 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/EntitlementConverter.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/EntitlementConverter.java @@ -247,9 +247,10 @@ private void postProcessEntitlementEntitlementToSubject if (baseContextRef != null) { // TODO: this should be done once per search. Not in every run of postProcessEntitlementEntitlementToSubject // this has to go outside of this method - PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(baseContextRef, "base context specification in "+entitlementDef, parentResult); + PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(subjectCtx, baseContextRef, + null, "base context specification in "+entitlementDef, parentResult); RefinedObjectClassDefinition baseContextObjectClassDefinition = subjectCtx.getRefinedSchema().determineCompositeObjectClassDefinition(baseContextShadow); - ResourceObjectIdentification baseContextIdentification = new ResourceObjectIdentification(baseContextObjectClassDefinition, ShadowUtil.getIdentifiers(baseContextShadow)); + ResourceObjectIdentification baseContextIdentification = ShadowUtil.getResourceObjectIdentification(baseContextShadow, baseContextObjectClassDefinition); searchHierarchyConstraints = new SearchHierarchyConstraints(baseContextIdentification, null); } @@ -457,9 +458,10 @@ public void collectEntitlementsAsObjectOperationDelete(ProvisioningContext s SearchHierarchyConstraints searchHierarchyConstraints = null; ResourceObjectReferenceType baseContextRef = entitlementOcDef.getBaseContext(); if (baseContextRef != null) { - PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(baseContextRef, "base context specification in "+entitlementOcDef, parentResult); + PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(subjectCtx, + baseContextRef, null, "base context specification in "+entitlementOcDef, parentResult); RefinedObjectClassDefinition baseContextObjectClassDefinition = subjectCtx.getRefinedSchema().determineCompositeObjectClassDefinition(baseContextShadow); - ResourceObjectIdentification baseContextIdentification = new ResourceObjectIdentification(baseContextObjectClassDefinition, ShadowUtil.getIdentifiers(baseContextShadow)); + ResourceObjectIdentification baseContextIdentification = ShadowUtil.getResourceObjectIdentification(baseContextShadow, baseContextObjectClassDefinition); searchHierarchyConstraints = new SearchHierarchyConstraints(baseContextIdentification, null); } diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectConverter.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectConverter.java index 3d93652e6c3..d4bf0db19e2 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectConverter.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -997,9 +997,9 @@ public SearchResultMetadata searchResourceObjects(final ProvisioningContext ctx, SearchHierarchyConstraints searchHierarchyConstraints = null; ResourceObjectReferenceType baseContextRef = objectClassDef.getBaseContext(); if (baseContextRef != null) { - PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(baseContextRef, "base context specification in "+objectClassDef, parentResult); + PrismObject baseContextShadow = resourceObjectReferenceResolver.resolve(ctx, baseContextRef, null, "base context specification in "+objectClassDef, parentResult); RefinedObjectClassDefinition baseContextObjectClassDefinition = ctx.getRefinedSchema().determineCompositeObjectClassDefinition(baseContextShadow); - ResourceObjectIdentification baseContextIdentification = new ResourceObjectIdentification(baseContextObjectClassDefinition, ShadowUtil.getIdentifiers(baseContextShadow)); + ResourceObjectIdentification baseContextIdentification = ShadowUtil.getResourceObjectIdentification(baseContextShadow, baseContextObjectClassDefinition); searchHierarchyConstraints = new SearchHierarchyConstraints(baseContextIdentification, null); } @@ -1508,7 +1508,8 @@ public List> fetchChanges(ProvisioningContext ctx, PrismPrope if (ctx.isWildcard()) { if (!MiscUtil.equals(shadowAttrsToReturn, attrsToReturn)) { // re-fetch the shadow if necessary (if attributesToGet does not match) - ResourceObjectIdentification identification = new ResourceObjectIdentification(shadowCtx.getObjectClassDefinition(), change.getIdentifiers()); + ResourceObjectIdentification identification = new ResourceObjectIdentification(shadowCtx.getObjectClassDefinition(), + change.getIdentifiers(), null); LOGGER.trace("Re-fetching object {} because of attrsToReturn", identification); currentShadow = connector.fetchObject(ShadowType.class, identification, shadowAttrsToReturn, ctx, parentResult); } diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectReferenceResolver.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectReferenceResolver.java index e1fc86c54ab..29a10c2fa25 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectReferenceResolver.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ResourceObjectReferenceResolver.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015 Evolveum + * Copyright (c) 2015-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,21 +17,32 @@ import java.util.Collection; +import javax.xml.namespace.QName; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; +import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.query.AndFilter; +import com.evolveum.midpoint.prism.query.ObjectFilter; +import com.evolveum.midpoint.prism.query.ObjectQuery; +import com.evolveum.midpoint.prism.query.QueryJaxbConvertor; import com.evolveum.midpoint.provisioning.api.GenericConnectorException; import com.evolveum.midpoint.provisioning.ucf.api.AttributesToReturn; import com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance; import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceObjectIdentification; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ResourceTypeUtil; +import com.evolveum.midpoint.util.Holder; import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.CommunicationException; import com.evolveum.midpoint.util.exception.ConfigurationException; @@ -39,9 +50,11 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.util.exception.SecurityViolationException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectReferenceResolutionFrequencyType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType; /** * @author semancik @@ -49,23 +62,73 @@ */ @Component public class ResourceObjectReferenceResolver { + + @Autowired(required = true) + private PrismContext prismContext; @Autowired(required = true) @Qualifier("cacheRepositoryService") private RepositoryService repositoryService; - PrismObject resolve(ResourceObjectReferenceType resourceObjectReference, String desc, OperationResult result) throws ObjectNotFoundException, SchemaException { + @Autowired(required = true) + @Qualifier("shadowCacheProvisioner") + private ShadowCache shadowCache; + + PrismObject resolve(ProvisioningContext ctx, ResourceObjectReferenceType resourceObjectReference, + QName objectClass, final String desc, OperationResult result) + throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, + SecurityViolationException { if (resourceObjectReference == null) { return null; } ObjectReferenceType shadowRef = resourceObjectReference.getShadowRef(); - if (shadowRef == null || shadowRef.getOid() == null) { - throw new ObjectNotFoundException("No shadowRef OID in "+desc); + if (shadowRef != null && shadowRef.getOid() != null) { + if (resourceObjectReference.getResolutionFrequency() == null + || resourceObjectReference.getResolutionFrequency() == ResourceObjectReferenceResolutionFrequencyType.ONCE) { + PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowRef.getOid(), null, result); + return shadow; + } + } else if (resourceObjectReference.getResolutionFrequency() == ResourceObjectReferenceResolutionFrequencyType.NEVER) { + throw new ObjectNotFoundException("No shadowRef OID in "+desc+" and resolution frequency set to NEVER"); + } + if (resourceObjectReference.getObjectClass() != null) { + objectClass = resourceObjectReference.getObjectClass(); + if (objectClass.getNamespaceURI() == null) { + objectClass = new QName(ResourceTypeUtil.getResourceNamespace(ctx.getResource()), objectClass.getLocalPart()); + } } - // TODO: implement resolution strategies - PrismObject shadow = repositoryService.getObject(ShadowType.class, shadowRef.getOid(), null, result); - return shadow; + ProvisioningContext subctx = ctx.spawn(objectClass); + subctx.assertDefinition(); + + ObjectQuery refQuery = QueryJaxbConvertor.createObjectQuery(ShadowType.class, resourceObjectReference.getFilter(), prismContext); + ObjectFilter baseFilter = ObjectQueryUtil.createResourceAndObjectClassFilter(ctx.getResource().getOid(), objectClass, prismContext); + ObjectFilter filter = AndFilter.createAnd(baseFilter, refQuery.getFilter()); + ObjectQuery query = ObjectQuery.createObjectQuery(filter); + + // TODO: implement "repo" search strategies + + Collection> options = null; + + final Holder shadowHolder = new Holder<>(); + ShadowHandler handler = new ShadowHandler() { + @Override + public boolean handle(ShadowType shadow) { + if (shadowHolder.getValue() != null) { + throw new IllegalStateException("More than one search results for " + desc); + } + shadowHolder.setValue(shadow); + return true; + } + }; + + shadowCache.searchObjectsIterative(subctx, query, options, handler, true, result); + + // TODO: implement storage of OID (ONCE search frequency) + + ShadowType shadowType = shadowHolder.getValue(); + return shadowType==null?null:shadowType.asPrismObject(); } + public PrismObject fetchResourceObject(ProvisioningContext ctx, Collection> identifiers, AttributesToReturn attributesToReturn, @@ -81,7 +144,7 @@ public PrismObject fetchResourceObject(ProvisioningContext ctx, throw new UnsupportedOperationException("Resource does not support 'read' operation"); } - ResourceObjectIdentification identification = new ResourceObjectIdentification(objectClassDefinition, identifiers); + ResourceObjectIdentification identification = new ResourceObjectIdentification(objectClassDefinition, identifiers, null); return connector.fetchObject(ShadowType.class, identification, attributesToReturn, ctx, parentResult); } catch (ObjectNotFoundException e) { diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java index a26eb8c90e9..43328bd9e0e 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -136,9 +136,6 @@ * The two principal classes that do the operations are: * ResourceObjectConvertor: executes operations on resource * ShadowManager: executes operations in the repository - * - * Note: These three classes were refactored recently. But it will need more refactoring. - * It is not a very pretty OO code. But it is better than before. * * @author Radovan Semancik * @author Katarina Valalikova @@ -711,6 +708,14 @@ public SearchResultMetadata searchObjectsIterative(ObjectQuery query, ResourceShadowDiscriminator coordinates = ObjectQueryUtil.getCoordinates(query.getFilter()); final ProvisioningContext ctx = ctxFactory.create(coordinates, task, parentResult); ctx.assertDefinition(); + + return searchObjectsIterative(ctx, query, options, handler, readFromRepository, parentResult); + } + + public SearchResultMetadata searchObjectsIterative(final ProvisioningContext ctx, ObjectQuery query, + Collection> options, final ShadowHandler handler, + final boolean readFromRepository, final OperationResult parentResult) throws SchemaException, + ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException { applyDefinition(ctx, query); GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options); @@ -793,7 +798,6 @@ ObjectQuery createAttributeQuery(ObjectQuery query) throws SchemaException { } else if (attributeFilter.size() == 1) { attributeQuery = ObjectQuery.createObjectQuery(attributeFilter.iterator().next()); } - } if (query != null && query.getPaging() != null){ @@ -817,35 +821,30 @@ ObjectQuery createAttributeQuery(ObjectQuery query) throws SchemaException { private List createAttributeQueryInternal(List conditions) throws SchemaException{ List attributeFilter = new ArrayList<>(); - ItemPath objectClassPath = new ItemPath(ShadowType.F_OBJECT_CLASS); - ItemPath resourceRefPath = new ItemPath(ShadowType.F_RESOURCE_REF); - for (ObjectFilter f : conditions){ - if (f instanceof EqualFilter){ - if (objectClassPath.equivalent(((EqualFilter) f).getFullPath())){ + for (ObjectFilter f : conditions) { + if (f instanceof EqualFilter) { + ItemPath parentPath = ((EqualFilter) f).getParentPath(); + if (parentPath == null || parentPath.isEmpty()) { continue; } - if (resourceRefPath.equivalent(((EqualFilter) f).getFullPath())){ - continue; - } - attributeFilter.add(f); - } else if (f instanceof NaryLogicalFilter){ + } else if (f instanceof NaryLogicalFilter) { List subFilters = createAttributeQueryInternal(((NaryLogicalFilter) f).getConditions()); - if (subFilters.size() > 1){ + if (subFilters.size() > 1) { if (f instanceof OrFilter){ attributeFilter.add(OrFilter.createOr(subFilters)); - } else if (f instanceof AndFilter){ + } else if (f instanceof AndFilter) { attributeFilter.add(AndFilter.createAnd(subFilters)); } else { throw new IllegalArgumentException("Could not translate query filter. Unknown type: " + f); } - } else if (subFilters.size() < 1){ + } else if (subFilters.size() < 1) { continue; } else if (subFilters.size() == 1) { attributeFilter.add(subFilters.iterator().next()); } - } else if (f instanceof SubstringFilter){ + } else if (f instanceof SubstringFilter) { attributeFilter.add(f); } diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java index 3539f6bd330..49894a3c265 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java index 16b44d67f37..0abdbc8c453 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/ConnectorInstanceIcfImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1076,7 +1076,7 @@ public PrismObject fetchObject(Class type, Resource throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, SecurityViolationException, ConfigurationException { - Collection> identifiers = resourceObjectIdentification.getIdentifiers(); + Collection> identifiers = resourceObjectIdentification.getPrimaryIdentifiers(); ObjectClassComplexTypeDefinition objectClassDefinition = resourceObjectIdentification.getObjectClassDefinition(); // Result type for this operation OperationResult result = parentResult.createMinorSubresult(ConnectorInstance.class.getName() @@ -2291,8 +2291,13 @@ private void recordResume() { if (searchHierarchyConstraints != null) { ResourceObjectIdentification baseContextIdentification = searchHierarchyConstraints.getBaseContext(); // Only LDAP connector really supports base context. And this one will work better with - // DN. And DN is usually stored in icfs:name. This is ugly, but practical. It works around ConnId problems. - ResourceAttribute secondaryIdentifier = ShadowUtil.getSecondaryIdentifier(objectClassDefinition, baseContextIdentification.getIdentifiers()); + // DN. And DN is secondary identifier (__NAME__). This is ugly, but practical. It works around ConnId problems. + ResourceAttribute secondaryIdentifier = baseContextIdentification.getSecondaryIdentifier(); + if (secondaryIdentifier == null) { + SchemaException e = new SchemaException("No secondary identifier in base context identification "+baseContextIdentification); + result.recordFatalError(e); + throw e; + } String secondaryIdentifierValue = secondaryIdentifier.getRealValue(String.class); ObjectClass baseContextIcfObjectClass = icfNameMapper.objectClassToIcf(baseContextIdentification.getObjectClassDefinition(), getSchemaNamespace(), connectorType, legacySchema); QualifiedUid containerQualifiedUid = new QualifiedUid(baseContextIcfObjectClass, new Uid(secondaryIdentifierValue)); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java index a275f69d7c7..ec55d3c8bf9 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/AbstractOpenDJTest.java @@ -122,7 +122,11 @@ public abstract class AbstractOpenDJTest extends AbstractIntegrationTest { protected static final File GROUP_SWASHBUCKLERS_FILE = new File(TEST_DIR, "group-swashbucklers.xml"); protected static final String GROUP_SWASHBUCKLERS_OID = "3d96846e-c570-11e3-a80f-001e8c717e5b"; protected static final String GROUP_SWASHBUCKLERS_DN = "cn=swashbucklers,ou=groups,dc=example,dc=com"; - + + protected static final File GROUP_SPECIALISTS_FILE = new File(TEST_DIR, "group-specialists.xml"); + protected static final String GROUP_SPECIALISTS_OID = "3da6ddca-cc0b-11e5-9b3f-2b7f453dbfb3"; + protected static final String GROUP_SPECIALISTS_DN = "cn=specialists,ou=specialgroups,dc=example,dc=com"; + protected static final File GROUP_CORSAIRS_FILE = new File(TEST_DIR, "group-corsairs.xml"); protected static final String GROUP_CORSAIRS_OID = "70a1f3ee-4b5b-11e5-95d0-001e8c717e5b"; protected static final String GROUP_CORSAIRS_DN = "cn=corsairs,ou=groups,dc=example,dc=com"; diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java index 6831dfe13a0..aa5dd95f3d5 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestDummy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1437,6 +1437,48 @@ public boolean handle(PrismObject object, OperationResult parentResu assertSteadyResource(); } + + @Test + public void test112SeachIterativeKindIntent() throws Exception { + final String TEST_NAME = "test112SeachIterativeKindIntent"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + OperationResult result = new OperationResult(TestDummy.class.getName() + + "." + TEST_NAME); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_DUMMY_OID, + ShadowKindType.ACCOUNT, "default", prismContext); + display("query", query); + + final List> foundObjects = new ArrayList>(); + ResultHandler handler = new ResultHandler() { + + @Override + public boolean handle(PrismObject object, OperationResult parentResult) { + foundObjects.add(object); + return true; + } + }; + + rememberShadowFetchOperationCount(); + + // WHEN + provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result); + + // THEN + result.computeStatus(); + display("searchObjectsIterative result", result); + TestUtil.assertSuccess(result); + assertShadowFetchOperationCountIncrement(1); + + display("Found shadows", foundObjects); + + assertEquals(4, foundObjects.size()); + checkConsistency(foundObjects); + assertProtected(foundObjects, 1); // MID-1640 + + assertSteadyResource(); + } private void assertProtected(List> shadows, int expectedNumberOfProtectedShadows) { int actual = countProtected(shadows); diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java index 8e5a556eea6..d4819cccf7b 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/impl/TestOpenDJ.java @@ -168,6 +168,10 @@ public class TestOpenDJ extends AbstractOpenDJTest { @Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { super.initSystem(initTask, initResult); + + openDJController.addEntry("dn: ou=specialgroups,dc=example,dc=com\n"+ + "objectclass: organizationalUnit\n"+ + "ou: specialgroups\n"); } @BeforeClass @@ -859,7 +863,8 @@ public void test130AddDeleteAccountSparrow() throws Exception { assertTrue(ex.getMessage().contains(ACCOUNT_SPARROW_OID)); } - assertShadows(1); + // Account shadow + shadow for base context + assertShadows(2); } @Test @@ -930,7 +935,7 @@ public void test140AddAndModifyAccountJack() throws Exception { assertEquals("First", changedSn); - assertShadows(2); + assertShadows(3); } @Test @@ -984,7 +989,7 @@ public void test145ModifyAccountJackJpegPhoto() throws Exception { assertEquals("Byte length changed (shadow)", bytesIn.length, bytesOut.length); assertTrue("Bytes do not match (shadow)", Arrays.equals(bytesIn, bytesOut)); - assertShadows(2); + assertShadows(3); } @Test @@ -1039,7 +1044,7 @@ public void test150ChangePassword() throws Exception { openDJController.assertPassword(entryAfter.getDN().toString(), "mehAbigH4X0R"); - assertShadows(3); + assertShadows(4); } @Test @@ -1088,7 +1093,7 @@ public void test151AddObjectWithPassword() throws Exception { openDJController.assertPassword(entryAfter.getDN().toString(), "t4k30v3rTh3W0rld"); - assertShadows(4); + assertShadows(5); } @Test @@ -1145,7 +1150,7 @@ public boolean handle(PrismObject prismObject, OperationResult paren assertEquals("Unexpected number of shadows", 9, objects.size()); // The extra shadow is a group shadow - assertShadows(10); + assertShadows(11); // Bad things may happen, so let's check if the shadow is still there and that is has the same OID PrismObject accountNew = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, taskManager.createTaskInstance(), result); @@ -1744,7 +1749,7 @@ public void test320AddAccountPosix() throws Exception { OpenDJController.assertAttribute(entry, "loginShell", "/bin/whisky"); OpenDJController.assertAttribute(entry, "homeDirectory", "/home/scotland"); - assertShadows(16); + assertShadows(17); } @Test @@ -1790,7 +1795,7 @@ public void test322ModifyAccountPosix() throws Exception { OpenDJController.assertAttribute(entry, "roomNumber", "Barber Shop"); OpenDJController.assertAttribute(entry, "uidNumber", "1001"); - assertShadows(16); + assertShadows(17); } @Test @@ -1826,7 +1831,7 @@ public void test329DeleteAccountPosix() throws Exception { assertTrue(ex.getMessage().contains(ACCOUNT_POSIX_MCMUTTON_OID)); } - assertShadows(15); + assertShadows(16); } /** @@ -1870,7 +1875,7 @@ public void test330SearchForPosixAccount() throws Exception { assertConnectorOperationIncrement(1); assertConnectorSimulatedPagingSearchIncrement(0); - assertShadows(16); + assertShadows(17); } // TODO: synchronization of auxiliary object classes @@ -1917,7 +1922,7 @@ public void test400AddGroupSwashbucklers() throws Exception { String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(groupDn)); - assertShadows(17); + assertShadows(18); } @Test @@ -1965,7 +1970,7 @@ public void test402AddAccountMorganWithAssociation() throws Exception { assertNotNull("No LDAP group entry"); openDJController.assertUniqueMember(groupEntry, accountDn); - assertShadows(18); + assertShadows(19); } @Test @@ -1998,7 +2003,7 @@ public void test405GetGroupSwashbucklers() throws Exception { String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(groupDn)); - assertShadows(18); + assertShadows(19); } @Test @@ -2032,7 +2037,7 @@ public void test410CreateLdapGroupAndSearchGroups() throws Exception { "cn=swashbucklers,ou=Groups,dc=example,dc=com", "cn=seadogs,ou=Groups,dc=example,dc=com"); - assertShadows(19); + assertShadows(20); } @Test @@ -2062,7 +2067,7 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { assertSuccess(result); display("Account shadow after", shadow); - assertShadows(20); + assertShadows(21); PrismObject groupSailorShadow = findShadowByName(RESOURCE_OPENDJ_GROUP_OBJECTCLASS, "cn=sailor,ou=groups,dc=example,dc=com", resource, result); display("Group shadow", groupSailorShadow); @@ -2070,7 +2075,7 @@ public void test412CreateLdapGroupWithMemberAndGet() throws Exception { assertEntitlementGroup(shadow, groupSailorOid); - assertShadows(20); + assertShadows(21); } @@ -2099,7 +2104,7 @@ public void test414AddGroupCorsairsAssociateUser() throws Exception { // Do NOT read provisioning shadow here. We want everything to be "fresh" - assertShadows(21); + assertShadows(22); } @Test @@ -2128,7 +2133,7 @@ public void test416AssociateUserToCorsairs() throws Exception { assertNotNull("No LDAP group entry"); openDJController.assertUniqueMember(groupEntry, ACCOUNT_MORGAN_DN); - assertShadows(21); + assertShadows(22); } @Test @@ -2153,7 +2158,7 @@ public void test418GetMorgan() throws Exception { assertEntitlementGroup(shadow, groupSailorOid); assertEntitlementGroup(shadow, GROUP_CORSAIRS_OID); - assertShadows(21); + assertShadows(22); } /** @@ -2196,7 +2201,189 @@ public void test429DeleteAccountMorgan() throws Exception { assertNotNull("No LDAP group entry"); openDJController.assertNoUniqueMember(groupEntry, ACCOUNT_MORGAN_DN); - assertShadows(20); + assertShadows(21); + } + + @Test + public void test450ListGroupsObjectclass() throws Exception { + final String TEST_NAME = "test450ListGroupsObjectclass"; + TestUtil.displayTestTile(TEST_NAME); + + Task task = taskManager.createTaskInstance(TestOpenDJ.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_OPENDJ_OID, + RESOURCE_OPENDJ_GROUP_OBJECTCLASS, prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + display("found objects", objects); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Wrong number of objects found", 5, objects.size()); + + assertShadows(21); + } + + @Test + public void test452ListLdapGroupsKindIntent() throws Exception { + final String TEST_NAME = "test452ListLdapGroupsKindIntent"; + TestUtil.displayTestTile(TEST_NAME); + + Task task = taskManager.createTaskInstance(TestOpenDJ.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "ldapGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + display("found objects", objects); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Wrong number of objects found", 5, objects.size()); + + assertShadows(21); + } + + @Test + public void test454ListSpecialGroupsKindIntent() throws Exception { + final String TEST_NAME = "test454ListSpecialGroupsKindIntent"; + TestUtil.displayTestTile(TEST_NAME); + + Task task = taskManager.createTaskInstance(TestOpenDJ.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "specialGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + display("found objects", objects); + result.computeStatus(); + TestUtil.assertSuccess(result); + + // Check that none of the normal LDAP groups appear here ... even if they have the same objectclass + assertEquals("Wrong number of objects found", 0, objects.size()); + + // Discovered base context for specialgroups + assertShadows(22); + } + + @Test + public void test456AddGroupSpecialists() throws Exception { + final String TEST_NAME = "test456AddGroupSpecialists"; + TestUtil.displayTestTile(TEST_NAME); + + OperationResult result = new OperationResult(TestOpenDJ.class.getName() + + "." + TEST_NAME); + + ShadowType object = parseObjectType(GROUP_SPECIALISTS_FILE, ShadowType.class); + IntegrationTestTools.display("Adding object", object); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result); + + // THEN + TestUtil.displayThen(TEST_NAME); + assertEquals(GROUP_SPECIALISTS_OID, addedObjectOid); + + ShadowType shadowType = repositoryService.getObject(ShadowType.class, GROUP_SPECIALISTS_OID, + null, result).asObjectable(); + PrismAsserts.assertEqualsPolyString("Wrong ICF name (repo)", GROUP_SPECIALISTS_DN, shadowType.getName()); + + PrismObject provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SPECIALISTS_OID, + null, taskManager.createTaskInstance(), result); + ShadowType provisioningShadowType = provisioningShadow.asObjectable(); + assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SPECIALISTS_DN), + dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); + + String uid = ShadowUtil.getSingleStringAttributeValue(shadowType, getPrimaryIdentifierQName()); + assertNotNull(uid); + ResourceAttribute memberAttr = ShadowUtil.getAttribute(provisioningShadow, new QName(RESOURCE_OPENDJ_NS, GROUP_MEMBER_ATTR_NAME)); + assertNull("Member attribute sneaked in", memberAttr); + + Entry ldapEntry = openDJController.searchAndAssertByEntryUuid(uid); + display("LDAP group", ldapEntry); + assertNotNull("No LDAP group entry"); + String groupDn = ldapEntry.getDN().toString(); + assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SPECIALISTS_DN), dnMatchingRule.normalize(groupDn)); + + assertShadows(23); + } + + @Test + public void test457ListLdapGroupsKindIntent() throws Exception { + final String TEST_NAME = "test457ListLdapGroupsKindIntent"; + TestUtil.displayTestTile(TEST_NAME); + + Task task = taskManager.createTaskInstance(TestOpenDJ.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "ldapGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + display("found objects", objects); + result.computeStatus(); + TestUtil.assertSuccess(result); + + assertEquals("Wrong number of objects found", 5, objects.size()); + + assertShadows(23); + } + + @Test + public void test458ListSpecialGroupsKindIntent() throws Exception { + final String TEST_NAME = "test458ListSpecialGroupsKindIntent"; + TestUtil.displayTestTile(TEST_NAME); + + Task task = taskManager.createTaskInstance(TestOpenDJ.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "specialGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = provisioningService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + display("found objects", objects); + result.computeStatus(); + TestUtil.assertSuccess(result); + + // Check that none of the normal LDAP groups appear here ... even if they have the same objectclass + assertEquals("Wrong number of objects found", 1, objects.size()); + + // Discovered base context for specialgroups + assertShadows(23); } @Test diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfOpenDj.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfOpenDj.java index 054b1e27736..40c97474f39 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfOpenDj.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/test/ucf/TestUcfOpenDj.java @@ -327,7 +327,7 @@ public void test100AddDeleteObject() throws Exception { cc.deleteObject(accountDefinition, null, identifiers, null, result); - ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); + ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers, null); PrismObject resObj = null; try { resObj = cc.fetchObject(ShadowType.class, identification, null, null, @@ -359,7 +359,7 @@ public void test110ChangeModifyObject() throws Exception { cc.modifyObject(accountDefinition, identifiers, changes, null, result); - ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); + ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers, null); PrismObject shadow = cc.fetchObject(ShadowType.class, identification, null, null, result); ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow); @@ -620,7 +620,7 @@ public void test500FetchObject() throws Exception { Collection> identifiers = resourceObject.getIdentifiers(); // Determine object class from the schema - ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); + ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers, null); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); // WHEN diff --git a/provisioning/provisioning-impl/src/test/resources/impl/opendj/group-specialists.xml b/provisioning/provisioning-impl/src/test/resources/impl/opendj/group-specialists.xml new file mode 100644 index 00000000000..fdd952bc615 --- /dev/null +++ b/provisioning/provisioning-impl/src/test/resources/impl/opendj/group-specialists.xml @@ -0,0 +1,33 @@ + + + + + + cn=specialists,ou=specialgroups,dc=example,dc=com + + ri:groupOfUniqueNames + entitlement + specialGroup + + cn=specialists,ou=specialgroups,dc=example,dc=COM + specialists + + diff --git a/provisioning/provisioning-impl/src/test/resources/object/resource-opendj.xml b/provisioning/provisioning-impl/src/test/resources/object/resource-opendj.xml index 0308a4cffdb..3d5f28d3ba7 100644 --- a/provisioning/provisioning-impl/src/test/resources/object/resource-opendj.xml +++ b/provisioning/provisioning-impl/src/test/resources/object/resource-opendj.xml @@ -1,6 +1,6 @@ + entitlement + specialGroup + Special LDAP Group + ri:groupOfUniqueNames + + ri:organizationalUnit + + + attributes/dn + ou=specialgroups,dc=example,dc=com + + + ri:entryUUID mr:stringIgnoreCase diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java index 177d114c3b7..16f1ca4d719 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestUnix.java @@ -1,6 +1,6 @@ package com.evolveum.midpoint.testing.story; /* - * Copyright (c) 2015 Evolveum + * Copyright (c) 2015-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,13 +54,16 @@ import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.PrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.query.ObjectQuery; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.schema.SearchResultList; import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.schema.util.ObjectQueryUtil; import com.evolveum.midpoint.schema.util.ShadowUtil; import com.evolveum.midpoint.task.api.Task; import com.evolveum.midpoint.test.DummyResourceContoller; @@ -83,6 +86,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @@ -266,7 +270,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti importObjectFromFile(SEQUENCE_UIDNUMBER_FILE, initResult); importObjectFromFile(SEQUENCE_GIDNUMBER_FILE, initResult); - DebugUtil.setDetailedDebugDump(true); +// DebugUtil.setDetailedDebugDump(true); } @Test @@ -850,6 +854,102 @@ public void test310AddUserWallyUnix() throws Exception { assertTrue("Unexpected unused values in the sequence", sequenceAfter.asObjectable().getUnusedValues().isEmpty()); } + @Test + public void test400ListAllAccountsObjectClass() throws Exception { + final String TEST_NAME = "test400ListAllAccountsObjectClass"; + TestUtil.displayTestTile(this, TEST_NAME); + Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_OPENDJ_OID, + OPENDJ_ACCOUNT_STRUCTURAL_OBJECTCLASS_NAME, prismContext); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + display("found objects", objects); + assertEquals("Wrong number of objects found", 7, objects.size()); + } + + @Test + public void test401ListAllAccountsKindIntent() throws Exception { + final String TEST_NAME = "test401ListAllAccountsKindIntent"; + TestUtil.displayTestTile(this, TEST_NAME); + Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ACCOUNT, "default", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + display("found objects", objects); + assertEquals("Wrong number of objects found", 7, objects.size()); + } + + @Test + public void test402ListLdapGroupsKindIntent() throws Exception { + final String TEST_NAME = "test402ListLdapGroupsKindIntent"; + TestUtil.displayTestTile(this, TEST_NAME); + Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "ldapGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + display("found objects", objects); + assertEquals("Wrong number of objects found", 2, objects.size()); + } + + @Test + public void test403ListUnixGroupsKindIntent() throws Exception { + final String TEST_NAME = "test403ListUnixGroupsKindIntent"; + TestUtil.displayTestTile(this, TEST_NAME); + Task task = taskManager.createTaskInstance(TestUnix.class.getName() + "." + TEST_NAME); + OperationResult result = task.getResult(); + + ObjectQuery query = ObjectQueryUtil.createResourceAndKindIntent(RESOURCE_OPENDJ_OID, + ShadowKindType.ENTITLEMENT, "unixGroup", prismContext); + display("query", query); + + // WHEN + TestUtil.displayWhen(TEST_NAME); + SearchResultList> objects = modelService.searchObjects(ShadowType.class, query, null, task, result); + + // THEN + TestUtil.displayThen(TEST_NAME); + result.computeStatus(); + TestUtil.assertSuccess(result); + + display("found objects", objects); + assertEquals("Wrong number of objects found", 1, objects.size()); + } + + private PrismObject createUser(String username, String givenName, String familyName, String roleOid) throws SchemaException { PrismObject user = createUser(username, givenName, familyName, true); if (roleOid != null) { diff --git a/testing/story/src/test/resources/unix/resource-opendj.xml b/testing/story/src/test/resources/unix/resource-opendj.xml index c0d8a2929d7..bcea7edc349 100644 --- a/testing/story/src/test/resources/unix/resource-opendj.xml +++ b/testing/story/src/test/resources/unix/resource-opendj.xml @@ -222,6 +222,15 @@ ldapGroup LDAP Group ri:groupOfUniqueNames + + ri:organizationalUnit + + + attributes/dn + ou=groups,dc=example,dc=com + + + ri:dn mr:stringIgnoreCase @@ -273,6 +282,15 @@ UNIX Group ri:groupOfNames ri:posixGroup + + ri:organizationalUnit + + + attributes/dn + ou=unixgroups,dc=example,dc=com + + + ri:dn mr:stringIgnoreCase From 296baec6ec387d9d8f8c28a5e3968bdae85d5690 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 5 Feb 2016 15:12:22 +0100 Subject: [PATCH 3/5] Fixing TestSecurity --- .../model-intest/src/test/resources/security/campaigns.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/model/model-intest/src/test/resources/security/campaigns.xml b/model/model-intest/src/test/resources/security/campaigns.xml index 1cdb9a8c4f8..10da978d6d3 100644 --- a/model/model-intest/src/test/resources/security/campaigns.xml +++ b/model/model-intest/src/test/resources/security/campaigns.xml @@ -61,7 +61,7 @@ notDecided 2015-12-04T01:10:20.032+01:00 - notDecided + notDecided 1 @@ -110,7 +110,7 @@ accept 2015-12-04T01:04:06.385+01:00 - accept + accept 1 @@ -131,7 +131,7 @@ noResponse 2015-12-04T01:10:08.670+01:00 - noResponse + noResponse 1 From b6ee12c12c0c46636955bb393c7b67e68af77815 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 5 Feb 2016 18:11:07 +0100 Subject: [PATCH 4/5] Improving Definition toString methods, fixing equals and hashCode. --- ...CompositeRefinedObjectClassDefinition.java | 40 +++++ .../RefinedObjectClassDefinition.java | 168 +++++++++++++++++- .../midpoint/prism/ComplexTypeDefinition.java | 68 +++++++ .../evolveum/midpoint/prism/Definition.java | 6 +- .../ObjectClassComplexTypeDefinition.java | 90 ++++++++++ 5 files changed, 369 insertions(+), 3 deletions(-) diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java index 912195c2540..3bf3f15557a 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/CompositeRefinedObjectClassDefinition.java @@ -323,6 +323,46 @@ public CompositeRefinedObjectClassDefinition clone() { return new CompositeRefinedObjectClassDefinition(structuralObjectClassDefinitionClone, auxiliaryObjectClassDefinitionsClone); } + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((auxiliaryObjectClassDefinitions == null) ? 0 : auxiliaryObjectClassDefinitions.hashCode()); + result = prime * result + + ((structuralObjectClassDefinition == null) ? 0 : structuralObjectClassDefinition.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + CompositeRefinedObjectClassDefinition other = (CompositeRefinedObjectClassDefinition) obj; + if (auxiliaryObjectClassDefinitions == null) { + if (other.auxiliaryObjectClassDefinitions != null) { + return false; + } + } else if (!auxiliaryObjectClassDefinitions.equals(other.auxiliaryObjectClassDefinitions)) { + return false; + } + if (structuralObjectClassDefinition == null) { + if (other.structuralObjectClassDefinition != null) { + return false; + } + } else if (!structuralObjectClassDefinition.equals(other.structuralObjectClassDefinition)) { + return false; + } + return true; + } + @Override public String debugDump() { return debugDump(0); diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java index d6e4ab3fc53..8907ffafb2a 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java @@ -940,6 +940,159 @@ public boolean matches(ShadowType shadowType) { } @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((associations == null) ? 0 : associations.hashCode()); + result = prime * result + ((attributeDefinitions == null) ? 0 : attributeDefinitions.hashCode()); + result = prime * result + + ((auxiliaryObjectClassDefinitions == null) ? 0 : auxiliaryObjectClassDefinitions.hashCode()); + result = prime * result + ((baseContext == null) ? 0 : baseContext.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((displayName == null) ? 0 : displayName.hashCode()); + result = prime * result + + ((displayNameAttributeDefinition == null) ? 0 : displayNameAttributeDefinition.hashCode()); + result = prime * result + ((identifiers == null) ? 0 : identifiers.hashCode()); + result = prime * result + ((intent == null) ? 0 : intent.hashCode()); + result = prime * result + (isDefault ? 1231 : 1237); + result = prime * result + ((kind == null) ? 0 : kind.hashCode()); + result = prime * result + ((objectClassDefinition == null) ? 0 : objectClassDefinition.hashCode()); + result = prime * result + ((objectDefinition == null) ? 0 : objectDefinition.hashCode()); + result = prime * result + ((protectedObjectPatterns == null) ? 0 : protectedObjectPatterns.hashCode()); + result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); + result = prime * result + ((schemaHandlingObjectTypeDefinitionType == null) ? 0 + : schemaHandlingObjectTypeDefinitionType.hashCode()); + result = prime * result + ((secondaryIdentifiers == null) ? 0 : secondaryIdentifiers.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + RefinedObjectClassDefinition other = (RefinedObjectClassDefinition) obj; + if (associations == null) { + if (other.associations != null) { + return false; + } + } else if (!associations.equals(other.associations)) { + return false; + } + if (attributeDefinitions == null) { + if (other.attributeDefinitions != null) { + return false; + } + } else if (!attributeDefinitions.equals(other.attributeDefinitions)) { + return false; + } + if (auxiliaryObjectClassDefinitions == null) { + if (other.auxiliaryObjectClassDefinitions != null) { + return false; + } + } else if (!auxiliaryObjectClassDefinitions.equals(other.auxiliaryObjectClassDefinitions)) { + return false; + } + if (baseContext == null) { + if (other.baseContext != null) { + return false; + } + } else if (!baseContext.equals(other.baseContext)) { + return false; + } + if (description == null) { + if (other.description != null) { + return false; + } + } else if (!description.equals(other.description)) { + return false; + } + if (displayName == null) { + if (other.displayName != null) { + return false; + } + } else if (!displayName.equals(other.displayName)) { + return false; + } + if (displayNameAttributeDefinition == null) { + if (other.displayNameAttributeDefinition != null) { + return false; + } + } else if (!displayNameAttributeDefinition.equals(other.displayNameAttributeDefinition)) { + return false; + } + if (identifiers == null) { + if (other.identifiers != null) { + return false; + } + } else if (!identifiers.equals(other.identifiers)) { + return false; + } + if (intent == null) { + if (other.intent != null) { + return false; + } + } else if (!intent.equals(other.intent)) { + return false; + } + if (isDefault != other.isDefault) { + return false; + } + if (kind != other.kind) { + return false; + } + if (objectClassDefinition == null) { + if (other.objectClassDefinition != null) { + return false; + } + } else if (!objectClassDefinition.equals(other.objectClassDefinition)) { + return false; + } + if (objectDefinition == null) { + if (other.objectDefinition != null) { + return false; + } + } else if (!objectDefinition.equals(other.objectDefinition)) { + return false; + } + if (protectedObjectPatterns == null) { + if (other.protectedObjectPatterns != null) { + return false; + } + } else if (!protectedObjectPatterns.equals(other.protectedObjectPatterns)) { + return false; + } + if (resourceType == null) { + if (other.resourceType != null) { + return false; + } + } else if (!resourceType.equals(other.resourceType)) { + return false; + } + if (schemaHandlingObjectTypeDefinitionType == null) { + if (other.schemaHandlingObjectTypeDefinitionType != null) { + return false; + } + } else if (!schemaHandlingObjectTypeDefinitionType.equals(other.schemaHandlingObjectTypeDefinitionType)) { + return false; + } + if (secondaryIdentifiers == null) { + if (other.secondaryIdentifiers != null) { + return false; + } + } else if (!secondaryIdentifiers.equals(other.secondaryIdentifiers)) { + return false; + } + return true; + } + + @Override public String debugDump() { return debugDump(0); } @@ -988,8 +1141,21 @@ protected String getDebugDumpClassName() { public String getHumanReadableName() { if (getDisplayName() != null) { return getDisplayName(); - } else { + } else if (getKind() != null) { return getKind()+":"+getIntent(); + } else if (getTypeName() != null) { + return getTypeName().getLocalPart(); + } else { + return "null"; + } + } + + @Override + public String toString() { + if (getKind() == null) { + return getDebugDumpClassName() + " ("+PrettyPrinter.prettyPrint(getTypeName())+")"; + } else { + return getDebugDumpClassName() + " ("+getKind()+":"+getIntent()+"="+PrettyPrinter.prettyPrint(getTypeName())+")"; } } diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java index 73e2aa8a5ce..77cf2155b2a 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/ComplexTypeDefinition.java @@ -356,6 +356,74 @@ public void replaceDefinition(QName propertyName, ItemDefinition newDefinition) } throw new IllegalArgumentException("The definition with name "+propertyName+" was not found in complex type "+getTypeName()); } + + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((compileTimeClass == null) ? 0 : compileTimeClass.hashCode()); + result = prime * result + (containerMarker ? 1231 : 1237); + result = prime * result + ((extensionForType == null) ? 0 : extensionForType.hashCode()); + result = prime * result + ((itemDefinitions == null) ? 0 : itemDefinitions.hashCode()); + result = prime * result + (objectMarker ? 1231 : 1237); + result = prime * result + ((superType == null) ? 0 : superType.hashCode()); + result = prime * result + (xsdAnyMarker ? 1231 : 1237); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ComplexTypeDefinition other = (ComplexTypeDefinition) obj; + if (compileTimeClass == null) { + if (other.compileTimeClass != null) { + return false; + } + } else if (!compileTimeClass.equals(other.compileTimeClass)) { + return false; + } + if (containerMarker != other.containerMarker) { + return false; + } + if (extensionForType == null) { + if (other.extensionForType != null) { + return false; + } + } else if (!extensionForType.equals(other.extensionForType)) { + return false; + } + if (itemDefinitions == null) { + if (other.itemDefinitions != null) { + return false; + } + } else if (!itemDefinitions.equals(other.itemDefinitions)) { + return false; + } + if (objectMarker != other.objectMarker) { + return false; + } + if (superType == null) { + if (other.superType != null) { + return false; + } + } else if (!superType.equals(other.superType)) { + return false; + } + if (xsdAnyMarker != other.xsdAnyMarker) { + return false; + } + return true; + } @Override public String debugDump(int indent) { diff --git a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Definition.java b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Definition.java index f68b76fc512..3ab53ceed2c 100644 --- a/infra/prism/src/main/java/com/evolveum/midpoint/prism/Definition.java +++ b/infra/prism/src/main/java/com/evolveum/midpoint/prism/Definition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2016 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,8 @@ import javax.xml.namespace.QName; import com.evolveum.midpoint.util.MiscUtil; +import com.evolveum.midpoint.util.PrettyPrinter; + import org.apache.commons.lang.StringUtils; import org.w3c.dom.Element; @@ -285,7 +287,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return getDebugDumpClassName() + " ("+getTypeName()+")"; + return getDebugDumpClassName() + " ("+PrettyPrinter.prettyPrint(getTypeName())+")"; } @Override diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java index 0f24f2e0e1f..0d27d230b9c 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java @@ -368,6 +368,96 @@ protected void copyDefinitionData(ObjectClassComplexTypeDefinition clone) { clone.secondaryIdentifiers = this.secondaryIdentifiers; clone.auxiliary = this.auxiliary; } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + (auxiliary ? 1231 : 1237); + result = prime * result + (defaultInAKind ? 1231 : 1237); + result = prime * result + ((descriptionAttribute == null) ? 0 : descriptionAttribute.hashCode()); + result = prime * result + ((displayNameAttribute == null) ? 0 : displayNameAttribute.hashCode()); + result = prime * result + ((identifiers == null) ? 0 : identifiers.hashCode()); + result = prime * result + ((intent == null) ? 0 : intent.hashCode()); + result = prime * result + ((kind == null) ? 0 : kind.hashCode()); + result = prime * result + ((namingAttribute == null) ? 0 : namingAttribute.hashCode()); + result = prime * result + ((nativeObjectClass == null) ? 0 : nativeObjectClass.hashCode()); + result = prime * result + ((secondaryIdentifiers == null) ? 0 : secondaryIdentifiers.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ObjectClassComplexTypeDefinition other = (ObjectClassComplexTypeDefinition) obj; + if (auxiliary != other.auxiliary) { + return false; + } + if (defaultInAKind != other.defaultInAKind) { + return false; + } + if (descriptionAttribute == null) { + if (other.descriptionAttribute != null) { + return false; + } + } else if (!descriptionAttribute.equals(other.descriptionAttribute)) { + return false; + } + if (displayNameAttribute == null) { + if (other.displayNameAttribute != null) { + return false; + } + } else if (!displayNameAttribute.equals(other.displayNameAttribute)) { + return false; + } + if (identifiers == null) { + if (other.identifiers != null) { + return false; + } + } else if (!identifiers.equals(other.identifiers)) { + return false; + } + if (intent == null) { + if (other.intent != null) { + return false; + } + } else if (!intent.equals(other.intent)) { + return false; + } + if (kind != other.kind) { + return false; + } + if (namingAttribute == null) { + if (other.namingAttribute != null) { + return false; + } + } else if (!namingAttribute.equals(other.namingAttribute)) { + return false; + } + if (nativeObjectClass == null) { + if (other.nativeObjectClass != null) { + return false; + } + } else if (!nativeObjectClass.equals(other.nativeObjectClass)) { + return false; + } + if (secondaryIdentifiers == null) { + if (other.secondaryIdentifiers != null) { + return false; + } + } else if (!secondaryIdentifiers.equals(other.secondaryIdentifiers)) { + return false; + } + return true; + } @Override protected String getDebugDumpClassName() { From bbc9f8396f24c4bb8f09b801ee266dc0fe6001c5 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Fri, 5 Feb 2016 18:16:50 +0100 Subject: [PATCH 5/5] Fixing resource content display (objectclass selection) --- .../input/RefinedObjectTypeChoicePanel.java | 15 ++++++++++++++- .../resources/content/PageContentAccounts.java | 7 ++++++- .../dto/AccountContentDataProvider.java | 18 +++++++++++++----- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/RefinedObjectTypeChoicePanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/RefinedObjectTypeChoicePanel.java index 0dcc62db357..cb854b0ed54 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/RefinedObjectTypeChoicePanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/RefinedObjectTypeChoicePanel.java @@ -15,6 +15,7 @@ */ package com.evolveum.midpoint.web.component.input; +import java.util.ArrayList; import java.util.List; import org.apache.wicket.markup.html.form.IChoiceRenderer; @@ -23,7 +24,10 @@ import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.util.DebugUtil; import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; /** @@ -32,6 +36,8 @@ */ public class RefinedObjectTypeChoicePanel extends DropDownChoicePanel { + private static final Trace LOGGER = TraceManager.getTrace(RefinedObjectTypeChoicePanel.class); + public RefinedObjectTypeChoicePanel(String id, IModel model, IModel> resourceModel) { super(id, model, createChoiceModel(resourceModel), createRenderer(), false); } @@ -46,7 +52,14 @@ public List getObject() { } catch (SchemaException e) { throw new IllegalArgumentException(e.getMessage(),e); } - return refinedSchema.getRefinedDefinitions(); + List refinedDefinitions = refinedSchema.getRefinedDefinitions(); + List defs = new ArrayList<>(); + for (RefinedObjectClassDefinition rdef: refinedDefinitions) { + if (rdef.getKind() != null) { + ((List)defs).add(rdef); + } + } + return defs; } @Override diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/PageContentAccounts.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/PageContentAccounts.java index a711ca7619a..f5e8c419d56 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/PageContentAccounts.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/PageContentAccounts.java @@ -625,7 +625,6 @@ private ObjectQuery createQuery() { private IModel createObjectClassModel() { return new LoadableModel(false) { - @Override protected RefinedObjectClassDefinition load() { try { @@ -634,6 +633,12 @@ protected RefinedObjectClassDefinition load() { throw new SystemException(ex.getMessage(), ex); } } + + @Override + public void setObject(RefinedObjectClassDefinition object) { + super.setObject(object); + } + }; } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java index 68299249f9c..c07a43397d7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/resources/content/dto/AccountContentDataProvider.java @@ -100,7 +100,7 @@ public Iterator internalIterator(long first, long count) { query.setPaging(paging); if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Query filter:\n{}", query); + LOGGER.trace("Query filter for {}:\n{}", objectClassModel.getObject(), query.debugDump()); } Collection> options = @@ -133,11 +133,19 @@ private boolean isUseObjectCounting() { } private ObjectQuery getObjectQuery() throws SchemaException { - if (objectClassModel.getObject() == null) { - throw new SchemaException("No default account definition in resource "+resourceOidModel.getObject()); + RefinedObjectClassDefinition rOcDef = objectClassModel.getObject(); + if (rOcDef == null) { + throw new SchemaException("No object class definition ("+resourceOidModel.getObject()+")"); } - ObjectQuery baseQuery = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceOidModel.getObject(), - objectClassModel.getObject().getTypeName(), getPage().getPrismContext()); + + ObjectQuery baseQuery; + if (rOcDef.getKind() != null) { + baseQuery = ObjectQueryUtil.createResourceAndKindIntent(resourceOidModel.getObject(), + rOcDef.getKind(), rOcDef.getIntent(), getPage().getPrismContext()); + } else { + baseQuery = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceOidModel.getObject(), + rOcDef.getTypeName(), getPage().getPrismContext()); + } ObjectQuery query = getQuery(); if (query != null) { ObjectFilter baseFilter = baseQuery.getFilter();