package de.thpeetz.kontor.media;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import de.thpeetz.kontor.admin.services.AdminService;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class SetupModuleMedia implements ApplicationListener<ContextRefreshedEvent> {

    boolean alreadySetup = false;

    @Autowired
    private AdminService adminService;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        adminService.addPermission(MediaConstants.MEDIA_ROLE);
        if (alreadySetup) {
            log.info("SetupModuleMedia already executed, skipping");
            return;
        }
        log.info("Set up Media data");
    }
}
