[SalesForce] How to call Controller Extension and its method within Schedule Class

I have the following apex class:

public with sharing class AssignPermissionSet{
List<PermissionSetAssignment> p=new List<PermissionSetAssignment>();
private PermissionSet per;
private User u;
private Account acct;
private Boolean insertPermissionSet=false;
private Boolean deletePermissionSet=false;
public AssignPermissionSet(ApexPages.StandardController stdController)
{
Account account1 = (Account)stdController.getRecord();
RecordType rt=[SELECT Id,Name FROM RecordType where Name='Account Group'];
try
{
per=[SELECT Id,Name FROM PermissionSet where Name='Key_Acc_Manager_Custom_Attributes'];
}
catch(Exception e)
{
System.debug('The following exception has occurred:' + e.getMessage());
}

u=[select id,name,(Select Id from PermissionSetAssignments Where PermissionSetID = :per.id)  from user where id =:UserInfo.getUserId() AND IsActive = true];
if (Test.isRunningTest())//This will execute in test class
{
acct=account1;
//This condition will bypass account recordtype while executing test class
if(acct.KeyAccountManager__c!= null && acct.KeyAccountManager__c==u.Id )
{
 insertPermissionSet=true;
}
else 
{
deletePermissionSet = true;

}
}
else
{  
acct = [Select Id,Name,KeyAccountManager__c from Account where Id=:account1.Id AND RecordTypeId=:rt.Id];//this will execute on UI..
//This condition will run only for Accout Group
acct = [Select Id,Name,KeyAccountManager__c from Account where Id=:account1.Id];
if(acct.KeyAccountManager__c!= null && acct.KeyAccountManager__c==u.Id && acct.RecordType.Name=='Account Group')
{
 insertPermissionSet=true;
}
else 
{
deletePermissionSet = true;

}
}


}

public void getPermissionSet()
{
    if(u.PermissionSetAssignments.size() == 0 && insertPermissionSet)
    {  
    p.add( new PermissionSetAssignment(AssigneeId = u.id,PermissionSetId = per.Id) );
    insert p; 
    }
    else if(u.PermissionSetAssignments.size()>0 && deletePermissionSet)
    {
    PermissionSetAssignment per1 = [SELECT AssigneeId,PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId=:u.id AND PermissionSetId =: per.id];
    delete per1;
    }
}

}

This class assigns the permission to the user based on the certain condition &I have to remove the permission after certain interval of time for this I am trying to write a scheduler class like this:

global class schedulePermission implements Schedulable 
{

//PermissionSet per1=[SELECT Id,Name FROM PermissionSet where Name='Key_Acc_Manager_Custom_Attributes'];
//User u1=[select id,name,(Select Id from PermissionSetAssignments Where PermissionSetID = :per1.id)  from user where id =:UserInfo.getUserId() AND IsActive = true];
global static void scheduleP()
{
schedulePermission sp=new schedulePermission ();
String CRON_EXP = '0 5 * * * ? ';
system.schedule('Schedule Job',CRON_EXP,sp);
}
global void execute(SchedulableContext sc)
{
AssignPermissionSet  APS=new AssignPermissionSet();
APS.getPermissionSet();
}

}

but when I call the apex class AssignPermissionSet APS=new AssignPermissionSet(); in the scheduler class then it is giving me an error:

Constructor not defined: [AssignPermissionSet].()

Can somebody help me what syntax i have missed her &how to call the apex class and its method which deletes the permssion?
Really Appreciate your suggession on this…

Best Answer

the only constructor your Account controller extension has is

public AssignPermissionSet(ApexPages.StandardController stdController)

so it requires an stdController as input. Therefore

schedulePermission sp=new schedulePermission ();

will not work. There are 2 solutions:
- you can create another constructor in your controller extension which will work without input parameter
- if you really do not want to touch the ControllerExtenstion, you can create dummy standard Controller Record in your Scheduler class as following:

Account acc= new Account();
ApexPages.StandardController stdAcc = new ApexPages.StandardController(acc);
AssignPermissionSet  APS=new AssignPermissionSet(stdAcc);

The real problem, however, as it is mentioned in comments - there is no connection between your Scheduler and ControllerExtension. As a result -Scheduler will have no idea which Account to process, I used New Account just to show you syntax for your current problem.