本文整理汇总了Java中permafrost.tundra.lang.ExceptionHelper类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionHelper类的具体用法?Java ExceptionHelper怎么用?Java ExceptionHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionHelper类属于permafrost.tundra.lang包,在下文中一共展示了ExceptionHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns the global variable value associated with the given key.
*
* @param key The key for the value to be returned.
* @return The global variable value associated with the given key.
* @throws ServiceException If a password decryption or global variable error occurs.
*/
public static String get(String key) throws ServiceException {
String value = null;
if (isSupported() && key != null) {
try {
GlobalVariablesManager globalVariablesManager = GlobalVariablesManager.getInstance();
if (globalVariablesManager.globalVariableExists(key)) {
GlobalVariables.GlobalVariableValue variable = globalVariablesManager.getGlobalVariableValue(key);
value = variable.getValue();
if (variable.isSecure()) {
PasswordManager passwordManager = OutboundPasswordStore.getStore();
WmSecureString password = passwordManager.retrievePassword(value);
value = password.toString();
}
}
} catch (Exception ex) {
ExceptionHelper.raise(ex);
}
}
return value;
}
示例2: create
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Creates a new service in the given package with the given name.
*
* @param packageName The name of the package to create the service in.
* @param serviceName The fully-qualified name of the service to be created.
* @param type The type of service to be created.
* @param subtype The subtype of service to be created.
* @throws ServiceException If an error creating the service occurs.
*/
private static void create(String packageName, String serviceName, String type, String subtype) throws ServiceException {
if (!PackageHelper.exists(packageName)) {
throw new IllegalArgumentException("package does not exist: " + packageName);
}
if (NodeHelper.exists(serviceName)) throw new IllegalArgumentException("node already exists: " + serviceName);
NSName service = NSName.create(serviceName);
if (type == null) type = NSServiceType.SVC_FLOW;
if (subtype == null) subtype = NSServiceType.SVCSUB_UNKNOWN;
NSServiceType serviceType = NSServiceType.create(type, subtype);
try {
ServerAPI.registerService(packageName, service, true, serviceType, null, null, null);
} catch (ServiceSetupException ex) {
ExceptionHelper.raise(ex);
}
}
示例3: respond
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Sets the HTTP response status, headers, and body for the current service invocation.
*
* @param code The HTTP response status code to be returned.
* @param message The HTTP response status message to be returned; if null, the standard message for the given
* code will be used.
* @param headers The HTTP headers to be returned; if null, no custom headers will be added to the response.
* @param content The HTTP response body to be returned.
* @param contentType The MIME content type of the response body being returned.
* @param charset The character set used if a text response is being returned.
* @throws ServiceException If an I/O error occurs.
*/
public static void respond(int code, String message, IData headers, InputStream content, String contentType, Charset charset) throws ServiceException {
try {
HttpHeader response = Service.getHttpResponseHeader();
if (response == null) {
// service was not invoked via HTTP, so throw an exception for HTTP statuses >= 400
if (code >= 400) ExceptionHelper.raise(StringHelper.normalize(content, charset));
} else {
setResponseStatus(response, code, message);
setContentType(response, contentType, charset);
setHeaders(response, headers);
setResponseBody(response, content);
}
} catch (IOException ex) {
ExceptionHelper.raise(ex);
}
}
示例4: invoke
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Invokes the given service with the given pipeline synchronously.
*
* @param service The service to be invoked.
* @param pipeline The input pipeline used when invoking the service.
* @param raise If true will rethrow exceptions thrown by the invoked service.
* @param clone If true the pipeline will first be cloned before being used by the invocation.
* @param logError Logs a caught exception if true and raise is false, otherwise exception is not logged.
* @return The output pipeline returned by the service invocation.
* @throws ServiceException If raise is true and the service throws an exception while being invoked.
*/
public static IData invoke(String service, IData pipeline, boolean raise, boolean clone, boolean logError) throws ServiceException {
if (service != null) {
if (pipeline == null) pipeline = IDataFactory.create();
try {
IDataUtil.merge(Service.doInvoke(NSName.create(service), normalize(pipeline, clone)), pipeline);
} catch (Exception exception) {
if (raise) {
ExceptionHelper.raise(exception);
} else {
pipeline = addExceptionToPipeline(pipeline, exception);
if (logError) ServerAPI.logError(exception);
}
}
}
return pipeline;
}
示例5: join
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Waits for an asynchronously invoked service to complete.
*
* @param serviceThread The service thread to wait on to finish.
* @param raise If true rethrows any exception thrown by the invoked service.
* @return The output pipeline from the service invocation executed by the given thread.
* @throws ServiceException If raise is true and an error occurs when waiting on the thread to finish.
*/
public static IData join(ServiceThread serviceThread, boolean raise) throws ServiceException {
IData pipeline = null;
if (serviceThread != null) {
try {
pipeline = serviceThread.getIData();
} catch (Throwable exception) {
if (raise) {
ExceptionHelper.raise(exception);
} else {
pipeline = addExceptionToPipeline(null, exception);
}
}
}
return pipeline;
}
示例6: get
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns the partner profile associated with the given internal ID from the Trading Networks database.
*
* @param id An internal ID associated with the partner profile to be returned.
* @return The partner profile associated with the given internal ID, or null if no profile for
* this ID exists.
* @throws ServiceException If a database error occurs.
*/
public static Profile get(String id) throws ServiceException {
if (id == null) return null;
Profile profile = null;
try {
// if the id is null or doesn't exist, this call returns null
ProfileSummary summary = ProfileStore.getProfileSummary(id);
if (summary != null) profile = ProfileStore.getProfile(id);
} catch(ProfileStoreException ex) {
ExceptionHelper.raise(ex);
}
return profile;
}
示例7: getExternalIDTypes
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns all Trading Networks external ID types as a map, where ID is the key to the map.
*
* @return All registered external ID types in Trading Networks by ID.
* @throws ServiceException If a database error occurs.
*/
private static Map<Integer, String> getExternalIDTypes() throws ServiceException {
Map<Integer, String> output = new TreeMap<Integer, String>();
try {
Hashtable types = LookupStore.getExternalIDTypes();
Enumeration keys = types.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
Integer value = (Integer)types.get(key);
output.put(value, key);
}
} catch(LookupStoreException ex) {
ExceptionHelper.raise(ex);
}
return output;
}
示例8: log
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Adds an activity log statement to the given BizDocEnvelope.
* TODO: convert this to a pure java service, rather than an invoke of a flow service.
*
* @param bizdoc The BizDocEnvelope to add the activity log statement to.
* @param messageType The type of message to be logged.
* @param messageClass The class of the message to be logged.
* @param messageSummary The summary of the message to be logged.
* @param messageDetails The detail of the message to be logged.
* @throws ServiceException If an error occurs while logging.
*/
public static void log(BizDocEnvelope bizdoc, String messageType, String messageClass, String messageSummary, String messageDetails) throws ServiceException {
IData input = IDataFactory.create();
IDataCursor cursor = input.getCursor();
IDataUtil.put(cursor, "$bizdoc", bizdoc);
IDataUtil.put(cursor, "$type", messageType);
IDataUtil.put(cursor, "$class", messageClass);
IDataUtil.put(cursor, "$summary", messageSummary);
IDataUtil.put(cursor, "$message", messageDetails);
cursor.destroy();
try {
Service.doInvoke(LOG_SERVICE, input);
} catch (Exception ex) {
ExceptionHelper.raise(ex);
}
}
示例9: removeContentPart
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Deletes the given BizDocContentPart from the Trading Networks database.
*
* @param document The BizDocEnvelope whose content part is to be deleted.
* @param partName The name of the content part to be deleted.
* @throws ServiceException If a database error occurs.
*/
public static void removeContentPart(BizDocEnvelope document, String partName) throws ServiceException {
if (document == null || partName == null) return;
Connection connection = null;
PreparedStatement statement = null;
try {
connection = Datastore.getConnection();
statement = connection.prepareStatement(DELETE_BIZDOC_CONTENT_SQL);
statement.clearParameters();
SQLWrappers.setCharString(statement, 1, document.getInternalId());
SQLWrappers.setCharString(statement, 2, partName);
statement.executeUpdate();
connection.commit();
} catch (SQLException ex) {
connection = Datastore.handleSQLException(connection, ex);
ExceptionHelper.raise(ex);
} finally {
SQLWrappers.close(statement);
Datastore.releaseConnection(connection);
}
}
示例10: validate
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns true if the given string can be parsed as a decimal number.
*
* @param decimal The string to validate.
* @param decimalPattern A java.text.DecimalFormat pattern string describing the format of the given decimal string.
* @param locale The locale to use if the string is only parseable in this localized format.
* @param raise True if an exception should be thrown if the string is not a valid decimal number.
* @return True if the string can be parsed as a decimal number, otherwise false.
* @throws ServiceException If raise is true and the given string is not a valid decimal number.
*/
public static boolean validate(String decimal, String decimalPattern, Locale locale, boolean raise) throws ServiceException {
boolean valid = false;
try {
if (decimal != null) {
parse(decimal, decimalPattern, locale);
valid = true;
}
} catch(Exception ex) {
if (raise) ExceptionHelper.raise(ex);
}
return valid;
}
示例11: validate
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns true if the given string can be parsed as a integer number.
*
* @param integer The string to validate.
* @param raise True if an exception should be thrown if the string is not a valid integer number.
* @return True if the string can be parsed as a integer number, otherwise false.
* @throws ServiceException If raise is true and the given string is not a valid integer number.
*/
public static boolean validate(String integer, boolean raise) throws ServiceException {
boolean valid = false;
try {
if (integer != null) {
parse(integer);
valid = true;
}
} catch (NumberFormatException ex) {
if (raise) ExceptionHelper.raise(ex);
}
return valid;
}
示例12: validate
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns true if the given string is a valid MIME type, optionally throwing an exception if the string is
* invalid.
*
* @param string The string to validate.
* @param raise Whether an exception should be thrown if the string is an invalid MIME type.
* @return True if the string is a well-formed MIME type.
* @throws ServiceException If raise is true and the given string is an invalid MIME type.
*/
public static boolean validate(String string, boolean raise) throws ServiceException {
boolean valid = false;
if (string != null) {
try {
MimeType type = new MimeType(string);
valid = true;
} catch (MimeTypeParseException ex) {
if (raise) ExceptionHelper.raise(ex);
}
}
return valid;
}
示例13: create
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Creates a new group with the given name unless it already exists.
*
* @param name The group name.
* @throws ServiceException If the group cannot be created.
*/
public static synchronized void create(String name) throws ServiceException {
try {
UserManager.addGroup(name);
} catch(Exception ex) {
ExceptionHelper.raise(ex);
}
}
示例14: resolve
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Resolves the given domain name or internet address, returning an IData representation.
*
* @param name The domain name or internet address to be resolved.
* @return An IData representation of the resolved address, containing the following keys: $domain, $host, $ip.
* @throws ServiceException If the address could not be resolved.
*/
public static IData resolve(String name) throws ServiceException {
IData output = null;
try {
output = InternetAddress.resolve(name).getIData();
} catch (UnknownHostException ex) {
ExceptionHelper.raise(ex);
}
return output;
}
示例15: localhost
import permafrost.tundra.lang.ExceptionHelper; //导入依赖的package包/类
/**
* Returns an IData representation of the localhost internet domain name and address.
*
* @return An IData representation of the localhost address, containing the following keys: $domain, $host, $ip.
* @throws ServiceException If the localhost address could not be resolved.
*/
public static IData localhost() throws ServiceException {
IData output = null;
try {
output = InternetAddress.localhost().getIData();
} catch (UnknownHostException ex) {
ExceptionHelper.raise(ex);
}
return output;
}