mirror of https://github.com/apache/archiva.git
Add some code for a possible implementation for syncing repositories using only one file with the data
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@549579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
66fa6ce2c3
commit
3c07daf9e5
|
@ -15,7 +15,8 @@
|
|||
~ 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>
|
||||
|
@ -23,6 +24,19 @@
|
|||
</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>
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
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 );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
"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"
|
|
Loading…
Reference in New Issue