From 86d4b5acb64066723ce4860486efb36ae408cedc Mon Sep 17 00:00:00 2001 From: evenisse Date: Tue, 3 Feb 2004 12:02:06 +0000 Subject: [PATCH] Initial version of jira issues status report git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114671 13f79535-47bb-0310-9956-ffa450edef68 --- jira/.cvsignore | 5 + jira/maven.xml | 3 + jira/plugin.jelly | 56 ++++ jira/plugin.properties | 4 + jira/project.properties | 9 + jira/project.xml | 46 ++++ .../org/apache/maven/jira/JiraDownloader.java | 239 ++++++++++++++++++ .../plugin-resources/images/status_closed.gif | Bin 0 -> 340 bytes .../images/status_inprogress.gif | Bin 0 -> 341 bytes .../plugin-resources/images/status_open.gif | Bin 0 -> 339 bytes .../images/status_reopened.gif | Bin 0 -> 346 bytes .../images/status_resolved.gif | Bin 0 -> 340 bytes jira/src/plugin-resources/jira.jsl | 75 ++++++ 13 files changed, 437 insertions(+) create mode 100644 jira/.cvsignore create mode 100644 jira/maven.xml create mode 100644 jira/plugin.jelly create mode 100644 jira/plugin.properties create mode 100644 jira/project.properties create mode 100644 jira/project.xml create mode 100644 jira/src/main/org/apache/maven/jira/JiraDownloader.java create mode 100644 jira/src/plugin-resources/images/status_closed.gif create mode 100644 jira/src/plugin-resources/images/status_inprogress.gif create mode 100644 jira/src/plugin-resources/images/status_open.gif create mode 100644 jira/src/plugin-resources/images/status_reopened.gif create mode 100644 jira/src/plugin-resources/images/status_resolved.gif create mode 100644 jira/src/plugin-resources/jira.jsl diff --git a/jira/.cvsignore b/jira/.cvsignore new file mode 100644 index 00000000..7244964b --- /dev/null +++ b/jira/.cvsignore @@ -0,0 +1,5 @@ +target +velocity.log +maven.log +.classpath +.project diff --git a/jira/maven.xml b/jira/maven.xml new file mode 100644 index 00000000..78ca961d --- /dev/null +++ b/jira/maven.xml @@ -0,0 +1,3 @@ + + + diff --git a/jira/plugin.jelly b/jira/plugin.jelly new file mode 100644 index 00000000..b86de005 --- /dev/null +++ b/jira/plugin.jelly @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jira/plugin.properties b/jira/plugin.properties new file mode 100644 index 00000000..c04800af --- /dev/null +++ b/jira/plugin.properties @@ -0,0 +1,4 @@ +# ------------------------------------------------------------------- +# P L U G I N P R O P E R I E S +# ------------------------------------------------------------------- +maven.jira.nbentries=1000 diff --git a/jira/project.properties b/jira/project.properties new file mode 100644 index 00000000..f21345e9 --- /dev/null +++ b/jira/project.properties @@ -0,0 +1,9 @@ +# ------------------------------------------------------------------- +# P R O J E C T P R O P E R T I E S +# ------------------------------------------------------------------- +maven.xdoc.date=left +## maven.xdoc.version=${pom.currentVersion} +maven.license.licenseFile=${basedir}/../LICENSE.txt +maven.checkstyle.header.file=${basedir}/../LICENSE.txt +maven.checkstyle.format = turbine +maven.checkstyle.properties = ${basedir}/../checkstyle.xml diff --git a/jira/project.xml b/jira/project.xml new file mode 100644 index 00000000..e702f6da --- /dev/null +++ b/jira/project.xml @@ -0,0 +1,46 @@ + + + + ../project.xml + 3 + maven-jira-plugin + Maven JIRA Plug-in + 1.0-SNAPSHOT + + Download issue from Jira + http://maven.apache.org/reference/plugins/jira/ + /www/maven.apache.org/reference/plugins/jira/ + + scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven/src/plugins-build/jira/ + http://cvs.apache.org/viewcvs/maven/src/plugins-build/jira/ + + + + + commons-httpclient + commons-httpclient + 2.0-rc2 + + + commons-jelly + commons-jelly + 20030902.160215 + + + commons-logging + commons-logging + 1.0.3 + + + + log4j + log4j + 1.2.8 + + + maven + maven + 1.0-rc1 + + + diff --git a/jira/src/main/org/apache/maven/jira/JiraDownloader.java b/jira/src/main/org/apache/maven/jira/JiraDownloader.java new file mode 100644 index 00000000..718afb46 --- /dev/null +++ b/jira/src/main/org/apache/maven/jira/JiraDownloader.java @@ -0,0 +1,239 @@ +package org.apache.maven.jira; + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache Maven" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache Maven", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * ==================================================================== + */ + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HostConfiguration; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpState; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.StatusLine; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.methods.GetMethod; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.apache.maven.jelly.MavenJellyContext; +import org.apache.maven.project.Project; + +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; + +public class JiraDownloader +{ + /** + * Log for debug output + */ + private static Log LOG = LogFactory.getLog(JiraDownloader.class); + + /** Output file for xml document */ + private File output; + + /** Number of entries max */ + private int nbEntriesMax; + + private Project project; + + /** + * Set the output file for the log. + * @param output the output file + */ + public void setOutput(File output) + { + this.output = output; + } + + /** + * @return Project + */ + public Object getProject() + { + return project; + } + + /** + * Sets the project. + * @param project The project to set + */ + public void setProject(Object project) + { + //System.out.println("Setting project: " + project); + this.project = (Project) project; + } + + /** + * Sets the number of entries. + * @param nbEntries The number of entries + */ + public void setNbEntries(int nbEntries) + { + nbEntriesMax = nbEntries; + } + + public void doExecute() throws Exception + { + MavenJellyContext ctx; + String proxyHost; + String proxyPort; + String proxyUser; + String proxyPass; + String link; + + if (getProject() == null) + { + throw new Exception("No project set."); + } + else + { + if (((Project) getProject()).getIssueTrackingUrl() == null) + { + throw new Exception("No issue tracking url set."); + } + else + { + String url = ((Project) getProject()).getIssueTrackingUrl(); + int pos = url.indexOf("?"); + String id = url.substring(pos+4); + url = url.substring(0, url.lastIndexOf("/")); + link = url + "/secure/IssueNavigator.jspa?view=rss&pid=" + id + "&sorter/field=issuekey&sorter/order=DESC&sorter/field=status&sorter/order=DESC&tempMax=" + String.valueOf(nbEntriesMax) + "&reset=true"; + } + } + + ctx = ((Project) getProject()).getContext(); + + proxyHost = ctx.getProxyHost(); + proxyPort = ctx.getProxyPort(); + proxyUser = ctx.getProxyUserName(); + proxyPass = ctx.getProxyPassword(); + + try + { + HttpClient cl = new HttpClient(); + HostConfiguration hc = new HostConfiguration(); + + if (proxyHost != null) + { + hc.setProxy(proxyHost, Integer.parseInt(proxyPort)); + } + HttpState state = new HttpState(); + + if (proxyUser != null && proxyPass != null) + { + state.setProxyCredentials(null, null, new UsernamePasswordCredentials(proxyUser, proxyPass)); + } + + cl.setHostConfiguration(hc); + cl.setState(state); + + // execute the GET + GetMethod gm = download(cl, link); + StatusLine sl = gm.getStatusLine(); + + if (sl == null) { + LOG.info("Unknown error validating link : " + link); + return; + } + + if (gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) + { + Header locationHeader = gm.getResponseHeader("Location"); + if (locationHeader == null) { + LOG.info("Site sent redirect, but did not set Location header"); + } else { + String newLink = locationHeader.getValue(); + LOG.debug("Following 1 redirect to " + newLink); + gm = download(cl, newLink); + } + } + + if (gm.getStatusCode() != HttpStatus.SC_OK) + { + String msg = "Received: [" + gm.getStatusCode() + "] for " + link; + LOG.info(msg); + System.out.println(msg); + } + + } + catch (Exception e) + { + LOG.warn("Error accessing " + link); + e.printStackTrace(); + } + } + + private GetMethod download(HttpClient cl, String link) + { + GetMethod gm = new GetMethod(link); + try + { + System.out.println("Downloading " + link); + gm.setFollowRedirects(true); + cl.executeMethod(gm); + final String strGetResponseBody = gm.getResponseBodyAsString(); + PrintWriter pw = new PrintWriter(new FileWriter(output)); + pw.print(strGetResponseBody); + pw.close(); + } + catch (Exception e) + { + System.out.println("Error downloading " + link); + } + return gm; + } +} diff --git a/jira/src/plugin-resources/images/status_closed.gif b/jira/src/plugin-resources/images/status_closed.gif new file mode 100644 index 0000000000000000000000000000000000000000..3328751882373b3045dfecadc49c27a9d9e52be8 GIT binary patch literal 340 zcmZ?wbhEHb6krfwxXJ(mvTIxzjAt^$F=Q`V#VY7;o3b(ZPVmuFchrqC4X+sn?JH1J zj|wQ>=@2uQfx+1LjIpHq;_QdnPB)$EW}Ft5kCt=jcfRQ3o4X7J9ZaT=%9Tmh+IpMveF4^k5v_Mf?MPkF7UvQCngVTz<`-2eao z!EPa$Q2fclD#D=4paaqg@)HAF;elxd9y(Iii;i=p>SPJ^ajo#IN#L1wyx@SYk=8UO zPm38mJsMY=TQjDrK7W;LCog03QL({DA;(Lexx$T~Sth1YSfJ9GU!7S^GPSvdmzkSg mSWdI2w^Uq?i#aNUUyylGNUt(8&Ryl|M zqo?k$3i>A}b-$Wlq@fq*5Ht7xs-l}&TKpWw|0j9=Ki{sX9(68NM_eK7|DqJ%+ztN^ z&Af8`k-AZ)v2j{{Qsd=p1N+2P0#d;*m)8E@RR90@LP^!Q|I-5gugE)d;hvUZiU5z5 zvQ84nEu;g*pDe5*4D1X#Agv%jF|ZXKXfE*3k+POQ;FYT5WFzRj%#$UDg`1(Y!ca$Q zaqfc!S&V)>SqFp|SnlbpEtFMY@#$>vu#1Vl!KkRBn(LY^lf%aGsPij2y|K8e9 z$J-RuqkxL|?dLnh%nc~s`C(7~`*nf;-`~jZIVvn4t)Un9e}BUNlNILi>pgR~`Q~o; zzs=+Sk(|02r#Y?WUb+5A-6-?_ligtzyZ@hSmG)dBt`KHyoc4dCwM*s}0jXf0g6(H6 z+*8&`3NGDM)OTFVFeRdLkECkc|NsBN4#Y<&{$yblVK8CP0Vx9ciGi)$VOD{Mj+C>8 z`QSAY9@QH{<{9 literal 0 HcmV?d00001 diff --git a/jira/src/plugin-resources/images/status_resolved.gif b/jira/src/plugin-resources/images/status_resolved.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ceb7999909f450c7a7f825a31178c52c2ff103a GIT binary patch literal 340 zcmZ?wbhEHb6krfwxXJ(m@%Q5yjAt^$F(fq}IC|=iRpJI#LI2(tz0#gb6xE~3o|I_> zuM8;O$-rRz;@68MZ-Hg+mR&%dhf23}dIpfug zu!`N;53|J;!hCZ#7#pVvNCjIZZ#{G2o@eehWu2tp(p^P;$F&SoA}aSts>c2Q{~zoS zatOtrEUY37IzR{nAU`p%6*^2S@X(PmRdnx4(TOt?J-ytsq=846y>!I}AHGFvC!`du z;aYQW@ym?evdxWx4UU2#A1$2XdIhXhnFVAxgt%**_*m3M*qB?|GDh%OUz9KW4k7-j>QvMbfM+R#Ei11|v literal 0 HcmV?d00001 diff --git a/jira/src/plugin-resources/jira.jsl b/jira/src/plugin-resources/jira.jsl new file mode 100644 index 00000000..70cb8f62 --- /dev/null +++ b/jira/src/plugin-resources/jira.jsl @@ -0,0 +1,75 @@ + + + + + + + + Jira Report + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeySummaryStatusResolutionBy
${key}${summary} + + + + + + + + + + + + + + + + + + + + ${status} + ${resolution}${assignee}
+
+
+ +
+
+ +
\ No newline at end of file