Search in sources :

Example 46 with RestartResponseException

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

the class PageResourceEdit method loadResource.

private ObjectViewDto loadResource() {
    if (!isEditing()) {
        return new ObjectViewDto();
    }
    ObjectViewDto dto;
    try {
        PrismObject<ResourceType> resource = loadResource(null);
        String xml = getPrismContext().serializeObjectToString(resource, PrismContext.LANG_XML);
        dto = new ObjectViewDto(resource.getOid(), WebComponentUtil.getName(resource), resource, xml);
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource", ex);
        throw new RestartResponseException(PageResources.class);
    }
    return dto;
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 47 with RestartResponseException

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

the class DynamicFormPanel method initialize.

private void initialize(final PrismObject<O> prismObject, String formOid, Form<?> mainForm, final Task task, final PageBase parentPage) {
    if (prismObject == null) {
        getSession().error(getString("DynamicFormPanel.object.must.not.be.null"));
        throw new RestartResponseException(parentPage);
    }
    //		setParent(parentPage);
    form = loadForm(formOid, task, parentPage);
    if (form == null || form.getFormDefinition() == null) {
        LOGGER.debug("No form or form definition; form OID = {}", formOid);
        // to avoid wicket exceptions
        add(new Label(ID_FORM_FIELDS));
        return;
    }
    final ObjectWrapperFactory owf = new ObjectWrapperFactory(parentPage);
    ObjectWrapper<O> objectWrapper = createObjectWrapper(owf, task, prismObject);
    wrapperModel = new LoadableModel<ObjectWrapper<O>>() {

        private static final long serialVersionUID = 1L;

        @Override
        protected ObjectWrapper<O> load() {
            return objectWrapper;
        }
    };
    initLayout(mainForm, parentPage);
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) Label(org.apache.wicket.markup.html.basic.Label)

Example 48 with RestartResponseException

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

the class PageAccounts method loadResources.

private List<ResourceItemDto> loadResources() {
    List<ResourceItemDto> resources = new ArrayList<>();
    OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
    try {
        List<PrismObject<ResourceType>> objects = getModelService().searchObjects(ResourceType.class, null, SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), createSimpleTask(OPERATION_LOAD_RESOURCES), result);
        if (objects != null) {
            for (PrismObject<ResourceType> object : objects) {
                StringBuilder nameBuilder = new StringBuilder(WebComponentUtil.getName(object));
                PrismProperty<OperationResultType> fetchResult = object.findProperty(ResourceType.F_FETCH_RESULT);
                if (fetchResult != null) {
                    nameBuilder.append(" (");
                    nameBuilder.append(fetchResult.getRealValue().getStatus());
                    nameBuilder.append(")");
                }
                resources.add(new ResourceItemDto(object.getOid(), nameBuilder.toString()));
            }
        }
        result.recordSuccess();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resources", ex);
        result.recordFatalError("Couldn't load resources, reason: " + ex.getMessage(), ex);
    } finally {
        if (result.isUnknown()) {
            result.computeStatus();
        }
    }
    Collections.sort(resources);
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result, false);
        throw new RestartResponseException(PageDashboard.class);
    }
    return resources;
}
Also used : ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) 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) PrismObject(com.evolveum.midpoint.prism.PrismObject) ResourceItemDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ResourceItemDto) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)

Example 49 with RestartResponseException

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

the class PageAccounts method createFilesModel.

private LoadableModel<List<String>> createFilesModel() {
    return new LoadableModel<List<String>>(false) {

        @Override
        protected List<String> load() {
            String[] filesArray;
            try {
                MidpointConfiguration config = getMidpointConfiguration();
                File exportFolder = new File(config.getMidpointHome() + "/export");
                filesArray = exportFolder.list(new FilenameFilter() {

                    @Override
                    public boolean accept(java.io.File dir, String name) {
                        return name.endsWith("xml");
                    }
                });
            } catch (Exception ex) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list files", ex);
                getSession().error("Couldn't list files, reason: " + ex.getMessage());
                throw new RestartResponseException(PageDashboard.class);
            }
            if (filesArray == null) {
                return new ArrayList<>();
            }
            List<String> list = Arrays.asList(filesArray);
            Collections.sort(list);
            return list;
        }
    };
}
Also used : FilenameFilter(java.io.FilenameFilter) RestartResponseException(org.apache.wicket.RestartResponseException) MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) PageDashboard(com.evolveum.midpoint.web.page.admin.home.PageDashboard) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) File(org.apache.wicket.util.file.File) 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)

Example 50 with RestartResponseException

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

the class PageDebugView method initObjectViewObject.

private LoadableModel<ObjectViewDto<?>> initObjectViewObject() {
    return new LoadableModel<ObjectViewDto<?>>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ObjectViewDto<?> load() {
            ObjectViewDto<?> objectViewDto = new ObjectViewDto<>();
            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();
            try {
                MidPointApplication application = PageDebugView.this.getMidpointApplication();
                Class<? extends ObjectType> type = getTypeFromParameters();
                GetOperationOptionsBuilder optionsBuilder = getSchemaService().getOperationOptionsBuilder().raw().resolveNames().tolerateRawData();
                if (getPageParameters().get(PARAM_SHOW_ALL_ITEMS).toBoolean(true)) {
                    optionsBuilder = optionsBuilder.retrieve();
                }
                PrismObject<? extends ObjectType> object = getModelService().getObject(type, objectOid.toString(), optionsBuilder.build(), task, result);
                PrismContext context = application.getPrismContext();
                String lex = context.serializerFor(dataLanguage).serialize(object);
                objectViewDto = new ObjectViewDto<>(object.getOid(), WebComponentUtil.getName(object), object, lex);
                result.recomputeStatus();
            } catch (Exception ex) {
                result.recordFatalError(getString("WebModelUtils.couldntLoadObject"), ex);
            }
            showResult(result, false);
            if (!WebComponentUtil.isSuccessOrHandledErrorOrWarning(result)) {
                showResult(result, false);
                throw new RestartResponseException(PageDebugList.class);
            }
            return objectViewDto;
        }
    };
}
Also used : Task(com.evolveum.midpoint.task.api.Task) 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) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) StringValue(org.apache.wicket.util.string.StringValue) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder)

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