use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageResource method refreshSchemaPerformed.
private void refreshSchemaPerformed(AjaxRequestTarget target) {
Task task = createSimpleTask(OPERATION_REFRESH_SCHEMA);
OperationResult parentResult = new OperationResult(OPERATION_REFRESH_SCHEMA);
try {
ResourceUtils.deleteSchema(resourceModel.getObject(), getModelService(), getPrismContext(), task, parentResult);
// try to load fresh scehma
getModelService().testResource(resourceModel.getObject().getOid(), task);
} catch (ObjectAlreadyExistsException | ObjectNotFoundException | SchemaException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error refreshing resource schema", e);
parentResult.recordFatalError("Error refreshing resource schema", e);
}
parentResult.computeStatus();
showResult(parentResult, "pageResource.refreshSchema.failed");
target.add(getFeedbackPanel());
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class ResourceWizardIssuesModel method load.
@NotNull
@Override
protected WizardIssuesDto load() {
final WizardIssuesDto issuesDto = new WizardIssuesDto();
if (!resourceModel.isLoaded()) {
// e.g. in first two wizard steps (IT PROBABLY DOES NOT WORK AS EXPECTED)
return issuesDto;
}
ResourceValidator validator = wizardPage.getResourceValidator();
ValidationResult validationResult = validator.validate(resourceModel.getObject(), Scope.QUICK, WebComponentUtil.getCurrentLocale(), wizardPage.createSimpleTask("validate"), new OperationResult("validate"));
issuesDto.fillFrom(validationResult);
issuesDto.sortIssues();
return issuesDto;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class TestConnectionMessagesPanel method initResultsModel.
private void initResultsModel(String resourceOid) {
OperationResult result = new OperationResult(OPERATION_TEST_CONNECTION);
List<OpResult> resourceResultsDto = new ArrayList<>();
List<ConnectorStruct> connectorStructs = new ArrayList<>();
if (StringUtils.isNotEmpty(resourceOid)) {
Task task = parentPage.createSimpleTask(OPERATION_TEST_CONNECTION);
try {
result = parentPage.getModelService().testResource(resourceOid, task);
} catch (ObjectNotFoundException e) {
result.recordFatalError("Failed to test resource connection", e);
}
for (OperationResult subresult : result.getSubresults()) {
if (isConnectorResult(subresult)) {
ConnectorStruct connectorStruct = new ConnectorStruct();
connectorStruct.connectorName = (String) subresult.getParams().get(OperationResult.PARAM_NAME);
if (connectorStruct.connectorName == null) {
connectorStruct.connectorName = "";
}
connectorStruct.connectorResultsDto = new ArrayList<>();
for (OperationResult subsubresult : subresult.getSubresults()) {
if (isKnownResult(subsubresult)) {
connectorStruct.connectorResultsDto.add(OpResult.getOpResult(parentPage, subsubresult));
}
}
connectorStructs.add(connectorStruct);
} else if (isKnownResult(subresult)) {
// resource operation
resourceResultsDto.add(OpResult.getOpResult(parentPage, subresult));
}
}
if (result.isSuccess()) {
result.recomputeStatus();
}
}
modelResourceResults = new ListModel<>(resourceResultsDto);
connectorResourceResults = new ListModel<>(connectorStructs);
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class PageAccount method loadAccount.
private ObjectWrapper<ShadowType> loadAccount(PageParameters parameters) {
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ShadowType.F_RESOURCE, GetOperationOptions.createResolve());
StringValue oid = parameters != null ? parameters.get(OnePageParameterEncoder.PARAMETER) : null;
PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, oid.toString(), options, PageAccount.this, task, result);
if (account == null) {
getSession().error(getString("pageAccount.message.cantEditAccount"));
showResult(result);
throw new RestartResponseException(PageResources.class);
}
ObjectWrapper wrapper = ObjectWrapperUtil.createObjectWrapper(null, null, account, ContainerStatus.MODIFYING, task, this);
OperationResultType fetchResult = account.getPropertyRealValue(ShadowType.F_FETCH_RESULT, OperationResultType.class);
wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
wrapper.setShowEmpty(false);
return wrapper;
}
use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.
the class RunReportPopupPanel method runConfirmPerformed.
// private void addFormUpdatingBehavior(FormComponent parent, String id, final IModel<JasperReportParameterDto> model) {
// Component c = parent.get(id);
// if (c == null) {
// return;
// }
// c.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
// }
private void runConfirmPerformed(AjaxRequestTarget target, IModel<ReportDto> model) {
ReportDto reportDto = model.getObject();
PrismContainerDefinition<ReportParameterType> paramContainerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(ReportConstants.REPORT_PARAMS_PROPERTY_NAME);
PrismContainer<ReportParameterType> paramContainer;
try {
paramContainer = paramContainerDef.instantiate();
ReportParameterType reportParam = new ReportParameterType();
PrismContainerValue<ReportParameterType> reportParamValue = reportParam.asPrismContainerValue();
reportParamValue.revive(getPrismContext());
paramContainer.add(reportParamValue);
List<JasperReportParameterDto> params = getParametersView().getModelObject();
for (JasperReportParameterDto paramDto : params) {
if (paramDto.getValue() == null) {
continue;
}
List<JasperReportValueDto> values = paramDto.getValue();
Class<?> paramClass = paramDto.getType();
boolean multivalue = false;
if (List.class.isAssignableFrom(paramClass)) {
paramClass = paramDto.getNestedType();
if (paramClass == null) {
getSession().error("Nested type for list must be defined!");
target.add(getPageBase().getFeedbackPanel());
return;
}
}
QName typeName = getPrismContext().getSchemaRegistry().determineTypeForClass(paramClass);
PrismPropertyDefinitionImpl<?> def = new PrismPropertyDefinitionImpl<>(new QName(ReportConstants.NS_EXTENSION, paramDto.getName()), typeName, getPrismContext());
def.setDynamic(true);
def.setRuntimeSchema(true);
// TODO multivalue is always 'false' here ...
def.setMaxOccurs(multivalue ? -1 : 1);
PrismProperty prop = def.instantiate();
for (JasperReportValueDto paramValue : values) {
Object realValue = paramValue.getValue();
if (realValue == null) {
continue;
}
if (AuditEventType.class.isAssignableFrom(paramClass)) {
paramClass = AuditEventTypeType.class;
realValue = AuditEventType.fromAuditEventType((AuditEventType) realValue);
} else if (AuditEventStage.class.isAssignableFrom(paramClass)) {
paramClass = AuditEventStageType.class;
realValue = AuditEventStage.fromAuditEventStage((AuditEventStage) realValue);
}
prop.addRealValue(realValue);
}
if (!prop.isEmpty()) {
reportParamValue.add(prop);
}
}
} catch (SchemaException | ClassNotFoundException e) {
OperationResult result = new OperationResult("Parameters serialization");
result.recordFatalError("Could not serialize parameters");
getPageBase().showResult(result);
return;
}
runConfirmPerformed(target, reportDto.getObject().asObjectable(), paramContainer);
}
Aggregations