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

The following examples show how to use org.apache.commons.lang.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 spacewalk 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 int - 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: EhCacheTicketRegistry.java    From cas4.0.x-server-wechat with Apache License 2.0 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 3
Source File: EhCacheTicketRegistry.java    From cas4.0.x-server-wechat with Apache License 2.0 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 4
Source File: ChannelSoftwareHandler.java    From spacewalk 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 int - 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 5
Source File: TestHandler.java    From spacewalk 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);
}