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);
}
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);
}
}
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);
}
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);
}
}
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;
}
Aggregations