perfsonar-dev - perfsonar: r3456 - in branches/WebAdmin/perfSONARWebAdmin: admin/wizard/services auxiliary
Subject: perfsonar development work
List archive
perfsonar: r3456 - in branches/WebAdmin/perfSONARWebAdmin: admin/wizard/services auxiliary
Chronological Thread
- From:
- To:
- Subject: perfsonar: r3456 - in branches/WebAdmin/perfSONARWebAdmin: admin/wizard/services auxiliary
- Date: Tue, 4 Mar 2008 05:23:59 -0500
Author: michalis
Date: 2008-03-04 05:23:58 -0500 (Tue, 04 Mar 2008)
New Revision: 3456
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperty.java
Log:
Adding comments
Modified:
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-03-03 16:14:59 UTC (rev 3455)
+++
branches/WebAdmin/perfSONARWebAdmin/admin/wizard/services/RRDMAHandler.java
2008-03-04 10:23:58 UTC (rev 3456)
@@ -436,9 +436,14 @@
throws IOException {
// The only other group for rrd ma is the Store group
+ // So in this case changes go into the service.property file
that uses
+ // groupig and description
+ // In order to keep that functionality we need in this case
to use the
+ // PerfsonarProperties class
if (group.equals("Store")) {
- // A class that makes modifying service properties a
little bit
- // easier
+
+ // Using PerfsonarProperties in order to keep the
grouping and
+ // description
PerfsonarProperties serviceProperties = null;
serviceProperties = new PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(ServicePath
@@ -446,14 +451,20 @@
// Getting the names for every property of the group
Iterator it = functionProperties.orderedKeys();
// Setting the value of each property
+
+ // An object that holds the property
group,description,value and key
PerfsonarProperty property = new PerfsonarProperty();
while (it.hasNext()) {
String key = (String) it.next();
// Setting service properties and wizard
properties
+
+ // Get the property
property = serviceProperties.getProperty(key);
+ // If key property does not exist the throw
an exception
if (property == null) {
throw new IOException("Key is invalid
" + key + " ");
} else {
+ // Change the value of the property
property.setValue(functionProperties.getProperty(key));
serviceProperties.setProperty(key,
property);
}
@@ -465,7 +476,9 @@
+ ServicePropertiesPath));
}
// We don't really have any other groups just the ones for
the servlet
- // administration
+ // administration, that does not use grouping and description
so we can
+ // use
+ // the ServiceProperties class as usual
else {
// A class that makes modifying service properties a
little bit
// easier
@@ -504,23 +517,33 @@
* @throws IOException
*/
private void lsActions(WizardProperties finalProperties) throws
IOException {
- // Using the ServiceProperties class to acces the
service.properties
- // file
+ // Changes happen into the service.property file that uses
groupig and
+ // description
+ // In order to keep that functionality we need in this case
to use the
+ // PerfsonarProperties class
PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(ServicePath
+ ServicePropertiesPath));
Iterator it = finalProperties.orderedKeys();
// Iterating through the LS registration properties properties
+
+ // Initializing the PerfsonarProperty object that holds
information
+ // about grouping and description
PerfsonarProperty property = new PerfsonarProperty();
while (it.hasNext()) {
String key = (String) it.next();
// Set the service properties
+
+ // Get the PerfsonarProperty object
property = serviceProperties.getProperty(key);
+
+ // If property key does not exist throw an exceptrion
if (property == null) {
throw new IOException("Key is invalid " + key
+ " ");
} else {
- property.setValue(finalProperties.getProperty(key));
- serviceProperties.setProperty(key, property);
+ // Else set the value right
+
property.setValue(finalProperties.getProperty(key));
+ serviceProperties.setProperty(key, property);
}
// Set the wizard properties
properties.setWizardProperty(key, finalProperties
@@ -548,8 +571,9 @@
private void existActions(WizardProperties finalProperties)
throws Exception {
- // Initiating ServiceProperties classes for handling input to
the
- // service.properties and servlet.properties file
+ // Changes happen into the service.property file that uses
groupig and
+ // description in order to keep that functionality we need in
this case
+ // to use the PerfsonarProperties class
PerfsonarProperties serviceProperties = new
PerfsonarPropertiesImpl();
serviceProperties.loadProperties(new
FileInputStream(ServicePath
+ ServicePropertiesPath));
@@ -601,6 +625,7 @@
PerfsonarProperty property = new PerfsonarProperty();
if (!key.endsWith("xmldb.db_uri")) {
property = serviceProperties.getProperty(key);
+ // If property key does not exist throw an
exceptrion
if (property == null) {
throw new Exception("Key is invalid "
+ key + " ");
} else {
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
2008-03-03 16:14:59 UTC (rev 3455)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperties.java
2008-03-04 10:23:58 UTC (rev 3456)
@@ -7,59 +7,81 @@
import java.util.Iterator;
/**
- * @author Michalis Michael
- *
+ * @author Michalis Michael,Cynet
+ *
+ * Interface descripton of PerfsonarProperties Specially designed to
understand
+ * and maintain grouping and description In order for the class to work as
+ * expected the standard property needs to be have the form of:
+ *
+ * #Group=property_group
+ * #Description=description_of_the_property
+ * property_key=property_value
+ *
*/
public interface PerfsonarProperties {
/**
+ * Loads PerfsonarProperties
+ *
* @param in
- * @throws UnsupportedEncodingException
- * @throws IOException
+ * Inputstream from the targeted properties file
+ * @throws UnsupportedEncodingException
+ * @throws IOException
*/
- public void loadProperties(InputStream in) throws
UnsupportedEncodingException, IOException;
-
+ public void loadProperties(InputStream in)
+ throws UnsupportedEncodingException, IOException;
+
/**
+ * Stored Perfsonar Properties in the targeted propertis file
+ *
* @param out
- * @throws IOException
+ * OutrputStream to the targeted file
+ * @throws IOException
*/
- public void storeProperties(OutputStream out ) throws IOException;
-
+ public void storeProperties(OutputStream out) throws IOException;
+
/**
+ * Set the property
* @param propertyKey
+ * The key of the property
* @param property
+ * The property iteself
*/
- public void setProperty(String propertyKey,PerfsonarProperty
property);
-
+ public void setProperty(String propertyKey, PerfsonarProperty
property);
+
/**
+ * Get the property as it is identified by the property key
* @param propertyKey
+ * The key of the property
* @return
+ * A PerfsonarProperty object
*/
public PerfsonarProperty getProperty(String propertyKey);
-
-
+
/**
+ * Remove a property from the table
* @param propertyKey
+ * The key of the property to be removed
*/
public void removeProperty(String propertyKey);
-
-
+
/**
+ * Get an iterator of the keys
* @return
+ * An iterator for the keys inside the table
*/
public Iterator getKeysIterator();
-
- /**
+
+ /**Get an iterator of the property entries
* @return
+ * An iterator for the PerfsonarProperty objects stored in the
Hashtable
*/
public Iterator getEntriesIterator();
-
+
/**
- * @return
+ * @return
+ * True if the HAshtable is empty
*/
public boolean isEmpty();
-
-
-
-
+
}
Modified:
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
===================================================================
---
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-03-03 16:14:59 UTC (rev 3455)
+++
branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarPropertiesImpl.java
2008-03-04 10:23:58 UTC (rev 3456)
@@ -17,6 +17,9 @@
/**
* @author Michalis Michael,CyNet
*
+ * An implentation of the PerfsonarProperties interface Extends the Hashtable
+ * class
+ *
*/
@SuppressWarnings("serial")
public class PerfsonarPropertiesImpl extends
@@ -86,13 +89,14 @@
if
(prop.length >= 1 && prop.length <= 2) {
if (!prop[0].equals("")) {
PerfsonarProperty property = new PerfsonarProperty();
-
if(group.length==2){
-
property.setGroup(group[1]);
-
}else{
+
if (group.length == 2) {
+
property.setGroup(group[1]);
+
} else {
property.setGroup("");
}
-
if(descr.length==2)
-
property.setDescription(descr[1]);
+
if (descr.length == 2)
+
property
+
.setDescription(descr[1]);
property.setKey(prop[0]);
if (prop.length == 2) {
property.setValue(prop[1]);
@@ -136,7 +140,8 @@
*
* @see
perfSONARWebAdmin.auxiliary.PerfsonarProperties#storeProperties(java.io.FileOutputStream)
*/
- public synchronized void storeProperties(OutputStream out) throws
IOException {
+ public synchronized void storeProperties(OutputStream out)
+ throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(out);
BufferedWriter bw = new BufferedWriter(writer);
Iterator it = this.keySet().iterator();
@@ -193,19 +198,22 @@
public static void main(String[] args) {
- //Properties properties = new Properties();
+ // Properties properties = new Properties();
PerfsonarProperties properties = new
PerfsonarPropertiesImpl();
try {
- properties.loadProperties(new
FileInputStream("test_service3.properties"));
-
- Iterator it = properties.getKeysIterator(); while
(it.hasNext()) {
- String key = (String) it.next(); PerfsonarProperty
pr =
- properties.getProperty(key);
System.out.println("#Group=" +
- pr.getGroup()); System.out.println("#Descritpion=" +
- pr.getDescription());
System.out.println(pr.getKey() + "=" +
- pr.getValue() + "\n\n"); }
+ properties.loadProperties(new FileInputStream(
+ "test_service3.properties"));
+ Iterator it = properties.getKeysIterator();
+ while (it.hasNext()) {
+ String key = (String) it.next();
+ PerfsonarProperty pr =
properties.getProperty(key);
+ System.out.println("#Group=" + pr.getGroup());
+ System.out.println("#Descritpion=" +
pr.getDescription());
+ System.out.println(pr.getKey() + "=" +
pr.getValue() + "\n\n");
+ }
+
PerfsonarProperty pro = new PerfsonarProperty();
pro.setDescription("A test property");
pro.setGroup("Test");
@@ -216,12 +224,12 @@
// properties.removeProperty("testProperty2");
// properties.storeProperties(new FileOutputStream(
// "test_service3.properties"));
- //Iterator it = properties.keySet().iterator();
- // while (it.hasNext()) {
- // String key = (String) it.next();
- // System.out.println(key + "=" +
properties.getProperty(key)
- // + "\n\n");
- // }
+ // Iterator it = properties.keySet().iterator();
+ // while (it.hasNext()) {
+ // String key = (String) it.next();
+ // System.out.println(key + "=" +
properties.getProperty(key)
+ // + "\n\n");
+ // }
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Modified: branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperty.java
===================================================================
--- branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperty.java
2008-03-03 16:14:59 UTC (rev 3455)
+++ branches/WebAdmin/perfSONARWebAdmin/auxiliary/PerfsonarProperty.java
2008-03-04 10:23:58 UTC (rev 3456)
@@ -1,7 +1,8 @@
package perfSONARWebAdmin.auxiliary;
/**
- * @author Michalis Michael
+ * @author Michalis Michael,Cynet A class to handle grouping and description
in
+ * properties file
*
*/
public class PerfsonarProperty {
@@ -9,12 +10,16 @@
//
-----------------------------------------------------------------------
// class fields
+ // The key of the property
private String Key = null;
+ // The value of the property
private String Value = null;
+ // The description of the property
private String Description = null;
+ // The group of the property
private String Group = null;
//
-----------------------------------------------------------------------
@@ -22,9 +27,13 @@
/**
* @param propertyKey
+ * The key of the property
* @param propertyValue
+ * The value of the property
* @param propertyDescription
- * @param PropertyGroup
+ * The description of the property
+ * @param propertyGroup
+ * The group of the property
*/
public PerfsonarProperty(String propertyKey, String propertyValue,
String propertyDescription, String propertyGroup) {
@@ -45,7 +54,7 @@
// public methods
/**
- * @return
+ * @return The description of the property
*/
public String getDescription() {
return Description;
@@ -53,35 +62,44 @@
/**
* @param description
+ * Set the description of the property
*/
public void setDescription(String description) {
Description = description;
}
/**
- * @return
+ * @return The group of the property
*/
public String getGroup() {
return Group;
}
+ /**
+ * @param group
+ * Set the gouop of the property
+ */
public void setGroup(String group) {
Group = group;
}
+ /**
+ * @return The key of the property
+ */
public String getKey() {
return Key;
}
/**
* @param key
+ * Set the key of the property
*/
public void setKey(String key) {
Key = key;
}
/**
- * @return
+ * @return The value of the property
*/
public String getValue() {
return Value;
@@ -89,6 +107,7 @@
/**
* @param value
+ * Set the vallue of the property
*/
public void setValue(String value) {
Value = value;
- perfsonar: r3456 - in branches/WebAdmin/perfSONARWebAdmin: admin/wizard/services auxiliary, svnlog, 03/04/2008
Archive powered by MHonArc 2.6.16.