Search in sources :

Example 6 with FocusSubwrapperDto

use of com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto in project midpoint by Evolveum.

the class PageAdminFocus method loadSubWrapperDto.

private <S extends ObjectType> FocusSubwrapperDto<S> loadSubWrapperDto(Class<S> type, String oid, boolean noFetch, Task task) {
    if (oid == null) {
        return null;
    }
    OperationResult subResult = task.getResult().createMinorSubresult(OPERATION_LOAD_SHADOW);
    String resourceName = null;
    try {
        Collection<SelectorOptions<GetOperationOptions>> loadOptions = null;
        if (ShadowType.class.equals(type)) {
            GetOperationOptions resourceOption = GetOperationOptions.createResolve();
            resourceOption.setReadOnly(true);
            loadOptions = SelectorOptions.createCollection(ShadowType.F_RESOURCE, resourceOption);
        }
        if (noFetch) {
            GetOperationOptions rootOptions = SelectorOptions.findRootOptions(loadOptions);
            if (rootOptions == null) {
                loadOptions.add(new SelectorOptions<GetOperationOptions>(GetOperationOptions.createNoFetch()));
            } else {
                rootOptions.setNoFetch(true);
            }
        }
        PrismObject<S> projection = WebModelServiceUtils.loadObject(type, oid, loadOptions, this, task, subResult);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Loaded projection {} ({}):\n{}", oid, loadOptions, projection == null ? null : projection.debugDump());
        }
        if (projection == null) {
            // No access or error
            return null;
        }
        S projectionType = projection.asObjectable();
        OperationResultType fetchResult = projectionType.getFetchResult();
        StringBuilder description = new StringBuilder();
        if (ShadowType.class.equals(type)) {
            ShadowType shadowType = (ShadowType) projectionType;
            ResourceType resource = shadowType.getResource();
            resourceName = WebComponentUtil.getName(resource);
            if (shadowType.getIntent() != null) {
                description.append(shadowType.getIntent()).append(", ");
            }
        } else if (OrgType.class.equals(type)) {
            OrgType orgType = (OrgType) projectionType;
            resourceName = orgType.getDisplayName() != null ? WebComponentUtil.getOrigStringFromPoly(orgType.getDisplayName()) : "";
        }
        description.append(WebComponentUtil.getOrigStringFromPoly(projectionType.getName()));
        ObjectWrapper<S> wrapper = ObjectWrapperUtil.createObjectWrapper(resourceName, description.toString(), projection, ContainerStatus.MODIFYING, true, task, this);
        wrapper.setLoadOptions(loadOptions);
        wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
        wrapper.setSelectable(true);
        wrapper.setMinimalized(true);
        wrapper.initializeContainers(this);
        subResult.computeStatus();
        return new FocusSubwrapperDto<S>(wrapper, UserDtoStatus.MODIFY);
    } catch (Exception ex) {
        subResult.recordFatalError("Couldn't load account." + ex.getMessage(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load account", ex);
        subResult.computeStatus();
        return new FocusSubwrapperDto<S>(false, resourceName, subResult);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto)

Aggregations

FocusSubwrapperDto (com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ObjectWrapper (com.evolveum.midpoint.web.component.prism.ObjectWrapper)3 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 Task (com.evolveum.midpoint.task.api.Task)1 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)1 InlineMenu (com.evolveum.midpoint.web.component.menu.cog.InlineMenu)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 ImgResources (com.evolveum.midpoint.web.resource.img.ImgResources)1 Serializable (java.io.Serializable)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1