Skip to content

Commit

Permalink
Fixed reporting of item path problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 21, 2016
1 parent 6e5a74f commit 624b1b4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 deletions.
Expand Up @@ -440,7 +440,17 @@ protected void editPerformed(AjaxRequestTarget target, ConditionalSearchFilterTy
correlationEditPerformed(target, object);
}

@Override
@Override
protected void performAddValueHook(AjaxRequestTarget target, ConditionalSearchFilterType added) {
parentPage.refreshIssues(target);
}

@Override
protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ConditionalSearchFilterType> item) {
parentPage.refreshIssues(target);
}

@Override
protected boolean buttonsDisabled(){
return !isAnySelected();
}
Expand Down
Expand Up @@ -368,15 +368,18 @@ ResourceValidator.wrongMatchingRule=Wrong matching rule for attribute ''{1}'' in
ResourceValidator.multipleItems=There are multiple definitions for attribute or association ''{1}'' in ''{0}''.
ResourceValidator.dependentObjectTypeDoesNotExist=Dependent kind/intent ''{1}'' does not exist in a dependency of ''{0}''.
ResourceValidator.targetObjectTypeDoesNotExist=Target kind/intent ''{1}'' for association ''{2}'' does not exist in schema handling for ''{0}''.
ResourceValidator.suspiciousMappingSource=Suspicious source for {1} for ''{2}'' in schema handling for ''{0}'': {3}
ResourceValidator.invalidMappingSource=Invalid source for {1} for ''{2}'' in schema handling for ''{0}'': {3}
ResourceValidator.missingMappingSource=Missing source for {1} for ''{2}'' in schema handling for ''{0}''
ResourceValidator.suspiciousMappingTarget=Suspicious target for {1} for ''{2}'' in schema handling for ''{0}'': {3}
ResourceValidator.invalidMappingTarget=Invalid target for {1} for ''{2}'' in schema handling for ''{0}'': {3}
ResourceValidator.missingMappingTarget=Missing target for {1} for ''{2}'' in schema handling for ''{0}''
ResourceValidator.superfluousMappingTarget=Superfluous target for {1} for ''{2}'' in schema handling for ''{0}'': {3}
ResourceValidator.unknownObjectClassInSynchronization=Unknown object class ''{1}'' for synchronization definition: ''{0}''.
ResourceValidator.noReaction=No reaction defined in ''{0}'' for situation(s): {1}
ResourceValidator.duplicateReactions=Duplicate reactions defined in ''{0}'' for situation(s): {1}
ResourceValidator.noSituation=Missing synchronization situation name in a reaction defined in ''{0}''
ResourceValidator.noCorrelationRule=No correlation rule in ''{0}''
ResourceValidator.outboundMapping=outbound mapping
ResourceValidator.inboundMapping=inbound mapping number {0}
AdminGuiConfigurationType.adminGuiConfiguration=Admin GUI Configuration
Expand Up @@ -66,14 +66,17 @@ public interface ResourceValidator {
String C_DEPENDENT_OBJECT_TYPE_DOES_NOT_EXIST = "dependentObjectTypeDoesNotExist";
String C_TARGET_OBJECT_TYPE_DOES_NOT_EXIST = "targetObjectTypeDoesNotExist";
String C_INVALID_MAPPING_SOURCE = "invalidMappingSource";
String C_SUSPICIOUS_MAPPING_SOURCE = "suspiciousMappingSource";
String C_MISSING_MAPPING_SOURCE = "missingMappingSource";
String C_INVALID_MAPPING_TARGET = "invalidMappingTarget";
String C_SUSPICIOUS_MAPPING_TARGET = "suspiciousMappingTarget";
String C_MISSING_MAPPING_TARGET = "missingMappingTarget";
String C_SUPERFLUOUS_MAPPING_TARGET = "superfluousMappingTarget";
String C_UNKNOWN_OBJECT_CLASS_IN_SYNCHRONIZATION = "unknownObjectClassInSynchronization";
String C_NO_REACTION = "noReaction";
String C_DUPLICATE_REACTIONS = "duplicateReactions";
String C_NO_SITUATION = "noSituation";
String C_NO_CORRELATION_RULE = "noCorrelationRule";

@NotNull
ValidationResult validate(@NotNull PrismObject<ResourceType> resourceObject, @NotNull Scope scope,
Expand Down
Expand Up @@ -162,8 +162,14 @@ public static PathResolutionResult resolvePathForType(@NotNull Class<? extends O
if (itemDef != null) {
return new PathResolutionResult(itemDef);
} else {
return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION,
"No definition for '" + path + "' in " + def.getName().getLocalPart(), null, null));
if (FocusType.class.equals(clazz) && context instanceof ResourceResolutionContext) {
ResourceResolutionContext rctx = (ResourceResolutionContext) context;
return new PathResolutionResult(new Issue(Issue.Severity.INFO, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION,
"Couldn't verify item path '" + path + "' because specific focus type (user, role, org, ...) is not defined for kind=" + rctx.kind + ", indent=" + rctx.intent, null, null));
} else {
return new PathResolutionResult(new Issue(Issue.Severity.WARNING, CAT_ITEM_PATH, C_NO_OBJECT_DEFINITION,
"No definition for '" + path + "' in " + def.getName().getLocalPart(), null, null));
}
}
}
}
Expand Up @@ -61,7 +61,6 @@
* - existence of dependent kind/intent/resource (in thorough scope)
* - checking references (thorough)
* - mapping: unknown channel / except-channel
* - mapping: invalid source, invalid target
* - empty mapping (?)
* - iteration tokens
* - invalid objectclass in synchronization
Expand Down Expand Up @@ -359,12 +358,17 @@ private void checkItemPath(ResourceValidationContext ctx, ItemPath path, Resourc
} else if (result.getDefinition() != null) {
// definition found => OK (ignoring any potential issues found)
} else {
String code = isSource ? C_INVALID_MAPPING_SOURCE : C_INVALID_MAPPING_TARGET;
String inOut = outbound ? getString(ctx.bundle, "ResourceValidator.outboundMapping") : getString(ctx.bundle, "ResourceValidator.inboundMapping", index);
Issue.Severity severity = Issue.getSeverity(result.getIssues());
if (severity == null) {
severity = Issue.Severity.INFO;
}
String code;
if (severity != Issue.Severity.INFO) {
code = isSource ? C_INVALID_MAPPING_SOURCE : C_INVALID_MAPPING_TARGET;
} else {
code = isSource ? C_SUSPICIOUS_MAPPING_SOURCE : C_SUSPICIOUS_MAPPING_TARGET;
}
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Issue issue : result.getIssues()) {
Expand All @@ -385,6 +389,20 @@ private String format(ItemPathType path) {
return path != null ? path.toString() : "";
}

private String format(List<?> items) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object o : items) {
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append(o);
}
return sb.toString();
}

@Nullable
private QName itemRefToName(ItemPathType ref) {
return ItemPath.asSingleName(ref != null ? ref.getItemPath() : null);
Expand Down Expand Up @@ -590,8 +608,13 @@ private void checkObjectSynchronization(ResourceValidationContext ctx, ItemPath
counts.put(reaction.getSituation(), c != null ? c+1 : 1);
}
}
checkMissingReactions(ctx, path, objectSync, counts, Arrays.asList(UNLINKED, UNMATCHED));
checkMissingReactions(ctx, path, objectSync, counts, Collections.singletonList(UNLINKED));
checkDuplicateReactions(ctx, path, objectSync, counts);
if (objectSync.getCorrelation().isEmpty()) {
ctx.validationResult.add(Issue.Severity.WARNING, CAT_SYNCHRONIZATION, C_NO_CORRELATION_RULE,
getString(ctx.bundle, CLASS_DOT + C_NO_CORRELATION_RULE, getName(objectSync)),
ctx.resourceRef, path);
}
}

private void checkDuplicateReactions(ResourceValidationContext ctx, ItemPath path, ObjectSynchronizationType objectSync,
Expand All @@ -604,7 +627,7 @@ private void checkDuplicateReactions(ResourceValidationContext ctx, ItemPath pat
}
if (!duplicates.isEmpty()) {
ctx.validationResult.add(Issue.Severity.WARNING, CAT_SYNCHRONIZATION, C_DUPLICATE_REACTIONS,
getString(ctx.bundle, CLASS_DOT + C_DUPLICATE_REACTIONS, getName(objectSync), String.valueOf(duplicates)),
getString(ctx.bundle, CLASS_DOT + C_DUPLICATE_REACTIONS, getName(objectSync), format(duplicates)),
ctx.resourceRef, path);
}
}
Expand All @@ -615,7 +638,7 @@ private void checkMissingReactions(ResourceValidationContext ctx, ItemPath path,
missing.removeAll(counts.keySet());
if (!missing.isEmpty()) {
ctx.validationResult.add(Issue.Severity.INFO, CAT_SYNCHRONIZATION, C_NO_REACTION,
getString(ctx.bundle, CLASS_DOT + C_NO_REACTION, getName(objectSync), String.valueOf(missing)),
getString(ctx.bundle, CLASS_DOT + C_NO_REACTION, getName(objectSync), format(missing)),
ctx.resourceRef, path);
}
}
Expand Down

0 comments on commit 624b1b4

Please sign in to comment.