Beispiel #1
0
func (j DeleteJob) Run() {
	revel.INFO.Println("delete job started")
	// get the applications
	apps, _ := models.GetApplications(j.Db)
	for a := range apps {
		revel.INFO.Printf("cleaning %s application logs", apps[a].Name)
		appRetentionConf := apps[a].Configuration.Retention
		cnfEl := reflect.ValueOf(appRetentionConf)
		for l := 0; l < cnfEl.NumField(); l++ {
			fld := cnfEl.Field(l)
			fldType := reflect.TypeOf(appRetentionConf).Field(l)
			level := fldType.Tag.Get("json")
			err := models.DeleteLog(j.Db, apps[a].Name, level, fld.Interface().(models.LevelConfiguration).DeleteDays)
			if err != nil {
				revel.ERROR.Println(err.Error())
			}
		}
	}
	revel.INFO.Println("delete job finished")
}
Beispiel #2
0
func (ctrl *AdminApi) List(modelType string) revel.Result {
	result := make(map[string]interface{})

	var modelObjs interface{}
	var err error
	switch modelType {
	case "application":
		modelObjs, err = models.GetApplications(ctrl.Db)
	case "group":
		modelObjs, err = models.GetGroups(ctrl.Db)
	case "user":
		modelObjs, err = models.GetUsers(ctrl.Db)
	}
	result["success"] = err == nil
	if err != nil {
		revel.ERROR.Println(err)
		result["message"] = err.Error()
	} else {
		result["result"] = modelObjs
	}
	return ctrl.RenderJson(result)
}