List of usage examples for org.apache.commons.lang3 SerializationUtils clone
public static <T extends Serializable> T clone(final T object)
Deep clone an Object using serialization.
This is many times slower than writing clone methods by hand on all objects in your object graph.
From source file:org.apache.syncope.client.console.pages.UserSelfModalPage.java
public UserSelfModalPage(final PageReference callerPageRef, final ModalWindow window, final UserTO userTO) { super(callerPageRef, window, userTO, Mode.SELF, userTO.getKey() != 0); this.initialUserTO = SerializationUtils.clone(userTO); setupEditPanel();/*from www. j a va2 s . c om*/ }
From source file:org.apache.syncope.client.console.panels.AnyObjectDirectoryPanel.java
@Override public ActionsPanel<AnyObjectTO> getActions(final IModel<AnyObjectTO> model) { final ActionsPanel<AnyObjectTO> panel = super.getActions(model); panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override//ww w . j ava 2 s . c om public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new AnyWrapper<>(new AnyObjectRestClient().read(model.getObject().getKey())), target)); } }, ActionType.EDIT, new StringBuilder().append(AnyEntitlement.READ.getFor(type)).append(",") .append(AnyEntitlement.UPDATE.getFor(type)).toString()).setRealm(realm); panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { final AnyObjectTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(null); send(AnyObjectDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new AnyWrapper<>(clone), target)); } @Override protected boolean statusCondition(final AnyObjectTO modelObject) { return addAjaxLink.isVisibleInHierarchy() && realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.CLONE, AnyEntitlement.CREATE.getFor(type)).setRealm(realm); if (wizardInModal) { panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { final IModel<AnyWrapper<AnyObjectTO>> formModel = new CompoundPropertyModel<>( new AnyWrapper<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false))); altDefaultModal.header( new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionType.MANAGE_RESOURCES, new StringBuilder().append(AnyEntitlement.READ.getFor(type)).append(",") .append(AnyEntitlement.UPDATE.getFor(type)).toString()).setRealm(realm); panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.propagation.tasks", model)); utilityModal.show(true); } }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST); panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { target.add(utilityModal.setContent( new NotificationTasks(AnyTypeKind.ANY_OBJECT, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.notification.tasks", model)); utilityModal.show(true); target.add(utilityModal); } }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST); } panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770646L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { try { restClient.delete(model.getObject().getETagValue(), 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); } @Override protected boolean statusCondition(final AnyObjectTO modelObject) { return realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.DELETE, AnyEntitlement.DELETE.getFor(type), true).setRealm(realm); return panel; }
From source file:org.apache.syncope.client.console.panels.AnyObjectSearchResultPanel.java
@Override protected List<IColumn<AnyObjectTO, String>> getColumns() { final List<IColumn<AnyObjectTO, String>> columns = new ArrayList<>(); for (String name : prefMan.getList(getRequest(), String.format(Constants.PREF_ANY_OBJECT_DETAILS_VIEW, type))) { final Field field = ReflectionUtils.findField(AnyObjectTO.class, name); if ("token".equalsIgnoreCase(name)) { columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name)); } else if (field != null && field.getType().equals(Date.class)) { columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name)); } else {/*from w ww . j a v a 2s . c o m*/ columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name)); } } for (String name : prefMan.getList(getRequest(), String.format(Constants.PREF_ANY_OBJECT_PLAIN_ATTRS_VIEW, type))) { if (pSchemaNames.contains(name)) { columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.PLAIN)); } } for (String name : prefMan.getList(getRequest(), String.format(Constants.PREF_ANY_OBJECT_DER_ATTRS_VIEW, type))) { if (dSchemaNames.contains(name)) { columns.add(new AttrColumn<AnyObjectTO>(name, SchemaType.DERIVED)); } } // Add defaults in case of no selection if (columns.isEmpty()) { for (String name : AnyObjectDisplayAttributesModalPage.ANY_OBJECT_DEFAULT_SELECTION) { columns.add(new PropertyColumn<AnyObjectTO, String>(new ResourceModel(name, name), name, name)); } } columns.add(new ActionColumn<AnyObjectTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = -3503023501954863131L; @Override public ActionLinksPanel<AnyObjectTO> getActions(final String componentId, final IModel<AnyObjectTO> model) { final ActionLinksPanel.Builder<AnyObjectTO> panel = ActionLinksPanel .builder(page.getPageReference()); panel.add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { final IModel<AnyHandler<AnyObjectTO>> formModel = new CompoundPropertyModel<>( new AnyHandler<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new StatusModal<AnyObjectTO>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false))); altDefaultModal.header(new Model<>( getString("any.edit", new Model<>(new AnyHandler<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ) .add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { send(AnyObjectSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new AnyHandler<>( new AnyObjectRestClient().read(model.getObject().getKey())), target)); } }, ActionLink.ActionType.EDIT, String.format("%s_%s", type, AnyEntitlement.READ)) .add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { final AnyObjectTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(0L); send(AnyObjectSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new AnyHandler<>(clone), target)); } }, ActionLink.ActionType.CLONE, StandardEntitlement.USER_CREATE) .add(new ActionLink<AnyObjectTO>() { private static final long serialVersionUID = -7978723352517770646L; @Override public void onClick(final AjaxRequestTarget target, final AnyObjectTO ignore) { try { restClient.delete(model.getObject().getETagValue(), model.getObject().getKey()); info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While deleting object {}", model.getObject().getKey(), e); error(getString(Constants.ERROR) + ": " + e.getMessage()); } SyncopeConsoleSession.get().getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, String.format("%s_%s", type, AnyEntitlement.DELETE)); return panel.build(componentId, model.getObject()); } @Override public ActionLinksPanel<Serializable> getHeader(final String componentId) { final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel .builder(page.getPageReference()); panel.add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { // still missing content target.add(modal.setContent(new AnyObjectDisplayAttributesModalPage<>(modal, page.getPageReference(), pSchemaNames, dSchemaNames, type))); modal.header(new ResourceModel("any.attr.display", "")); modal.show(true); } }, ActionLink.ActionType.CHANGE_VIEW, String.format("%s_%s", type, AnyEntitlement.READ)) .add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { if (target != null) { target.add(container); } } }, ActionLink.ActionType.RELOAD, String.format("%s_%s", type, AnyEntitlement.SEARCH)); return panel.build(componentId); } }); return columns; }
From source file:org.apache.syncope.client.console.panels.GroupDirectoryPanel.java
@Override public ActionsPanel<GroupTO> getActions(final IModel<GroupTO> model) { final ActionsPanel<GroupTO> panel = super.getActions(model); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override//from w w w . jav a2s .c o m public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { send(GroupDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new GroupWrapper(restClient.read(model.getObject().getKey())), target)); } }, ActionType.EDIT, new StringBuilder().append(StandardEntitlement.GROUP_READ).append(",") .append(StandardEntitlement.GROUP_UPDATE).toString()).setRealm(realm); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = 6242834621660352855L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { GroupTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(null); send(GroupDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new GroupWrapper(clone), target)); } @Override protected boolean statusCondition(final GroupTO modelObject) { return realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.CLONE, StandardEntitlement.GROUP_CREATE).setRealm(realm); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = 6242834621660352855L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { target.add(typeExtensionsModal.setContent( new TypeExtensionDirectoryPanel(typeExtensionsModal, model.getObject(), pageRef))); typeExtensionsModal.header(new StringResourceModel("typeExtensions", model)); typeExtensionsModal.show(true); } }, ActionType.TYPE_EXTENSIONS, StandardEntitlement.GROUP_UPDATE).setRealm(realm); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { templates.setTargetObject(model.getObject()); templates.toggle(target, true); } @Override public boolean isIndicatorEnabled() { return false; } }, ActionType.MEMBERS, new StringBuilder().append(StandardEntitlement.GROUP_READ).append(",") .append(StandardEntitlement.GROUP_UPDATE).toString()).setRealm(realm); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.bulkMembersAction(model.getObject().getKey(), BulkMembersActionType.PROVISION); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While provisioning members of group {}", model.getObject().getKey(), e); SyncopeConsoleSession.get() .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionType.PROVISION_MEMBERS, String.format("%s,%s", StandardEntitlement.TASK_CREATE, StandardEntitlement.TASK_EXECUTE)); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.bulkMembersAction(model.getObject().getKey(), BulkMembersActionType.DEPROVISION); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While provisioning members of group {}", model.getObject().getKey(), e); SyncopeConsoleSession.get() .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionType.DEPROVISION_MEMBERS, String.format("%s,%s", StandardEntitlement.TASK_CREATE, StandardEntitlement.TASK_EXECUTE)); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { IModel<AnyWrapper<GroupTO>> formModel = new CompoundPropertyModel<>( new AnyWrapper<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false))); altDefaultModal.header( new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionType.MANAGE_RESOURCES, StandardEntitlement.GROUP_READ).setRealm(realm); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.GROUP, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.propagation.tasks", model)); utilityModal.show(true); } }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { target.add(utilityModal .setContent(new NotificationTasks(AnyTypeKind.GROUP, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.notification.tasks", model)); utilityModal.show(true); } }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.delete(model.getObject().getETagValue(), 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); } @Override protected boolean statusCondition(final GroupTO modelObject) { return realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.DELETE, StandardEntitlement.GROUP_DELETE, true).setRealm(realm); return panel; }
From source file:org.apache.syncope.client.console.panels.GroupSearchResultPanel.java
@Override protected List<IColumn<GroupTO, String>> getColumns() { final List<IColumn<GroupTO, String>> columns = new ArrayList<>(); for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DETAILS_VIEW)) { final Field field = ReflectionUtils.findField(GroupTO.class, name); if ("token".equalsIgnoreCase(name)) { columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name)); } else if (field != null && field.getType().equals(Date.class)) { columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name)); } else {/*from w w w . ja v a 2 s . co m*/ columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name)); } } for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_PLAIN_ATTRS_VIEW)) { if (pSchemaNames.contains(name)) { columns.add(new AttrColumn<GroupTO>(name, SchemaType.PLAIN)); } } for (String name : prefMan.getList(getRequest(), Constants.PREF_GROUP_DER_ATTRS_VIEW)) { if (dSchemaNames.contains(name)) { columns.add(new AttrColumn<GroupTO>(name, SchemaType.DERIVED)); } } // Add defaults in case of no selection if (columns.isEmpty()) { for (String name : GroupDisplayAttributesModalPage.GROUP_DEFAULT_SELECTION) { columns.add(new PropertyColumn<GroupTO, String>(new ResourceModel(name, name), name, name)); } prefMan.setList(getRequest(), getResponse(), Constants.PREF_GROUP_DETAILS_VIEW, Arrays.asList(GroupDisplayAttributesModalPage.GROUP_DEFAULT_SELECTION)); } columns.add(new ActionColumn<GroupTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = -3503023501954863131L; @Override public ActionLinksPanel<GroupTO> getActions(final String componentId, final IModel<GroupTO> model) { final ActionLinksPanel.Builder<GroupTO> panel = ActionLinksPanel.builder(page.getPageReference()); panel.add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770645L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { final IModel<AnyHandler<GroupTO>> formModel = new CompoundPropertyModel<>( new AnyHandler<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new StatusModal<GroupTO>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false))); altDefaultModal.header(new Model<>( getString("any.edit", new Model<>(new AnyHandler<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ) .add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { send(GroupSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new GroupHandler( new GroupRestClient().read(model.getObject().getKey())), target)); } }, ActionLink.ActionType.EDIT, StandardEntitlement.GROUP_READ) .add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { final GroupTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(0L); send(GroupSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new GroupHandler(clone), target)); } }, ActionLink.ActionType.CLONE, StandardEntitlement.GROUP_CREATE) .add(new ActionLink<GroupTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.delete(model.getObject().getETagValue(), model.getObject().getKey()); info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); LOG.error("While deleting object {}", model.getObject().getKey(), e); } SyncopeConsoleSession.get().getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.GROUP_DELETE); return panel.build(componentId); } @Override public ActionLinksPanel<Serializable> getHeader(final String componentId) { final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel .builder(page.getPageReference()); return panel.add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { target.add(modal.setContent(new GroupDisplayAttributesModalPage<>(modal, page.getPageReference(), pSchemaNames, dSchemaNames))); modal.header(new ResourceModel("any.attr.display", "")); modal.show(true); } }, ActionLink.ActionType.CHANGE_VIEW, StandardEntitlement.GROUP_READ) .add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { if (target != null) { target.add(container); } } }, ActionLink.ActionType.RELOAD, StandardEntitlement.GROUP_SEARCH).build(componentId); } }); return columns; }
From source file:org.apache.syncope.client.console.panels.RoleDirectoryPanel.java
@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//from www. jav a 2 s .c o m 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; }
From source file:org.apache.syncope.client.console.panels.RoleSearchResultPanel.java
@Override protected List<IColumn<RoleTO, String>> getColumns() { final List<IColumn<RoleTO, String>> columns = new ArrayList<>(); columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("key"), "key", "key")); columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("entitlements", "Entitlements"), null, "entitlements")); columns.add(new PropertyColumn<RoleTO, String>(new ResourceModel("realms"), null, "realms")); columns.add(new ActionColumn<RoleTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = -3503023501954863131L; @Override//from www . ja va2 s .c om public ActionLinksPanel<RoleTO> getActions(final String componentId, final IModel<RoleTO> model) { final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder(page.getPageReference()); panel.add(new ActionLink<RoleTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final RoleTO ignore) { send(RoleSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new RoleHandler(new RoleRestClient().read(model.getObject().getKey())), target)); } }, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ).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(RoleSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new RoleHandler(clone), target)); } }, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE).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()); info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While deleting object {}", model.getObject().getKey(), e); error(getString(Constants.ERROR) + ": " + e.getMessage()); } SyncopeConsoleSession.get().getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE); return panel.build(componentId); } @Override public ActionLinksPanel<RoleTO> getHeader(final String componentId) { final ActionLinksPanel.Builder<RoleTO> panel = ActionLinksPanel.builder(page.getPageReference()); return panel.add(new ActionLink<RoleTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final RoleTO ignore) { if (target != null) { target.add(container); } } }, ActionLink.ActionType.RELOAD, StandardEntitlement.ROLE_LIST).build(componentId); } }); return columns; }
From source file:org.apache.syncope.client.console.panels.UserDirectoryPanel.java
@Override public ActionsPanel<UserTO> getActions(final IModel<UserTO> model) { final ActionsPanel<UserTO> panel = super.getActions(model); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override//from w ww . j a va2s . com public void onClick(final AjaxRequestTarget target, final UserTO ignore) { send(UserDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new UserWrapper(new UserRestClient().read(model.getObject().getKey())), target)); } }, ActionType.EDIT, new StringBuilder().append(StandardEntitlement.USER_READ).append(",") .append(StandardEntitlement.USER_UPDATE).toString()).setRealm(realm); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { UserTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(null); clone.setUsername(model.getObject().getUsername() + "_clone"); send(UserDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new UserWrapper(clone), target)); } @Override protected boolean statusCondition(final UserTO modelObject) { return addAjaxLink.isVisibleInHierarchy() && realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.CLONE, StandardEntitlement.USER_CREATE).setRealm(realm); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { try { UserRestClient.class.cast(restClient).mustChangePassword(model.getObject().getETagValue(), !model.getObject().isMustChangePassword(), model.getObject().getKey()); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (Exception 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); } }, ActionType.MUSTCHANGEPASSWORD, StandardEntitlement.USER_UPDATE).setRealm(realm); if (wizardInModal) { panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -4875218360625971340L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>( new AnyWrapper<>(model.getObject())); displayAttributeModal.setFormModel(formModel); target.add(displayAttributeModal.setContent(new ChangePasswordModal(displayAttributeModal, pageRef, new UserWrapper(model.getObject())))); displayAttributeModal.header( new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))))); displayAttributeModal.show(true); } }, ActionType.PASSWORD_RESET, new StringBuilder().append(StandardEntitlement.USER_UPDATE).toString()) .setRealm(realm); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>( new AnyWrapper<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", true))); altDefaultModal.header( new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionType.ENABLE, StandardEntitlement.USER_UPDATE).setRealm(realm); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>( new AnyWrapper<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new AnyStatusModal<>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), "resource", false))); altDefaultModal.header( new Model<>(getString("any.edit", new Model<>(new AnyWrapper<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_UPDATE).setRealm(realm); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { target.add(utilityModal.setContent(new AnyPropagationTasks(utilityModal, AnyTypeKind.USER, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.propagation.tasks", model)); utilityModal.show(true); } }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { target.add(utilityModal.setContent( new NotificationTasks(AnyTypeKind.USER, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.notification.tasks", model)); utilityModal.show(true); target.add(utilityModal); } }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST); } panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { try { restClient.delete(model.getObject().getETagValue(), model.getObject().getKey()); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (Exception 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); } @Override protected boolean statusCondition(final UserTO modelObject) { return realm.startsWith(SyncopeConstants.ROOT_REALM); } }, ActionType.DELETE, StandardEntitlement.USER_DELETE, true).setRealm(realm); return panel; }
From source file:org.apache.syncope.client.console.panels.UserSearchResultPanel.java
@Override protected List<IColumn<UserTO, String>> getColumns() { final List<IColumn<UserTO, String>> columns = new ArrayList<>(); for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_DETAILS_VIEW)) { final Field field = ReflectionUtils.findField(UserTO.class, name); if ("token".equalsIgnoreCase(name)) { columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name)); } else if (field != null && field.getType().equals(Date.class)) { columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name)); } else {//from w w w . j a v a 2 s . co m columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name)); } } for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_PLAIN_ATTRS_VIEW)) { if (pSchemaNames.contains(name)) { columns.add(new AttrColumn<UserTO>(name, SchemaType.PLAIN)); } } for (String name : prefMan.getList(getRequest(), Constants.PREF_USERS_DER_ATTRS_VIEW)) { if (dSchemaNames.contains(name)) { columns.add(new AttrColumn<UserTO>(name, SchemaType.DERIVED)); } } // Add defaults in case of no selection if (columns.isEmpty()) { for (String name : UserDisplayAttributesModalPage.USER_DEFAULT_SELECTION) { columns.add(new PropertyColumn<UserTO, String>(new ResourceModel(name, name), name, name)); } prefMan.setList(getRequest(), getResponse(), Constants.PREF_USERS_DETAILS_VIEW, Arrays.asList(UserDisplayAttributesModalPage.USER_DEFAULT_SELECTION)); } columns.add(new ActionColumn<UserTO, String>(new ResourceModel("actions", "")) { private static final long serialVersionUID = -3503023501954863131L; @Override public ActionLinksPanel<UserTO> getActions(final String componentId, final IModel<UserTO> model) { final ActionLinksPanel.Builder<UserTO> panel = ActionLinksPanel.builder(page.getPageReference()); panel.add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { final IModel<AnyHandler<UserTO>> formModel = new CompoundPropertyModel<>( new AnyHandler<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new StatusModal<UserTO>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), false))); altDefaultModal.header(new Model<>( getString("any.edit", new Model<>(new AnyHandler<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionLink.ActionType.MANAGE_RESOURCES, StandardEntitlement.USER_READ) .add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { final IModel<AnyHandler<UserTO>> formModel = new CompoundPropertyModel<>( new AnyHandler<>(model.getObject())); altDefaultModal.setFormModel(formModel); target.add(altDefaultModal.setContent(new StatusModal<UserTO>(altDefaultModal, pageRef, formModel.getObject().getInnerObject(), true))); altDefaultModal.header(new Model<>( getString("any.edit", new Model<>(new AnyHandler<>(model.getObject()))))); altDefaultModal.show(true); } }, ActionLink.ActionType.ENABLE, StandardEntitlement.USER_READ) .add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { send(UserSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( new AnyHandler<>( new UserRestClient().read(model.getObject().getKey())), target)); } }, ActionLink.ActionType.EDIT, StandardEntitlement.USER_READ).add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { final UserTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(0L); send(UserSearchResultPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new AnyHandler<>(clone), target)); } }, ActionLink.ActionType.CLONE, StandardEntitlement.USER_CREATE) .add(new ActionLink<UserTO>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final UserTO ignore) { try { restClient.delete(model.getObject().getETagValue(), model.getObject().getKey()); info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While deleting object {}", model.getObject().getKey(), e); error(getString(Constants.ERROR) + ": " + e.getMessage()); } SyncopeConsoleSession.get().getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.USER_DELETE); return panel.build(componentId, model.getObject()); } @Override public ActionLinksPanel<Serializable> getHeader(final String componentId) { final ActionLinksPanel.Builder<Serializable> panel = ActionLinksPanel .builder(page.getPageReference()); return panel.add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { target.add(modal.setContent(new UserDisplayAttributesModalPage<>(modal, page.getPageReference(), pSchemaNames, dSchemaNames))); modal.header(new ResourceModel("any.attr.display", "")); modal.show(true); } }, ActionLink.ActionType.CHANGE_VIEW, StandardEntitlement.USER_READ) .add(new ActionLink<Serializable>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final Serializable ignore) { if (target != null) { target.add(container); } } }, ActionLink.ActionType.RELOAD, StandardEntitlement.USER_SEARCH).build(componentId); } }); return columns; }
From source file:org.apache.syncope.client.console.policies.PolicyDirectoryPanel.java
@Override public ActionsPanel<T> getActions(final IModel<T> model) { final ActionsPanel<T> panel = super.getActions(model); panel.add(new ActionLink<T>() { private static final long serialVersionUID = -3722207913631435501L; @Override//from w ww . j a v a 2 s . c om public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) { send(PolicyDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>( restClient.getPolicy(model.getObject().getKey()), target)); } }, ActionLink.ActionType.EDIT, StandardEntitlement.POLICY_UPDATE); panel.add(new ActionLink<T>() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) { final AbstractPolicyTO clone = SerializationUtils.clone(model.getObject()); clone.setKey(null); send(PolicyDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(clone, target)); } }, ActionLink.ActionType.CLONE, StandardEntitlement.POLICY_CREATE); addCustomActions(panel, model); panel.add(new ActionLink<T>() { private static final long serialVersionUID = -3722207913631435501L; @Override public void onClick(final AjaxRequestTarget target, final AbstractPolicyTO ignore) { final T policyTO = model.getObject(); try { restClient.delete(policyTO.getKey()); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While deleting {}", policyTO.getKey(), e); SyncopeConsoleSession.get() .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.POLICY_DELETE, true); return panel; }