// Copyright 2011 The MOE Authors All Rights Reserved

package com.google.devtools.moe.client.repositories;

import com.google.common.collect.ImmutableList;
import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * Configuration for a MOE metadata scrubber.
 */
public class MetadataScrubberConfig {
  @SerializedName("usernames_to_scrub")
  private List<String> usernamesToScrub;

  @SerializedName("scrub_confidential_words")
  private boolean scrubConfidentialWords = true;

  /**
   * Formatting for changelog adapted from fromRepository for commits in toRepository. See
   * {@link DescriptionMetadataScrubber}.
   */
  @SerializedName("log_format")
  private String logFormat = "{description}\n\tChange on {date} by {author}";

  public MetadataScrubberConfig() {} // Constructed by gson

  public List<String> getUsernamesToScrub() {
    return usernamesToScrub;
  }

  /**
   * Access the boolean field, which can be used as a trigger for
   * the proper MetadataScrubber to scrub any confidential words.
   * @return boolean whether confidential words should be scrubbed
   */
  public boolean getScrubConfidentialWords() {
    return scrubConfidentialWords;
  }

  public String getLogFormat() {
    return logFormat;
  }

  /**
   * @return the list of {@link MetadataScrubber}s as determined by this configuration
   */
  public List<MetadataScrubber> getScrubbers() {
    ImmutableList.Builder<MetadataScrubber> scrubbersBuilder = ImmutableList.builder();

    if (usernamesToScrub != null && !usernamesToScrub.isEmpty()) {
      scrubbersBuilder.add(new MetadataUsernameScrubber(getUsernamesToScrub()));
    }

    if (getScrubConfidentialWords()) {
      // Here is where you can use a MetadataScrubber that scrubs confidential words.
    }

    scrubbersBuilder.add(new PublicSectionMetadataScrubber());

    scrubbersBuilder.add(new DescriptionMetadataScrubber(logFormat));

    return scrubbersBuilder.build();
  }
}

@@ -496,22 +496,116 @@
  true;%0A%0A
+  @SerializedName(%22sensitive_res%22)%0A  private List%3CString%3E sensitiveRes = ImmutableList.of();%0A%0A
   /**%0A
-
    * For
@@ -1285,16 +1285,185 @@
 s;%0A  %7D%0A%0A
+  /** A list of regular expressions for sensitive text to be scrubbed from revision metadata. */%0A  public List%3CString%3E getSensitiveRes() %7B%0A    return sensitiveRes;%0A  %7D%0A%0A
   public
@@ -1914,20 +1914,17 @@
     if (
-getS
+s
 crubConf
@@ -1936,18 +1936,16 @@
 ialWords
-()
 ) %7B%0A    

Add a "sensitive_res" setting to the metadata_scrubber_config, allowing custom additional regexes to be scrubbed from change descriptions. Add regex for "[] "[] "[] to SENSITIVE_WORDS and rename SENSITIVE_WORDS to the more accurate name, SENSITIVE_RES. Change on 2013/01/07 by kpy <kpy@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=40836763