001package systems.dmx.files.migrations;
002
003import systems.dmx.config.ConfigService;
004
005import systems.dmx.core.Topic;
006import systems.dmx.core.service.Inject;
007import systems.dmx.core.service.Migration;
008
009import java.util.List;
010import java.util.logging.Logger;
011
012
013
014/**
015 * Adds "Disk Quota" config topic to each username.
016 * Runs only in UPDATE mode.
017 * <p>
018 * Note: when CLEAN_INSTALLing the admin user already got its config topics
019 * as the Config service is already in charge.
020 * <p>
021 * Part of DM 4.7
022 */
023public class Migration3 extends Migration {
024
025    // ---------------------------------------------------------------------------------------------- Instance Variables
026
027    @Inject
028    private ConfigService configService;
029
030    private Logger logger = Logger.getLogger(getClass().getName());
031
032    // -------------------------------------------------------------------------------------------------- Public Methods
033
034    @Override
035    public void run() {
036        List<Topic> usernames = dmx.getTopicsByType("dmx.accesscontrol.username");
037        logger.info("########## Adding \"dmx.files.disk_quota\" config topic to " + usernames.size() + " usernames");
038        for (Topic username : usernames) {
039            configService.createConfigTopic("dmx.files.disk_quota", username);
040        }
041    }
042}