Search in sources :

Example 46 with SchemaException

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

the class Construction method evaluateAttributes.

private void evaluateAttributes(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    attributeMappings = new ArrayList<>();
    // assignments.size(), assignments});
    for (ResourceAttributeDefinitionType attribudeDefinitionType : getConstructionType().getAttribute()) {
        QName attrName = ItemPathUtil.getOnlySegmentQName(attribudeDefinitionType.getRef());
        if (attrName == null) {
            throw new SchemaException("No attribute name (ref) in attribute definition in account construction in " + getSource());
        }
        if (!attribudeDefinitionType.getInbound().isEmpty()) {
            throw new SchemaException("Cannot process inbound section in definition of attribute " + attrName + " in account construction in " + getSource());
        }
        MappingType outboundMappingType = attribudeDefinitionType.getOutbound();
        if (outboundMappingType == null) {
            throw new SchemaException("No outbound section in definition of attribute " + attrName + " in account construction in " + getSource());
        }
        Mapping<? extends PrismPropertyValue<?>, ? extends PrismPropertyDefinition<?>> attributeMapping = evaluateAttribute(attribudeDefinitionType, task, result);
        if (attributeMapping != null) {
            attributeMappings.add(attributeMapping);
        }
    }
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) ResourceAttributeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType)

Example 47 with SchemaException

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

the class Construction method evaluateAssociations.

private void evaluateAssociations(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
    associationMappings = new ArrayList<>();
    for (ResourceObjectAssociationType associationDefinitionType : getConstructionType().getAssociation()) {
        QName assocName = ItemPathUtil.getOnlySegmentQName(associationDefinitionType.getRef());
        if (assocName == null) {
            throw new SchemaException("No association name (ref) in association definition in construction in " + getSource());
        }
        MappingType outboundMappingType = associationDefinitionType.getOutbound();
        if (outboundMappingType == null) {
            throw new SchemaException("No outbound section in definition of association " + assocName + " in construction in " + getSource());
        }
        Mapping<PrismContainerValue<ShadowAssociationType>, PrismContainerDefinition<ShadowAssociationType>> assocMapping = evaluateAssociation(associationDefinitionType, task, result);
        if (assocMapping != null) {
            associationMappings.add(assocMapping);
        }
    }
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) ResourceObjectAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectAssociationType)

Example 48 with SchemaException

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

the class PageTasks method synchronizeTasksPerformed.

private void synchronizeTasksPerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_SYNCHRONIZE_TASKS);
    try {
        getTaskService().synchronizeTasks(result);
        result.computeStatus();
        if (result.isSuccess()) {
            // brutal hack - the subresult's message contains statistics
            result.recordStatus(OperationResultStatus.SUCCESS, result.getLastSubresult().getMessage());
        }
    } catch (RuntimeException | SchemaException | SecurityViolationException e) {
        result.recordFatalError("Couldn't synchronize tasks", e);
    }
    showResult(result);
    //refresh feedback and table
    refreshTables(target);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 49 with SchemaException

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

the class SearchFilterType method parseFromXNode.

public void parseFromXNode(XNode xnode, PrismContext prismContext) throws SchemaException {
    if (xnode == null || xnode.isEmpty()) {
        this.filterClauseXNode = null;
        this.description = null;
    } else {
        if (!(xnode instanceof MapXNode)) {
            throw new SchemaException("Cannot parse filter from " + xnode);
        }
        MapXNode xmap = (MapXNode) xnode;
        XNode xdesc = xmap.get(SearchFilterType.F_DESCRIPTION);
        if (xdesc != null) {
            if (xdesc instanceof PrimitiveXNode<?>) {
                String desc = ((PrimitiveXNode<String>) xdesc).getParsedValue(DOMUtil.XSD_STRING, String.class);
                setDescription(desc);
            } else {
                throw new SchemaException("Description must have a primitive value");
            }
        }
        MapXNode xfilter = new MapXNode();
        for (Entry<QName, XNode> entry : xmap.entrySet()) {
            if (!QNameUtil.match(entry.getKey(), SearchFilterType.F_DESCRIPTION) && !QNameUtil.match(entry.getKey(), new QName("condition"))) {
                xfilter.put(entry.getKey(), entry.getValue());
            }
        }
        if (xfilter.size() > 1) {
            throw new SchemaException("Filter clause has more than one item: " + xfilter);
        }
        this.filterClauseXNode = xfilter;
        QueryConvertor.parseFilterPreliminarily(xfilter, prismContext);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) QName(javax.xml.namespace.QName) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) XNode(com.evolveum.midpoint.prism.xnode.XNode) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode)

Example 50 with SchemaException

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

the class XmlTypeConverter method polyStringToJava.

/**
     * Parse PolyString from DOM element.
     */
private static PolyString polyStringToJava(Element polyStringElement) throws SchemaException {
    Element origElement = DOMUtil.getChildElement(polyStringElement, PrismConstants.POLYSTRING_ELEMENT_ORIG_QNAME);
    if (origElement == null) {
        // element as the value of orig
        if (DOMUtil.hasChildElements(polyStringElement)) {
            throw new SchemaException("Missing element " + PrismConstants.POLYSTRING_ELEMENT_ORIG_QNAME + " in polystring element " + DOMUtil.getQName(polyStringElement));
        }
        String orig = polyStringElement.getTextContent();
        return new PolyString(orig);
    }
    String orig = origElement.getTextContent();
    String norm = null;
    Element normElement = DOMUtil.getChildElement(polyStringElement, PrismConstants.POLYSTRING_ELEMENT_NORM_QNAME);
    if (normElement != null) {
        norm = normElement.getTextContent();
    }
    return new PolyString(orig, norm);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Element(org.w3c.dom.Element) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

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