Search in sources :

Example 1 with UserCacheRecord

use of password.pwm.svc.report.UserCacheRecord in project pwm by pwm-project.

the class AdminServlet method processReportData.

@ActionHandler(action = "reportData")
public ProcessStatus processReportData(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException {
    final int maximum = Math.min(pwmRequest.readParameterAsInt("maximum", 1000), 10 * 1000);
    final ReportService reportService = pwmRequest.getPwmApplication().getReportService();
    final ArrayList<UserCacheRecord> reportData = new ArrayList<>();
    ClosableIterator<UserCacheRecord> cacheBeanIterator = null;
    try {
        cacheBeanIterator = reportService.iterator();
        while (cacheBeanIterator.hasNext() && reportData.size() < maximum) {
            final UserCacheRecord userCacheRecord = cacheBeanIterator.next();
            if (userCacheRecord != null) {
                reportData.add(userCacheRecord);
            }
        }
    } finally {
        if (cacheBeanIterator != null) {
            cacheBeanIterator.close();
        }
    }
    final HashMap<String, Object> returnData = new HashMap<>();
    returnData.put("users", reportData);
    final RestResultBean restResultBean = RestResultBean.withData(returnData);
    pwmRequest.outputJsonResult(restResultBean);
    return ProcessStatus.Halt;
}
Also used : UserCacheRecord(password.pwm.svc.report.UserCacheRecord) ReportService(password.pwm.svc.report.ReportService) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) RestResultBean(password.pwm.ws.server.RestResultBean)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ReportService (password.pwm.svc.report.ReportService)1 UserCacheRecord (password.pwm.svc.report.UserCacheRecord)1 RestResultBean (password.pwm.ws.server.RestResultBean)1