Skip to content

Commit

Permalink
fix for MID-5453 - evaluating resource capabilities for shadow panel
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jul 17, 2019
1 parent 6b33ef3 commit 8203f14
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Expand Up @@ -2908,6 +2908,43 @@ public static ItemVisibility checkShadowActivationAndPasswordVisibility(ItemWrap

}

public static boolean isActivationSupported(ShadowType shadowType) {
ResourceType resource = shadowType.getResource();

if (resource == null) {
//TODO: what to return if we don't have resource available?
return true;
}

ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource.asPrismObject(), shadowType.getKind(), shadowType.getIntent());

if (ResourceTypeUtil.isActivationCapabilityEnabled(resource, resourceObjectTypeDefinitionType)) {
return true;
}

return false;

}

public static boolean isPasswordSupported(ShadowType shadowType) {
ResourceType resource = shadowType.getResource();

if (resource == null) {
//TODO: what to return if we don't have resource available?
return true;
}

ResourceObjectTypeDefinitionType resourceObjectTypeDefinitionType = ResourceTypeUtil.findObjectTypeDefinition(resource.asPrismObject(), shadowType.getKind(), shadowType.getIntent());

if (ResourceTypeUtil.isPasswordCapabilityEnabled(resource, resourceObjectTypeDefinitionType)) {
return true;
}

return false;

}


public static boolean isAssociationSupported(ShadowType shadowType) {
ResourceType resource = shadowType.getResource();

Expand Down
Expand Up @@ -83,10 +83,12 @@ private void initLayout() {

Panel activationPanel = getPageBase().initItemPanel(ID_ACTIVATION, ActivationType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ShadowType.F_ACTIVATION),
itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
activationPanel.add(new VisibleBehaviour(() -> isActivationSupported()));
add(activationPanel);

Panel passwordPanel = getPageBase().initItemPanel(ID_PASSWORD, PasswordType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(getModel(), ItemPath.create(ShadowType.F_CREDENTIALS, CredentialsType.F_PASSWORD)),
itemWrapper -> checkShadowContainerVisibility(itemWrapper, getModel()));
passwordPanel.add(new VisibleBehaviour(() -> isCredentialsSupported()));
add(passwordPanel);
} catch (SchemaException e) {
getSession().error("Cannot create panels for shadow, reason: " + e.getMessage());
Expand All @@ -108,4 +110,14 @@ private boolean checkAssociationsVisibility() {
return WebComponentUtil.isAssociationSupported(shadowType);

}

private boolean isActivationSupported() {
ShadowType shadowType = getModelObject().getObjectOld().asObjectable();
return WebComponentUtil.isActivationSupported(shadowType);
}

private boolean isCredentialsSupported() {
ShadowType shadowType = getModelObject().getObjectOld().asObjectable();
return WebComponentUtil.isPasswordSupported(shadowType);
}
}

0 comments on commit 8203f14

Please sign in to comment.