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());
}
}
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;
}
Aggregations