Search in sources :

Example 11 with CompiledGuiProfile

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());
}
Also used : CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 12 with CompiledGuiProfile

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());
}
Also used : ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 13 with CompiledGuiProfile

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;
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionFactory(com.evolveum.midpoint.repo.common.expression.ExpressionFactory) ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Example 14 with CompiledGuiProfile

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;
}
Also used : CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Example 15 with CompiledGuiProfile

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);
    }
}
Also used : CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Aggregations

CompiledGuiProfile (com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 Test (org.testng.annotations.Test)4 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)2 GuiProfiledPrincipal (com.evolveum.midpoint.model.api.authentication.GuiProfiledPrincipal)2 ArrayList (java.util.ArrayList)2 RestartResponseException (org.apache.wicket.RestartResponseException)2 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 AssignmentHolderDetailsModel (com.evolveum.midpoint.gui.impl.page.admin.assignmentholder.AssignmentHolderDetailsModel)1 ModelInteractionService (com.evolveum.midpoint.model.api.ModelInteractionService)1 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)1 Referencable (com.evolveum.midpoint.prism.Referencable)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)1 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)1 VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)1