Search in sources :

Example 36 with SchemaException

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

the class BeanUnmarshaller method unmarshalPolyStringFromMap.

private Object unmarshalPolyStringFromMap(MapXNode map, Class<?> beanClass, ParsingContext pc) throws SchemaException {
    String orig = map.getParsedPrimitiveValue(QNameUtil.nullNamespace(PolyString.F_ORIG), DOMUtil.XSD_STRING);
    if (orig == null) {
        throw new SchemaException("Null polystring orig in " + map);
    }
    String norm = map.getParsedPrimitiveValue(QNameUtil.nullNamespace(PolyString.F_NORM), DOMUtil.XSD_STRING);
    Object value = new PolyStringType(new PolyString(orig, norm));
    return toCorrectPolyStringClass(value, beanClass, map);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 37 with SchemaException

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

the class YamlLexicalProcessor method createJacksonGenerator.

public YAMLGenerator createJacksonGenerator(StringWriter out) throws SchemaException {
    try {
        MidpointYAMLFactory factory = new MidpointYAMLFactory();
        MidpointYAMLGenerator generator = (MidpointYAMLGenerator) factory.createGenerator(out);
        generator.setPrettyPrinter(new DefaultPrettyPrinter());
        generator.setCodec(configureMapperForSerialization());
        return generator;
    } catch (IOException ex) {
        throw new SchemaException("Schema error during serializing to JSON.", ex);
    }
}
Also used : DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MidpointYAMLGenerator(com.evolveum.midpoint.prism.lex.json.yaml.MidpointYAMLGenerator) MidpointYAMLFactory(com.evolveum.midpoint.prism.lex.json.yaml.MidpointYAMLFactory) IOException(java.io.IOException)

Example 38 with SchemaException

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

the class BeanMarshaller method getHeterogeneousListPropertyName.

// bean should have only two features: "list" attribute and multivalued property into which we should store the elements
@NotNull
<T> QName getHeterogeneousListPropertyName(Class<T> beanClass) throws SchemaException {
    List<String> properties = inspector.getPropOrder(beanClass);
    if (!properties.contains(DOMUtil.IS_LIST_ATTRIBUTE_NAME)) {
        throw new SchemaException("Couldn't unmarshal heterogeneous list into class without '" + DOMUtil.IS_LIST_ATTRIBUTE_NAME + "' attribute. Class: " + beanClass.getName() + " has the following properties: " + properties);
    }
    if (properties.size() > 2) {
        throw new SchemaException("Couldn't unmarshal heterogeneous list into class with more than one property " + "other than '" + DOMUtil.IS_LIST_ATTRIBUTE_NAME + "'. Class " + beanClass.getName() + " has the following properties: " + properties);
    }
    String contentProperty = properties.stream().filter(p -> !DOMUtil.IS_LIST_ATTRIBUTE_NAME.equals(p)).findFirst().orElseThrow(() -> new SchemaException("Couldn't unmarshal heterogeneous list into class without " + "content-holding property. Class: " + beanClass.getName() + "."));
    return new QName(inspector.determineNamespace(beanClass), contentProperty);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) NotNull(org.jetbrains.annotations.NotNull)

Example 39 with SchemaException

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

the class QueryConvertor method parseOrgFilter.

private static <C extends Containerable> OrgFilter parseOrgFilter(MapXNode clauseXMap, PrismContainerDefinition<C> pcd, boolean preliminaryParsingOnly, PrismContext prismContext) throws SchemaException {
    if (Boolean.TRUE.equals(clauseXMap.getParsedPrimitiveValue(ELEMENT_IS_ROOT, DOMUtil.XSD_BOOLEAN))) {
        // TODO check if other content is present
        if (preliminaryParsingOnly) {
            return null;
        } else {
            return OrgFilter.createRootOrg();
        }
    }
    XNode xorgrefnode = clauseXMap.get(ELEMENT_ORG_REF);
    if (xorgrefnode == null) {
        throw new SchemaException("No organization reference defined in the search query.");
    }
    MapXNode xorgrefmap = toMap(xorgrefnode);
    String orgOid = xorgrefmap.getParsedPrimitiveValue(ELEMENT_OID, DOMUtil.XSD_STRING);
    if (orgOid == null || StringUtils.isBlank(orgOid)) {
        throw new SchemaException("No oid attribute defined in the organization reference element.");
    }
    // original (in my opinion incorrect) place
    String scopeString = xorgrefmap.getParsedPrimitiveValue(ELEMENT_SCOPE, DOMUtil.XSD_STRING);
    if (scopeString == null) {
        // here it is placed by the serializer
        scopeString = clauseXMap.getParsedPrimitiveValue(ELEMENT_SCOPE, DOMUtil.XSD_STRING);
    }
    Scope scope = scopeString != null ? Scope.valueOf(scopeString) : null;
    if (preliminaryParsingOnly) {
        return null;
    } else {
        return OrgFilter.createOrg(orgOid, scope);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Scope(com.evolveum.midpoint.prism.query.OrgFilter.Scope)

Example 40 with SchemaException

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

the class QueryConvertor method getPath.

private static ItemPath getPath(MapXNode clauseXMap, QName key) throws SchemaException {
    XNode xnode = clauseXMap.get(key);
    if (xnode == null) {
        return null;
    }
    if (!(xnode instanceof PrimitiveXNode<?>)) {
        throw new SchemaException("Expected that field " + key + " will be primitive, but it is " + xnode.getDesc());
    }
    ItemPathType itemPathType = clauseXMap.getParsedPrimitiveValue(key, ItemPathType.COMPLEX_TYPE);
    return itemPathType != null ? itemPathType.getItemPath() : null;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType)

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