Change login-restrictions (concurrent User session and license Expiry Date) from user Input

Hi, I checked the login-restriction sample project and i saw you have to specify the number of concurrent user sessions and license expiry date in code (LicenceConfig.java file) see below Cuba 1

I was thinking if can change these value from a screen which allows a user to enter his values then from this update the LicenceConfig.java file values according to user input. Something like this below
Cuba 2

Here is the controller

public class LicenseSetting extends AbstractWindow {

@Inject
private LicenseService licenseService;

@Inject 
private TextField session_txt;
@Inject 
private DateField expiry_date;


int session_num =0;
Date expiry_Date =null;

@Override
public void ready() {
	// TODO Auto-generated method stub
	super.ready();
	
	session_txt.addValueChangeListener(e->{
		
		if(e.getValue() !=null)
		{
			session_num = (int) e.getValue();
		}
	});
	
	expiry_date.addValueChangeListener(e->{
		
		if(e.getValue() !=null)
		{
			expiry_Date = (Date) e.getValue();
		}
	});
}

public void onOkbtnClick() {
	licenseService.changeUserSessionsExpiryDate(session_num, expiry_date);
}

public void onCancelbtnClick() {

}

}

Here is the service

@Override
public boolean changeUserSessionsExpiryDate(int session, Date expiry_date) {
// TODO Auto-generated method stub
try(Transaction tx = persistence.createTransaction())
{
long timeMilli = expiry_date.getTime();

		//session - contains the value of allowed user sessions
		//TimeMilli - contains the License expiryDate to Milliseconds
		//How will i change/set the values to the LicenseConfig.java from the service
		
		tx.commit();
	}
	return false;
}

Hi,
If you change the @Source type to SourceType.DATABASE, then configuration properties will be stored in the database, and you will be able to change them in runtime.
See Using Configuration Interfaces - CUBA Platform. Developer’s Manual and Property Types - CUBA Platform. Developer’s Manual

Also add the setter methods to the configuration interface for the properties you need to change.

Thanks for your assistance,

I have followed the manual as you suggested, the property values are now saved on the Database. However i am only able to change the license.expirationDate, the license.concurrentSessionsLimit gives this message. see below

q1

Here is the configuration interface

@Source(type = SourceType.DATABASE)
public interface LicenseConfig extends Config {

    /**
     *  @return a number of concurrent user sessions allowed by license.
     *  Default value is 3.
     */
    @Property("license.concurrentSessionsLimit")
    @DefaultInt(3)
    Integer getConcurrentSessionsLimit();
    void setconcurrentSessionsLimit(Integer concurrentSessionsLimit);

What can i do with this one

It means that you have specified “license.concurrentSessionsLimit = …” somewhere in the app.properties file, or via system property.
Property value specified via app.properties has higher priority than value from database.

True that, i just removed it and it works just fine.

Thanks again, you help is very much appreciated