You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ry...@apache.org on 2007/04/30 07:50:32 UTC
svn commit: r533596 -
/lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
Author: ryan
Date: Sun Apr 29 22:50:31 2007
New Revision: 533596
URL: http://svn.apache.org/viewvc?view=rev&rev=533596
Log:
adding a general Properties -> NamedList function
Modified:
lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java?view=diff&rev=533596&r1=533595&r2=533596
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java Sun Apr 29 22:50:31 2007
@@ -18,10 +18,12 @@
package org.apache.solr.handler.admin;
import java.io.IOException;
+import java.util.Properties;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
+import org.apache.solr.util.NamedList;
import org.apache.solr.util.SimpleOrderedMap;
/**
@@ -34,21 +36,29 @@
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException
{
- SimpleOrderedMap<String> props = new SimpleOrderedMap<String>();
+ NamedList<String> props = null;
String name = req.getParams().get( "name" );
if( name != null ) {
+ props = new SimpleOrderedMap<String>();
props.add( name, System.getProperty(name) );
}
else {
- java.util.Enumeration e = System.getProperties().propertyNames();
- while(e.hasMoreElements()) {
- String prop = (String)e.nextElement();
- props.add( prop, System.getProperty(prop) );
- }
+ props = toNamedList( System.getProperties() );
}
rsp.add( "system.properties", props );
}
+ public static NamedList<String> toNamedList( Properties p )
+ {
+ NamedList<String> props = new SimpleOrderedMap<String>();
+ java.util.Enumeration e = p.propertyNames();
+ while(e.hasMoreElements()) {
+ String prop = (String)e.nextElement();
+ props.add( prop, p.getProperty(prop) );
+ }
+ return props;
+ }
+
//////////////////////// SolrInfoMBeans methods //////////////////////
@Override
Re: svn commit: r533596 - /lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
Posted by Ryan McKinley <ry...@gmail.com>.
Bertrand Delacretaz wrote:
> On 4/30/07, ryan@apache.org <ry...@apache.org> wrote:
>
>> ...Modified:
>>
>> lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
>>
> ...
>> + public static NamedList<String> toNamedList( Properties p )
>
> IIUC this method is of general use, it might be good to move it to a
> utility class, org.apache.solr.util.NamedListUtils maybe?
>
Actually, I realized Properties implements Map so it doesn't need any
special!
Re: svn commit: r533596 - /lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
Posted by Bertrand Delacretaz <bd...@apache.org>.
On 4/30/07, ryan@apache.org <ry...@apache.org> wrote:
> ...Modified:
> lucene/solr/trunk/src/java/org/apache/solr/handler/admin/PropertiesRequestHandler.java
...
> + public static NamedList<String> toNamedList( Properties p )
IIUC this method is of general use, it might be good to move it to a
utility class, org.apache.solr.util.NamedListUtils maybe?
-Bertrand