ease json mapping for js code

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1402488 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-26 12:57:23 +00:00
parent 8146f7ea37
commit 9a77a9926c
1 changed files with 75 additions and 0 deletions

View File

@ -21,7 +21,9 @@ package org.apache.archiva.admin.model.beans;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -73,6 +75,13 @@ public class RemoteRepository
*/ */
private Map<String, String> extraParameters; private Map<String, String> extraParameters;
/**
* field to ease json mapping wrapper on <code>extraParameters</code> field
*
* @since 1.4-M4
*/
private List<PropertyEntry> extraParametersEntries;
/** /**
* extraHeaders. * extraHeaders.
* *
@ -80,6 +89,13 @@ public class RemoteRepository
*/ */
private Map<String, String> extraHeaders; private Map<String, String> extraHeaders;
/**
* field to ease json mapping wrapper on <code>extraHeaders</code> field
*
* @since 1.4-M4
*/
private List<PropertyEntry> extraHeadersEntries;
public RemoteRepository() public RemoteRepository()
{ {
@ -226,6 +242,35 @@ public class RemoteRepository
this.extraParameters = extraParameters; this.extraParameters = extraParameters;
} }
public void addExtraParameter( String key, String value )
{
getExtraParameters().put( key, value );
}
public List<PropertyEntry> getExtraParametersEntries()
{
this.extraParametersEntries = new ArrayList<PropertyEntry>();
for ( Map.Entry<String, String> entry : getExtraParameters().entrySet() )
{
this.extraParametersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
}
return this.extraParametersEntries;
}
public void setExtraParametersEntries( List<PropertyEntry> extraParametersEntries )
{
if ( extraParametersEntries == null )
{
return;
}
this.extraParametersEntries = extraParametersEntries;
for ( PropertyEntry propertyEntry : extraParametersEntries )
{
this.addExtraParameter( propertyEntry.getKey(), propertyEntry.getValue() );
}
}
public Map<String, String> getExtraHeaders() public Map<String, String> getExtraHeaders()
{ {
if ( this.extraHeaders == null ) if ( this.extraHeaders == null )
@ -240,6 +285,36 @@ public class RemoteRepository
this.extraHeaders = extraHeaders; this.extraHeaders = extraHeaders;
} }
public void addExtraHeader( String key, String value )
{
getExtraHeaders().put( key, value );
}
public List<PropertyEntry> getExtraHeadersEntries()
{
this.extraHeadersEntries = new ArrayList<PropertyEntry>();
for ( Map.Entry<String, String> entry : getExtraHeaders().entrySet() )
{
this.extraHeadersEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) );
}
return this.extraHeadersEntries;
}
public void setExtraHeadersEntries( List<PropertyEntry> extraHeadersEntries )
{
if ( extraHeadersEntries == null )
{
return;
}
this.extraHeadersEntries = extraHeadersEntries;
for ( PropertyEntry propertyEntry : extraHeadersEntries )
{
this.addExtraHeader( propertyEntry.getKey(), propertyEntry.getValue() );
}
}
@Override @Override
public String toString() public String toString()
{ {