private void updateAccountStatusPerformed( AjaxRequestTarget target, AccountContentDto dto, boolean enabled) { List<AccountContentDto> accounts = isAnythingSelected(target, dto); OperationResult result = new OperationResult(OPERATION_ADJUST_ACCOUNT_STATUS); if (accounts.isEmpty()) { return; } ActivationStatusType status = enabled ? ActivationStatusType.ENABLED : ActivationStatusType.DISABLED; for (AccountContentDto acc : accounts) { ObjectDelta delta = ObjectDelta.createModificationReplaceProperty( ShadowType.class, acc.getAccountOid(), new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS), getPrismContext(), status); try { Task task = createSimpleTask(OPERATION_ADJUST_ACCOUNT_STATUS); getModelService() .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result); } catch (Exception e) { LoggingUtils.logException(LOGGER, "Couldn't enable/disable account(s) on resource", e); result.recordPartialError("Couldn't enable/disable account(s) on resource", e); } } result.recomputeStatus(); showResult(result); target.add(getFeedbackPanel()); }
private void importAccount(AjaxRequestTarget target, AccountContentDto row) { List<AccountContentDto> accounts = isAnythingSelected(target, row); if (accounts.isEmpty()) { return; } OperationResult result = new OperationResult(OPERATION_CREATE_USER_FROM_ACCOUNTS); for (AccountContentDto dto : accounts) { OperationResult subResult = result.createMinorSubresult(OPERATION_CREATE_USER_FROM_ACCOUNT); try { getModelService() .importFromResource( dto.getAccountOid(), createSimpleTask(OPERATION_CREATE_USER_FROM_ACCOUNT), subResult); } catch (Exception ex) { subResult.computeStatus( getString("pageContentAccounts.message.cantImportAccount", dto.getAccountOid())); LoggingUtils.logException( LOGGER, "Can't import account {},oid={}", ex, dto.getAccountName(), dto.getAccountOid()); } finally { subResult.computeStatusIfUnknown(); } } result.computeStatus(); showResult(result); target.add(getFeedbackPanel()); target.add(getTable()); }
private void removeOwnerPerformed(AjaxRequestTarget target, AccountContentDto row) { List<AccountContentDto> accounts = isAnythingSelected(target, row); if (accounts.isEmpty()) { return; } for (AccountContentDto dto : accounts) { reloadOwnerChangeModel(dto.getAccountOid(), dto.getOwnerOid()); ownerChangePerformed(target, null); } target.add(getTable()); target.add(getFeedbackPanel()); }
private void deleteConfirmedPerformed(AjaxRequestTarget target) { List<AccountContentDto> selected = new ArrayList<AccountContentDto>(); if (singleDelete != null) { selected.add(singleDelete); } else { selected = isAnythingSelected(target, null); } OperationResult result = new OperationResult(OPERATION_DELETE_ACCOUNT_FROM_RESOURCE); for (AccountContentDto acc : selected) { String accOid = acc.getAccountOid(); try { Task task = createSimpleTask(OPERATION_DELETE_ACCOUNT_FROM_RESOURCE); ObjectDelta delta = ObjectDelta.createDeleteDelta(ShadowType.class, accOid, getPrismContext()); getModelService() .executeChanges(WebMiscUtil.createDeltaCollection(delta), null, task, result); } catch (Exception e) { result.recordPartialError("Couldn't delete account from resource.", e); LoggingUtils.logException(LOGGER, "Couldn't delete account from resource", e); } } if (result.isUnknown()) { result.recomputeStatus("Error occurred during resource account deletion."); } if (result.isSuccess()) { result.recordStatus( OperationResultStatus.SUCCESS, "Selected accounts have been successfully deleted."); } AccountContentDataProvider provider = (AccountContentDataProvider) getTable().getDataTable().getDataProvider(); provider.clearCache(); TablePanel table = getTable(); target.add(table); showResult(result); target.add(getFeedbackPanel()); }
private void changeOwnerPerformed(AjaxRequestTarget target, AccountContentDto dto) { reloadOwnerChangeModel(dto.getAccountOid(), dto.getOwnerOid()); showModalWindow(MODAL_ID_OWNER_CHANGE, target); }
private void addRowMenuToTable(final AccountContentDto dto) { dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.enableAccount"), true, new HeaderMenuAction(this) { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { updateAccountStatusPerformed(target, dto, true); } })); dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.disableAccount"), true, new HeaderMenuAction(this) { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { updateAccountStatusPerformed(target, dto, false); } })); dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.deleteAccount"), true, new HeaderMenuAction(this) { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { deleteAccountPerformed(target, dto); } })); dto.getMenuItems().add(new InlineMenuItem()); dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.importAccount"), new ColumnMenuAction<UserListItemDto>() { @Override public void onClick(AjaxRequestTarget target) { importAccount(target, dto); } })); dto.getMenuItems().add(new InlineMenuItem()); dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.changeOwner"), new ColumnMenuAction<UserListItemDto>() { @Override public void onClick(AjaxRequestTarget target) { changeOwnerPerformed(target, dto); } })); dto.getMenuItems() .add( new InlineMenuItem( createStringResource("pageContentAccounts.menu.removeOwner"), true, new HeaderMenuAction(this) { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { removeOwnerPerformed(target, dto); } })); }