Sebastian Sdorra avatar Sebastian Sdorra committed 64647db

improve auto close method

Comments (0)

Files changed (1)

src/main/java/sonia/scm/jira/SoapJiraHandler.java

 import java.text.MessageFormat;
 
 import java.util.GregorianCalendar;
+import java.util.Locale;
 import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  *
    *
    *
    * @param issueId
-   * @param autoCloseWords
+   * @param autoCloseWord
    *
    * @throws JiraException
    */
   @Override
-  public void close(String issueId, String autoCloseWords) throws JiraException
+  public void close(String issueId, String autoCloseWord) throws JiraException
   {
     if (logger.isInfoEnabled())
     {
-      logger.info("close issue {}", issueId);
+      logger.info("try to close issue {}", issueId);
     }
 
     try
 
       for (RemoteNamedObject rnm : rnms)
       {
-        if (rnm.getName().toLowerCase().contains(autoCloseWords.toLowerCase()))
+        if (contains(rnm.getName(), autoCloseWord))
         {
           id = rnm.getId();
 
    * Method description
    *
    *
+   * @param text
+   * @param value
+   *
+   * @return
+   */
+  private boolean contains(String text, String value)
+  {
+    return toLowerCase(text).contains(toLowerCase(value));
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param comment
    * @param contains
    *
     return body;
   }
 
+  /**
+   * Method description
+   *
+   *
+   * @param value
+   *
+   * @return
+   */
+  private String toLowerCase(String value)
+  {
+    return Strings.nullToEmpty(value).toLowerCase(Locale.ENGLISH);
+  }
+
   //~--- fields ---------------------------------------------------------------
 
   /** Field description */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.