use of org.apache.syncope.core.persistence.api.dao.MalformedPathException in project syncope by apache.
the class JPARealmDAO method findByFullPath.
@Transactional(readOnly = true)
@Override
public Realm findByFullPath(final String fullPath) {
if (SyncopeConstants.ROOT_REALM.equals(fullPath)) {
return getRoot();
}
if (StringUtils.isBlank(fullPath) || !PATH_PATTERN.matcher(fullPath).matches()) {
throw new MalformedPathException(fullPath);
}
Realm root = getRoot();
if (root == null) {
return null;
}
Realm current = root;
for (final String pathElement : fullPath.substring(1).split("/")) {
Optional<Realm> first = findChildren(current).stream().filter(realm -> pathElement.equals(realm.getName())).findFirst();
if (first.isPresent()) {
current = first.get();
} else {
return null;
}
}
return current;
}
Aggregations