Search in sources :

Example 1 with SchemaException

use of com.evolveum.midpoint.util.exception.SchemaException in project midpoint by Evolveum.

the class DynamicFormPanel method instantiateObject.

private PrismObject<O> instantiateObject(QName objectType, PageBase parentPage) {
    PrismObjectDefinition<O> objectDef = parentPage.getPrismContext().getSchemaRegistry().findObjectDefinitionByType(objectType);
    PrismObject<O> prismObject;
    try {
        prismObject = objectDef.instantiate();
    } catch (SchemaException e) {
        LoggingUtils.logException(LOGGER, "Could not initialize model for forgot password", e);
        throw new RestartResponseException(parentPage);
    }
    return prismObject;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 2 with SchemaException

use of com.evolveum.midpoint.util.exception.SchemaException in project midpoint by Evolveum.

the class PrismPropertyPanel method hasPendingModification.

private boolean hasPendingModification(IModel<IW> model) {
    ItemWrapper propertyWrapper = model.getObject();
    ContainerWrapper containerWrapper = propertyWrapper.getContainer();
    if (containerWrapper == null) {
        // TODO - ok?
        return false;
    }
    ObjectWrapper objectWrapper = containerWrapper.getObject();
    if (objectWrapper == null) {
        return false;
    }
    PrismObject prismObject = objectWrapper.getObject();
    if (!ShadowType.class.isAssignableFrom(prismObject.getCompileTimeClass())) {
        return false;
    }
    PrismProperty objectChange = prismObject.findProperty(ShadowType.F_OBJECT_CHANGE);
    if (objectChange == null || objectChange.getValue() == null) {
        return false;
    }
    ItemPath path = propertyWrapper.getItem().getPath();
    ObjectDeltaType delta = (ObjectDeltaType) objectChange.getValue().getValue();
    try {
        for (ItemDeltaType itemDelta : delta.getItemDelta()) {
            ItemDelta iDelta = DeltaConvertor.createItemDelta(itemDelta, (Class<? extends Objectable>) prismObject.getCompileTimeClass(), prismObject.getPrismContext());
            if (iDelta.getPath().equivalent(path)) {
                return true;
            }
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't check if property has pending modification", ex);
    }
    return false;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with SchemaException

use of com.evolveum.midpoint.util.exception.SchemaException in project midpoint by Evolveum.

the class ObjectWrapperFactory method createObjectWrapper.

public <O extends ObjectType> ObjectWrapper<O> createObjectWrapper(String displayName, String description, PrismObject<O> object, ContainerStatus status, boolean delayContainerCreation, AuthorizationPhaseType authorizationPhase, Task task) {
    if (authorizationPhase == null) {
        authorizationPhase = AuthorizationPhaseType.REQUEST;
    }
    try {
        //        	Task task = modelServiceLocator.createSimpleTask(CREATE_OBJECT_WRAPPER);
        OperationResult result = task.getResult();
        PrismObjectDefinition<O> objectDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectDefinition(object, authorizationPhase, task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Edit definition for {}:\n{}", object, objectDefinitionForEditing.debugDump(1));
        }
        RefinedObjectClassDefinition objectClassDefinitionForEditing = null;
        if (isShadow(object)) {
            PrismReference resourceRef = object.findReference(ShadowType.F_RESOURCE_REF);
            PrismObject<ResourceType> resource = resourceRef.getValue().getObject();
            Validate.notNull(resource, "No resource object in the resourceRef");
            objectClassDefinitionForEditing = modelServiceLocator.getModelInteractionService().getEditObjectClassDefinition((PrismObject<ShadowType>) object, resource, authorizationPhase);
        }
        return createObjectWrapper(displayName, description, object, objectDefinitionForEditing, objectClassDefinitionForEditing, status, delayContainerCreation, result);
    } catch (SchemaException | ConfigurationException | ObjectNotFoundException ex) {
        throw new SystemException(ex);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 4 with SchemaException

use of com.evolveum.midpoint.util.exception.SchemaException in project midpoint by Evolveum.

the class SampleFormFocusTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusModel, LoadableModel<List<AssignmentEditorDto>> assignmentsModel, PageBase pageBase) {
    add(new Label(ID_HEADER, "Object details"));
    WebMarkupContainer body = new WebMarkupContainer("body");
    add(body);
    addPrismPropertyPanel(body, ID_PROP_NAME, FocusType.F_NAME);
    addPrismPropertyPanel(body, ID_PROP_FULL_NAME, UserType.F_FULL_NAME);
    // TODO: create proxy for these operations
    Task task = pageBase.createSimpleTask(OPERATION_SEARCH_ROLES);
    List<PrismObject<RoleType>> availableRoles;
    try {
        availableRoles = pageBase.getModelService().searchObjects(RoleType.class, null, null, task, task.getResult());
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
        task.getResult().recordFatalError(e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load roles", e);
        availableRoles = new ArrayList<>();
    // TODO: better errror reporting
    }
    add(new SimpleRoleSelector<F, RoleType>(ID_ROLES, assignmentsModel, availableRoles));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 5 with SchemaException

use of com.evolveum.midpoint.util.exception.SchemaException in project midpoint by Evolveum.

the class ReportCreateHandlerDto method getReportParams.

public String getReportParams() {
    PrismObject<TaskType> taskObject = taskDto.getTaskType().asPrismObject();
    PrismContainer<ReportParameterType> container = taskObject.findContainer(new ItemPath(TaskType.F_EXTENSION, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
    if (container == null || container.isEmpty()) {
        return null;
    }
    PrismContainerValue<ReportParameterType> pcv = container.getValue();
    PrismContext prismContext = ((MidPointApplication) Application.get()).getPrismContext();
    try {
        return WebXmlUtil.stripNamespaceDeclarations(prismContext.xmlSerializer().serialize(pcv, ReportConstants.REPORT_PARAMS_PROPERTY_NAME));
    } catch (SchemaException e) {
        throw new SystemException("Couldn't serialize report parameters: " + e.getMessage(), e);
    }
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) PrismContext(com.evolveum.midpoint.prism.PrismContext) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ReportParameterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportParameterType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

SchemaException (com.evolveum.midpoint.util.exception.SchemaException)576 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)235 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)214 QName (javax.xml.namespace.QName)132 SystemException (com.evolveum.midpoint.util.exception.SystemException)113 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)100 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)100 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)92 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)89 Task (com.evolveum.midpoint.task.api.Task)87 PrismObject (com.evolveum.midpoint.prism.PrismObject)86 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)69 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)68 ArrayList (java.util.ArrayList)67 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)59 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)49 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)47 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)46 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)34 Test (org.testng.annotations.Test)34