use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccount method loadAccount.
private ShadowWrapper loadAccount(PageParameters parameters) {
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = getOperationOptionsBuilder().item(ShadowType.F_RESOURCE_REF).resolve().build();
StringValue oid = parameters != null ? parameters.get(OnePageParameterEncoder.PARAMETER) : null;
if (oid == null) {
getSession().error(getString("pageAccount.message.cantEditAccount"));
showResult(result);
throw new RestartResponseException(PageResources.class);
}
PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, oid.toString(), options, PageAccount.this, task, result);
if (account == null) {
getSession().error(getString("pageAccount.message.cantEditAccount"));
showResult(result);
throw new RestartResponseException(PageResources.class);
}
PrismObjectWrapperFactory<ShadowType> owf = getRegistry().getObjectWrapperFactory(account.getDefinition());
WrapperContext context = new WrapperContext(task, result);
context.setShowEmpty(false);
ShadowWrapper wrapper;
try {
wrapper = (ShadowWrapper) owf.createObjectWrapper(account, ItemStatus.NOT_CHANGED, context);
// TODO: fetch result???
} catch (SchemaException e) {
LOGGER.error("Cannot create wrapper for shadow {}", account);
result.recordFatalError(getString("PageAccount.message.loadAccount.fatalError"));
throw new RestartResponseException(PageResources.class);
}
return wrapper;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method initMemberTable.
private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
memberContainer.setOutputMarkupId(true);
memberContainer.setOutputMarkupPlaceholderTag(true);
form.add(memberContainer);
// TODO QName defines a relation value which will be used for new member creation
MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions()) {
private static final long serialVersionUID = 1L;
@Override
protected UserProfileStorage.TableId getTableId() {
return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName());
}
@Override
protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
columns.add(createRelationColumn());
return columns;
}
@Override
protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
return false;
}
Class<?> objectClass = rowModel.getObject().getValue().getClass();
return WebComponentUtil.hasDetailsPage(objectClass);
}
@Override
protected boolean showNewObjectCreationPopup() {
return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
}
@Override
protected List<Component> createToolbarButtonsList(String buttonId) {
List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
AjaxIconButton assignButton = createAssignButton(buttonId);
buttonsList.add(1, assignButton);
return buttonsList;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return createRowActions();
}
@Override
protected String getStorageKey() {
return AbstractRoleMemberPanel.this.createStorageKey();
}
protected PageStorage getPageStorage(String storageKey) {
return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
}
@Override
protected Search<AH> createSearch(Class<AH> type) {
return createMemberSearch(type);
}
@Override
protected SelectableBeanObjectDataProvider<AH> createProvider() {
SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
provider.setIsMemberPanel(true);
provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
return provider;
}
@Override
public void refreshTable(AjaxRequestTarget target) {
if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
clearCache();
}
if (reloadPageOnRefresh()) {
throw new RestartResponseException(getPage().getClass());
} else {
super.refreshTable(target);
}
}
@Override
protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
if (refList == null) {
refList = new ArrayList<>();
}
if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
refList.addAll(relation.getArchetypeRefs());
}
ObjectReferenceType membershipRef = new ObjectReferenceType();
membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
refList.add(membershipRef);
return refList;
}
@Override
protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
return loadMultiFunctionalButtonModel(true);
}
@Override
protected String getTitleForNewObjectButton() {
return createStringResource("TreeTablePanel.menu.createMember").getString();
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class ProgressAwareChangesExecutorImpl method configureTask.
private void configureTask(Collection<ObjectDelta<? extends ObjectType>> deltas, ModelExecuteOptions options, Task task) throws SchemaException {
MidPointPrincipal user = AuthUtil.getPrincipalUser();
if (user == null) {
throw new RestartResponseException(PageLogin.class);
} else {
task.setOwner(user.getFocus().asPrismObject());
}
task.setRootActivityDefinition(createNonIterativeChangeExecutionDef(deltas, toModelExecutionOptionsBean(options)));
task.setChannel(SchemaConstants.CHANNEL_USER_URI);
task.setName("Execute changes");
task.setInitiallyRunnable();
task.addArchetypeInformation(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value());
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class AbstractRoleMemberPanel method initMemberTable.
private <AH extends AssignmentHolderType> void initMemberTable(Form<?> form) {
WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
memberContainer.setOutputMarkupId(true);
memberContainer.setOutputMarkupPlaceholderTag(true);
form.add(memberContainer);
// TODO QName defines a relation value which will be used for new member creation
MainObjectListPanel<AH> childrenListPanel = new MainObjectListPanel<>(ID_MEMBER_TABLE, getDefaultObjectTypeClass(), getSearchOptions(), getPanelConfiguration()) {
private static final long serialVersionUID = 1L;
@Override
protected UserProfileStorage.TableId getTableId() {
return AbstractRoleMemberPanel.this.getTableId(getComplexTypeQName());
}
@Override
protected List<IColumn<SelectableBean<AH>, String>> createDefaultColumns() {
List<IColumn<SelectableBean<AH>, String>> columns = super.createDefaultColumns();
columns.add(createRelationColumn());
return columns;
}
@Override
protected boolean isObjectDetailsEnabled(IModel<SelectableBean<AH>> rowModel) {
if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
return false;
}
Class<?> objectClass = rowModel.getObject().getValue().getClass();
return WebComponentUtil.hasDetailsPage(objectClass);
}
@Override
protected List<Component> createToolbarButtonsList(String buttonId) {
List<Component> buttonsList = super.createToolbarButtonsList(buttonId);
AjaxIconButton assignButton = createAssignButton(buttonId);
buttonsList.add(1, assignButton);
return buttonsList;
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return createRowActions();
}
@Override
protected String getStorageKey() {
return AbstractRoleMemberPanel.this.createStorageKey();
}
protected PageStorage getPageStorage(String storageKey) {
return getSession().getSessionStorage().getPageStorageMap().get(storageKey);
}
@Override
protected Search<AH> createSearch(Class<AH> type) {
return createMemberSearch(type);
}
@Override
protected SelectableBeanObjectDataProvider<AH> createProvider() {
SelectableBeanObjectDataProvider<AH> provider = createSelectableBeanObjectDataProvider(() -> getCustomizedQuery(getSearchModel().getObject()), null);
provider.addQueryVariables(ExpressionConstants.VAR_PARENT_OBJECT, AbstractRoleMemberPanel.this.getModelObject());
return provider;
}
@Override
public void refreshTable(AjaxRequestTarget target) {
if (getSearchModel().isAttached() && getSearchModel().getObject() != null && getSearchModel().getObject().isTypeChanged()) {
clearCache();
}
if (reloadPageOnRefresh()) {
throw new RestartResponseException(getPage().getClass());
} else {
super.refreshTable(target);
}
}
@Override
protected boolean showNewObjectCreationPopup() {
return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
}
@Override
protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
if (refList == null) {
refList = new ArrayList<>();
}
if (relation != null && CollectionUtils.isNotEmpty(relation.getArchetypeRefs())) {
refList.addAll(relation.getArchetypeRefs());
}
ObjectReferenceType membershipRef = new ObjectReferenceType();
membershipRef.setOid(AbstractRoleMemberPanel.this.getModelObject().getOid());
membershipRef.setType(AbstractRoleMemberPanel.this.getModelObject().asPrismObject().getComplexTypeDefinition().getTypeName());
membershipRef.setRelation(relation != null && CollectionUtils.isNotEmpty(relation.getRelations()) ? relation.getRelations().get(0) : null);
refList.add(membershipRef);
return refList;
}
@Override
protected LoadableModel<MultiFunctinalButtonDto> loadButtonDescriptions() {
return loadMultiFunctionalButtonModel(true);
}
@Override
public ContainerPanelConfigurationType getPanelConfiguration() {
return AbstractRoleMemberPanel.this.getPanelConfiguration();
}
@Override
protected String getTitleForNewObjectButton() {
return createStringResource("TreeTablePanel.menu.createMember").getString();
}
};
childrenListPanel.setOutputMarkupId(true);
memberContainer.add(childrenListPanel);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class ContainerListDataProvider method internalIterator.
@Override
public Iterator<? extends PrismContainerValueWrapper<C>> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", first, count);
getAvailableData().clear();
Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_CONTAINERS);
OperationResult result = task.getResult();
try {
ObjectPaging paging = createPaging(first, count);
ObjectQuery query = getQuery();
if (query == null) {
query = getPrismContext().queryFactory().createQuery();
}
query.setPaging(paging);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} with {}", getType().getSimpleName(), query.debugDump());
}
List<C> list = WebModelServiceUtils.searchContainers(getType(), query, options, result, getPageBase());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} containers", getType().getSimpleName(), list.size());
}
for (C object : list) {
WrapperContext context = new WrapperContext(task, result);
PrismContainerWrapperFactory<C> factory = getPageBase().findContainerWrapperFactory(object.asPrismContainerValue().getDefinition());
getAvailableData().add(factory.createValueWrapper(null, object.asPrismContainerValue(), ValueStatus.NOT_CHANGED, context));
}
} catch (Exception ex) {
result.recordFatalError(getPageBase().createStringResource("ContainerListDataProvider.message.listContainers.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list containers", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageError.class);
}
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
Aggregations