~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.maven.archiva</groupId>
<artifactId>archiva-parent</artifactId>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-meeper</artifactId>
- <packaging>pom</packaging>
<name>Maven Meeper</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-csv</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
</project>
--- /dev/null
+package org.apache.maven.archiva.meeper;
+
+/*
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.csv.CSVParser;
+
+/**
+ * Read a csv file with the synced repositories information
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class Reader
+{
+ private CSVParser parser;
+
+ public Reader( InputStream stream )
+ {
+ parser = new CSVParser( new InputStreamReader( stream ) );
+ }
+
+ public List parse()
+ throws IOException
+ {
+ String[][] data = parser.getAllValues();
+ List repos = new ArrayList( data.length - 1 );
+
+ /* ignore headers line */
+ for ( int i = 1; i < data.length; i++ )
+ {
+ int j = 0;
+ SyncedRepository repo = new SyncedRepository();
+ repo.setGroupId( data[i][j++] );
+ repo.setLocation( data[i][j++] );
+ repo.setProtocol( data[i][j++] );
+ repo.setContactName( data[i][j++] );
+ repo.setContactMail( data[i][j++] );
+ repos.add( repo );
+ }
+
+ return repos;
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.meeper;
+
+/*
+ * 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.builder.ReflectionToStringBuilder;
+
+/**
+ * Stores a synced repository data.
+ *
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SyncedRepository
+{
+ private String groupId;
+
+ private String location;
+
+ private String protocol;
+
+ private String contactName;
+
+ private String contactMail;
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setContactName( String contactName )
+ {
+ this.contactName = contactName;
+ }
+
+ public String getContactName()
+ {
+ return contactName;
+ }
+
+ public void setContactMail( String contactMail )
+ {
+ this.contactMail = contactMail;
+ }
+
+ public String getContactMail()
+ {
+ return contactMail;
+ }
+
+ public void setLocation( String location )
+ {
+ this.location = location;
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public void setProtocol( String protocol )
+ {
+ this.protocol = protocol;
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public String toString()
+ {
+ return ReflectionToStringBuilder.toString( this );
+ }
+}
--- /dev/null
+package org.apache.maven.archiva.meeper;
+
+/*
+ * 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.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class ReaderTest
+ extends TestCase
+{
+
+ private Reader reader;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ reader = new Reader( this.getClass().getClassLoader()
+ .getResourceAsStream( "org/apache/maven/archiva/meeper/sync.csv" ) );
+ }
+
+ public void testParse()
+ throws Exception
+ {
+ List repos = reader.parse();
+ assertEquals( 2, repos.size() );
+ for ( Iterator it = repos.iterator(); it.hasNext(); )
+ {
+ SyncedRepository repo = (SyncedRepository) it.next();
+ System.out.println( repo );
+ }
+ }
+
+}
--- /dev/null
+"groupId","location","protocol","contactName","contactMail"
+"asm","maven@forge.objectweb.org:../../groups/maven/htdocs/maven2","rsync_ssh","EugeneKuleshov","eu@javatx.org"
+"ch.qos.logback","rsync://pixie.qos.ch/mvnrepo","rsync","Ceki Gulcu","ceki@qos.ch"