Skip to content
This repository

Deprecated the use of the System properties in favor of a method parameter. #99

Closed
wants to merge 1 commit into from

2 participants

Pascal Gélinas Henrik Lundgren
Pascal Gélinas

Using System properties for configuring short-lived job like merging two design document is just bad practice, IMHO.

Henrik Lundgren
Owner

The justification for a system property is that you may want to have different behaviour in different environments. say dev and prod

Pascal Gélinas

Good point. Then how about keeping this change but not deprecating the use of the System properties, so that one can force update (or not) by using the mergeWith(DesignDocument, boolean) method? Because right now it's impossible for two merge running concurrently to use different update_on_diff policy (which is a case I've run into).

Henrik Lundgren helun closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 11, 2012
Pascal Gélinas pgelinas Deprecated the use of the System properties in favor of a method para…
…meter.
d720647
This page is out of date. Refresh to see the latest.
37 org.ektorp/src/main/java/org/ektorp/support/DesignDocument.java
@@ -28,7 +28,19 @@
28 28
29 29 public final static String ID_PREFIX = "_design/";
30 30 private final static String DEFAULT_LANGUAGE = "javascript";
  31 + /**
  32 + * @deprecated use {@link #mergeWith(DesignDocument, boolean)} instead if
  33 + * you wish to specify wheter to update on design doc difference
  34 + * or only add new elements.
  35 + */
  36 + @Deprecated
31 37 public static final String AUTO_UPDATE_VIEW_ON_CHANGE = "org.ektorp.support.AutoUpdateViewOnChange";
  38 + /**
  39 + * @deprecated use {@link #mergeWith(DesignDocument, boolean)} instead if
  40 + * you wish to specify wheter to update on design doc difference
  41 + * or only add new elements.
  42 + */
  43 + @Deprecated
32 44 public static final String UPDATE_ON_DIFF = "org.ektorp.support.UpdateDesignDocOnDiff";
33 45
34 46 private Map<String, View> views;
@@ -182,8 +194,19 @@ public void removeFilter(String name) {
182 194 filters().remove(name);
183 195 }
184 196
185   - public boolean mergeWith(DesignDocument dd) {
186   - boolean updateOnDiff = updateOnDiff();
  197 + /**
  198 + * Merge this design document with the specified document, the result being
  199 + * stored in this design document.
  200 + *
  201 + * @param dd
  202 + * the design document to merge with
  203 + * @param updateOnDiff
  204 + * true to overwrite existing views/functions in this document
  205 + * with the views/functions in the specified document; false will
  206 + * only add new views/functions.
  207 + * @return true if there was any modification to this document, false otherwise.
  208 + */
  209 + public boolean mergeWith(DesignDocument dd, boolean updateOnDiff) {
187 210 boolean changed = mergeViews(dd.views(), updateOnDiff);
188 211 changed = mergeFunctions(lists(), dd.lists(), updateOnDiff) || changed;
189 212 changed = mergeFunctions(shows(), dd.shows(), updateOnDiff) || changed;
@@ -191,6 +214,16 @@ public boolean mergeWith(DesignDocument dd) {
191 214 changed = mergeFunctions(updates(), dd.updates(), updateOnDiff) || changed;
192 215 return changed;
193 216 }
  217 +
  218 + /**
  219 + * This method will check for the two system properties boolean
  220 + * {@link #AUTO_UPDATE_VIEW_ON_CHANGE} and {@link #UPDATE_ON_DIFF}, then call
  221 + * {@link #mergeWith(DesignDocument, boolean)}. The default value is false for both.
  222 + *
  223 + */
  224 + public boolean mergeWith(DesignDocument dd) {
  225 + return mergeWith(dd, updateOnDiff());
  226 + }
194 227
195 228 private boolean mergeFunctions(Map<String, String> existing, Map<String, String> mergeFunctions,
196 229 boolean updateOnDiff) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.