Search in sources :

Example 1 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PageAdminObjectDetails method loadObjectWrapper.

protected ObjectWrapper<O> loadObjectWrapper(PrismObject<O> objectToEdit) {
    Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
    OperationResult result = task.getResult();
    PrismObject<O> object = null;
    Collection<SelectorOptions<GetOperationOptions>> loadOptions = null;
    try {
        if (!isEditingFocus()) {
            if (objectToEdit == null) {
                LOGGER.trace("Loading object: New object (creating)");
                O focusType = createNewObject();
                getMidpointApplication().getPrismContext().adopt(focusType);
                object = (PrismObject<O>) focusType.asPrismObject();
            } else {
                LOGGER.trace("Loading object: New object (supplied): {}", objectToEdit);
                object = objectToEdit;
            }
        } else {
            loadOptions = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
            String focusOid = getObjectOidParameter();
            object = WebModelServiceUtils.loadObject(getCompileTimeClass(), focusOid, loadOptions, this, task, result);
            LOGGER.trace("Loading object: Existing object (loadled): {} -> {}", focusOid, object);
        }
        result.recordSuccess();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get object.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
    }
    showResult(result, false);
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Loaded object:\n{}", object.debugDump());
    }
    if (object == null) {
        if (isEditingFocus()) {
            getSession().error(getString("pageAdminFocus.message.cantEditFocus"));
        } else {
            getSession().error(getString("pageAdminFocus.message.cantNewFocus"));
        }
        throw new RestartResponseException(getRestartResponsePage());
    }
    ContainerStatus status = isEditingFocus() ? ContainerStatus.MODIFYING : ContainerStatus.ADDING;
    ObjectWrapper<O> wrapper;
    ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
    try {
        wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, status, task);
    } catch (Exception ex) {
        result.recordFatalError("Couldn't get user.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
        wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, null, null, status, false);
    }
    wrapper.setLoadOptions(loadOptions);
    showResult(wrapper.getResult(), false);
    loadParentOrgs(wrapper, task, result);
    wrapper.setShowEmpty(!isEditingFocus());
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Loaded focus wrapper:\n{}", wrapper.debugDump());
    }
    return wrapper;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ContainerStatus(com.evolveum.midpoint.web.component.prism.ContainerStatus) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectWrapperFactory(com.evolveum.midpoint.web.component.prism.ObjectWrapperFactory) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 2 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PrismPropertyRealValueFromContainerableModel method getObject.

@Override
public T getObject() {
    C object = model.getObject();
    PrismProperty<T> property;
    try {
        property = object.asPrismContainerValue().findOrCreateProperty(path);
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
        //todo show message in page error [lazyman]
        throw new RestartResponseException(PageError.class);
    }
    return getRealValue(property != null ? property.getRealValue() : null);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) PageError(com.evolveum.midpoint.web.page.error.PageError)

Example 3 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PrismPropertyRealValueFromObjectWrapperModel method getObject.

@Override
public T getObject() {
    PrismProperty<T> property;
    try {
        property = getPrismObject().findOrCreateProperty(path);
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
        //todo show message in page error [lazyman]
        throw new RestartResponseException(PageError.class);
    }
    T val = getRealValue(property != null ? property.getRealValue() : null);
    if (val == null) {
        return defaultValue;
    } else {
        return val;
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) PageError(com.evolveum.midpoint.web.page.error.PageError)

Example 4 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class OrgTreeProvider method getChildren.

@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
    //    	getAvailableData().clear();
    LOGGER.debug("Loading children for {}", new Object[] { node });
    Iterator<SelectableBean<OrgType>> iterator = null;
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
    node.getValue().getOid()).asc(ObjectType.F_NAME).build();
    OperationResult result = new OperationResult(LOAD_ORG_UNITS);
    try {
        //            Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
        Collection<SelectorOptions<GetOperationOptions>> options = null;
        Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
        List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
        LOGGER.debug("Found {} units.", units.size());
        List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
        for (PrismObject<OrgType> unit : units) {
            SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
            list.add(selectable);
        //                if (getAvailableData().contains(selectable)){
        //                	getAvailableData().remove(selectable);
        //                } 
        //                getAvailableData().add(selectable);
        }
        getAvailableData().addAll(list);
        //            Collections.sort(list);
        iterator = list.iterator();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
        result.recordFatalError("Unable to load org unit", ex);
    } finally {
        result.computeStatus();
    }
    if (WebComponentUtil.showResultInPage(result)) {
        getPageBase().showResult(result);
        throw new RestartResponseException(PageOrgTree.class);
    }
    if (iterator == null) {
        iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
    }
    LOGGER.debug("Finished loading children.");
    return iterator;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 5 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PageAdminResources method loadResource.

protected PrismObject<ResourceType> loadResource(Collection<SelectorOptions<GetOperationOptions>> options) {
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCE);
    PrismObject<ResourceType> resource = null;
    try {
        Task task = createSimpleTask(OPERATION_LOAD_RESOURCE);
        LOGGER.trace("getObject(resource) oid={}, options={}", getResourceOid(), options);
        resource = getModelService().getObject(ResourceType.class, getResourceOid(), options, task, result);
        result.recomputeStatus();
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("getObject(resource) result\n:{}", result.debugDump());
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get resource", ex);
        result.recordFatalError("Couldn't get resource, reason: " + ex.getMessage(), ex);
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        if (resource != null) {
            showResult(result);
        } else {
            getSession().error(getString("pageAdminResources.message.cantLoadResource"));
            throw new RestartResponseException(PageResources.class);
        }
    }
    return resource;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) RestartResponseException(org.apache.wicket.RestartResponseException)

Aggregations

RestartResponseException (org.apache.wicket.RestartResponseException)73 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)36 Task (com.evolveum.midpoint.task.api.Task)27 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)20 ArrayList (java.util.ArrayList)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 CommonException (com.evolveum.midpoint.util.exception.CommonException)8 SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)5 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)5 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)5 PageError (com.evolveum.midpoint.web.page.error.PageError)5 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 Collection (java.util.Collection)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 IModel (org.apache.wicket.model.IModel)4 StringValue (org.apache.wicket.util.string.StringValue)4