예제 #1
0
  /**
   * Loads the config from storage
   *
   * @return
   */
  public HooksConfig loadHooksConfig() {
    /*
     * 1. First, read from CFG file. This is just a seed data that can be
     * overwritten by the repo (#2 below)
     */
    HooksConfig fileConfig = null;
    try {
      fileConfig = readFromFile();
    } catch (Exception e) {
      log.error("Error reading default hooks from cfg file. Will skip ", e);
    }

    /*
     * 2. Now, read from Rapture repo, if there is any data related to this.
     * The data in the repo takes precedendece over the one in the init file
     */

    HooksConfig repoConfig = null;
    try {
      HooksConfig hooksConfig = new HooksConfig();
      hooksConfig.setIdToHook(new HashMap<String, SingleHookConfig>());
      repoConfig = HooksConfigStorage.readByStorageLocation(hooksConfig.getStorageLocation());
    } catch (Exception e) {
      log.error("Error reading hooks from rapture repo. Will skip ", e);
    }

    /*
     * 3. Now do the mixing
     */
    HooksConfig config = new HooksConfig();
    config.setIdToHook(new HashMap<String, SingleHookConfig>());
    if (fileConfig != null) {
      for (SingleHookConfig hookConfig : HooksConfigHelper.getHooks(fileConfig)) {
        HooksConfigHelper.registerHook(config, hookConfig);
      }
    }
    if (repoConfig != null) {
      for (SingleHookConfig hookConfig : HooksConfigHelper.getHooks(repoConfig)) {
        HooksConfigHelper.registerHook(config, hookConfig);
      }
    }

    return config;
  }
예제 #2
0
 /**
  * Stores the {@link HooksConfig} into persistent storage
  *
  * @param config
  * @param user
  * @param comment
  */
 public void storeHooksConfig(HooksConfig config, String user, String comment) {
   HooksConfigStorage.add(config, user, comment);
 }