maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1379870 - in /maven/plugins/trunk/maven-changes-plugin/src: main/java/org/apache/maven/plugin/jira/ test/java/org/apache/maven/plugin/jira/
Date Sat, 01 Sep 2012 22:07:13 GMT
Author: dennisl
Date: Sat Sep  1 22:07:12 2012
New Revision: 1379870

URL: http://svn.apache.org/viewvc?rev=1379870&view=rev
Log:
Refactor the generation of the query string into a Builder class.

This was part of a patch for
[MCHANGES-285] SAXException parsing JIRA XML from JIRA 5.1 

Submitted by: Ton Swieb
Reviewed by: Dennis Lundberg

I have reformated code to follow our code style and added a license header that was missing.

Added:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
  (with props)
Modified:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraDownloader.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraHelper.java
    maven/plugins/trunk/maven-changes-plugin/src/test/java/org/apache/maven/plugin/jira/JiraHelperTestCase.java

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java?rev=1379870&r1=1379869&r2=1379870&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
Sat Sep  1 22:07:12 2012
@@ -103,243 +103,10 @@ public abstract class AbstractJiraDownlo
     private MavenProject project;
     /** The maven settings. */
     private Settings settings;
-    /** Mapping containing all allowed JIRA status values. */
-    protected final Map<String,String> statusMap = new HashMap<String,String>(
8 );
-    /** Mapping containing all allowed JIRA resolution values. */
-    protected final Map<String,String> resolutionMap = new HashMap<String,String>(
8 );
-    /** Mapping containing all allowed JIRA priority values. */
-    protected final Map<String,String> priorityMap = new HashMap<String,String>(
8 );
-    /** Mapping containing all allowed JIRA type values. */
-    protected final Map<String,String> typeMap = new HashMap<String,String>(
8 );
     /** The pattern used to parse dates from the JIRA xml file. */
     protected String jiraDatePattern;
 
     /**
-     * Creates a filter given the parameters and some defaults.
-     *
-     * @return request parameters to be added to URL used for downloading the JIRA issues
-     */
-    private String createFilter()
-    {
-        // If the user has defined a filter - use that
-        if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
-        {
-            return this.filter;
-        }
-
-        StringBuffer localFilter = new StringBuffer( 16 );
-
-        // add fix versions
-        if ( fixVersionIds != null )
-        {
-            String[] fixVersions = fixVersionIds.split( "," );
-
-            for ( int i = 0; i < fixVersions.length; i++ )
-            {
-                if ( fixVersions[i].length() > 0 )
-                {
-                    localFilter.append( "&fixfor=" ).append( fixVersions[i].trim() );
-                }
-            }
-        }
-
-        // get the Status Ids
-        if ( statusIds != null )
-        {
-            String[] stats = statusIds.split( "," );
-            for ( String stat : stats )
-            {
-                stat = stat.trim();
-                String statusParam = statusMap.get( stat );
-
-                if ( statusParam != null )
-                {
-                    localFilter.append( "&statusIds=" ).append( statusParam );
-                }
-                else
-                {
-                    // if it's numeric we can handle it too.
-                    try
-                    {
-                        Integer.parseInt( stat );
-                        localFilter.append( "&statusIds=" ).append( stat );
-                    }
-                    catch ( NumberFormatException nfe )
-                    {
-                        getLog().error( "maven-changes-plugin: invalid statusId " + stat
);
-                    }
-                }
-            }
-        }
-
-        // get the Priority Ids
-        if ( priorityIds != null )
-        {
-            String[] prios = priorityIds.split( "," );
-
-            for ( String prio : prios ) 
-            {
-                prio = prio.trim();
-                String priorityParam = priorityMap.get( prio );
-
-                if ( priorityParam != null )
-                {
-                    localFilter.append( "&priorityIds=" ).append( priorityParam );
-                }
-            }
-        }
-
-        // get the Resolution Ids
-        if ( resolutionIds != null )
-        {
-            String[] resos = resolutionIds.split( "," );
-
-            for ( String reso : resos ) 
-            {
-                reso = reso.trim();
-                String resoParam = resolutionMap.get( reso );
-
-                if ( resoParam != null )
-                {
-                    localFilter.append( "&resolutionIds=" ).append( resoParam );
-                }
-            }
-        }
-
-        // add components
-        if ( component != null )
-        {
-            String[] components = component.split( "," );
-
-            for ( String component : components ) 
-            {
-                component = component.trim();
-                if ( component.length() > 0 )
-                {
-                    localFilter.append( "&component=" ).append( component );
-                }
-            }
-        }
-
-        // get the Type Ids
-        if ( typeIds != null )
-        {
-            String[] types = typeIds.split( "," );
-
-            for ( String type : types )
-            {
-                String typeParam = typeMap.get( type.trim() );
-
-                if ( typeParam != null )
-                {
-                    localFilter.append( "&type=" ).append( typeParam );
-                }
-            }
-        }
-
-        // get the Sort order
-        int validSortColumnNames = 0;
-        if ( sortColumnNames != null )
-        {
-            String[] sortColumnNamesArray = sortColumnNames.split( "," );
-            // N.B. Add in reverse order (it's the way JIRA 3 likes it!!)
-            for ( int i = sortColumnNamesArray.length - 1; i >= 0; i-- )
-            {
-                String lowerColumnName = sortColumnNamesArray[i].trim().toLowerCase( Locale.ENGLISH
);
-                boolean descending = false;
-                String fieldName = null;
-                if ( lowerColumnName.endsWith( "desc" ) )
-                {
-                    descending = true;
-                    lowerColumnName = lowerColumnName.substring( 0, lowerColumnName.length()
- 4 ).trim();
-                }
-                else if ( lowerColumnName.endsWith( "asc" ) )
-                {
-                    descending = false;
-                    lowerColumnName = lowerColumnName.substring( 0, lowerColumnName.length()
- 3 ).trim();
-                }
-
-                if ( "key".equals( lowerColumnName ) )
-                {
-                    fieldName = "issuekey";
-                }
-                else if ( "summary".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "status".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "resolution".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "assignee".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "reporter".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "type".equals( lowerColumnName ) )
-                {
-                    fieldName = "issuetype";
-                }
-                else if ( "priority".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "version".equals( lowerColumnName ) )
-                {
-                    fieldName = "versions";
-                }
-                else if ( "fix version".equals( lowerColumnName ) )
-                {
-                    fieldName = "fixVersions";
-                }
-                else if ( "component".equals( lowerColumnName ) )
-                {
-                    fieldName = "components";
-                }
-                else if ( "created".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                else if ( "updated".equals( lowerColumnName ) )
-                {
-                    fieldName = lowerColumnName;
-                }
-                if ( fieldName != null )
-                {
-                    localFilter.append( "&sorter/field=" );
-                    localFilter.append( fieldName );
-                    localFilter.append( "&sorter/order=" );
-                    localFilter.append( descending ? "DESC" : "ASC" );
-                    validSortColumnNames++;
-                }
-                else
-                {
-                    // Error in the configuration
-                    getLog().error(
-                        "maven-changes-plugin: The configured value '" + lowerColumnName
-                            + "' for sortColumnNames is not correct." );
-                }
-            }
-        }
-        if ( validSortColumnNames == 0 )
-        {
-            // Error in the configuration
-            getLog().error(
-                "maven-changes-plugin: None of the configured sortColumnNames '" + sortColumnNames
+ "' are correct." );
-        }
-
-
-        return localFilter.toString();
-    }
-
-    /**
      * Execute the query on the JIRA server.
      *
      * @throws Exception on error
@@ -364,65 +131,31 @@ public abstract class AbstractJiraDownlo
 
             client.setState( state );
 
-            Map<String,String> urlMap = JiraHelper.getJiraUrlAndProjectId( project.getIssueManagement().getUrl()
);
-
-            String jiraUrl = urlMap.get( "url" );
-            getLog().debug( "JIRA lives at: " + jiraUrl );
+            String fullUrl = null;
+            fullUrl = getParameterBasedQueryURL( client );
+            String baseUrl = JiraHelper.getBaseUrl( fullUrl );
 
-            String jiraId = urlMap.get( "id" );
-
-            determineProxy( jiraUrl, client );
+            getLog().debug( "JIRA lives at: " + baseUrl );
+            determineProxy( baseUrl, client );
 
             prepareBasicAuthentication( client );
 
             boolean jiraAuthenticationSuccessful = false;
             if ( isJiraAuthenticationConfigured() )
             {
-                jiraAuthenticationSuccessful = doJiraAuthentication( client, jiraUrl );
+                jiraAuthenticationSuccessful = doJiraAuthentication( client, baseUrl );
             }
 
             if ( ( isJiraAuthenticationConfigured() && jiraAuthenticationSuccessful
)
                 || !isJiraAuthenticationConfigured() )
             {
-                if ( jiraId == null || jiraId.length() == 0 )
+                if ( log.isDebugEnabled() )
                 {
-                    log.debug( "The JIRA URL " + project.getIssueManagement().getUrl()
-                        + " doesn't include a pid, trying to extract it from JIRA." );
-                    jiraId = JiraHelper.getPidFromJira( log, project.getIssueManagement().getUrl(),
client );
+                    log.debug( "download jira issues from url " + fullUrl );
                 }
 
-                if ( jiraId == null )
-                {
-                    getLog().error( "The issue management URL in the POM does not include
a pid,"
-                        + " and it was not possible to extract it from the page at that URL."
);
-                }
-                else
-                {
-                    // create the URL for getting the proper issues from JIRA
-                    String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid="
+ jiraId;
-
-                    if ( getFixFor() != null )
-                    {
-                        fullURL += "&fixfor=" + getFixFor();
-                    }
-
-                    String createdFilter = createFilter();
-                    if ( createdFilter.charAt( 0 ) != '&' )
-                    {
-                        fullURL += "&";
-                    }
-                    fullURL += createdFilter;
-
-                    fullURL += ( "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none"
);
-
-                    if ( log.isDebugEnabled() )
-                    {
-                        log.debug( "download jira issues from url " + fullURL );
-                    }
-
-                    // execute the GET
-                    download( client, fullURL );
-                }
+                // execute the GET
+                download( client, fullUrl );
             }
         }
         catch ( Exception e )
@@ -438,6 +171,51 @@ public abstract class AbstractJiraDownlo
         }
     }
 
+    private String getParameterBasedQueryURL( HttpClient client )
+    {
+        Map<String, String> urlMap = JiraHelper.getJiraUrlAndProjectId( project.getIssueManagement().getUrl()
);
+        String jiraUrl = urlMap.get( "url" );
+        String jiraId = urlMap.get( "id" );
+
+        if ( jiraId == null || jiraId.length() == 0 )
+        {
+            log.debug( "The JIRA URL " + project.getIssueManagement().getUrl()
+                           + " doesn't include a pid, trying to extract it from JIRA." );
+            jiraId = JiraHelper.getPidFromJira( log, project.getIssueManagement().getUrl(),
client );
+        }
+
+        if ( jiraId == null )
+        {
+            throw new RuntimeException( "The issue management URL in the POM does not include
a pid,"
+                                            + " and it was not possible to extract it from
the page at that URL." );
+        }
+        else
+        {
+            // create the URL for getting the proper issues from JIRA
+            String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" +
jiraId;
+
+            if ( getFixFor() != null )
+            {
+                fullURL += "&fixfor=" + getFixFor();
+            }
+
+            String createdFilter =
+                new ParameterQueryBuilder( log ).fixVersionIds( fixVersionIds ).statusIds(
statusIds )
+                        .priorityIds( priorityIds ).resolutionIds( resolutionIds ).components(
component )
+                        .typeIds( typeIds ).sortColumnNames( sortColumnNames ).filter( filter
).build();
+
+            if ( createdFilter.charAt( 0 ) != '&' )
+            {
+                fullURL += "&";
+            }
+            fullURL += createdFilter;
+
+            fullURL += ( "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none"
);
+
+            return fullURL;
+        }
+    }
+
     /**
      * Override this method if you need to get issues for a specific Fix For.
      *

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraDownloader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraDownloader.java?rev=1379870&r1=1379869&r2=1379870&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraDownloader.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraDownloader.java
Sat Sep  1 22:07:12 2012
@@ -31,31 +31,5 @@ public final class JiraDownloader
 {
     public JiraDownloader()
     {
-        statusMap.put( "Open", "1" );
-        statusMap.put( "In Progress", "3" );
-        statusMap.put( "Reopened", "4" );
-        statusMap.put( "Resolved", "5" );
-        statusMap.put( "Closed", "6" );
-
-        resolutionMap.put( "Unresolved", "-1" );
-        resolutionMap.put( "Fixed", "1" );
-        resolutionMap.put( "Won't Fix", "2" );
-        resolutionMap.put( "Duplicate", "3" );
-        resolutionMap.put( "Incomplete", "4" );
-        resolutionMap.put( "Cannot Reproduce", "5" );
-
-        priorityMap.put( "Blocker", "1" );
-        priorityMap.put( "Critical", "2" );
-        priorityMap.put( "Major", "3" );
-        priorityMap.put( "Minor", "4" );
-        priorityMap.put( "Trivial", "5" );
-
-        typeMap.put( "Bug", "1" );
-        typeMap.put( "New Feature", "2" );
-        typeMap.put( "Task", "3" );
-        typeMap.put( "Improvement", "4" );
-        typeMap.put( "Wish", "5" );
-        typeMap.put( "Test", "6" );
-        typeMap.put( "Sub-task", "7" );
     }
 }

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraHelper.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraHelper.java?rev=1379870&r1=1379869&r2=1379870&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraHelper.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraHelper.java
Sat Sep  1 22:07:12 2012
@@ -190,4 +190,13 @@ public class JiraHelper
     {
         // utility class
     }
+
+    /**
+     * @since 2.8
+     */
+    public static String getBaseUrl( String url )
+    {
+        int index = url.indexOf( "/", 8 ); //Ignore http:// or https://
+        return url.substring( 0, index );
+    }
 }

Added: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java?rev=1379870&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
(added)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
Sat Sep  1 22:07:12 2012
@@ -0,0 +1,339 @@
+package org.apache.maven.plugin.jira;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * JIRA 3.x way of constructing a search query based on URL parameters.
+ * 
+ * @author ton.swieb@finalist.com
+ * @since 2.8
+ */
+public class ParameterQueryBuilder {
+    /** Log for debug output. */
+    protected Log log;
+    private String filter = "";
+    private StringBuilder query = new StringBuilder();
+
+    /** Mapping containing all allowed JIRA status values. */
+    protected final Map<String,String> statusMap = new HashMap<String,String>(
8 );
+    /** Mapping containing all allowed JIRA resolution values. */
+    protected final Map<String,String> resolutionMap = new HashMap<String,String>(
8 );
+    /** Mapping containing all allowed JIRA priority values. */
+    protected final Map<String,String> priorityMap = new HashMap<String,String>(
8 );
+    /** Mapping containing all allowed JIRA type values. */
+    protected final Map<String,String> typeMap = new HashMap<String,String>(
8 );
+
+    public ParameterQueryBuilder( Log log )
+    {
+        this.log = log;
+
+        statusMap.put( "Open", "1" );
+        statusMap.put( "In Progress", "3" );
+        statusMap.put( "Reopened", "4" );
+        statusMap.put( "Resolved", "5" );
+        statusMap.put( "Closed", "6" );
+
+        resolutionMap.put( "Unresolved", "-1" );
+        resolutionMap.put( "Fixed", "1" );
+        resolutionMap.put( "Won't Fix", "2" );
+        resolutionMap.put( "Duplicate", "3" );
+        resolutionMap.put( "Incomplete", "4" );
+        resolutionMap.put( "Cannot Reproduce", "5" );
+
+        priorityMap.put( "Blocker", "1" );
+        priorityMap.put( "Critical", "2" );
+        priorityMap.put( "Major", "3" );
+        priorityMap.put( "Minor", "4" );
+        priorityMap.put( "Trivial", "5" );
+
+        typeMap.put( "Bug", "1" );
+        typeMap.put( "New Feature", "2" );
+        typeMap.put( "Task", "3" );
+        typeMap.put( "Improvement", "4" );
+        typeMap.put( "Wish", "5" );
+        typeMap.put( "Test", "6" );
+        typeMap.put( "Sub-task", "7" );
+    }
+
+    public ParameterQueryBuilder fixVersionIds( String fixVersionIds )
+    {
+        // add fix versions
+        if ( fixVersionIds != null )
+        {
+            String[] fixVersions = fixVersionIds.split( "," );
+
+            for ( int i = 0; i < fixVersions.length; i++ )
+            {
+                if ( fixVersions[i].length() > 0 )
+                {
+                    query.append( "&fixfor=" ).append( fixVersions[i].trim() );
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder statusIds( String statusIds )
+    {
+        // get the Status Ids
+        if ( statusIds != null )
+        {
+            String[] stats = statusIds.split( "," );
+            for ( String stat : stats )
+            {
+                stat = stat.trim();
+                String statusParam = statusMap.get( stat );
+
+                if ( statusParam != null )
+                {
+                    query.append( "&statusIds=" ).append( statusParam );
+                }
+                else
+                {
+                    // if it's numeric we can handle it too.
+                    try
+                    {
+                        Integer.parseInt( stat );
+                        query.append( "&statusIds=" ).append( stat );
+                    }
+                    catch ( NumberFormatException nfe )
+                    {
+                        getLog().error( "maven-changes-plugin: invalid statusId " + stat
);
+                    }
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder priorityIds( String priorityIds )
+    {
+        // get the Priority Ids
+        if ( priorityIds != null )
+        {
+            String[] prios = priorityIds.split( "," );
+
+            for ( String prio : prios )
+            {
+                prio = prio.trim();
+                String priorityParam = priorityMap.get( prio );
+
+                if ( priorityParam != null )
+                {
+                    query.append( "&priorityIds=" ).append( priorityParam );
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder resolutionIds( String resolutionIds )
+    {
+        // get the Resolution Ids
+        if ( resolutionIds != null )
+        {
+            String[] resos = resolutionIds.split( "," );
+
+            for ( String reso : resos )
+            {
+                reso = reso.trim();
+                String resoParam = resolutionMap.get( reso );
+
+                if ( resoParam != null )
+                {
+                    query.append( "&resolutionIds=" ).append( resoParam );
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder components( String components )
+    {
+        // add components
+        if ( components != null )
+        {
+            String[] componentsArr = components.split( "," );
+
+            for ( String component : componentsArr )
+            {
+                component = component.trim();
+                if ( component.length() > 0 )
+                {
+                    query.append( "&component=" ).append( component );
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder typeIds( String typeIds )
+    {
+
+        // get the Type Ids
+        if ( typeIds != null )
+        {
+            String[] types = typeIds.split( "," );
+
+            for ( String type : types )
+            {
+                String typeParam = typeMap.get( type.trim() );
+
+                if ( typeParam != null )
+                {
+                    query.append( "&type=" ).append( typeParam );
+                }
+            }
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder sortColumnNames( String sortColumnNames )
+    {
+        // get the Sort order
+        int validSortColumnNames = 0;
+        if ( sortColumnNames != null )
+        {
+            String[] sortColumnNamesArray = sortColumnNames.split( "," );
+            // N.B. Add in reverse order (it's the way JIRA 3 likes it!!)
+            for ( int i = sortColumnNamesArray.length - 1; i >= 0; i-- )
+            {
+                String lowerColumnName = sortColumnNamesArray[i].trim().toLowerCase( Locale.ENGLISH
);
+                boolean descending = false;
+                String fieldName = null;
+                if ( lowerColumnName.endsWith( "desc" ) )
+                {
+                    descending = true;
+                    lowerColumnName = lowerColumnName.substring( 0, lowerColumnName.length()
- 4 ).trim();
+                }
+                else if ( lowerColumnName.endsWith( "asc" ) )
+                {
+                    descending = false;
+                    lowerColumnName = lowerColumnName.substring( 0, lowerColumnName.length()
- 3 ).trim();
+                }
+
+                if ( "key".equals( lowerColumnName ) )
+                {
+                    fieldName = "issuekey";
+                }
+                else if ( "summary".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "status".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "resolution".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "assignee".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "reporter".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "type".equals( lowerColumnName ) )
+                {
+                    fieldName = "issuetype";
+                }
+                else if ( "priority".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "version".equals( lowerColumnName ) )
+                {
+                    fieldName = "versions";
+                }
+                else if ( "fix version".equals( lowerColumnName ) )
+                {
+                    fieldName = "fixVersions";
+                }
+                else if ( "component".equals( lowerColumnName ) )
+                {
+                    fieldName = "components";
+                }
+                else if ( "created".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                else if ( "updated".equals( lowerColumnName ) )
+                {
+                    fieldName = lowerColumnName;
+                }
+                if ( fieldName != null )
+                {
+                    query.append( "&sorter/field=" );
+                    query.append( fieldName );
+                    query.append( "&sorter/order=" );
+                    query.append( descending ? "DESC" : "ASC" );
+                    validSortColumnNames++;
+                }
+                else
+                {
+                    // Error in the configuration
+                    getLog().error(
+                        "maven-changes-plugin: The configured value '" + lowerColumnName
+                            + "' for sortColumnNames is not correct." );
+                }
+            }
+        }
+        if ( validSortColumnNames == 0 )
+        {
+            // Error in the configuration
+            getLog().error(
+                "maven-changes-plugin: None of the configured sortColumnNames '" + sortColumnNames
+ "' are correct." );
+        }
+        return this;
+    }
+
+    public ParameterQueryBuilder filter( String filter )
+    {
+        this.filter = filter;
+        return this;
+    }
+
+    public String build()
+    {
+        // If the user has defined a filter - use that
+        if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
+        {
+            return this.filter;
+        }
+        else
+        {
+            return query.toString();
+        }
+    }
+
+    public Log getLog()
+    {
+        return log;
+    }
+}

Propchange: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-changes-plugin/src/test/java/org/apache/maven/plugin/jira/JiraHelperTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/test/java/org/apache/maven/plugin/jira/JiraHelperTestCase.java?rev=1379870&r1=1379869&r2=1379870&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/test/java/org/apache/maven/plugin/jira/JiraHelperTestCase.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/test/java/org/apache/maven/plugin/jira/JiraHelperTestCase.java
Sat Sep  1 22:07:12 2012
@@ -50,4 +50,15 @@ public class JiraHelperTestCase
         map = JiraHelper.getJiraUrlAndProjectId( "http://jira.codehaus.org/browse/MSHARED/component/13380"
);
         assertEquals( "http://jira.codehaus.org", map.get( "url" ) );
     }
+
+    public void testGetBaseUrl()
+    {
+        String expected = "http://www.jira.com";
+        String actual = JiraHelper.getBaseUrl( "http://www.jira.com/context/test?werewrew"
);
+        assertEquals( expected, actual );
+
+        expected = "https://www.jira.com";
+        actual = JiraHelper.getBaseUrl( "https://www.jira.com/context/test?werewrew" );
+        assertEquals( expected, actual );
+    }
 }



Mime
View raw message