Author: carlos
Date: Tue Feb 19 16:35:46 2008
New Revision: 629286
URL: http://svn.apache.org/viewvc?rev=629286&view=rev
Log:
Reformat
Modified:
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/CsvReader.java
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SyncedRepository.java
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/Synchronizer.java
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SynchronizerOptions.java
Modified:
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/CsvReader.java
URL:
http://svn.apache.org/viewvc/maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/CsvReader.java?rev=629286&r1=629285&r2=629286&view=diff
==============================================================================
---
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/CsvReader.java
(original)
+++
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/CsvReader.java
Tue Feb 19 16:35:46 2008
@@ -29,58 +29,66 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez</a>
* @version $Id$
*/
-public class CsvReader {
+public class CsvReader
+{
/**
* @param is
* @return [EMAIL PROTECTED] List} of [EMAIL PROTECTED] SyncedRepository}
* @throws IOException
*/
- public List parse(InputStream is) throws IOException
+ public List parse( InputStream is )
+ throws IOException
{
- InputStreamReader reader = new InputStreamReader(is);
- CSVParser parser = new CSVParser(reader);
+ InputStreamReader reader = new InputStreamReader( is );
+ CSVParser parser = new CSVParser( reader );
- try {
+ try
+ {
String[][] data = parser.getAllValues();
- List repos = new ArrayList(data.length - 1);
+ List repos = new ArrayList( data.length - 1 );
/* ignore headers line */
for ( int i = 1; i < data.length; i++ )
{
- int j = data[i].length -1;
+ int j = data[i].length - 1;
SyncedRepository repo = new SyncedRepository();
switch ( data[i].length )
{
case 7:
- repo.setSvnUrl( getValue(data[i][j--]));
+ repo.setSvnUrl( getValue( data[i][j--] ) );
case 6:
- repo.setSshOptions( getValue(data[i][j--]));
+ repo.setSshOptions( getValue( data[i][j--] ) );
case 5:
- repo.setContactMail( getValue(data[i][j--]));
+ repo.setContactMail( getValue( data[i][j--] ) );
case 4:
- repo.setContactName( getValue(data[i][j--]));
+ repo.setContactName( getValue( data[i][j--] ) );
case 3:
- repo.setProtocol(getValue( data[i][j--]));
+ repo.setProtocol( getValue( data[i][j--] ) );
case 2:
- repo.setLocation( getValue(data[i][j--]));
+ repo.setLocation( getValue( data[i][j--] ) );
case 1:
- repo.setGroupId(getValue( data[i][j--]));
+ repo.setGroupId( getValue( data[i][j--] ) );
repos.add( repo );
break;
default:
- //line ignored data[i];
+ // line ignored data[i];
}
}
return repos;
- } finally {
- try {
+ }
+ finally
+ {
+ try
+ {
reader.close();
- } catch (IOException e) {
+ }
+ catch ( IOException e )
+ {
// ignore
}
}
Modified:
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SyncedRepository.java
URL:
http://svn.apache.org/viewvc/maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SyncedRepository.java?rev=629286&r1=629285&r2=629286&view=diff
==============================================================================
---
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SyncedRepository.java
(original)
+++
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SyncedRepository.java
Tue Feb 19 16:35:46 2008
@@ -23,10 +23,13 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Carlos Sanchez</a>
* @version $Id$
*/
-public class SyncedRepository {
+public class SyncedRepository
+{
public static final String PROTOCOL_SSH = "rsync_ssh";
+
public static final String PROTOCOL_RSYNC = "rsync";
+
public static final String PROTOCOL_SVN = "svn";
private String groupId;
@@ -45,51 +48,63 @@
private String out, err;
- public void setGroupId(String groupId) {
+ public void setGroupId( String groupId )
+ {
this.groupId = groupId;
}
- public String getGroupId() {
+ public String getGroupId()
+ {
return groupId;
}
- public void setContactName(String contactName) {
+ public void setContactName( String contactName )
+ {
this.contactName = contactName;
}
- public String getContactName() {
+ public String getContactName()
+ {
return contactName;
}
- public void setContactMail(String contactMail) {
+ public void setContactMail( String contactMail )
+ {
this.contactMail = contactMail;
}
- public String getContactMail() {
+ public String getContactMail()
+ {
return contactMail;
}
- public void setLocation(String location) {
+ public void setLocation( String location )
+ {
this.location = location;
}
- public String getLocation() {
+ public String getLocation()
+ {
return location;
}
- public void setProtocol(String protocol) {
+ public void setProtocol( String protocol )
+ {
this.protocol = protocol;
}
- public String getProtocol() {
+ public String getProtocol()
+ {
return protocol;
}
- public String getSshOptions() {
+ public String getSshOptions()
+ {
return sshOptions;
}
- public void setSshOptions(String sshOptions) {
+ public void setSshOptions( String sshOptions )
+ {
this.sshOptions = sshOptions;
}
@@ -103,23 +118,28 @@
this.svnUrl = svnUrl;
}
- public String toString() {
- return ReflectionToStringBuilder.toString(this);
+ public String toString()
+ {
+ return ReflectionToStringBuilder.toString( this );
}
- public String getOut() {
+ public String getOut()
+ {
return out;
}
- public void setOut(String out) {
+ public void setOut( String out )
+ {
this.out = out;
}
- public String getErr() {
+ public String getErr()
+ {
return err;
}
- public void setErr(String err) {
+ public void setErr( String err )
+ {
this.err = err;
}
Modified:
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/Synchronizer.java
URL:
http://svn.apache.org/viewvc/maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/Synchronizer.java?rev=629286&r1=629285&r2=629286&view=diff
==============================================================================
---
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/Synchronizer.java
(original)
+++
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/Synchronizer.java
Tue Feb 19 16:35:46 2008
@@ -15,11 +15,11 @@
import org.codehaus.plexus.util.cli.Commandline;
/**
- * exclusions=$HOME/bin/synchronize/syncopate/exclusions.txt
- * BASEDIR=$HOME/repository-staging/to-ibiblio/maven2
+ * exclusions=$HOME/bin/synchronize/syncopate/exclusions.txt
BASEDIR=$HOME/repository-staging/to-ibiblio/maven2
* CHANGED_LOG=/tmp/sync-changed.log
*/
-public class Synchronizer {
+public class Synchronizer
+{
private static final String RSYNC = "rsync";
@@ -32,74 +32,89 @@
private List failedRepositories = new ArrayList();
- public Synchronizer(SynchronizerOptions options) {
+ public Synchronizer( SynchronizerOptions options )
+ {
this.options = options;
}
- public void sync(List repositories) {
+ public void sync( List repositories )
+ {
Iterator it = repositories.iterator();
- while (it.hasNext()) {
+ while ( it.hasNext() )
+ {
SyncedRepository repo = (SyncedRepository) it.next();
- try {
- sync(repo);
- } catch (RuntimeException e) {
- System.out.println("Error synchronizing repository " +
repo.getGroupId() + ". "
- + e.getMessage());
- failedRepositories.add(repo);
- } catch (InterruptedException e) {
- System.out.println("Repository sync for " + repo.getGroupId()
+ " was interrupted");
+ try
+ {
+ sync( repo );
+ }
+ catch ( RuntimeException e )
+ {
+ System.out.println( "Error synchronizing repository " +
repo.getGroupId() + ". " + e.getMessage() );
+ failedRepositories.add( repo );
+ }
+ catch ( InterruptedException e )
+ {
+ System.out.println( "Repository sync for " + repo.getGroupId()
+ " was interrupted" );
}
}
}
- public void sync(SyncedRepository repo) throws InterruptedException {
- int exitCode = syncMetadata(repo);
- if (exitCode != 0) {
- throw new RuntimeException("Error synchronizing metadata. Exit
code: " + exitCode);
+ public void sync( SyncedRepository repo )
+ throws InterruptedException
+ {
+ int exitCode = syncMetadata( repo );
+ if ( exitCode != 0 )
+ {
+ throw new RuntimeException( "Error synchronizing metadata. Exit
code: " + exitCode );
}
- exitCode = syncArtifacts(repo);
- if (exitCode != 0) {
- throw new RuntimeException("Error synchronizing artifacts. Exit
code: " + exitCode);
+ exitCode = syncArtifacts( repo );
+ if ( exitCode != 0 )
+ {
+ throw new RuntimeException( "Error synchronizing artifacts. Exit
code: " + exitCode );
}
}
- private int syncMetadata(SyncedRepository repo) throws
InterruptedException {
+ private int syncMetadata( SyncedRepository repo )
+ throws InterruptedException
+ {
Commandline cl = new Commandline();
- cl.setExecutable(RSYNC);
+ cl.setExecutable( RSYNC );
- cl.createArg().setValue("--include=*/");
- cl.createArg().setValue("--include=**/maven-metadata.xml*");
- cl.createArg().setValue("--exclude=*");
- cl.createArg().setValue("--exclude-from=" +
options.getExclusionsFile());
- addCommonArguments(cl, repo);
+ cl.createArg().setValue( "--include=*/" );
+ cl.createArg().setValue( "--include=**/maven-metadata.xml*" );
+ cl.createArg().setValue( "--exclude=*" );
+ cl.createArg().setValue( "--exclude-from=" +
options.getExclusionsFile() );
+ addCommonArguments( cl, repo );
- System.out.println("=== Synchronizing metadata " + repo.getGroupId() +
" "
- + repo.getLocation());
- return executeCommandLine(cl, repo);
+ System.out.println( "=== Synchronizing metadata " + repo.getGroupId()
+ " " + repo.getLocation() );
+ return executeCommandLine( cl, repo );
}
- private int syncArtifacts(SyncedRepository repo) {
+ private int syncArtifacts( SyncedRepository repo )
+ {
Commandline cl = new Commandline();
- cl.setExecutable(RSYNC);
+ cl.setExecutable( RSYNC );
- cl.createArg().setValue("--exclude-from=" +
options.getExclusionsFile());
- cl.createArg().setValue("--ignore-existing");
- addCommonArguments(cl, repo);
+ cl.createArg().setValue( "--exclude-from=" +
options.getExclusionsFile() );
+ cl.createArg().setValue( "--ignore-existing" );
+ addCommonArguments( cl, repo );
- System.out.println("=== Synchronizing artifacts " + repo.getGroupId()
+ " "
- + repo.getLocation());
- return executeCommandLine(cl, repo);
+ System.out.println( "=== Synchronizing artifacts " + repo.getGroupId()
+ " " + repo.getLocation() );
+ return executeCommandLine( cl, repo );
}
- private void addCommonArguments(Commandline cl, SyncedRepository repo) {
- if (options.isDryRun()) {
- cl.createArg().setValue(DRY_RUN);
+ private void addCommonArguments( Commandline cl, SyncedRepository repo )
+ {
+ if ( options.isDryRun() )
+ {
+ cl.createArg().setValue( DRY_RUN );
}
// cl.createArg().setValue("$RSYNC_OPTS");
- cl.createArg().setValue("-Lrtivz");
- if (SyncedRepository.PROTOCOL_SSH.equals(repo.getProtocol())) {
+ cl.createArg().setValue( "-Lrtivz" );
+ if ( SyncedRepository.PROTOCOL_SSH.equals( repo.getProtocol() ) )
+ {
String s = repo.getSshOptions() == null ? "" :
repo.getSshOptions();
- cl.createArg().setValue("--rsh=ssh " + s);
+ cl.createArg().setValue( "--rsh=ssh " + s );
}
String groupDir = "";
@@ -111,98 +126,126 @@
cl.createArg().setValue( options.getBasedir() + "/" + groupDir );
}
- private int executeCommandLine(Commandline cl, SyncedRepository repo) {
+ private int executeCommandLine( Commandline cl, SyncedRepository repo )
+ {
CommandLineUtils.StringStreamConsumer out = new
CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer err = new
CommandLineUtils.StringStreamConsumer();
- System.out.println("About to execute " + cl);
+ System.out.println( "About to execute " + cl );
int exitCode;
- try {
- exitCode = CommandLineUtils.executeCommandLine(cl, out, err,
TIMEOUT);
- } catch (CommandLineException e) {
- throw new RuntimeException(e);
+ try
+ {
+ exitCode = CommandLineUtils.executeCommandLine( cl, out, err,
TIMEOUT );
+ }
+ catch ( CommandLineException e )
+ {
+ throw new RuntimeException( e );
}
- repo.setOut(out.getOutput());
+ repo.setOut( out.getOutput() );
String serr = err.getOutput();
- if ((serr != null) && serr.length() > 0) {
- repo.setErr(serr);
+ if ( ( serr != null ) && serr.length() > 0 )
+ {
+ repo.setErr( serr );
}
return exitCode;
}
- public static void main(String[] args) {
- if ((args.length != 2) && (args.length != 3)) {
- System.out.println("Arguments required: CONFIG_PROPERTIES_FILE
REPOSITORIES_FILE [go]");
+ public static void main( String[] args )
+ {
+ if ( ( args.length != 2 ) && ( args.length != 3 ) )
+ {
+ System.out.println( "Arguments required: CONFIG_PROPERTIES_FILE
REPOSITORIES_FILE [go]" );
return;
}
int i = 0;
- SynchronizerOptions options = SynchronizerOptions.parse(new
File(args[i++]));
- Synchronizer synchronizer = new Synchronizer(options);
+ SynchronizerOptions options = SynchronizerOptions.parse( new File(
args[i++] ) );
+ Synchronizer synchronizer = new Synchronizer( options );
FileInputStream is = null;
- try {
- is = new FileInputStream(new File(args[i++]));
- } catch (FileNotFoundException e) {
- System.err.println("Repositories file " + args[i - 1] + " is not
present");
+ try
+ {
+ is = new FileInputStream( new File( args[i++] ) );
+ }
+ catch ( FileNotFoundException e )
+ {
+ System.err.println( "Repositories file " + args[i - 1] + " is not
present" );
}
List repositories;
- try {
- repositories = new CsvReader().parse(is);
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- try {
+ try
+ {
+ repositories = new CsvReader().parse( is );
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ finally
+ {
+ try
+ {
is.close();
- } catch (IOException e) {
+ }
+ catch ( IOException e )
+ {
}
}
- if (args.length == 3) {
+ if ( args.length == 3 )
+ {
String go = args[i++];
- if ((go != null) && ("go".equals(go))) {
- options.setDryRun(false);
+ if ( ( go != null ) && ( "go".equals( go ) ) )
+ {
+ options.setDryRun( false );
}
}
- synchronizer.sync(repositories);
+ synchronizer.sync( repositories );
- if (synchronizer.failedRepositories.isEmpty()) {
- synchronizer.sendEmail("SUCCESS", "--- All repositories
synchronized successfully ---");
- } else {
+ if ( synchronizer.failedRepositories.isEmpty() )
+ {
+ synchronizer.sendEmail( "SUCCESS", "--- All repositories
synchronized successfully ---" );
+ }
+ else
+ {
StringBuffer sb = new StringBuffer();
- sb.append("--- Some repositories were not synchronized ---");
+ sb.append( "--- Some repositories were not synchronized ---" );
Iterator it = synchronizer.failedRepositories.iterator();
- while (it.hasNext()) {
+ while ( it.hasNext() )
+ {
SyncedRepository repo = (SyncedRepository) it.next();
- sb.append(repo.getGroupId());
- sb.append("\n");
- sb.append(repo.getErr());
- sb.append("\n");
- sb.append("\n");
+ sb.append( repo.getGroupId() );
+ sb.append( "\n" );
+ sb.append( repo.getErr() );
+ sb.append( "\n" );
+ sb.append( "\n" );
}
- synchronizer.sendEmail("FAILURE", sb.toString());
+ synchronizer.sendEmail( "FAILURE", sb.toString() );
}
/* send email out */
}
- private void sendEmail(String subject, String text) {
+ private void sendEmail( String subject, String text )
+ {
SimpleEmail email = new SimpleEmail();
- email.setHostName(options.getMailHostname());
- try {
- email.addTo(options.getMailTo());
- email.setFrom(options.getMailFrom());
- email.setSubject(options.getMailSubject() + " " + subject);
- email.setMsg(text);
+ email.setHostName( options.getMailHostname() );
+ try
+ {
+ email.addTo( options.getMailTo() );
+ email.setFrom( options.getMailFrom() );
+ email.setSubject( options.getMailSubject() + " " + subject );
+ email.setMsg( text );
email.send();
- } catch (EmailException e) {
- throw new RuntimeException(e);
+ }
+ catch ( EmailException e )
+ {
+ throw new RuntimeException( e );
}
}
}
Modified:
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SynchronizerOptions.java
URL:
http://svn.apache.org/viewvc/maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SynchronizerOptions.java?rev=629286&r1=629285&r2=629286&view=diff
==============================================================================
---
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SynchronizerOptions.java
(original)
+++
maven/archiva/tools/trunk/maven-meeper/src/main/java/org/apache/maven/archiva/meeper/SynchronizerOptions.java
Tue Feb 19 16:35:46 2008
@@ -6,122 +6,165 @@
import java.io.IOException;
import java.util.Properties;
-public class SynchronizerOptions {
+public class SynchronizerOptions
+{
private static final String BASEDIR = "basedir";
+
private static final String LOG_FILE = "log";
+
private static final String EXCLUSIONS_FILE = "exclusionsFile";
+
private static final String MAIL_HOST_NAME = "mailHostName";
+
private static final String MAIL_TO = "mailTo";
+
private static final String MAIL_FROM = "mailFrom";
+
private static final String MAIL_SUBJECT = "mailSubject";
+
private static final String MAIL_FOOTER = "mailFooter";
+
private String exclusionsFile;
+
private String basedir;
+
private String logFile;
+
private boolean dryRun = true;
+
private String mailHostname, mailTo, mailFrom, mailSubject, mailFooter;
- public String getExclusionsFile() {
+ public String getExclusionsFile()
+ {
return exclusionsFile;
}
- public void setExclusionsFile(String exclusionsFile) {
+ public void setExclusionsFile( String exclusionsFile )
+ {
this.exclusionsFile = exclusionsFile;
}
- public String getBasedir() {
+ public String getBasedir()
+ {
return basedir;
}
- public void setBasedir(String basedir) {
+ public void setBasedir( String basedir )
+ {
this.basedir = basedir;
}
- public String getLogFile() {
+ public String getLogFile()
+ {
return logFile;
}
- public void setLogFile(String logFile) {
+ public void setLogFile( String logFile )
+ {
this.logFile = logFile;
}
- public void setDryRun(boolean dryRun) {
+ public void setDryRun( boolean dryRun )
+ {
this.dryRun = dryRun;
}
- public boolean isDryRun() {
+ public boolean isDryRun()
+ {
return dryRun;
}
- public static SynchronizerOptions parse(File f) {
+ public static SynchronizerOptions parse( File f )
+ {
FileInputStream is;
- try {
- is = new FileInputStream(f);
- } catch (FileNotFoundException e) {
- throw new IllegalArgumentException("File does not exist: " + f, e);
+ try
+ {
+ is = new FileInputStream( f );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new IllegalArgumentException( "File does not exist: " + f, e
);
}
Properties properties = new Properties();
- try {
- properties.load(is);
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- try {
+ try
+ {
+ properties.load( is );
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ finally
+ {
+ try
+ {
is.close();
- } catch (IOException e) {
+ }
+ catch ( IOException e )
+ {
}
}
SynchronizerOptions options = new SynchronizerOptions();
- options.setExclusionsFile(properties.getProperty(EXCLUSIONS_FILE));
- options.setLogFile(properties.getProperty(LOG_FILE));
- options.setBasedir(properties.getProperty(BASEDIR));
- options.setMailHostname(properties.getProperty(MAIL_HOST_NAME));
- options.setMailTo(properties.getProperty(MAIL_TO));
- options.setMailFrom(properties.getProperty(MAIL_FROM));
- options.setMailSubject(properties.getProperty(MAIL_SUBJECT));
+ options.setExclusionsFile( properties.getProperty( EXCLUSIONS_FILE ) );
+ options.setLogFile( properties.getProperty( LOG_FILE ) );
+ options.setBasedir( properties.getProperty( BASEDIR ) );
+ options.setMailHostname( properties.getProperty( MAIL_HOST_NAME ) );
+ options.setMailTo( properties.getProperty( MAIL_TO ) );
+ options.setMailFrom( properties.getProperty( MAIL_FROM ) );
+ options.setMailSubject( properties.getProperty( MAIL_SUBJECT ) );
return options;
}
- public void setMailHostname(String mailHostname) {
+ public void setMailHostname( String mailHostname )
+ {
this.mailHostname = mailHostname;
}
- public String getMailHostname() {
+ public String getMailHostname()
+ {
return mailHostname;
}
- public String getMailTo() {
+ public String getMailTo()
+ {
return mailTo;
}
- public void setMailTo(String mailTo) {
+ public void setMailTo( String mailTo )
+ {
this.mailTo = mailTo;
}
- public String getMailFrom() {
+ public String getMailFrom()
+ {
return mailFrom;
}
- public void setMailFrom(String mailFrom) {
+ public void setMailFrom( String mailFrom )
+ {
this.mailFrom = mailFrom;
}
- public String getMailSubject() {
+ public String getMailSubject()
+ {
return mailSubject;
}
- public void setMailSubject(String mailSubject) {
+ public void setMailSubject( String mailSubject )
+ {
this.mailSubject = mailSubject;
}
- public void setMailFooter(String mailFooter) {
+ public void setMailFooter( String mailFooter )
+ {
this.mailFooter = mailFooter;
}
- public String getMailFooter() {
+ public String getMailFooter()
+ {
return mailFooter;
}
}