Skip to content

Commit

Permalink
Fix exception when changing report output type
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 13, 2018
1 parent a8b48be commit 71dd769
Showing 1 changed file with 10 additions and 4 deletions.
Expand Up @@ -16,10 +16,12 @@

package com.evolveum.midpoint.repo.sql.helpers.mapper;

import com.evolveum.midpoint.repo.sql.data.common.enums.RExportType;
import com.evolveum.midpoint.repo.sql.data.common.enums.SchemaEnum;
import com.evolveum.midpoint.repo.sql.helpers.modify.MapperContext;
import com.evolveum.midpoint.repo.sql.util.RUtil;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType;
import org.apache.commons.lang.StringUtils;

/**
Expand All @@ -32,10 +34,14 @@ public SchemaEnum map(Enum input, MapperContext context) {
String repoEnumClass = null;
try {
String className = input.getClass().getSimpleName();
className = StringUtils.left(className, className.length() - 4);

repoEnumClass = "com.evolveum.midpoint.repo.sql.data.common.enums.R" + className;
Class clazz = Class.forName(repoEnumClass);
Class clazz;
if (input instanceof ExportType) {
clazz = RExportType.class; // todo fix this brutal hack
} else {
className = StringUtils.left(className, className.length() - 4);
repoEnumClass = "com.evolveum.midpoint.repo.sql.data.common.enums.R" + className;
clazz = Class.forName(repoEnumClass);
}

if (!SchemaEnum.class.isAssignableFrom(clazz)) {
throw new SystemException("Can't translate enum value " + input);
Expand Down

0 comments on commit 71dd769

Please sign in to comment.