Skip to content

Commit

Permalink
fix for MID-3728 (#orgUnit authorization makes visible New organizati…
Browse files Browse the repository at this point in the history
…on menu item)
  • Loading branch information
KaterynaHonchar committed May 9, 2017
1 parent 93ad3ac commit 4581bcc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
Expand Up @@ -1532,27 +1532,41 @@ public boolean isVisible() {
}
});
submenu.add(edit);
MenuItem newMenu = new MenuItem(createStringResource(newKey), newPageClass) {
private static final long serialVersionUID = 1L;

@Override
protected boolean isMenuActive() {
if (!PageBase.this.getPage().getClass().equals(newPageClass)) {
return false;
MenuItem newMenu = new MenuItem(createStringResource(newKey), newPageClass, null, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
try {
return getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_ADD_ACTION_URL,
AuthorizationPhaseType.REQUEST, (new OrgType(getPrismContext())).asPrismObject(),
null, null, null);
} catch (SchemaException ex){
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't solve authorization for New organization menu item", ex);
}
return true;
}
}) {
private static final long serialVersionUID = 1L;

if (PageBase.this.getPage() instanceof PageAdminFocus) {
PageAdminFocus page = (PageAdminFocus) PageBase.this.getPage();
return !page.isEditingFocus();
} else if (PageBase.this.getPage() instanceof PageResourceWizard) {
PageResourceWizard page = (PageResourceWizard) PageBase.this.getPage();
return page.isNewResource();
} else {
return false;
@Override
protected boolean isMenuActive() {
if (!PageBase.this.getPage().getClass().equals(newPageClass)) {
return false;
}

if (PageBase.this.getPage() instanceof PageAdminFocus) {
PageAdminFocus page = (PageAdminFocus) PageBase.this.getPage();
return !page.isEditingFocus();
} else if (PageBase.this.getPage() instanceof PageResourceWizard) {
PageResourceWizard page = (PageResourceWizard) PageBase.this.getPage();
return page.isNewResource();
} else {
return false;
}
}
}
};
submenu.add(newMenu);
};
submenu.add(newMenu);
}

private void createFocusPageViewMenu(List<MenuItem> submenu, String viewKey,
Expand Down
Expand Up @@ -340,6 +340,12 @@ public class AuthorizationConstants {
public static final QName AUTZ_UI_UNASSIGN_ACTION_QNAME = new QName(NS_AUTHORIZATION_MODEL, "unassign");
public static final String AUTZ_UI_UNASSIGN_ACTION_URL = NS_AUTHORIZATION_MODEL + "#unassign";

public static final QName AUTZ_UI_MODIFY_ACTION_QNAME = new QName(NS_AUTHORIZATION_MODEL, "modify");
public static final String AUTZ_UI_MODIFY_ACTION_URL = QNameUtil.qNameToUri(AUTZ_UI_MODIFY_ACTION_QNAME);

public static final QName AUTZ_UI_ADD_ACTION_QNAME = new QName(NS_AUTHORIZATION_MODEL, "add");
public static final String AUTZ_UI_ADD_ACTION_URL = QNameUtil.qNameToUri(AUTZ_UI_ADD_ACTION_QNAME);

public static final QName AUTZ_UI_DELEGATE_ACTION_QNAME = new QName(NS_AUTHORIZATION_UI, "delegate");
public static final String AUTZ_UI_DELEGATE_ACTION_URL = QNameUtil.qNameToUri(AUTZ_UI_DELEGATE_ACTION_QNAME);

Expand Down

0 comments on commit 4581bcc

Please sign in to comment.