at.spardat.xma.boot.exc.BRTCodes Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* s IT Solutions AT Spardat GmbH - initial API and implementation
*******************************************************************************/
package at.spardat.xma.boot.exc;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Defines error constants and a method to get a localized text for some of them.
*
* @author CGS
* @version $Id: BRTCodes.java 2647 2008-08-26 13:53:08Z webok $
*/
public class BRTCodes {
/**
* Resource IDs for general messages
*/
public static final String APPLICATION_ERROR_TITLE = "APPLICATION_ERROR_TITLE";
public static final String ERROR_REASON = "ERROR_REASON";
public static final String LOGHINT = "LOGHINT";
// module constant
public static final int MODULE = 1002000;
/**
* RemoteCall, the server could not be contacted
* same ID as boot runtime, but other module
*/
public static final int APPLICATION_ERROR = MODULE + 1;
/**
* RemoteCall, the server could not be contacted
* same ID as boot runtime, but other module
*/
public static final int SERVER_UNREACHABLE = MODULE + 3;
/**
* RemoteCall, the server has been contacted but returned an unknown error
* same ID as boot runtime, but other module
*/
public static final int SERVER_ERROR = MODULE + 4;
/**
* Some Execption was thrown in the client or server side login procedure.
* same ID as boot runtime, but other module
*/
public static final int LOGIN_TECHNICAL_ERROR = MODULE + 201;
/**
* Serverevent is not allowed for the user
* same ID as boot runtime, but other module
*
*/
public static final int PERMISSION_DENIED = MODULE + 202;
/**
* The application version differs between client and server
* and the boot runtime was not able to update the application
*/
public static final int VERSION_UPDATE_ERROR = MODULE + 501;
/**
* component not found in application
*/
public static final int INVALID_CALL_XMA_URI = MODULE + 601;
/**
* component not found in application
*/
public static final int COMPONENT_NOT_FOUND = MODULE + 602;
/**
* component is not accepted as its host is either not in 'boot.transport.hostname.accept'
* or in 'boot.transport.hostname.block'.
*/
public static final int COMPONENT_NOT_ACCEPTED = MODULE + 603;
/**
* Returns true if a provided BaseException code originates from this
* module, i.e., is defined above.
*/
public boolean isXMAExceptionCode (int code) {
return code - (code%1000) == MODULE;
}
private static final String BUNDLE_NAME = "at.spardat.xma.boot.exc.Texts"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME);
/**
* Returns the localized text for a particular code. The resource bundle is
* expected to provide an entry for a key that equals the code minus the
* MODULE constant.
*
* @param code a code defined by one of the constants above
* @return a localized String never null
*/
public static String getText (int code) {
String key = "";
key = String.valueOf (code - MODULE);
return getText( key );
}
public static String getText( String key ) {
try {
return RESOURCE_BUNDLE.getString (key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}