Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4669 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard

Subject: perfsonar development work

List archive

perfsonar: r4669 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4669 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard
  • Date: Sun, 26 Oct 2008 19:12:57 -0400

Author: pgerakios
Date: 2008-10-26 19:12:57 -0400 (Sun, 26 Oct 2008)
New Revision: 4669

Added:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedMap.java
Modified:
branches/WebAdmin/CHANGELOG
branches/WebAdmin/ant/const.properties
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/LoadClass.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedSet.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
Log:
0.9.9b

Modified: branches/WebAdmin/CHANGELOG
===================================================================
--- branches/WebAdmin/CHANGELOG 2008-10-24 13:36:12 UTC (rev 4668)
+++ branches/WebAdmin/CHANGELOG 2008-10-26 23:12:57 UTC (rev 4669)
@@ -10,3 +10,9 @@
version 0.9.8b

- Fixed some unknown bugs introduced by version 0.9.7b
+
+0.9.9b:
+
+Fixed section ordering issue - Groups in wizard.properties are displayed in
the order read in the .properties file
+- LoadClass now matches the types of arguments with an appropriate
constructor super-type.
+

Modified: branches/WebAdmin/ant/const.properties
===================================================================
--- branches/WebAdmin/ant/const.properties 2008-10-24 13:36:12 UTC (rev
4668)
+++ branches/WebAdmin/ant/const.properties 2008-10-26 23:12:57 UTC (rev
4669)
@@ -9,7 +9,7 @@
target.server=127.0.0.1
service.name=perfsonar-web-admin
jarfilename=perfsonar-web-admin
-version=0.9.8b
+version=0.9.9b

antcontrib.jar=${basedir}/lib/misc/ant-contrib-1.0b3.jar
antpsbase.jar=${basedir}/lib/misc/perfsonar-base-ant-1.0.20080303.jar

Modified: branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-10-24 13:36:12 UTC (rev 4668)
+++ branches/WebAdmin/perfSONARWebAdmin/admin/wizard/Wizard.java
2008-10-26 23:12:57 UTC (rev 4669)
@@ -5,6 +5,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Iterator;
import java.util.Properties;

@@ -32,11 +33,13 @@

import perfSONARWebAdmin.auxiliary.LoadClass;
import perfSONARWebAdmin.auxiliary.MaskedException;
+import perfSONARWebAdmin.auxiliary.OrderedMap;

/**
* Servlet to be used as a wizard for configuring perfSONAR service
*
* @author Michalis Michael, CyNet
+ * @author Prodromos Gerakios, GRNET
*
*/
@SuppressWarnings("serial")
@@ -86,7 +89,7 @@
super.init(arg0);
// Initializing all fields
properties = new WizardProperties();
- groupedProperties = new Hashtable<String, WizardProperties>();
+ //groupedProperties = new OrderedMap<String,
WizardProperties>();
ServletContext sc = getServletContext();
ServicePath = sc.getRealPath("/");


Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/LoadClass.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/LoadClass.java
2008-10-24 13:36:12 UTC (rev 4668)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/LoadClass.java
2008-10-26 23:12:57 UTC (rev 4669)
@@ -1,8 +1,30 @@
package perfSONARWebAdmin.auxiliary;
+import java.lang.reflect.Constructor;

public class LoadClass
{

+ public static boolean isSubtype( Class cls1 , Class cls2 )
+ {
+ return cls2.isAssignableFrom(cls1);
+ }
+
+ public static boolean isSubtype( Class[] acls1 , Class[] acls2 )
+ {
+ if( (acls1 == null && acls2 != null) || (acls1 != null && acls2 ==
null ) ) return false;
+ if( acls1 == null ) return true;
+ if( acls1.length != acls2.length ) return false;
+ for(int i = 0 ; i < acls1.length ; i++ ) if(
!isSubtype(acls1[i],acls2[i]) ) return false;
+ return true;
+ }
+
+ public static Constructor findConstructor( Class cls1 , Class[] args )
+ {
+ Constructor[] cons = cls1.getConstructors();
+ for( Constructor c : cons ) if( isSubtype( args ,
c.getParameterTypes() ) ) return c;
+ return null;
+ }
+
public static Object load( String name , Object[] args ) throws
MaskedException
{
Class cls = null;
@@ -14,7 +36,16 @@
{
Class[] argsClass = new Class[args.length];
for(int i = 0; i < args.length ; i++ ) argsClass[i] =
args[i].getClass(); /* Construct corresponding Class array */
- return cls.getConstructor(argsClass).newInstance(args);
+ try
+ {
+ return cls.getConstructor(argsClass).newInstance(args);
+ }
+ catch( Throwable t )
+ {
+ Constructor c =
findConstructor(cls,argsClass);
+ if( c == null ) throw t;
+ return c.newInstance(args);
+ }
}
}
catch( LinkageError le )

Added: branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedMap.java

Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedSet.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedSet.java
2008-10-24 13:36:12 UTC (rev 4668)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/OrderedSet.java
2008-10-26 23:12:57 UTC (rev 4669)
@@ -532,31 +532,34 @@
} // end of RNulls
};

-public final class OrderedSet extends AbstractSet {
+public class OrderedSet<A> extends AbstractSet<A> {

/** Queue of collections of elements. */
- private java.util.LinkedList queue = new java.util.LinkedList ();
+ private java.util.LinkedList queue = new java.util.LinkedList();
/** Objects stored in this set. */
Object[] objects = null;

/** Creates new OrderedSet */
public OrderedSet() { }

- public boolean add(Object obj) {
- queue.add (Collections.singleton(obj));
- return true;
- }
+ public boolean add(A obj)
+ {
+ queue.add ( Collections.singleton(obj));
+ return true;
+ }

/**
* * Adds all of the elements in the specified collection
to this collection.
* */
- public boolean addAll(Collection coll) {
+ public boolean addAll(Collection<? extends A> coll)
+ {
queue.add (coll);
return true;
- }
+ }


- private Object[] getObjects() {
+ private Object[] getObjects()
+ {
if (objects != null) return objects;

class Col2Enum implements
Enumerations.Processor
@@ -569,42 +572,31 @@
Enumeration altered = Enumerations.convert
(Collections.enumeration (queue), new Col2Enum () );
Enumeration sequenced = Enumerations.concat (altered);
Enumeration result = Enumerations.removeDuplicates (sequenced);
- ArrayList objectList = new ArrayList();
+ ArrayList<A> objectList = new ArrayList<A>();
for (int i = 0; result.hasMoreElements();
i++) {
- objectList.add(result.nextElement());
+ objectList.add((A)result.nextElement());
}
- objects = objectList.toArray();
-
+ objects = objectList.toArray();
return objects;
}


/**

* * Returns an iterator over the elements contained in this
collection.

* */
-
public Iterator iterator() {
-
final int size = getObjects().length;
-
return new Iterator() {
-
int i
= 0;
-

public boolean hasNext() {
-

return
i < size;
-


}
-


-

public Object
next() {
-


return objects[i++];
-


}
-



-


public void remove() {
-


throw new
UnsupportedOperationException("Remove is not supported.");
-



}
-


};
-
}
+ public Iterator<A> iterator()
+ {
+ final int size = getObjects().length;
+ return new Iterator<A>()
+ {
+ int i = 0;
+ public boolean hasNext() { return
i < size; }
+ public A next() { return (A) objects[i++]; }
+ public void remove() { throw new
UnsupportedOperationException("Remove is not supported."); }
+ };
+ }


-
/**
-
* * Returns the number of elements in this collection.
-
* */
-
public int size() {
-
return getObjects().length;
-
}
+ /**
+ * Returns the number of elements in this collection.
+ * */
+ public int size() { return getObjects().length; }
}
-
-

Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-10-24 13:36:12 UTC (rev 4668)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/HTMLOutput.java
2008-10-26 23:12:57 UTC (rev 4669)
@@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@@ -350,13 +351,12 @@

private String mainBody( Hashtable<String, WizardProperties>
Properties )
{
- List<String> groupnames = new
ArrayList<String>(Properties.keySet());
- Collections.sort(groupnames);
+ Set<String> groupnames = Properties.keySet();
Iterator groupIt = groupnames.iterator();
String ret = "";
boolean equalsLS,equalsCheck;
- while (groupIt.hasNext()) {
-
+ while (groupIt.hasNext())
+ {
String group = (String) groupIt.next();
WizardProperties pro = Properties.get(group);
Iterator it = pro.orderedKeys();
@@ -366,16 +366,15 @@
equalsLS = group.equals("LS");
equalsCheck = pr.getCheck();

- if( equalsLS ) ret += tr(td("Do you wish to
register with an LS?") +
+ if( equalsLS ) ret = table(true, tr(td("Do you wish
to register with an LS?") +

td(times(13)+ input("radio","useLS","yes","checkIt(this);", times(2) +
"yes" + nbsp)+
-
times(5) + radio_chk("radio","useLS","no","checkIt(this);", times(14) +
"yes" + nbsp)));
- else if ( equalsCheck ) ret =
tr(td(pr.getPropertyComment())) + times(21) + optionsHtml(pr)+ times(21);
+
times(5) + radio_chk("radio","useLS","no","checkIt(this);", times(14) +
"no" + nbsp))));
+ else if ( equalsCheck ) ret +=
table(true,tr(td(pr.getPropertyComment())) + times(21) + optionsHtml(pr)+
times(21));

- if( equalsLS || equalsCheck )
- ret+= table(true,
(equalsLS?input("hidden","Vl_useLS","yes",null,""):input("hidden","Vl_"+pr.getKey(),pr.getProposedValue(),null,""))
+
- ret +
mainBodyBody(it,pr,pro,equalsLS,equalsCheck)
+ ret+= table(true,(( equalsLS || equalsCheck ) ?
+
((equalsLS?input("hidden","Vl_useLS","yes",null,""):input("hidden","Vl_"+pr.getKey(),pr.getProposedValue(),null,""))):"")
+
+ mainBodyBody(it,pr,pro,equalsLS,equalsCheck)
);
- else ret+= mainBodyBody(it,pr,pro,false,false);
}
return ret;
}
@@ -423,9 +422,9 @@
Hashtable<String, WizardProperties> Properties,
String message)
throws IOException {

- List<String> groupnames = new
ArrayList<String>(Properties.keySet());
- Collections.sort(groupnames);
- Iterator groupIt = groupnames.iterator();
+ Set<String> groupnames = Properties.keySet();
+ //Collections.sort(groupnames);
+ Iterator<String> groupIt = groupnames.iterator();
preemptModified("default.css");
println("<div class=\"top\"><br>" + message + "</br></div>");
println("<div id=\"properties\" class=\"properties\">");
@@ -433,7 +432,7 @@
out
.println("<input type=\"hidden\"
name=\"function\" value=\"finish\" >");
while (groupIt.hasNext()) {
- String group = (String) groupIt.next();
+ String group = groupIt.next();
println("<p class=\"groupheading\">" + group + "
Configuration:</p>");
WizardProperties pro = Properties.get(group);
Iterator it = pro.orderedKeys();
@@ -565,7 +564,7 @@
}
}
if(check){
- println("</table></div></td></tr>");
+ //println("</table></div></td></tr>");
}

println("</table>");

Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2008-10-24 13:36:12 UTC (rev 4668)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/wizard/WizardProperties.java
2008-10-26 23:12:57 UTC (rev 4669)
@@ -31,6 +31,7 @@
import org.xml.sax.SAXException;

import perfSONARWebAdmin.auxiliary.OrderedSet;
+import perfSONARWebAdmin.auxiliary.OrderedMap;

/**
* A dirty little hack, to extend properties functionality. Old
functionalities
@@ -323,7 +324,8 @@
return;
}

- DescendantIterator it = new
DescendantIterator(propertiesList,file);
+ //DescendantIterator it = new
DescendantIterator(propertiesList,file);
+ Iterator it = propertiesList.iterator();
Element entry,group,property;
WizardProperty pr;
sorted = new OrderedSet();
@@ -358,7 +360,7 @@
public Hashtable<String, WizardProperties> prepareProperties()
{
if(isEmpty()) return null;
- Hashtable<String, WizardProperties> groupTable = new Hashtable<String,
WizardProperties>();
+ OrderedMap<String, WizardProperties> groupTable = new
OrderedMap<String, WizardProperties>();
Iterator it = keySet().iterator();
WizardProperties other = new WizardProperties();
WizardProperties wp = null;



  • perfsonar: r4669 - in branches/WebAdmin: . ant perfSONARWebAdmin/admin/wizard perfSONARWebAdmin/auxiliary perfSONARWebAdmin/auxiliary/wizard, svnlog, 10/26/2008

Archive powered by MHonArc 2.6.16.

Top of Page