本文整理汇总了Java中org.apache.commons.lang.UnhandledException类的典型用法代码示例。如果您正苦于以下问题:Java UnhandledException类的具体用法?Java UnhandledException怎么用?Java UnhandledException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnhandledException类属于org.apache.commons.lang包,在下文中一共展示了UnhandledException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: waitForMetric
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public static void waitForMetric(final JMXGet jmx, final String metricName, final int expectedValue)
throws TimeoutException, InterruptedException {
GenericTestUtils.waitFor(new Supplier<Boolean>() {
@Override
public Boolean get() {
try {
final int currentValue = Integer.parseInt(jmx.getValue(metricName));
LOG.info("Waiting for " + metricName +
" to reach value " + expectedValue +
", current value = " + currentValue);
return currentValue == expectedValue;
} catch (Exception e) {
throw new UnhandledException("Test failed due to unexpected exception", e);
}
}
}, 1000, Integer.MAX_VALUE);
}
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:DFSTestUtil.java
示例2: unescape
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
/**
* <p>Unescapes any Java literals found in the <code>String</code>.
* For example, it will turn a sequence of <code>'\'</code> and
* <code>'n'</code> into a newline character, unless the <code>'\'</code>
* is preceded by another <code>'\'</code>.</p>
*
* @param str the <code>String</code> to unescape, may be null
* @return a new unescaped <code>String</code>, <code>null</code> if null string input
*/
public static String unescape(String str) {
if (str == null) {
return null;
}
try {
StringWriter writer = new StringWriter(str.length());
unescapeJava(writer, str);
return writer.toString();
}
catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
throw new UnhandledException(ioe);
}
}
开发者ID:waterguo,项目名称:antsdb,代码行数:25,代码来源:ExprUtil.java
示例3: parseMenuNode
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private String parseMenuNode(int menuIndex, String menuTemplate, Properties menuAttributes,
TagParser tagParser) {
String modeAttribute = menuAttributes.getProperty("mode");
boolean modeIsRead = "read".equalsIgnoreCase(modeAttribute);
boolean modeIsWrite = "write".equalsIgnoreCase(modeAttribute);
boolean menuMode = parserParameters.isMenuMode();
if (menuMode && modeIsRead || !menuMode && modeIsWrite) {
return "";
}
try {
NodeList menuNodes = new NodeList(menuTemplate, parserParameters.getDocumentRequest().getHttpServletRequest(), tagParser);
DocumentRequest documentRequest = parserParameters.getDocumentRequest();
TextDocumentDomainObject document = (TextDocumentDomainObject) documentRequest.getDocument();
final MenuDomainObject menu = document.getMenu(menuIndex);
StringWriter contentWriter = new StringWriter();
nodeMenu(new SimpleElement("menu", menuAttributes, menuNodes), contentWriter, menu, new Perl5Matcher(), tagParser);
String content = contentWriter.toString();
return addMenuAdmin(menuIndex, menuMode, content, menu, documentRequest.getHttpServletRequest(), documentRequest.getHttpServletResponse(), menuAttributes.getProperty("label"));
} catch (Exception e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:24,代码来源:MenuParser.java
示例4: tagVelocity
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private String tagVelocity(String content) {
VelocityEngine velocityEngine = service.getVelocityEngine(parserParameters.getDocumentRequest().getUser());
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("request", parserParameters.getDocumentRequest().getHttpServletRequest());
velocityContext.put("response", parserParameters.getDocumentRequest().getHttpServletResponse());
velocityContext.put("viewing", viewing);
velocityContext.put("document", viewing.getTextDocument());
velocityContext.put("util", new VelocityTagUtil());
StringWriter stringWriter = new StringWriter();
try {
velocityEngine.init();
velocityEngine.evaluate(velocityContext, stringWriter, null, content);
} catch (Exception e) {
throw new UnhandledException(e);
}
return stringWriter.toString();
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:18,代码来源:TagParser.java
示例5: getRoleReferencesForUser
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private RoleId[] getRoleReferencesForUser(UserDomainObject user) {
try {
String sqlStr = SQL_SELECT_ALL_ROLES + ", user_roles_crossref"
+ " WHERE user_roles_crossref.role_id = roles.role_id"
+ " AND user_roles_crossref.user_id = ?";
final Object[] parameters = new String[]{"" + user.getId()};
String[][] sqlResult = (String[][]) services.getDatabase().execute(new SqlQueryCommand(sqlStr, parameters, Utility.STRING_ARRAY_ARRAY_HANDLER));
RoleId[] roleReferences = new RoleId[sqlResult.length];
for (int i = 0; i < sqlResult.length; i++) {
String[] sqlRow = sqlResult[i];
roleReferences[i] = getRoleReferenceFromSqlResult(sqlRow);
}
return roleReferences;
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:18,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例6: getAllRoleNames
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public String[] getAllRoleNames() {
try {
final Object[] parameters = new String[]{};
String[] roleNamesMinusUsers = services.getProcedureExecutor().executeProcedure(SPROC_GET_ALL_ROLES, parameters, new StringArrayResultSetHandler());
Set<String> roleNamesSet = new HashSet<>();
for (int i = 0; i < roleNamesMinusUsers.length; i += 2) {
String roleName = roleNamesMinusUsers[i + 1];
roleNamesSet.add(roleName);
}
roleNamesSet.add(getRole(RoleId.USERS).getName());
String[] roleNames = roleNamesSet.toArray(new String[roleNamesSet.size()]);
Arrays.sort(roleNames);
return roleNames;
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:22,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例7: getAllUsersWithRole
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public UserDomainObject[] getAllUsersWithRole(RoleDomainObject role) {
try {
if (null == role) {
return new UserDomainObject[]{};
}
final Object[] parameters = new String[]{"" + role.getId()};
String[] usersWithRole = services.getProcedureExecutor().executeProcedure(SPROC_GET_USERS_WHO_BELONGS_TO_ROLE, parameters, new StringArrayResultSetHandler());
UserDomainObject[] result = new UserDomainObject[usersWithRole.length / 2];
for (int i = 0; i < result.length; i++) {
String userIdStr = usersWithRole[i * 2];
result[i] = getUser(Integer.parseInt(userIdStr));
}
return result;
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:19,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例8: addRole
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
void addRole(final RoleDomainObject role) throws RoleAlreadyExistsException, NameTooLongException {
try {
final int unionOfPermissionSetIds = getUnionOfRolePermissionIds(role);
final int newRoleId = ((Number) services.getDatabase().execute(new TransactionDatabaseCommand() {
public Object executeInTransaction(DatabaseConnection connection) throws DatabaseException {
return connection.executeUpdateAndGetGeneratedKey(SQL_INSERT_INTO_ROLES, new String[]{
role.getName(),
""
+ unionOfPermissionSetIds});
}
})).intValue();
role.setId(new RoleId(newRoleId));
} catch (IntegrityConstraintViolationException icvse) {
throw new RoleAlreadyExistsException("A role with the name \"" + role.getName()
+ "\" already exists.");
} catch (StringTruncationException stse) {
throw new NameTooLongException("Role name too long: " + role.getName());
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:22,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例9: getUserPhoneNumbers
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public PhoneNumber[] getUserPhoneNumbers(int userToChangeId) {
try {
final Object[] parameters = new String[]{
"" + userToChangeId};
String[][] phoneNumberData = (String[][]) services.getDatabase().execute(new SqlQueryCommand(
"SELECT phones.number, phones.phonetype_id\n"
+ "FROM phones\n"
+ "WHERE phones.user_id = ?", parameters, Utility.STRING_ARRAY_ARRAY_HANDLER
));
List<PhoneNumber> phoneNumbers = new ArrayList<>();
for (String[] row : phoneNumberData) {
String phoneNumberString = row[0];
int phoneTypeId = Integer.parseInt(row[1]);
PhoneNumberType phoneNumberType = PhoneNumberType.getPhoneNumberTypeById(phoneTypeId);
PhoneNumber phoneNumber = new PhoneNumber(phoneNumberString, phoneNumberType);
phoneNumbers.add(phoneNumber);
}
return phoneNumbers.toArray(new PhoneNumber[phoneNumbers.size()]);
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:23,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例10: getUserAdminRolesReferencesForUser
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private RoleId[] getUserAdminRolesReferencesForUser(UserDomainObject loggedOnUser) {
try {
final Object[] parameters = new String[]{"" + loggedOnUser.getId()};
String[] roleIds = (String[]) services.getDatabase().execute(new SqlQueryCommand("SELECT role_id\n"
+ "FROM useradmin_role_crossref\n"
+ "WHERE user_id = ?", parameters, Utility.STRING_ARRAY_HANDLER));
List<RoleId> useradminPermissibleRolesList = new ArrayList<>(roleIds.length);
for (String roleId : roleIds) {
useradminPermissibleRolesList.add(new RoleId(Integer.parseInt(roleId)));
}
return useradminPermissibleRolesList.toArray(new RoleId[useradminPermissibleRolesList.size()]);
} catch (DatabaseException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:18,代码来源:ImcmsAuthenticatorAndUserAndRoleMapper.java
示例11: synchExternalUserInImcms
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private UserDomainObject synchExternalUserInImcms(String loginName, UserDomainObject externalUser,
UserDomainObject imcmsUser) {
externalUser.setImcmsExternal(true);
addExternalRolesToUser(externalUser);
if (null != imcmsUser) {
externalUser.setRoleIds(imcmsUser.getRoleIds());
imcmsAuthenticatorAndUserMapperAndRole.saveUser(loginName, externalUser);
} else {
try {
imcmsAuthenticatorAndUserMapperAndRole.addUser(externalUser);
} catch (UserAlreadyExistsException shouldNotBeThrown) {
throw new UnhandledException(shouldNotBeThrown);
}
}
return imcmsAuthenticatorAndUserMapperAndRole.getUser(loginName);
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:19,代码来源:ExternalizedImcmsAuthenticatorAndUserRegistry.java
示例12: createUserFromLdapAttributes
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private UserDomainObject createUserFromLdapAttributes(Map<String, String> ldapAttributeValues) {
UserDomainObject newlyFoundLdapUser = new UserDomainObject();
PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(newlyFoundLdapUser);
try {
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
if (null == propertyDescriptor.getWriteMethod()) {
continue;
}
String uncapitalizedPropertyName = propertyDescriptor.getName();
String capitalizedPropertyName = StringUtils.capitalize(uncapitalizedPropertyName);
String ldapAttributeName = userPropertyNameToLdapAttributeNameMap.getProperty(capitalizedPropertyName);
if (null != ldapAttributeName) {
String ldapAttributeValue = ldapAttributeValues.get(ldapAttributeName);
if (null != ldapAttributeValue) {
BeanUtils.setProperty(newlyFoundLdapUser, uncapitalizedPropertyName, ldapAttributeValue);
}
}
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new UnhandledException(e);
}
return newlyFoundLdapUser;
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:25,代码来源:LdapUserAndRoleRegistry.java
示例13: classIsSignedByCertificatesInKeyStore
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public static boolean classIsSignedByCertificatesInKeyStore(Class clazz, KeyStore keyStore) {
Object[] signers = clazz.getSigners();
if (null == signers) {
return false;
}
for (Object signer : signers) {
if (!(signer instanceof Certificate)) {
return false;
}
Certificate certificate = (Certificate) signer;
try {
if (null == keyStore.getCertificateAlias(certificate)) {
return false;
}
} catch (KeyStoreException e) {
throw new UnhandledException(e);
}
}
return true;
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:21,代码来源:Utility.java
示例14: sendMail
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
public void sendMail(Mail mail)
throws IOException {
Email email = mail.getMail();
try {
setEncryption(email);
email.setHostName(host);
email.setSmtpPort(port);
email.setCharset("UTF-8");
email.send();
} catch (EmailException e) {
if (Utility.throwableContainsMessageContaining(e, "no object DCH")) {
throw new UnhandledException("\"no object DCH\" Likely cause: the activation jar-file cannot see the mail jar-file. Different ClassLoaders?", e);
} else {
throw new UnhandledException(e);
}
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:20,代码来源:SMTP.java
示例15: getLines
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
/**
* Separate the given string in lines using readline
*
* @param value
* @return list of found lines
*/
public static List<String> getLines(String value) {
final List<String> result = new ArrayList<String>();
if (value != null) {
final BufferedReader br = new BufferedReader(new StringReader(value));
try {
String l = br.readLine();
while (l!=null) {
result.add(l);
l = br.readLine();
}
} catch (IOException e) {
throw new UnhandledException(e);
}
}
return result;
}
开发者ID:hellonico,项目名称:wife,代码行数:23,代码来源:SwiftParseUtils.java
示例16: execute
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
/**
* @param connection the JDBC connection to use
*/
public void execute(Connection connection) {
final Injector injector = createInjector();
final SingleConnectionHibernateHelper hibernateHelper = createHibernateHelper(connection, injector);
final FileDao fileDao = injector.getInstance(FileDao.class);
final Set<DesignFileHandler> handlers = getAllDesignHandlers(fileDao);
final Transaction transaction = hibernateHelper.beginTransaction();
try {
final ArrayDao arrayDao = injector.getInstance(ArrayDao.class);
final List<Long> arrayDesignIds = getArrayDesignIds(hibernateHelper, arrayDao);
hibernateHelper.getCurrentSession().clear();
fixArrayDesigns(handlers, arrayDao, arrayDesignIds);
transaction.commit();
} catch (final Exception e) {
transaction.rollback();
throw new UnhandledException(e);
}
}
开发者ID:NCIP,项目名称:caarray,代码行数:27,代码来源:FixIlluminaGenotypingCsvDesignProbeNamesMigrator.java
示例17: doHibernateExecute
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void doHibernateExecute(final SingleConnectionHibernateHelper hibernateHelper) {
try {
List<Organism> allOrganisms = getAllOrganisms(hibernateHelper);
Map<String, List<Organism>> nameToOrganismsListMap = buildNamesToOrganismsListMap(allOrganisms);
for (List<Organism> organismsWithSameNameList : nameToOrganismsListMap.values()) {
if (organismsWithSameNameList.size() > 1) {
processOrganismsWithSameName(hibernateHelper, organismsWithSameNameList.get(0).getScientificName(),
organismsWithSameNameList);
} else if (organismsWithSameNameList.size() == 1) {
Organism organism = organismsWithSameNameList.get(0);
if (null != organism.getTermSource()
&& !ExperimentOntology.NCBI.getOntologyName().equals(organism.getTermSource().getName())) {
organism.setTermSource(getNcbiTermSource(hibernateHelper));
}
}
}
} catch (Exception exception) {
throw new UnhandledException("Cannot fix the Organisms in DB.", exception);
}
}
开发者ID:NCIP,项目名称:caarray,代码行数:24,代码来源:FixOrganismsMigrator.java
示例18: unescape
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
/**
* <p>
* Unescapes the entities in a <code>String</code>.
* </p>
*
* <p>
* For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return
* "\u00A1"
* </p>
*
* @param str
* The <code>String</code> to escape.
* @return A new escaped <code>String</code>.
*/
public String unescape(String str) {
int firstAmp = str.indexOf('&');
if (firstAmp < 0) {
return str;
} else {
StringWriter stringWriter = createStringWriter(str);
try {
this.doUnescape(stringWriter, str, firstAmp);
} catch (IOException e) {
// This should never happen because ALL the StringWriter methods called by #escape(Writer, String)
// do not throw IOExceptions.
throw new UnhandledException(e);
}
return stringWriter.toString();
}
}
开发者ID:pister,项目名称:wint,代码行数:31,代码来源:Entities.java
示例19: clone
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
@Override
public TemplateNames clone() {
try {
return (TemplateNames) super.clone();
} catch (CloneNotSupportedException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:9,代码来源:TemplateNames.java
示例20: loadFile
import org.apache.commons.lang.UnhandledException; //导入依赖的package包/类
private String loadFile(File file) {
try {
return fileLoader.getCachedFileString(file);
} catch (IOException e) {
throw new UnhandledException(e);
}
}
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:8,代码来源:DefaultProcedureExecutor.java
注:本文中的org.apache.commons.lang.UnhandledException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论