当前位置: 首页>>代码示例>>Java>>正文


Java UnhandledException类代码示例

本文整理汇总了Java中org.apache.commons.lang.UnhandledException的典型用法代码示例。如果您正苦于以下问题:Java UnhandledException类的具体用法?Java UnhandledException怎么用?Java UnhandledException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnhandledException类属于org.apache.commons.lang包,在下文中一共展示了UnhandledException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.apache.commons.lang.UnhandledException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。