Search in sources :

Example 11 with ObjectViewDto

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

the class PageResourceEdit method savePerformed.

private void savePerformed(AjaxRequestTarget target) {
    ObjectViewDto dto = model.getObject();
    if (StringUtils.isEmpty(dto.getXml())) {
        error(getString("pageResourceEdit.message.emptyXml"));
        target.add(getFeedbackPanel());
        return;
    }
    Task task = createSimpleTask(OPERATION_SAVE_RESOURCE);
    OperationResult result = task.getResult();
    try {
        Holder<PrismObject<ResourceType>> objectHolder = new Holder<PrismObject<ResourceType>>(null);
        validateObject(dto.getXml(), objectHolder, PrismContext.LANG_XML, false, result);
        if (result.isAcceptable()) {
            PrismObject<ResourceType> newResource = objectHolder.getValue();
            updateConnectorRef(newResource, task, result);
            if (!isEditing()) {
                //we're adding new resource
                ObjectDelta delta = ObjectDelta.createAddDelta(newResource);
                getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
            } else {
                //we're editing existing resource
                PrismObject<ResourceType> oldResource = dto.getObject();
                ObjectDelta<ResourceType> delta = oldResource.diff(newResource);
                getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), ModelExecuteOptions.createRaw(), task, result);
            }
            result.computeStatus();
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save resource", ex);
        result.recordFatalError("Couldn't save resource.", ex);
    }
    if (WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result);
        setResponsePage(new PageResources(false));
    } else {
        showResult(result);
        target.add(getFeedbackPanel());
    }
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Holder(com.evolveum.midpoint.util.Holder) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectViewDto(com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 12 with ObjectViewDto

use of com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto 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)

Aggregations

ObjectViewDto (com.evolveum.midpoint.web.page.admin.dto.ObjectViewDto)12 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 Task (com.evolveum.midpoint.task.api.Task)4 RestartResponseException (org.apache.wicket.RestartResponseException)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 Holder (com.evolveum.midpoint.util.Holder)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 ChooseTypePanel (com.evolveum.midpoint.web.page.admin.configuration.component.ChooseTypePanel)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ObjectPolicyConfigurationEditor (com.evolveum.midpoint.web.component.ObjectPolicyConfigurationEditor)1 AEPlevel (com.evolveum.midpoint.web.page.admin.configuration.dto.AEPlevel)1 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)1 SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)1