Java Code Examples for org.apache.commons.lang3.BooleanUtils#toInteger()

The following examples show how to use org.apache.commons.lang3.BooleanUtils#toInteger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChannelSoftwareHandler.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns whether the channel may be managed by the given user.
 * @param loggedInUser The current user
 * @param channelLabel The label for the channel in question
 * @param login The login for the user in question
 * @return whether the channel may be managed by the given user.
 * @throws FaultException thrown if
 *   - The loggedInUser doesn't have permission to perform this action
 *   - The login, sessionKey, or channelLabel is invalid
 *
 * @xmlrpc.doc Returns whether the channel may be managed by the given user.
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("string", "channelLabel", "label of the channel")
 * @xmlrpc.param #param_desc("string", "login", "login of the target user")
 * @xmlrpc.returntype #param_desc("int", "status", "1 if manageable, 0 if not")
 */
public int isUserManageable(User loggedInUser, String channelLabel,
        String login) throws FaultException {
    User target = XmlRpcUserHelper.getInstance().lookupTargetUser(
            loggedInUser, login);

    Channel channel = lookupChannelByLabel(loggedInUser.getOrg(), channelLabel);
    if (!channel.isCustom()) {
        throw new InvalidChannelException(
                "Manageable flag is relevant for custom channels only.");
    }
    //Verify permissions
    if (!(UserManager.verifyChannelAdmin(loggedInUser, channel) ||
          loggedInUser.hasRole(RoleFactory.CHANNEL_ADMIN))) {
        throw new PermissionCheckFailureException();
    }

    boolean flag = ChannelManager.verifyChannelManage(target, channel.getId());
    return BooleanUtils.toInteger(flag);
}
 
Example 2
Source File: EmmActionDaoImpl.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public List<EmmAction> getActionList(int companyID, String sortBy, boolean order, Boolean activenessFilter) {
	String sortColumn;

	if (StringUtils.isEmpty(sortBy)) {
		sortBy = "shortname";
	}

	sortColumn = "r." + sortBy;
	if (VARCHAR_COLUMNS.contains(sortBy)) {
		sortColumn = "UPPER( " + sortColumn + " )";
	}

	String sqlStatement = "SELECT r.company_id, r.action_id, r.shortname, r.description, r.creation_date, r.change_date, r.active, count(u.form_id) used"
			+ " FROM rdir_action_tbl r"
				+ " LEFT JOIN userform_tbl u ON (u.startaction_id = r.action_id OR u.endaction_id = r.action_id)"
			+ " WHERE r.company_id = ? AND r.deleted = 0" + (activenessFilter == null ? "" : " AND r.active = " + BooleanUtils.toInteger(activenessFilter))
			+ " GROUP BY r.company_id, r.action_id, r.shortname, r.description, r.creation_date, r.change_date, r.active"
			+ " ORDER BY " + sortColumn + " " + (order ? "ASC" : "DESC") + ", r.action_id ASC";

	return select(logger, sqlStatement, (resultSet, i) -> {
		EmmAction newBean = new EmmActionImpl();
		newBean.setId(resultSet.getInt("action_id"));
		newBean.setCompanyID(resultSet.getInt("company_id"));
		newBean.setShortname(resultSet.getString("shortname"));
		newBean.setDescription(resultSet.getString("description"));
		newBean.setUsed(resultSet.getInt("used"));
		newBean.setCreationDate(resultSet.getTimestamp("creation_date"));
		newBean.setChangeDate(resultSet.getTimestamp("change_date"));
		newBean.setIsActive(resultSet.getInt("active") == 1);
		if (newBean.getUsed() > 0) {
			newBean.setFormNames(getUserFormNames(newBean.getId(), companyID));
		} else {
			newBean.setFormNames("");
		}
		return newBean;
	}, companyID);
}
 
Example 3
Source File: ChannelSoftwareHandler.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns whether the channel may be subscribed to by the given user.
 * @param loggedInUser The current user
 * @param channelLabel The label for the channel in question
 * @param login The login for the user in question
 * @return whether the channel may be subscribed to by the given user.
 * @throws FaultException thrown if
 *   - The loggedInUser doesn't have permission to perform this action
 *   - The login, sessionKey, or channelLabel is invalid
 *
 * @xmlrpc.doc Returns whether the channel may be subscribed to by the given user.
 * @xmlrpc.param #session_key()
 * @xmlrpc.param #param_desc("string", "channelLabel", "label of the channel")
 * @xmlrpc.param #param_desc("string", "login", "login of the target user")
 * @xmlrpc.returntype #param_desc("int", "status", "1 if subscribable, 0 if not")
 */
public int isUserSubscribable(User loggedInUser, String channelLabel,
        String login) throws FaultException {
    User target = XmlRpcUserHelper.getInstance().lookupTargetUser(
            loggedInUser, login);

    Channel channel = lookupChannelByLabel(loggedInUser.getOrg(), channelLabel);
    //Verify permissions
    if (!(UserManager.verifyChannelAdmin(loggedInUser, channel) ||
          loggedInUser.hasRole(RoleFactory.CHANNEL_ADMIN))) {
        throw new PermissionCheckFailureException();
    }

    boolean flag = ChannelManager.verifyChannelSubscribe(target, channel.getId());
    return BooleanUtils.toInteger(flag);
}
 
Example 4
Source File: EhCacheTicketRegistry.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 * @see Cache#getKeysWithExpiryCheck()
 */
@Override
public int sessionCount() {
    return BooleanUtils.toInteger(this.supportRegistryState, this.ticketGrantingTicketsCache
            .getKeysWithExpiryCheck().size(), super.sessionCount());
}
 
Example 5
Source File: EhCacheTicketRegistry.java    From springboot-shiro-cas-mybatis with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 * @see Cache#getKeysWithExpiryCheck()
 */
@Override
public int serviceTicketCount() {
    return BooleanUtils.toInteger(this.supportRegistryState, this.serviceTicketsCache.getKeysWithExpiryCheck()
            .size(), super.serviceTicketCount());
}
 
Example 6
Source File: TestHandler.java    From uyuni with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check whether the xmlrpc server env is hosted or not.
 *
 * @return 1 if system is a satellite.
 */
public int envIsSatellite() {
    return BooleanUtils.toInteger(true);
}