Skip to content

Commit

Permalink
Merge branch 'master' into ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Mar 19, 2015
2 parents 1b3a948 + c1b4ec5 commit d12c94b
Show file tree
Hide file tree
Showing 21 changed files with 1,180 additions and 130 deletions.
Expand Up @@ -21,6 +21,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingStrengthType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;
Expand All @@ -44,6 +45,7 @@ public class ACAttributeDto implements Serializable {
public static final String F_NAME = "name";
public static final String F_VALUES = "values";

// construction.getRef should point to the same attribute as definition
private PrismPropertyDefinition definition;
private ResourceAttributeDefinitionType construction;
private List<ACValueConstructionDto> values;
Expand Down Expand Up @@ -131,8 +133,18 @@ public ResourceAttributeDefinitionType getConstruction() throws SchemaException
}

ResourceAttributeDefinitionType attrConstruction = new ResourceAttributeDefinitionType();
attrConstruction.setRef(new ItemPathType(new ItemPath(definition.getName())));
MappingType outbound = construction != null && construction.getOutbound() != null ? construction.getOutbound().clone() : new MappingType();
if (construction != null && construction.getRef() != null) {
attrConstruction.setRef(construction.getRef()); // preserves original ref (including xmlns prefix!) - in order to avoid false deltas when comparing old and new values
} else {
attrConstruction.setRef(new ItemPathType(new ItemPath(definition.getName())));
}
MappingType outbound;
if (construction != null && construction.getOutbound() != null) {
outbound = construction.getOutbound().clone();
} else {
outbound = new MappingType();
outbound.setStrength(MappingStrengthType.STRONG);
}
attrConstruction.setOutbound(outbound);

ExpressionType expression = new ExpressionType();
Expand Down
Expand Up @@ -537,6 +537,11 @@ public ObjectDelta getObjectDelta() throws SchemaException {
// password change will always look like add,
// therefore we push replace
pDelta.setValuesToReplace(Arrays.asList(newValCloned));
} else if (propertyDef.isSingleValue()) {
// values for single-valued properties should be pushed via replace
// in order to prevent problems e.g. with summarizing deltas for
// unreachable resources
pDelta.setValueToReplace(newValCloned);
} else {
pDelta.addValueToAdd(newValCloned);
}
Expand Down
Expand Up @@ -191,6 +191,7 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
mappingObject.setExpression(new ExpressionType());
}

mappingObject.getExpression().getExpressionEvaluator().clear();
mappingObject.getExpression().getExpressionEvaluator().add(deserializeExpression(prismContext, expression));
}

Expand All @@ -199,6 +200,7 @@ public MappingType prepareDtoToSave(PrismContext prismContext) throws SchemaExce
mappingObject.setCondition(new ExpressionType());
}

mappingObject.getCondition().getExpressionEvaluator().clear();
mappingObject.getCondition().getExpressionEvaluator().add(deserializeExpression(prismContext, condition));
}

Expand Down
Expand Up @@ -654,6 +654,9 @@ private boolean isUseObjectCounting() throws SchemaException {
}

RefinedObjectClassDefinition refinedObjectClassDefinition = resourceSchema.getRefinedDefinition(typeDefinition.getTypeName());
if (refinedObjectClassDefinition == null) {
return false;
}
return refinedObjectClassDefinition.isObjectCountingEnabled();
}

Expand Down
Expand Up @@ -1493,8 +1493,10 @@ private Collection<SimpleValidationError> performCustomValidation(PrismObject<Us
if(userModel != null && userModel.getObject() != null && userModel.getObject().getObject() != null){
user = userModel.getObject().getObject();

for(ObjectDelta delta: deltas){
delta.applyTo(user);
for (ObjectDelta delta: deltas) {
if (UserType.class.isAssignableFrom(delta.getObjectTypeClass())) { // because among deltas there can be also ShadowType deltas
delta.applyTo(user);
}
}
}
}
Expand Down
Expand Up @@ -119,23 +119,13 @@ public static <O extends Objectable> ObjectQuery createObjectQueryInternal(Class
return createObjectQueryInternal(objDef, filterType, pagingType, prismContext);
}

private static boolean isNotEmpty(SearchFilterType filterType, PagingType pagingType){
boolean filterNotEmpty = filterType != null && filterType.containsFilterClause();
if (!filterNotEmpty && pagingType == null) {
return false;
}
return true;
}

public static <O extends Objectable> ObjectQuery createObjectQueryInternal(PrismObjectDefinition<O> objDef, SearchFilterType filterType, PagingType pagingType, PrismContext prismContext)
throws SchemaException {



try {
ObjectQuery query = new ObjectQuery();

if (isNotEmpty(filterType, pagingType)) {
if (filterType != null && filterType.containsFilterClause()) {
MapXNode rootFilter = filterType.getFilterClauseXNode();
ObjectFilter filter = QueryConvertor.parseFilter(rootFilter, objDef);
query.setFilter(filter);
Expand Down
Expand Up @@ -120,7 +120,14 @@ public static GetOperationOptions createRetrieve(RetrieveOption retrieve) {
return options;
}

public Boolean getResolve() {
public static GetOperationOptions createRetrieve(RelationalValueSearchQuery query) {
GetOperationOptions options = new GetOperationOptions();
options.retrieve = RetrieveOption.INCLUDE;
options.setRelationalValueSearchQuery(query);
return options;
}

public Boolean getResolve() {
return resolve;
}

Expand Down
Expand Up @@ -28,6 +28,7 @@
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.ItemPathSegment;
import com.evolveum.midpoint.prism.path.NameItemPathSegment;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

Expand Down Expand Up @@ -132,16 +133,17 @@ public boolean isRoot() {
return false;
}

public static boolean hasToLoadPath(QName container, Collection<SelectorOptions<GetOperationOptions>> options) {
return hasToLoadPath(new ItemPath(container), options);
public static boolean hasToLoadPath(QName itemName, Collection<SelectorOptions<GetOperationOptions>> options) {
return hasToLoadPath(new ItemPath(itemName), options);
}

// TODO find a better way to specify this
private static final Set<ItemPath> PATHS_NOT_RETURNED_BY_DEFAULT = new HashSet<>(Arrays.asList(
new ItemPath(UserType.F_JPEG_PHOTO),
new ItemPath(TaskType.F_SUBTASK),
new ItemPath(TaskType.F_NODE_AS_OBSERVED),
new ItemPath(TaskType.F_NEXT_RUN_START_TIMESTAMP)));
new ItemPath(TaskType.F_NEXT_RUN_START_TIMESTAMP),
new ItemPath(LookupTableType.F_TABLE)));

public static boolean hasToLoadPath(ItemPath path, Collection<SelectorOptions<GetOperationOptions>> options) {
List<SelectorOptions<GetOperationOptions>> retrieveOptions = filterRetrieveOptions(options);
Expand Down
Expand Up @@ -18,14 +18,25 @@

import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.xnode.PrimitiveXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LoginEventType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import com.evolveum.prism.xml.ns._public.types_3.RawType;
import org.apache.commons.lang.StringUtils;

import javax.xml.bind.JAXBElement;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

Expand Down Expand Up @@ -69,7 +80,51 @@ public static String toStringValue(PrismPropertyValue propertyValue) {
return value.toString();
} else if (value instanceof ResourceAttributeDefinitionType) {
ResourceAttributeDefinitionType radt = (ResourceAttributeDefinitionType) value;
return "(a value or a more complex mapping for the '" + radt.getRef() + "' attribute)";
ItemPathType ref = radt.getRef();
String path;
if (ref != null) {
path = ref.getItemPath().toString();
} else {
path = "(null)";
}
StringBuilder sb = new StringBuilder();
MappingType mappingType = radt.getOutbound();
if (mappingType != null) {
if (mappingType.getExpression() == null) {
sb.append("Empty mapping for ").append(path);
} else {
sb.append(path).append(" = ");
boolean first = true;
for (JAXBElement<?> evaluator : mappingType.getExpression().getExpressionEvaluator()) {
if (first) {
first = false;
} else {
sb.append(", ");
}
if (QNameUtil.match(SchemaConstants.C_VALUE, evaluator.getName()) && evaluator.getValue() instanceof RawType) {
RawType raw = (RawType) evaluator.getValue();
try {
XNode xnode = raw.serializeToXNode();
if (xnode instanceof PrimitiveXNode) {
sb.append(((PrimitiveXNode) xnode).getStringValue());
} else {
sb.append("(a complex value)");
}
} catch (SchemaException e) {
sb.append("(an invalid value)");
}
} else {
sb.append("(a complex expression)");
}
}
}
if (mappingType.getStrength() != null) {
sb.append(" (").append(mappingType.getStrength().value()).append(")");
}
} else {
sb.append("Empty mapping for ").append(path);
}
return sb.toString();
} else if (value instanceof QName) {
QName qname = (QName) value;
if (StringUtils.isNotEmpty(qname.getNamespaceURI())) {
Expand Down
Expand Up @@ -34,6 +34,7 @@
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.DeltaConvertor;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType;
Expand Down Expand Up @@ -85,7 +86,8 @@ public static void assertObjectNotFoundFault(FaultMessage ex) throws FaultMessag

public static void assertIllegalArgumentFault(FaultMessage ex) throws FaultMessage {
if (!(ex.getFaultInfo() instanceof IllegalArgumentFaultType)) {
Assert.fail("not illegal argument fault.");
IntegrationTestTools.display("Unexpected exception in fault", ex.getFaultInfo());
Assert.fail("not illegal argument fault. Was: "+ex.getFaultInfo());
}
throw ex;
}
Expand Down

0 comments on commit d12c94b

Please sign in to comment.