 
                        
        
                        
        net.customware.license.atlassian.exemption.TrialPeriodExemption Maven / Gradle / Ivy
 The newest version!
        
        package net.customware.license.atlassian.exemption;
import java.util.Calendar;
import com.atlassian.license.License;
/**
 * This exemption allows the product to be run without a license for a specified
 * period after a new or renewed license is installed.
 */
public class TrialPeriodExemption extends AbstractLicenseExemption {
    private int trialDays;
    public TrialPeriodExemption( int trialDays ) {
        this.trialDays = trialDays;
    }
    /**
     * The number of days to allow a free trial for.
     * 
     * @return The free trial days.
     */
    public int getTrialDays() {
        return trialDays;
    }
    /**
     * Returns the date the free trial will expire, based on the current
     * Confluence License.
     * 
     * @return
     */
    public Calendar getTrialExpiry( Object context ) {
        License license = getLicense( context );
        if ( license != null ) {
            Calendar date = Calendar.getInstance();
            date.setTime( license.getDateCreated() );
            date.add( Calendar.DAY_OF_YEAR, trialDays );
            return date;
        }
        return null;
    }
    public boolean isExempt( Object context ) {
        Calendar trialExpiry = getTrialExpiry( context );
        if ( trialExpiry != null ) {
            Calendar now = Calendar.getInstance();
            return now.before( trialExpiry );
        }
        return false;
    }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy