
net.customware.license.atlassian.restriction.UserCountRestriction Maven / Gradle / Ivy
The newest version!
package net.customware.license.atlassian.restriction;
import net.customware.license.support.simple.SimpleLicenseContent;
import net.customware.license.support.simple.SimpleRestrictionException;
public class UserCountRestriction extends AbstractLicenseRestriction {
@Override
protected void checkRestriction( Object context, SimpleLicenseContent content, Object attributeValue ) throws SimpleRestrictionException {
Number maxUsers = (Number) attributeValue;
// unlimited number of users
if( maxUsers != null && maxUsers.intValue() == -1 )
return ;
if ( maxUsers != null && maxUsers.intValue() > 0 ) {
com.atlassian.license.License license = getLicense( context );
int users = license.getUsers();
if ( users > maxUsers.intValue() )
throw new SimpleRestrictionException( "This license supports " + maxUsers + " users but the Atlassian license allows " + users + "." );
}
}
public static void setMaxUserCount( SimpleLicenseContent content, Integer maxUserCount ) {
content.setAttribute( UserCountRestriction.class, maxUserCount );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy