Introduction

The purpose of this task is to remove all DeviceID tokens from the token repository that have not been used within a specific number of days.  The period of time that the tokens must have been inactive before being deleted is determined by the task parameter "days".

The task can be found by navigating to "Administration | Tasks", then scrolling down to the task "Delete inactive DeviceID Tokens";

Task Parameters

The task parameters are used by the task script to determine which tokens are to be deleted and are edited by left clicking on the context menu of the task and selecting "Parameters";

A new window titled "Task Parameters" will now open that lists the parameters making them available for editing, and the default parameters for this task are as follows;;









Only inactive DeviceID tokens that have been assigned to users that have been inactive for the specified number of days will  be selected for deletion.





The parameters may then be editing by selecting one of the parameters, then clicking on the button.


Editing and Scheduling the Task

Viewing and Editing the task

The task can be edited by left clicking on the context menu of the task and selecting "Edit";

A new window will not open titled "Task - Edit";







Enter the name to be assigned to the task within the management console.





Enter a description of what the task will do.





The version number of the task.





This field is used to specify when the task is scheduled to execute.





This field will determine if the task schedule is enabled (if enabled the task will execute at the scheduled time).





Specifies how many times the task should be repeated after the task is executed.





import com.deepnet.das.util.Util
import com.deepnet.das.token.TokenAssignment
import com.deepnet.das.token.AssignmentStatus
import com.deepnet.das.token.Product
import com.deepnet.das.exception.ProductNotFoundException
import com.deepnet.das.token.TokenAssignmentService

def now = new Date()
def from = now - Integer.valueOf(days)

            def product = Product.findByName('DeviceID')
if(!product){
throw new ProductNotFoundException()
}
def criteria = TokenAssignment.createCriteria()

def query = {
lt 'lastUpdated', from
eq 'status', AssignmentStatus.INACTIVE.toString()
token {
eq 'product', product
                        }
}

def count = 0
def scrollable = criteria.scroll(query)

            def tokens = []

while(scrollable.next()){
def tk =  scrollable.get(0)
tokens << tk
}

            for(token in tokens){
Util.getBean("tokenAssignmentService", TokenAssignmentService.class).unlink(token)
                count += 1
                onProgress(count, "Tokens deleted:  " + count)
            }

setEndMessage(count + " tokens deleted")



Scheduling the Task

Select the "Enable Schedule" checkbox to ensure the task schedule is activated, then use the pencil icon ("")  to specify the time and frequency settings for automated task execution.

Manual Task Execution

The task can be run manually from the management console by left click on the context menu of the task, then selecting "Run";

A new window will open titled "Execute Task" will then open (the window will be populated with the default task property values);







Provide a brief description that will be used to describe the purpose of the task in the audit log.





Only inactive DeviceID tokens that have been assigned to users that have been inactive for the specified number of days will  be selected for deletion.




To execute the task click  the  button.