Skip to content

Commit

Permalink
Fixed MID-3369: Exceptions when previewing association-related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Aug 25, 2016
1 parent 99958c7 commit 214b2c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -54,14 +54,14 @@ private void initLayout() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return object != null && object.getSourceValue() instanceof PrismReferenceValue;
return hasValidReferenceValue(object);
}
};
final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return object == null || !(object.getSourceValue() instanceof PrismReferenceValue);
return !hasValidReferenceValue(object);
}
};

Expand All @@ -83,12 +83,18 @@ public void onClick(AjaxRequestTarget target) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(refValue);
WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);

}
};
link.add(visibleIfReference);
add(link);
}

private boolean hasValidReferenceValue(SceneItemValue object) {
return object != null && object.getSourceValue() instanceof PrismReferenceValue
&& ((PrismReferenceValue) object.getSourceValue()).getTargetType() != null;
}

private ObjectTypeGuiDescriptor getObjectTypeDescriptor() {
SceneItemValue value = getModelObject();
if (value.getSourceValue() instanceof PrismReferenceValue) {
Expand Down
Expand Up @@ -104,11 +104,12 @@ public <O extends ObjectType> void resolve(ObjectDelta<O> objectDelta, Task task
PrismObject<O> originalObject = null;
boolean originalObjectFetched = false;
final Class<O> clazz = objectDelta.getObjectTypeClass();
boolean managedByProvisioning = ResourceType.class.isAssignableFrom(clazz) || ShadowType.class.isAssignableFrom(clazz);
PrismObjectDefinition<O> objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz);
if (objectDefinition == null) {
warn(result, "Definition for " + clazz + " couldn't be found");
} else {
if (ResourceType.class.isAssignableFrom(clazz) || ShadowType.class.isAssignableFrom(clazz)) {
if (managedByProvisioning) {
try {
provisioningService.applyDefinition(objectDelta, result);
} catch (ObjectNotFoundException | CommunicationException | ConfigurationException e) {
Expand All @@ -117,7 +118,7 @@ public <O extends ObjectType> void resolve(ObjectDelta<O> objectDelta, Task task
}
}
for (ItemDelta itemDelta : objectDelta.getModifications()) {
if (objectDefinition != null) {
if (objectDefinition != null && !managedByProvisioning) {
ItemDefinition<?> def = objectDefinition.findItemDefinition(itemDelta.getPath());
if (def != null) {
itemDelta.applyDefinition(def);
Expand Down

0 comments on commit 214b2c2

Please sign in to comment.