Search in sources :

Example 11 with RestartResponseException

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

the class PageAccounts method loadResourceObjectClass.

private void loadResourceObjectClass() {
    AccountDetailsSearchDto dto = searchModel.getObject();
    PrismObject<ResourceType> resourcePrism;
    OperationResult result = new OperationResult(OPERATION_GET_OBJECT_CLASS);
    List<QName> accountObjectClassList = new ArrayList<>();
    ResourceItemDto resourceDto = resourceModel.getObject();
    String oid = resourceDto.getOid();
    try {
        resourcePrism = getModelService().getObject(ResourceType.class, oid, null, createSimpleTask(OPERATION_GET_INTENTS), result);
        ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPrismContext());
        schema.getObjectClassDefinitions();
        for (Definition def : schema.getDefinitions()) {
            accountObjectClassList.add(def.getTypeName());
        }
        dto.setObjectClassList(accountObjectClassList);
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
        result.recordFatalError("Couldn't load object class list from resource.: " + e.getMessage(), e);
        showResult(result, false);
        resourceModel.setObject(null);
        new RestartResponseException(PageAccounts.this);
    }
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Definition(com.evolveum.midpoint.prism.Definition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 12 with RestartResponseException

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

the class PageDebugView method loadObject.

private ObjectViewDto loadObject() {
    StringValue objectOid = getPageParameters().get(PARAM_OBJECT_ID);
    if (objectOid == null || StringUtils.isEmpty(objectOid.toString())) {
        getSession().error(getString("pageDebugView.message.oidNotDefined"));
        throw new RestartResponseException(PageDebugList.class);
    }
    Task task = createSimpleTask(OPERATION_LOAD_OBJECT);
    //todo is this result != null ?
    OperationResult result = task.getResult();
    ObjectViewDto dto = null;
    try {
        MidPointApplication application = PageDebugView.this.getMidpointApplication();
        GetOperationOptions rootOptions = GetOperationOptions.createRaw();
        rootOptions.setResolveNames(true);
        rootOptions.setTolerateRawData(true);
        Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOptions);
        // FIXME: ObjectType.class will not work well here. We need more specific type.
        //todo on page debug list create page params, put there oid and class for object type and send that to this page....read it here
        Class type = ObjectType.class;
        StringValue objectType = getPageParameters().get(PARAM_OBJECT_TYPE);
        if (objectType != null && StringUtils.isNotBlank(objectType.toString())) {
            type = getPrismContext().getSchemaRegistry().determineCompileTimeClass(new QName(SchemaConstantsGenerated.NS_COMMON, objectType.toString()));
        }
        // TODO make this configurable (or at least do not show campaign cases in production)
        if (UserType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        if (LookupTableType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(LookupTableType.F_ROW, GetOperationOptions.createRetrieve(new RelationalValueSearchQuery(ObjectPaging.createPaging(PrismConstants.T_ID, OrderDirection.ASCENDING)))));
        }
        if (AccessCertificationCampaignType.class.isAssignableFrom(type)) {
            options.add(SelectorOptions.create(AccessCertificationCampaignType.F_CASE, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
        }
        PrismObject<ObjectType> object = getModelService().getObject(type, objectOid.toString(), options, task, result);
        PrismContext context = application.getPrismContext();
        String lex = context.serializerFor(dataLanguage).serialize(object);
        dto = new ObjectViewDto(object.getOid(), WebComponentUtil.getName(object), object, lex);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't load object.", ex);
    }
    if (dto == null) {
        showResult(result);
        throw new RestartResponseException(PageDebugList.class);
    }
    showResult(result, false);
    if (!WebComponentUtil.isSuccessOrHandledErrorOrWarning(result)) {
        showResult(result, false);
        throw new RestartResponseException(PageDebugList.class);
    }
    return dto;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) PrismContext(com.evolveum.midpoint.prism.PrismContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RestartResponseException(org.apache.wicket.RestartResponseException) MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) RestartResponseException(org.apache.wicket.RestartResponseException) StringValue(org.apache.wicket.util.string.StringValue) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)

Example 13 with RestartResponseException

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

the class DynamicFieldGroupPanel method createItemWrapper.

private ItemWrapper createItemWrapper(AbstractFormItemType formField, ObjectWrapper objectWrapper) {
    ItemPathType itemPathType = GuiImplUtil.getPathType(formField);
    if (itemPathType == null) {
        getSession().error("Bad form item definition. It has to contain reference to the real attribute");
        LOGGER.error("Bad form item definition. It has to contain reference to the real attribute");
        throw new RestartResponseException(getPageBase());
    }
    ItemPath path = itemPathType.getItemPath();
    ItemDefinition itemDef = objectWrapper.getObject().getDefinition().findItemDefinition(path);
    ItemWrapper itemWrapper = null;
    if (itemDef instanceof PrismContainerDefinition) {
        itemWrapper = objectWrapper.findContainerWrapper(path);
    } else {
        itemWrapper = objectWrapper.findPropertyWrapper(path);
    }
    if (itemWrapper == null) {
        getSession().error("Bad form item definition. No attribute with path: " + path + " was found");
        LOGGER.error("Bad form item definition. No attribute with path: " + path + " was found");
        throw new RestartResponseException(getPageBase());
    }
    applyFormDefinition(itemWrapper, formField);
    return itemWrapper;
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ItemDefinition(com.evolveum.midpoint.prism.ItemDefinition) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 14 with RestartResponseException

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

the class ObjectNameColumn method onClickPerformed.

private void onClickPerformed(AjaxRequestTarget target, IModel<SelectableBean<O>> rowModel) {
    SelectableBean<O> selectableBean = rowModel.getObject();
    O value = selectableBean.getValue();
    if (value == null) {
        OperationResult result = selectableBean.getResult();
        throw new RestartResponseException(new PageOperationResult(result));
    } else {
        if (selectableBean.getResult() != null) {
            throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
        } else {
            ObjectNameColumn.this.onClick(target, rowModel);
        }
    }
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult)

Example 15 with RestartResponseException

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

the class CertCaseDtoProvider method internalSize.

@Override
protected int internalSize() {
    LOGGER.trace("begin::internalSize()");
    int count = 0;
    OperationResult result = new OperationResult(OPERATION_COUNT_OBJECTS);
    try {
        Task task = getPageBase().createSimpleTask(OPERATION_COUNT_OBJECTS);
        count = countCases(campaignOid, null, getPageBase().getPrismContext(), task, result);
    } catch (Exception ex) {
        result.recordFatalError(getPageBase().createStringResource("CertCaseDtoProvider.message.internalSize.fatalError").getString(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        getPageBase().showResult(result, false);
        throw new RestartResponseException(PageError.class);
    }
    LOGGER.trace("end::internalSize()");
    return count;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException)

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