Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2246 - in infrastructure/jira-dpml: . svn/src/main/net/dpml/jira svn/src/test/net/dpml/jira

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: peter AT neubauer.se
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2246 - in infrastructure/jira-dpml: . svn/src/main/net/dpml/jira svn/src/test/net/dpml/jira
  • Date: Fri, 08 Apr 2005 11:51:57 -0400

Author: peter AT neubauer.se
Date: Fri Apr 8 11:51:52 2005
New Revision: 2246

Modified:
infrastructure/jira-dpml/.classpath
infrastructure/jira-dpml/index.xml
infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnHelper.java
infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnUpdateListener.java
infrastructure/jira-dpml/svn/src/test/net/dpml/jira/SvnCommandTest.java
Log:
more tweaking on the way to svn INFRA-3


Modified: infrastructure/jira-dpml/.classpath
==============================================================================
--- infrastructure/jira-dpml/.classpath (original)
+++ infrastructure/jira-dpml/.classpath Fri Apr 8 11:51:52 2005
@@ -1,25 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ <classpathentry output="svn/target/classes" kind="src"
path="svn/src/main">
<attributes>
</attributes>
</classpathentry>
- <classpathentry kind="src" path="svn/src/main">
+ <classpathentry output="svn/target/test-classes" kind="src"
path="svn/src/test">
<attributes>
</attributes>
</classpathentry>
- <classpathentry kind="var"
path="MAGIC_CACHE/atlassian-jira/jars/atlassian-jira-3.1.jar">
+ <classpathentry kind="con" path="net.dpml.MAGIC/deps">
+ <attributes>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
</attributes>
</classpathentry>
- <classpathentry kind="var"
path="MAGIC_CACHE/osuser/jars/osuser-1.0-dev-16Feb05.jar">
+ <classpathentry kind="var"
path="MAGIC_CACHE/junit/jars/junit-3.8.1.jar">
<attributes>
</attributes>
</classpathentry>
- <classpathentry kind="src" path="svn/src/test">
+ <classpathentry kind="var"
path="MAGIC_CACHE/log4j/jars/log4j-1.2.8.jar">
<attributes>
</attributes>
</classpathentry>
- <classpathentry
sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.0.0/src/org.junit_3.8.1/junitsrc.zip"
kind="var" path="JUNIT_HOME/junit.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

Modified: infrastructure/jira-dpml/index.xml
==============================================================================
--- infrastructure/jira-dpml/index.xml (original)
+++ infrastructure/jira-dpml/index.xml Fri Apr 8 11:51:52 2005
@@ -6,7 +6,7 @@
<info>
<group>atlassian-jira</group>
<name>atlassian-jira</name>
- <version>3.1</version>
+ <version>3.1.1</version>
</info>
</resource>
<resource>
@@ -16,6 +16,13 @@
<version>1.0-dev-16Feb05</version>
</info>
</resource>
+<resource>
+ <info>
+ <group>junit</group>
+ <name>junit</name>
+ <version>3.8.1</version>
+ </info>
+</resource>
<project basedir="svn">
<info>
<group>dpml/jira</group>

Modified: infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnHelper.java
==============================================================================
--- infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnHelper.java
(original)
+++ infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnHelper.java Fri
Apr 8 11:51:52 2005
@@ -17,53 +17,51 @@
*/
package net.dpml.jira;

-import java.io.IOException;
+import java.io.File;
import java.io.PrintStream;

public class SvnHelper
{
- public static void checkout( String url, String user, String password,
String destinationPath, PrintStream log ) throws Exception
+ public static void update( File workDir, PrintStream log ) throws
Exception
{
- String[] t_args = new String[]{"svn","checkout", url,
- "--username", user, "--password", password,
destinationPath};
- log.println( format(t_args) );
- executeCommand( log, t_args );
- return;
-
+ String[] t_args = new String[]{"update"};
+ log.println( format( t_args ) );
+ executeCommand( log, "svn", t_args, workDir );
+ return;

}
- public static void commit( String file, String user, String password,
PrintStream log ) throws Exception
+
+ public static void commit( String file, String user, String password,
+ PrintStream log ) throws Exception
{
- String[] t_args = new String[]{"svn","commit", file,
- "--username", user, "--password", password};
- log.println( format(t_args) );
- executeCommand( log, t_args );
- return;
-
+ String[] t_args = new String[]{"svn", "commit", file, "--username",
+ user, "--password", password};
+ log.println( format( t_args ) );
+ //executeCommand( log, t_args );
+ return;

}

private static String format( String[] iT_args )
{
StringBuffer result = new StringBuffer();
- for (int i=0; i<iT_args.length; i++ )
+ for ( int i = 0; i < iT_args.length; i++ )
{
- result.append(iT_args[i] + " ");
+ result.append( iT_args[i] + " " );
}
return result.toString();
}

- public static void updateSvnPassword( String htpasswordPath, String
passwordFilePath,
- String confirmedUser, String password, PrintStream log )
+ public static void updateSvnPassword( String htpasswordPath,
+ File passwordFilePath, String confirmedUser, String password,
+ PrintStream log, String iWorkingDir )
{
try
{
- String m_CommandLine = htpasswordPath + " " + "-b "
- + passwordFilePath + " " + confirmedUser + " " +
password;
- String[] t_args = new String[]{htpasswordPath, "-b",
passwordFilePath,
- confirmedUser, password};
+ String m_CommandLine = htpasswordPath;
+ String[] t_args = new
String[]{"-b",passwordFilePath.getAbsolutePath(), confirmedUser, password};
log.println( t_args );
- executeCommand( log, t_args );
+ executeCommand( log, m_CommandLine,t_args, new File(iWorkingDir)
);
return;
}
catch ( Exception e )
@@ -76,10 +74,10 @@

}

- private static void executeCommand( PrintStream log, String[] t_args )
throws Exception
+ private static void executeCommand( PrintStream log, String command,
String[] t_args, File workDir )
+ throws Exception
{
- Process p = Runtime.getRuntime().exec(
- t_args );
+ Process p = Runtime.getRuntime().exec( command, t_args, workDir);
if ( p.waitFor() != 0 )
{
java.io.DataInputStream dis = new java.io.DataInputStream( p
@@ -89,9 +87,9 @@
while ( ( str = dis.readLine() ) != null )
sb.append( str );
log.println( "error: " + sb );
- throw new Exception(sb.toString());
+ throw new Exception( sb.toString() );
}
return;
}
-
+
}

Modified:
infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnUpdateListener.java
==============================================================================
---
infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnUpdateListener.java
(original)
+++
infrastructure/jira-dpml/svn/src/main/net/dpml/jira/SvnUpdateListener.java
Fri Apr 8 11:51:52 2005
@@ -17,153 +17,186 @@
*/
package net.dpml.jira;

+import java.io.File;
+import java.util.Map;
+
import com.atlassian.jira.event.JiraEvent;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.event.user.UserEvent;
import com.atlassian.jira.event.user.UserEventListener;

-import java.util.Map;
-
/**
- * A listener for debugging - prints everything it 'hears' to System.err
+ * A listener for updating Svn user acoount file from Jira user events.
+ * To make the commit/checkout work, we are relying on the cached svn
credentials,
+ * so if your repo is user-protected, you woul need to check out the stuff
manually once.
+ *
* <p>
* Useful for debuggin when certain events are fired, and the content of
those
* events.
*/
-public class SvnUpdateListener extends AbstractIssueEventListener implements
UserEventListener
+public class SvnUpdateListener extends AbstractIssueEventListener implements
+ UserEventListener
{
- public void init(Map params)
+ public static final String PWD_FILE_NAME = "pwdFileName";
+
+ private Map m_Params;
+
+ public static final String WORK_DIR = "workDir";
+
+ private String m_svnWorkingDir;
+
+ private String m_passwordFile;
+
+ public void init( Map params )
{
- log("DebugListener.init");
- log(params.toString());
+ log( "SvnListener.init" );
+ log( params.toString() );
+ m_Params = params;
+
+ m_svnWorkingDir = params.get( WORK_DIR ).toString();
+ m_passwordFile = params.get( PWD_FILE_NAME ).toString();
+ try
+ {
+ SvnHelper.update( new File(m_svnWorkingDir), System.out );
+ }
+ catch ( Exception e )
+ {
+ log( "could not update:" + m_Params.toString() );
+ }
}

public String[] getAcceptedParams()
{
- return new String[0];
+ return new String[]{PWD_FILE_NAME, WORK_DIR};
}

// IssueEventListener implementation
- public void issueAssigned(IssueEvent event)
+ public void issueAssigned( IssueEvent event )
{
- log("DebugListener.issueAssigned");
- logEvent(event);
+ log( "DebugListener.issueAssigned" );
+ logEvent( event );
}

- public void issueClosed(IssueEvent event)
+ public void issueClosed( IssueEvent event )
{
- log("DebugListener.issueClosed");
- logEvent(event);
+ log( "DebugListener.issueClosed" );
+ logEvent( event );
}

- public void issueCreated(IssueEvent event)
+ public void issueCreated( IssueEvent event )
{
- log("DebugListener.issueCreated");
- logEvent(event);
+ log( "DebugListener.issueCreated" );
+ logEvent( event );
}

- public void issueResolved(IssueEvent event)
+ public void issueResolved( IssueEvent event )
{
- log("DebugListener.issueResolved");
- logEvent(event);
+ log( "DebugListener.issueResolved" );
+ logEvent( event );
}

- public void issueReopened(IssueEvent event)
+ public void issueReopened( IssueEvent event )
{
- log("DebugListener.issueReopened");
- logEvent(event);
+ log( "DebugListener.issueReopened" );
+ logEvent( event );
}

- public void issueUpdated(IssueEvent event)
+ public void issueUpdated( IssueEvent event )
{
- log("DebugListener.issueUpdated");
- logEvent(event);
+ log( "DebugListener.issueUpdated" );
+ logEvent( event );
}

- public void issueCommented(IssueEvent event)
+ public void issueCommented( IssueEvent event )
{
- log("DebugListener.issueCommented");
- logEvent(event);
+ log( "DebugListener.issueCommented" );
+ logEvent( event );
}

- public void issueDeleted(IssueEvent event)
+ public void issueDeleted( IssueEvent event )
{
- log("DebugListener.issueCommented");
- logEvent(event);
+ log( "DebugListener.issueCommented" );
+ logEvent( event );
}

- public void issueMoved(IssueEvent event)
+ public void issueMoved( IssueEvent event )
{
- log("DebugListener.issueMoved");
- logEvent(event);
+ log( "DebugListener.issueMoved" );
+ logEvent( event );
}

- public void issueWorkLogged(IssueEvent event)
+ public void issueWorkLogged( IssueEvent event )
{
- log("DebugListener.issueWorkLogged");
- logEvent(event);
+ log( "DebugListener.issueWorkLogged" );
+ logEvent( event );
}

- public void issueGenericEvent(IssueEvent event)
+ public void issueGenericEvent( IssueEvent event )
{
- log("DebugListener.issueGenericEvent");
- logEvent(event);
+ log( "DebugListener.issueGenericEvent" );
+ logEvent( event );
}

// UserEventListener implementation
- public void userSignup(UserEvent event)
+ public void userSignup( UserEvent event )
{
- log("DebugListener.userSignup");
- logEvent(event);
+ log( "DebugListener.userSignup" );
+ logEvent( event );
}

- public void userCreated(UserEvent event)
+ public void userCreated( UserEvent event )
{
- log("DebugListener.userCreated");
- logEvent(event);
+ log( "SvnListener.userCreated" );
+ logEvent( event );
+ String username = event.getUser().getEmail();
+ String password = "test";
+ SvnHelper.updateSvnPassword("/usr/bin/htpaswd2", new
File(m_svnWorkingDir, m_passwordFile), username, password, System.out,
m_svnWorkingDir);
}

- public void userForgotPassword(UserEvent event)
+ public void userForgotPassword( UserEvent event )
{
- log("DebugListener.userForgotPassword");
- logEvent(event);
+ log( "DebugListener.userForgotPassword" );
+
+ logEvent( event );
}

- public void userForgotUsername(UserEvent event)
+ public void userForgotUsername( UserEvent event )
{
- log("DebugListener.userForgotUsername");
- logEvent(event);
+ log( "DebugListener.userForgotUsername" );
+ logEvent( event );
}

- private void logEvent(JiraEvent event)
+ private void logEvent( JiraEvent event )
{
try
{
- if (event instanceof IssueEvent)
+ if ( event instanceof IssueEvent )
{
IssueEvent issueEvent = (IssueEvent) event;
- //log("Issue: [#" + issueEvent.getIssue().getLong("id") + "]
" + issueEvent.getIssue().getString("summary"));
- //log("Comment: " + issueEvent.getComment());
- //log("Change Group: " + issueEvent.getChangeLog());
+ // log("Issue: [#" + issueEvent.getIssue().getLong("id") +
"] "
+ // + issueEvent.getIssue().getString("summary"));
+ // log("Comment: " + issueEvent.getComment());
+ // log("Change Group: " + issueEvent.getChangeLog());
}
- else if (event instanceof UserEvent)
+ else if ( event instanceof UserEvent )
{
UserEvent userEvent = (UserEvent) event;
- log("User: " + userEvent.getUser().getName() + " (" +
userEvent.getUser().getEmail() + ")");
+ log( "User: " + userEvent.getUser().getName() + " ("
+ + userEvent.getUser().getEmail() + ")" );
}

- log(" Time: " + event.getTime());
+ log( " Time: " + event.getTime() );
}
- catch (Exception e)
+ catch ( Exception e )
{
e.printStackTrace();
}
}

- private void log(String msg)
+ private void log( String msg )
{
- System.err.println(this.getClass().getName() + msg);
+ System.out.println( this.getClass().getName() + msg );
}

public boolean isInternal()
@@ -178,6 +211,11 @@

public String getDescription()
{
- return "This listener will debug the events it receives to
System.err";
+ String description = "A listener for updating Svn user acoount file
from Jira user events."
+ + "<table>" +
+ "<tr><td><b>pwdFileName</b></td><td>the name of the
*.pwd file within the svnWork directory</td></tr>"
+ + "<tr><td><b>workDir</b></td><td>the directory where the
file is previously checked out with svn commit rights</td></tr>" +
+ "</table>";
+ return description;
}
}

Modified:
infrastructure/jira-dpml/svn/src/test/net/dpml/jira/SvnCommandTest.java
==============================================================================
--- infrastructure/jira-dpml/svn/src/test/net/dpml/jira/SvnCommandTest.java
(original)
+++ infrastructure/jira-dpml/svn/src/test/net/dpml/jira/SvnCommandTest.java
Fri Apr 8 11:51:52 2005
@@ -17,17 +17,35 @@
*/
package net.dpml.jira;

+import java.util.HashMap;
+import java.util.Map;
+
import junit.framework.TestCase;

public class SvnCommandTest extends TestCase
{
public void testSvnCheckout() throws Exception
{
-
SvnHelper.checkout("https://scm.dpml.net/repos/dpml/development/main/transit/core/etc/";,
"peter AT neubauer.se", "test", "/tmp/", System.out );
+ String m_1 =
"https://scm.dpml.net/repos/dpml/development/main/transit/core/etc/";;
+ String m_2 = "peter AT neubauer.se";
+ String m_string = "test";
+ String m_string2 = "target";
+ Map params = new HashMap();
+ params.put(SvnUpdateListener.SVN_CONTAINER,m_1);
+ String file = "test";
+ params.put(SvnUpdateListener.PWD_FILE_NAME,file);
+ params.put(SvnUpdateListener.USERNAME,m_1);
+ params.put(SvnUpdateListener.PASSWORD,m_string);
+ params.put(SvnUpdateListener.WORK_DIR,m_string2);
+
+ //SvnUpdateListener listener = new SvnUpdateListener();
+ //listener.init(params);
+
}
public void testSvnCommit() throws Exception
{
- SvnHelper.commit("/tmp/project.module", "peter AT neubauer.se",
"jhsmssf", "testing jira adapter", System.out );
+ assertTrue(true);
+ //SvnHelper.commit("/tmp/project.module", "peter AT neubauer.se",
"jhsmssf", "testing jira adapter", System.out );
}

}



  • svn commit: r2246 - in infrastructure/jira-dpml: . svn/src/main/net/dpml/jira svn/src/test/net/dpml/jira, peter, 04/08/2005

Archive powered by MHonArc 2.6.24.

Top of Page