You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2011/11/21 15:15:00 UTC
svn commit: r1204509 [1/3] - in
/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin: ./
src/main/java/org/apache/maven/plugins/patchtracker/
src/main/java/org/apache/maven/plugins/patchtracker/tracking/
src/main/java/org/apache/maven/plugins/patcht...
Author: olamy
Date: Mon Nov 21 14:14:59 2011
New Revision: 1204509
URL: http://svn.apache.org/viewvc?rev=1204509&view=rev
Log:
add interface for PatchTracker first implementation is jira
Added:
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java (with props)
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/resources/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/resources/wsdl/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/resources/wsdl/jira.wsdl
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/plugins/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/plugins/patchtracker/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/plugins/patchtracker/tracking/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/plugins/patchtracker/tracking/jira/
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/test/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTrackerTest.java (with props)
Modified:
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/pom.xml
maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/CreatePatchMojo.java
Modified: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/pom.xml?rev=1204509&r1=1204508&r2=1204509&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/pom.xml (original)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/pom.xml Mon Nov 21 14:14:59 2011
@@ -97,6 +97,54 @@ under the License.
<artifactId>plexus-utils</artifactId>
<version>3.0</version>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interactivity-jline</artifactId>
+ <version>1.0-alpha-6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis</groupId>
+ <artifactId>axis</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxrpc-api</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.soap</groupId>
+ <artifactId>saaj-api</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>0.4</version>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -105,4 +153,85 @@ under the License.
</dependency>
</dependencies>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3.8</version>
+ <executions>
+ <execution>
+ <id>create-component-descriptor</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>axistools-maven-plugin</artifactId>
+ <version>1.4</version>
+ <configuration>
+ <packageSpace>org.apache.maven.plugins.patchtracker.tracking.jira.soap</packageSpace>
+ <sourceDirectory>src/main/resources/wsdl</sourceDirectory>
+ <outputDirectory>target/generated-sources/jira</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>atlassian.public</id>
+ <url>http://maven.atlassian.com/content/groups/public</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
</project>
Modified: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/CreatePatchMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/CreatePatchMojo.java?rev=1204509&r1=1204508&r2=1204509&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/CreatePatchMojo.java (original)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/CreatePatchMojo.java Mon Nov 21 14:14:59 2011
@@ -19,6 +19,7 @@ package org.apache.maven.plugins.patchtr
import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
@@ -28,8 +29,15 @@ import org.apache.maven.scm.manager.ScmM
import org.apache.maven.scm.provider.ScmProvider;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
/**
* Goal which create a diff/patch file from the current project and create an issue in the project
@@ -67,6 +75,61 @@ public class CreatePatchMojo
*/
protected String providerType = "";
+ /**
+ * @parameter default-value="${settings}"
+ * @required
+ * @readonly
+ */
+ protected Settings settings;
+
+
+ /**
+ * if user/password are stored in your settings.xml in a server
+ *
+ * @parameter expression="${patch.serverId}" default-value=""
+ */
+ protected String serverId;
+
+ /**
+ * if path tracker url is not stored in the pom.
+ * <b>For jira, url must include project key!: http://jira.codehaus.org/browse/MNG</b>
+ *
+ * @parameter expression="${patch.serverUrl}" default-value=""
+ */
+ protected String serverUrl;
+
+ /**
+ * @parameter expression="${patch.user}" default-value=""
+ */
+ protected String user;
+
+ /**
+ * @parameter expression="${patch.password}" default-value=""
+ */
+ protected String password;
+
+ /**
+ * @parameter expression="${patch.system}" default-value=""
+ */
+ protected String system;
+
+ /**
+ * @parameter expression="${patch.summary}" default-value=""
+ */
+ protected String summary;
+
+ /**
+ * @parameter expression="${patch.description}" default-value=""
+ */
+ protected String description;
+
+ /**
+ * Component used to prompt for input.
+ *
+ * @component
+ */
+ private Prompter prompter;
+
public void execute()
throws MojoExecutionException
{
@@ -74,7 +137,11 @@ public class CreatePatchMojo
String patchContent = getPatchContent();
+ PatchTrackerRequest patchTrackerRequest = buidPatchTrackerRequest();
+ patchTrackerRequest.setPatchContent( patchContent );
+
+ getLog().debug( patchTrackerRequest.toString() );
}
@@ -113,4 +180,179 @@ public class CreatePatchMojo
throw new MojoExecutionException( e.getMessage(), e );
}
}
+
+ protected PatchTrackerRequest buidPatchTrackerRequest()
+ throws MojoExecutionException
+ {
+ try
+ {
+ return new PatchTrackerRequest().setUrl( getPatchTrackerUrl() ).setUserName(
+ getPatchTrackerUsername() ).setPassword( getPatchTrackerPassword() ).setSummary(
+ getPatchTrackerSummary() ).setDescription( getPatchTrackerDescription() );
+ }
+ catch ( PrompterException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ }
+
+
+ protected String getPatchTrackerUrl()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = project.getIssueManagement() == null ? "" : project.getIssueManagement().getUrl();
+
+ // cli must win !
+ if ( StringUtils.isNotEmpty( serverUrl ) )
+ {
+ value = serverUrl;
+ }
+
+ return getValue( value, "path tracker url ? (http://jira.codehaus.org/browse/MNG)", null, true,
+ "you must configure a patch system or at least use interactive mode", value );
+ }
+
+ protected String getPatchTrackerSummary()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = summary;
+
+ return getValue( value, "patch summary ? (wonderfull patch to fix ....) ", Collections.<String>emptyList(),
+ true, "you must configure a patch summary or at least use interactive mode", null );
+ }
+
+ protected String getPatchTrackerDescription()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = description;
+
+ return getValue( value, "patch description ?(this patch fix this very annoying issue ....) ", null, false,
+ "you must configure a patch summary or at least use interactive mode", null );
+ }
+
+ protected String getPatchTrackerUsername()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = null;
+
+ if ( StringUtils.isNotEmpty( serverId ) )
+ {
+ Server server = getServer( serverId );
+ if ( server == null )
+ {
+ getLog().warn( "no server found in your settings.xml with id:" + serverId );
+ }
+ else
+ {
+ value = server.getUsername();
+ }
+
+ }
+
+ // cli must win !
+ if ( StringUtils.isNotEmpty( user ) )
+ {
+ value = user;
+ }
+
+ return getValue( value, "patch tracker username ?", null, true,
+ "you must configure a user for your patch tracker or at least use interactive mode", value );
+ }
+
+ protected String getPatchTrackerPassword()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = null;
+
+ if ( StringUtils.isNotEmpty( serverId ) )
+ {
+ Server server = getServer( serverId );
+ if ( server == null )
+ {
+ getLog().warn( "no server found in your settings.xml with id:" + serverId );
+ }
+ else
+ {
+ value = server.getPassword();
+ }
+
+ }
+
+ // cli must win !
+ if ( StringUtils.isNotEmpty( password ) )
+ {
+ value = password;
+ }
+
+ return getValue( value, "patch tracker password ?", null, true,
+ "you must configure a password for your patch tracker or at least use interactive mode",
+ value );
+ }
+
+ protected String getPatchTrackerSystem()
+ throws PrompterException, MojoExecutionException
+ {
+ String value = project.getIssueManagement() == null ? "" : project.getIssueManagement().getSystem();
+
+ // cli must win !
+ if ( StringUtils.isNotEmpty( system ) )
+ {
+ value = system;
+ }
+
+ return getValue( value, "path tracker system id ?", Arrays.asList( "jira" ), true,
+ "you must configure a patch system or at least use interactive mode", "jira" );
+ }
+
+ protected String getValue( String currentValue, String message, List<String> possibleValues, boolean mandatory,
+ String errorMessage, String defaultValue )
+ throws PrompterException, MojoExecutionException
+ {
+ boolean loadFromPrompt = false;
+ String value = currentValue;
+ if ( mandatory && StringUtils.isEmpty( value ) )
+ {
+ if ( settings.isInteractiveMode() )
+ {
+
+ getLog().debug( "1st prompt message " + message + ", defaultValue " + defaultValue + ", possibleValues"
+ + possibleValues );
+ value = ( possibleValues == null || possibleValues.isEmpty() )
+ ? prompter.prompt( message, defaultValue )
+ : prompter.prompt( message, possibleValues, defaultValue );
+ loadFromPrompt = true;
+ }
+ else
+ {
+ throw new MojoExecutionException( errorMessage );
+ }
+ if ( StringUtils.isEmpty( value ) )
+ {
+ throw new MojoExecutionException( errorMessage );
+ }
+ }
+
+ if ( settings.isInteractiveMode() && !loadFromPrompt )
+ {
+ getLog().debug( "1st prompt message " + message + ", defaultValue " + defaultValue + ", possibleValues"
+ + possibleValues );
+ value = ( possibleValues == null || possibleValues.isEmpty() ) ? ( StringUtils.isEmpty( defaultValue )
+ ? prompter.prompt( message )
+ : prompter.prompt( message, defaultValue ) )
+ : ( StringUtils.isEmpty( defaultValue )
+ ? prompter.prompt( message, possibleValues )
+ : prompter.prompt( message, possibleValues, defaultValue ) );
+ }
+ return value;
+ }
+
+
+ protected Server getServer( String id )
+ {
+ if ( StringUtils.isEmpty( id ) )
+ {
+ return null;
+ }
+ return settings.getServer( id );
+ }
}
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,33 @@
+package org.apache.maven.plugins.patchtracker.tracking;
+/*
+ * 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.
+ */
+
+/**
+ * provide some services around a patch tracker.
+ * A patch tracker can be an issue tracker (jira) or a patch reviewer (reviewboar)
+ *
+ * @author Olivier Lamy
+ */
+public interface PatchTracker
+{
+
+ PatchTrackerResult createPatch( PatchTrackerRequest patchTrackerRequest )
+ throws PatchTrackerException;
+
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTracker.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,37 @@
+package org.apache.maven.plugins.patchtracker.tracking;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ */
+public class PatchTrackerException
+ extends Exception
+{
+
+ public PatchTrackerException( String s )
+ {
+ super( s );
+ }
+
+ public PatchTrackerException( String s, Throwable throwable )
+ {
+ super( s, throwable );
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,140 @@
+package org.apache.maven.plugins.patchtracker.tracking;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ */
+public class PatchTrackerRequest
+{
+ private String url;
+
+ private String userName;
+
+ private String password;
+
+ private String patchContent;
+
+ private String summary;
+
+ private String description;
+
+ /**
+ * used for updating a patch in the patch tracker, (an issue id for jira: MNG-1234)
+ */
+ private String patchId;
+
+ public PatchTrackerRequest()
+ {
+ // no op
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public PatchTrackerRequest setUrl( String url )
+ {
+ this.url = url;
+ return this;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ public PatchTrackerRequest setUserName( String userName )
+ {
+ this.userName = userName;
+ return this;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public PatchTrackerRequest setPassword( String password )
+ {
+ this.password = password;
+ return this;
+ }
+
+ public String getPatchContent()
+ {
+ return patchContent;
+ }
+
+ public PatchTrackerRequest setPatchContent( String patchContent )
+ {
+ this.patchContent = patchContent;
+ return this;
+ }
+
+ public String getSummary()
+ {
+ return summary;
+ }
+
+ public PatchTrackerRequest setSummary( String summary )
+ {
+ this.summary = summary;
+ return this;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public PatchTrackerRequest setDescription( String description )
+ {
+ this.description = description;
+ return this;
+ }
+
+ public String getPatchId()
+ {
+ return patchId;
+ }
+
+ public PatchTrackerRequest setPatchId( String patchId )
+ {
+ this.patchId = patchId;
+ return this;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "PatchTrackerRequest" );
+ sb.append( "{url='" ).append( url ).append( '\'' );
+ sb.append( ", userName='" ).append( userName ).append( '\'' );
+ sb.append( ", password='" ).append( password ).append( '\'' );
+ sb.append( ", patchContent='" ).append( patchContent ).append( '\'' );
+ sb.append( ", summary='" ).append( summary ).append( '\'' );
+ sb.append( ", description='" ).append( description ).append( '\'' );
+ sb.append( ", patchId='" ).append( patchId ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerRequest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,62 @@
+package org.apache.maven.plugins.patchtracker.tracking;
+/*
+ * 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ */
+public class PatchTrackerResult
+{
+ /**
+ * patchid will be an issue id for jira: MNG-1234
+ */
+ private String patchId;
+
+ /**
+ * link to the patch. for jira link to the issue: http:://jira.codehaus.org/browse/MNG-1234
+ */
+ private String patchUrl;
+
+ public PatchTrackerResult()
+ {
+ // no op
+ }
+
+ public String getPatchId()
+ {
+ return patchId;
+ }
+
+ public PatchTrackerResult setPatchId( String patchId )
+ {
+ this.patchId = patchId;
+ return this;
+ }
+
+ public String getPatchUrl()
+ {
+ return patchUrl;
+ }
+
+ public PatchTrackerResult setPatchUrl( String patchUrl )
+ {
+ this.patchUrl = patchUrl;
+ return this;
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/PatchTrackerResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,161 @@
+package org.apache.maven.plugins.patchtracker.tracking.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 org.apache.commons.lang.StringUtils;
+import org.apache.maven.plugins.patchtracker.tracking.PatchTracker;
+import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerException;
+import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerRequest;
+import org.apache.maven.plugins.patchtracker.tracking.PatchTrackerResult;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.JiraSoapServiceService;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.JiraSoapServiceServiceLocator;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteAuthenticationException;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteException;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteIssue;
+
+import javax.xml.rpc.ServiceException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author Olivier Lamy
+ * @plexus.component role="org.apache.maven.plugins.patchtracker.tracking.PatchTracker" role-hint="jira"
+ */
+public class JiraPatchTracker
+ implements PatchTracker
+{
+ public PatchTrackerResult createPatch( PatchTrackerRequest patchTrackerRequest )
+ throws PatchTrackerException
+ {
+
+ JiraSession jiraSession = createSession( patchTrackerRequest );
+ try
+ {
+ RemoteIssue remoteIssue = null;
+ // is it an update
+ if ( patchTrackerRequest.getPatchId() != null )
+ {
+
+ }
+ else
+ {
+ remoteIssue = new RemoteIssue();
+ remoteIssue.setProject( extractProjectKey( patchTrackerRequest.getUrl() ) );
+ remoteIssue.setSummary( patchTrackerRequest.getSummary() );
+ remoteIssue.setDescription( patchTrackerRequest.getDescription() );
+
+ remoteIssue = jiraSession.createIssue( remoteIssue );
+
+ // TODO handle of boolean result
+ jiraSession.addBase64EncodedAttachmentsToIssue( remoteIssue.getKey(), remoteIssue.getKey(),
+ patchTrackerRequest.getPatchContent() );
+ }
+
+ PatchTrackerResult patchTrackerResult = new PatchTrackerResult();
+ patchTrackerResult.setPatchId( remoteIssue.getKey() );
+ patchTrackerResult.setPatchUrl(
+ extractBaseUrl( patchTrackerRequest.getUrl() ) + "/browse/" + remoteIssue.getKey() );
+ return patchTrackerResult;
+ }
+ catch ( RemoteAuthenticationException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( RemoteException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( java.rmi.RemoteException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ }
+
+
+ public JiraSession createSession( PatchTrackerRequest patchTrackerRequest )
+ throws PatchTrackerException
+ {
+ if ( StringUtils.isEmpty( patchTrackerRequest.getUserName() ) || StringUtils.isEmpty(
+ patchTrackerRequest.getPassword() ) )
+ {
+ // remote access not supported
+ throw new PatchTrackerException( "username or password for jira access are null or empty" );
+ }
+ JiraSoapServiceService jiraSoapServiceGetter = new JiraSoapServiceServiceLocator();
+ try
+ {
+ org.apache.maven.plugins.patchtracker.tracking.jira.soap.JiraSoapService service =
+ jiraSoapServiceGetter.getJirasoapserviceV2(
+ new URL( extractBaseUrlAsUrl( patchTrackerRequest.getUrl() ), "rpc/soap/jirasoapservice-v2" ) );
+ return new JiraSession( service, service.login( patchTrackerRequest.getUserName(),
+ patchTrackerRequest.getPassword() ),
+ extractProjectKey( patchTrackerRequest.getUrl() ) );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( ServiceException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( RemoteAuthenticationException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( RemoteException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ catch ( java.rmi.RemoteException e )
+ {
+ throw new PatchTrackerException( e.getMessage(), e );
+ }
+ }
+
+ /**
+ * @param url https://jira.codehaus.org/browse/MNG
+ * @return the project key MNG
+ */
+ protected String extractProjectKey( String url )
+ {
+ return ( StringUtils.endsWith( url, "/" ) )
+ ? StringUtils.substringAfterLast( StringUtils.removeEnd( url, "/" ), "/" )
+ : StringUtils.substringAfterLast( url, "/" );
+
+
+ }
+
+ /**
+ * @param url https://jira.codehaus.org/browse/MNG
+ * @return https://jira.codehaus.org
+ */
+ protected String extractBaseUrl( String url )
+ {
+ return StringUtils.substringBefore( url, "/browse" );
+
+ }
+
+ protected URL extractBaseUrlAsUrl( String url )
+ throws MalformedURLException
+ {
+ return new URL( extractBaseUrl( url ) );
+
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraPatchTracker.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java?rev=1204509&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java (added)
+++ maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java Mon Nov 21 14:14:59 2011
@@ -0,0 +1,63 @@
+package org.apache.maven.plugins.patchtracker.tracking.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 org.apache.maven.plugins.patchtracker.tracking.jira.soap.JiraSoapService;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteAuthenticationException;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteException;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteIssue;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemotePermissionException;
+import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteValidationException;
+
+/**
+ * @author Olivier Lamy
+ */
+public class JiraSession
+{
+ private final JiraSoapService service;
+
+ /**
+ * security token is used by the server to associate SOAP invocations with the user.
+ */
+ private final String token;
+
+ private final String projectKey;
+
+ public JiraSession( JiraSoapService service, String token, String projectKey )
+ {
+ this.service = service;
+ this.token = token;
+ this.projectKey = projectKey;
+ }
+
+ public RemoteIssue createIssue( RemoteIssue remoteIssue )
+ throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
+ java.rmi.RemoteException
+ {
+ return service.createIssue( token, remoteIssue );
+ }
+
+ public boolean addBase64EncodedAttachmentsToIssue( String issueKey, String fileName, String attachmentContent )
+ throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
+ java.rmi.RemoteException
+ {
+ return service.addBase64EncodedAttachmentsToIssue( token, issueKey, new String[]{ fileName },
+ new String[]{ attachmentContent } );
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-patch-tracker-plugin/src/main/java/org/apache/maven/plugins/patchtracker/tracking/jira/JiraSession.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision