use of org.apache.syncope.client.console.layout.ConsoleLayoutInfo in project syncope by apache.
the class RoleDirectoryPanel method getActions.
@Override
public ActionsPanel<RoleTO> getActions(final IModel<RoleTO> model) {
final ActionsPanel<RoleTO> panel = super.getActions(model);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new RoleWrapper(new RoleRestClient().read(model.getObject().getKey())), target));
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final RoleTO clone = SerializationUtils.clone(model.getObject());
clone.setKey(null);
send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new RoleWrapper(clone), target));
}
}, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final String query = SyncopeClient.getUserSearchConditionBuilder().and(SyncopeClient.getUserSearchConditionBuilder().inRoles(model.getObject().getKey()), SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue()).query();
final AnyTypeRestClient typeRestClient = new AnyTypeRestClient();
final AnyTypeClassRestClient classRestClient = new AnyTypeClassRestClient();
final AnyTypeTO anyTypeTO = typeRestClient.read(AnyTypeKind.USER.name());
ModalPanel panel = new AnyPanel(BaseModal.CONTENT_ID, anyTypeTO, null, null, false, pageRef) {
private static final long serialVersionUID = -7514498203393023415L;
@Override
protected Panel getDirectoryPanel(final String id) {
final Panel panel = new UserDirectoryPanel.Builder(classRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm("/").setFiltered(true).setFiql(query).disableCheckBoxes().addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(new UserTO(), anyTypeTO.getClasses(), FormLayoutInfoUtils.fetch(typeRestClient.list()).getLeft(), pageRef), false).setWizardInModal(false).build(id);
MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, StandardEntitlement.USER_SEARCH);
return panel;
}
};
membersModal.header(new StringResourceModel("role.members", RoleDirectoryPanel.this, model));
membersModal.setContent(panel);
membersModal.show(true);
target.add(membersModal);
}
}, ActionLink.ActionType.MEMBERS, StandardEntitlement.USER_SEARCH);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final ConsoleLayoutInfo info = new ConsoleLayoutInfo(model.getObject().getKey());
info.setContent(restClient.readConsoleLayoutInfo(model.getObject().getKey()));
utilityModal.header(new ResourceModel("console.layout.info", "JSON Content"));
utilityModal.setContent(new JsonEditorPanel(utilityModal, new PropertyModel<String>(info, "content"), false, pageRef) {
private static final long serialVersionUID = -8927036362466990179L;
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
restClient.setConsoleLayoutInfo(info.getKey(), info.getContent());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
modal.show(false);
modal.close(target);
} catch (Exception e) {
LOG.error("While updating console layout info for role {}", info.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
});
utilityModal.show(true);
target.add(utilityModal);
}
}, ActionLink.ActionType.LAYOUT_EDIT, StandardEntitlement.ROLE_UPDATE);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
try {
restClient.delete(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE, true);
return panel;
}
Aggregations