001
014
015 package com.liferay.portal.kernel.upgrade.util;
016
017 import com.liferay.portal.kernel.upgrade.StagnantRowException;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.StringUtil;
020
021
024 public class DefaultPKMapper extends ValueMapperWrapper {
025
026 public DefaultPKMapper(ValueMapper valueMapper) {
027 super(valueMapper);
028 }
029
030 @Override
031 public Object getNewValue(Object oldValue) throws Exception {
032 String oldValueString = GetterUtil.getString(String.valueOf(oldValue));
033
034 if (oldValueString.equals("-1") || oldValueString.equals("0") ||
035 oldValueString.equals("")) {
036
037 return new Long(0);
038 }
039
040 try {
041 ValueMapper valueMapper = getValueMapper();
042
043 if (oldValue instanceof String) {
044 oldValue = StringUtil.toLowerCase(oldValueString);
045 }
046
047 return valueMapper.getNewValue(oldValue);
048 }
049 catch (StagnantRowException sre) {
050 return new Long(0);
051 }
052 }
053
054 }