use of com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile in project midpoint by Evolveum.
the class WebModelServiceUtils method isEnableExperimentalFeature.
public static boolean isEnableExperimentalFeature(ModelInteractionService modelInteractionService, Task task, OperationResult result) {
CompiledGuiProfile adminGuiConfig = null;
try {
adminGuiConfig = modelInteractionService.getCompiledGuiProfile(task, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());
}
if (adminGuiConfig == null) {
return false;
}
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());
}
use of com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile in project midpoint by Evolveum.
the class WebModelServiceUtils method isEnableExperimentalFeature.
public static boolean isEnableExperimentalFeature(Task task, ModelServiceLocator pageBase) {
OperationResult result = task.getResult();
ModelInteractionService mInteractionService = pageBase.getModelInteractionService();
CompiledGuiProfile adminGuiConfig = null;
try {
adminGuiConfig = mInteractionService.getCompiledGuiProfile(task, result);
result.recomputeStatus();
result.recordSuccessIfUnknown();
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Cannot load admin gui config", e);
result.recordPartialError("Cannot load admin gui config. Reason: " + e.getLocalizedMessage());
}
if (adminGuiConfig == null) {
return false;
}
return BooleanUtils.isTrue(adminGuiConfig.isEnableExperimentalFeatures());
}
use of com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile in project midpoint by Evolveum.
the class PageBase method executeResultScriptHook.
private OperationResult executeResultScriptHook(OperationResult result) {
CompiledGuiProfile adminGuiConfiguration = getCompiledGuiProfile();
if (adminGuiConfiguration.getFeedbackMessagesHook() == null) {
return result;
}
FeedbackMessagesHookType hook = adminGuiConfiguration.getFeedbackMessagesHook();
ExpressionType expressionType = hook.getOperationResultHook();
if (expressionType == null) {
return result;
}
String contextDesc = "operation result (" + result.getOperation() + ") script hook";
Task task = getPageTask();
OperationResult topResult = task.getResult();
try {
ExpressionFactory factory = getExpressionFactory();
PrismPropertyDefinition<OperationResultType> outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(ExpressionConstants.OUTPUT_ELEMENT_NAME, OperationResultType.COMPLEX_TYPE);
Expression<PrismPropertyValue<OperationResultType>, PrismPropertyDefinition<OperationResultType>> expression = factory.makeExpression(expressionType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), contextDesc, task, topResult);
VariablesMap variables = new VariablesMap();
OperationResultType resultType = result.createOperationResultType();
variables.put(ExpressionConstants.VAR_INPUT, resultType, OperationResultType.class);
ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task);
PrismValueDeltaSetTriple<PrismPropertyValue<OperationResultType>> outputTriple = expression.evaluate(context, topResult);
if (outputTriple == null) {
return null;
}
Collection<PrismPropertyValue<OperationResultType>> values = outputTriple.getNonNegativeValues();
if (values == null || values.isEmpty()) {
return null;
}
if (values.size() > 1) {
throw new SchemaException("Expression " + contextDesc + " produced more than one value");
}
OperationResultType newResultType = values.iterator().next().getRealValue();
if (newResultType == null) {
return null;
}
return OperationResult.createOperationResult(newResultType);
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
topResult.recordFatalError(e);
if (StringUtils.isEmpty(result.getMessage())) {
topResult.setMessage("Couldn't process operation result script hook.");
}
topResult.addSubresult(result);
LoggingUtils.logUnexpectedException(LOGGER, contextDesc, e);
if (InternalsConfig.nonCriticalExceptionsAreFatal()) {
throw new SystemException(e.getMessage(), e);
} else {
return topResult;
}
}
}
use of com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile in project midpoint by Evolveum.
the class PageAdminObjectDetails method getObjectFormTypes.
public List<ObjectFormType> getObjectFormTypes() {
CompiledGuiProfile adminGuiConfiguration = getCompiledGuiProfile();
ObjectFormsType objectFormsType = adminGuiConfiguration.getObjectForms();
if (objectFormsType == null) {
return null;
}
List<ObjectFormType> objectForms = objectFormsType.getObjectForm();
if (objectForms == null || objectForms.isEmpty()) {
return objectForms;
}
List<ObjectFormType> validObjectForms = new ArrayList<>();
for (ObjectFormType objectForm : objectForms) {
if (isSupportedObjectType(objectForm.getType())) {
validObjectForms.add(objectForm);
}
}
return validObjectForms;
}
use of com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile in project midpoint by Evolveum.
the class SearchFactory method getSearchBoxConfiguration.
private static SearchBoxConfigurationType getSearchBoxConfiguration(ModelServiceLocator modelServiceLocator, QName type, String collectionViewName, Search.PanelType panelType) {
OperationResult result = new OperationResult(LOAD_ADMIN_GUI_CONFIGURATION);
try {
CompiledGuiProfile guiConfig = modelServiceLocator.getModelInteractionService().getCompiledGuiProfile(null, result);
CompiledObjectCollectionView view = guiConfig.findObjectCollectionView(type, collectionViewName);
if (view != null) {
if (Search.PanelType.MEMBER_PANEL.equals(panelType) && view.getAdditionalPanels() != null && view.getAdditionalPanels().getMemberPanel() != null) {
return view.getAdditionalPanels().getMemberPanel().getSearchBoxConfiguration();
}
return view.getSearchBoxConfiguration();
}
return null;
} catch (SchemaException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException ex) {
throw new SystemException(ex);
}
}
Aggregations