package com.vci.client.ui.exception;
|
|
import java.util.Locale;
|
|
import com.vci.common.exception.LocaleCommonDisplay;
|
import com.vci.common.exception.VciException;
|
import com.vci.corba.common.VCIError;
|
import com.vci.mw.InvocationUtility;
|
|
public class ClientExceptionHandler {
|
|
private static ClientExceptionHandler instance = null;
|
|
private ClientExceptionHandler() {
|
|
}
|
|
public static synchronized ClientExceptionHandler getInstance() {
|
if (instance == null) {
|
instance = new ClientExceptionHandler();
|
}
|
|
return instance;
|
}
|
|
public VCIError getClientString(VCIError vciError, String fileName) {
|
VciException exp = new VciException(vciError.code,
|
vciError.messages);
|
String str = LocaleCommonDisplay.getI18nString(exp, fileName,
|
getClientLocale());
|
vciError.code = str;
|
return vciError;
|
}
|
|
/**
|
* 获取国际化的错误提示信息,将其设置到PLMError的key中
|
* @param plmError
|
* @return
|
*/
|
public VCIError getLocalString(VCIError vciError, String fileName) {
|
VciException exp = new VciException(vciError.code, vciError.messages);
|
String str = LocaleCommonDisplay.getI18nString(exp, fileName, getClientLocale());
|
vciError.code = str;
|
return vciError;
|
}
|
|
private Locale getClientLocale() {
|
Locale locale = null;
|
try {
|
if (InvocationUtility.getInvocation() == null) {
|
return Locale.getDefault();
|
}
|
String language = InvocationUtility.getInvocation().language;
|
if (language == null || language.trim().equals("")) {
|
language = Locale.getDefault().getLanguage();
|
}
|
|
String country = InvocationUtility.getInvocation().country;
|
if (country == null || country.trim().equals("")) {
|
country = Locale.getDefault().getCountry();
|
}
|
locale = new Locale(language, country);
|
} catch (Exception e) {
|
e.printStackTrace();
|
locale = Locale.getDefault();
|
}
|
|
|
return locale;
|
}
|
}
|