Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r5101 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model

Subject: perfsonar development work

List archive

perfsonar: r5101 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r5101 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model
  • Date: Mon, 6 Apr 2009 09:30:27 -0400

Author: melis
Date: 2009-04-06 09:30:26 -0400 (Mon, 06 Apr 2009)
New Revision: 5101

Modified:

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceComboboxModel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
Log:
updated the Looking Glass to the latest version before I hand over the
development

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LGRequest.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -204,7 +204,7 @@
IPerfsonarResponse listener) throws Exception {
// TODO Auto-generated method stub

- System.out.print("[LGRequest] The response is:");
+ /*System.out.print("[LGRequest] The response is:");

StringWriter sw = new StringWriter();
XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(response));
@@ -213,7 +213,7 @@
String XMLStr = sw.toString();

System.out.println("" + XMLStr);
-
+*/
}

/**

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/LookingGlassMainPanel.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -27,6 +27,7 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -42,6 +43,7 @@
import javax.swing.event.EventListenerList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.perfsonarui.lookingglass.model.Command;
import org.perfsonar.perfsonarui.lookingglass.model.DeviceComboboxModel;
import org.perfsonar.perfsonarui.lookingglass.model.DeviceListModel;
@@ -121,12 +123,12 @@

private WebservicesModel webservicesModel;

- private boolean and = true;
+ private boolean and = false;

- private boolean importExportEnabled = false;
- private boolean searchEnabled = false;
- private boolean andOrEnabled = false;
- private boolean appendEnabled = false;
+ private static final boolean importExportEnabled = true;
+ private static final boolean searchEnabled = true;
+ private static final boolean andOrEnabled = true;
+ private static final boolean appendEnabled = false;

public LookingGlassMainPanel(Component parentFrame, IPerfsonarTab
iperftab) {
super(parentFrame, iperftab);
@@ -343,23 +345,36 @@
jLabel5.setText("<html>Device OS<br>Command:</html>");

buttonGroup1.add(jRadioButton1);
- jRadioButton1.setSelected(true);
+ jRadioButton2.setSelected(true);
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(ActionEvent e) {
- radiobuttonClicked();
+ if (jRadioButton1.isSelected())
+ radiobuttonClicked(true);
+ else radiobuttonClicked(false);
}
});
jRadioButton1.setText("AND");

buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("OR");
+ jRadioButton2.addActionListener(new java.awt.event.ActionListener() {

+ public void actionPerformed(ActionEvent e) {
+ if (jRadioButton2.isSelected())
+ radiobuttonClicked(false);
+ else radiobuttonClicked(true);
+ }
+ });
+
if (!andOrEnabled){
jRadioButton1.setEnabled(false);
jRadioButton2.setEnabled(false);
- jRadioButton1.setToolTipText("This feature hasn't been
implemented yet.");
- jRadioButton2.setToolTipText("This feature hasn't been
implemented yet.");
+ jRadioButton1.setToolTipText("This feature hasn't been
implemented yet");
+ jRadioButton2.setToolTipText("This feature hasn't been
implemented yet");
+ } else {
+ jRadioButton1.setEnabled(true);
+ jRadioButton2.setEnabled(true);
}

org.jdesktop.layout.GroupLayout jPanel5Layout = new
org.jdesktop.layout.GroupLayout(jPanel5);
@@ -390,6 +405,13 @@
searchTextField.setEnabled(false);
searchTextField.setToolTipText("This feature hasn't been
implemented yet.");
}
+ searchTextField.addActionListener(new java.awt.event.ActionListener()
{
+
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ highlightButtonActionPerformed(evt);
+ }
+ });
+
highlightButton.setText("Search");
if (!searchEnabled){
highlightButton.setEnabled(false);
@@ -508,6 +530,7 @@
jTabbedPane1.setTitleAt(i, ((MPDevicePair)
model.getSelectedEndpoints().get(i)).toString());
}
} else {
+ String errorString = "";
if (status != null){
resultTextArea.setText(status);

@@ -515,7 +538,11 @@

jTabbedPane1.add(scroll);
jTabbedPane1.setTitleAt(i, ((MPDevicePair)
model.getSelectedEndpoints().get(i)).toString());
- }
+ //errorString = "\n"+status;
+ }
+
+ //JOptionPane.showMessageDialog(this, "An error
occured!"+errorString, "Error!", JOptionPane.ERROR_MESSAGE);
+
}
}
if (jTabbedPane1.getTabCount() > 0){
@@ -545,31 +572,43 @@
**/
public void webserviceComboboxActionperformedHandler(Document response) {

- //System.out.println("[LookingGlassMainPanel] Response caught,
updating model...");
+ System.out.println("[LookingGlassMainPanel] Response caught, updating
model...");

busy = true;

- parameterStringTextField.setText("");
- this.parameterStringTextField.setEnabled(false);
+ try {
+ this.deviceCombobox.removeAllItems();
+ this.deviceComboboxModel.removeAllElements();
+ this.functionCombobox.removeAllItems();
+ this.functionComboboxModel.removeAllElements();
+ this.deviceCombobox.setEnabled(false);
+ this.functionCombobox.setEnabled(false);
+
+ System.out.println("adding metadata");
+
model.addMetadataForCurrentMP((LGEndpoint)webserviceCombobox.getSelectedItem(),response);
+
+ System.out.println("initiating combobox");
+
deviceComboboxModel.initComboBox(this.webserviceCombobox.getSelectedItem());
+
+ System.out.println("setting selected item");
+ deviceCombobox.setSelectedIndex(0);
+
+ parameterStringTextField.setText("");
+ //this.parameterStringTextField.setEnabled(true);
+ this.deviceCombobox.setEnabled(true);
+ this.functionCombobox.setEnabled(true);
+
+ } catch (PerfSONARException ex) {
+ System.out.println("Perfsonar exception caught");
+ javax.swing.JOptionPane.showMessageDialog(this,
ex.getResultDescription(), "Error!", javax.swing.JOptionPane.ERROR_MESSAGE);

- this.deviceCombobox.removeAllItems();
- this.deviceCombobox.setEnabled(true);
- this.deviceComboboxModel.removeAllElements();
- this.functionCombobox.removeAllItems();
- this.functionCombobox.setEnabled(true);
- this.functionComboboxModel.removeAllElements();
-
-
-
- try {
- model.clearMetadata();
- model.addMetadataForCurrentMP(response);
-
this.deviceComboboxModel.initComboBox(this.webserviceCombobox.getSelectedItem());
+ //ex.printStackTrace();
} catch (Exception ex) {
+ System.out.println("exception caught");
javax.swing.JOptionPane.showMessageDialog(this, "An error occured
while getting\n" +
"the metadata from the Measurement Point", "Error!",
javax.swing.JOptionPane.ERROR_MESSAGE);

- ex.printStackTrace();
+ //ex.printStackTrace();
}

if (deviceCombobox.getItemCount() != 0) {
@@ -599,7 +638,16 @@

if (deviceComboboxModel.getSelectedItem() != null) {
this.parameterStringTextField.setEnabled(true);
- functionComboboxModel.initComboBox((String)
deviceCombobox.getSelectedItem());
+ if (deviceListModel.getSize() == 0)
+
functionComboboxModel.initComboBox(deviceComboboxModel.getAllElements());
+ else {
+ List devices = new
ArrayList(deviceListModel.getAllElements());
+ MPDevicePair pair = new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
+ (String)deviceCombobox.getSelectedItem());
+ if (!devices.contains(pair))
+ devices.add(pair);
+ functionComboboxModel.initComboBox(devices);
+ }
functionCombobox.setEnabled(true);
functionCombobox.setSelectedIndex(0);
addDeviceButton.setEnabled(true);
@@ -625,14 +673,18 @@
this.parameterStringTextField.setEnabled(true);

descriptionTextField.setText(model.getDescription(
- FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
- (String) deviceCombobox.getSelectedItem()));
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION));
syntaxTextField.setText(model.getSyntax(
- FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
- (String) deviceCombobox.getSelectedItem()));
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION));
+ if (syntaxTextField.getText() == null ||
+ syntaxTextField.getText().equals("")
+ || syntaxTextField.getText().equals("N/A")){
+ this.parameterStringTextField.setEnabled(false);
+ //this.parameterStringTextField.setText("");
+ }
+ else this.parameterStringTextField.setEnabled(true);
commandTextField.setText(model.getCommand(
- FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION,
- (String) deviceCombobox.getSelectedItem()));
+ FunctionComboboxModel.COMMANDPREFIX + "" +
functionCombobox.getSelectedItem() + FunctionComboboxModel.COMMANDVERSION));


} else {
@@ -652,8 +704,12 @@

if (deviceCombobox.getSelectedIndex() > -1) {

- if (!deviceListModel.getAllElements().contains( new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
(String)deviceCombobox.getSelectedItem()))) {
- MPDevicePair endpoint = new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
(String)deviceCombobox.getSelectedItem());
+ if (!deviceListModel.getAllElements().contains(
+ new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
+ (String)deviceCombobox.getSelectedItem()))) {
+ MPDevicePair endpoint =
+ new
MPDevicePair((LGEndpoint)webserviceCombobox.getSelectedItem(),
+ (String)deviceCombobox.getSelectedItem());
deviceListModel.addElement(endpoint);
//model.addSelectedEndpoint(endpoint);

@@ -682,7 +738,8 @@
exportButton.setEnabled(false);
removeDeviceButton.setEnabled(false);
resultTextArea.setText(null);
- //statusTextField.setText(null);
+
functionComboboxModel.initComboBox(deviceComboboxModel.getAllElements());
+ //statusTextField.setText(null);

}
}
@@ -693,20 +750,14 @@

// selected devices
List selectedDevices = deviceListModel.getAllElements();
- Iterator it = selectedDevices.iterator();
-
- // all devices which are supported by the MP
- List devices = model.getDevices();
-
+
Vector functions = null;
Iterator commands = null;
Command comm = null;

if (!selectedDevices.isEmpty()) {
- while (it.hasNext() && supported) {
- // the functions supported by one of the selected devices
- String device = (String) it.next();
- functions = model.getFunctions(device);
+ while (supported) {
+ //functions = model.getFunctions(device); //change to use
getFunctions(MPDevicePair)
commands = functions.iterator();

boolean supportedByDevice = false;
@@ -736,12 +787,11 @@
} else {
return FunctionComboboxModel.COMMANDPREFIX + "" + res +
FunctionComboboxModel.COMMANDVERSION;
}
-
}

public String getParameters() {
String res = parameterStringTextField.getText();
- if (res.equals("N/A")) {
+ if (res.equals("N/A") || !parameterStringTextField.isEnabled()) {
return "";
} else {
return res;
@@ -818,7 +868,7 @@

JFileChooser fc = new JFileChooser();

- int returnVal = fc.showOpenDialog(this);
+ int returnVal = fc.showSaveDialog(this);
File destination = null;
if(returnVal == JFileChooser.APPROVE_OPTION) {
destination = fc.getSelectedFile();
@@ -830,7 +880,7 @@
fos = new FileOutputStream(destination);
out = new ObjectOutputStream(fos);
out.writeObject(deviceListModel.getAllElements());
-
+ System.out.println(deviceListModel.getAllElements());
} catch (IOException ex) {
ex.printStackTrace();
} finally {
@@ -868,6 +918,8 @@

List endpoints = (List)in.readObject();

+ System.out.println("Endpoints: " + endpoints);
+
deviceListModel.addAllElements(endpoints);
//model.addSelectedEndpoints(endpoints);
System.out.println("deviceListModel filled with data");
@@ -948,8 +1000,16 @@
exportButton.setEnabled(true);
}

- public void radiobuttonClicked() {
+ public void radiobuttonClicked(boolean and) {
+ System.out.println(and ? "Enabling AND mode" : "Enabling OR mode");
+ functionComboboxModel.setAnd(and);

+ this.and = and;
+
+ //if (deviceListModel.getAllElements() == null ||
deviceListModel.getAllElements().size() == 0)
+
functionComboboxModel.initComboBox(deviceComboboxModel.getAllElements());
+ //else
+ //
functionComboboxModel.initComboBox(deviceListModel.getAllElements());
}

public void appendOutputActionPerformed(java.awt.event.ActionEvent evt) {

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/MPDevicePair.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -19,7 +19,7 @@

public MPDevicePair(LGEndpoint mp, String device){
this.mp = mp;
- this.device = device;
+ this.device = device;
}

public String getDevice() {

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceComboboxModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceComboboxModel.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/DeviceComboboxModel.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -10,6 +10,7 @@
package org.perfsonar.perfsonarui.lookingglass.model;

import java.util.Iterator;
+import java.util.List;
import javax.swing.DefaultComboBoxModel;

/**
@@ -50,4 +51,7 @@

}

+ public List getAllElements(){
+ return model.getMPDevicePairs();
+ }
}
\ No newline at end of file

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/FunctionComboboxModel.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -10,8 +10,10 @@

import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
+import org.perfsonar.perfsonarui.lookingglass.MPDevicePair;
import org.perfsonar.perfsonarui.lookingglass.support.StringComparator;

/**
@@ -26,8 +28,11 @@
private LookingGlassClientModel model = null;
//Indicated whether to use the symbolic command or
//the description in the combobox
- private boolean symbolic = true;
private String selectedDevice = null;
+
+ private List<MPDevicePair> selectedEndpoints = null;
+
+ private boolean and = false;

/** Creates a new instance of webserviceComboboxModel */
public FunctionComboboxModel(LookingGlassClientModel model) {
@@ -39,7 +44,7 @@
/**
* Fill up the combobox with some usefuls tuff
**/
- public void initComboBox(String selectedDevice) {
+ /*public void initComboBox(String selectedDevice) {

this.selectedDevice = selectedDevice;

@@ -48,29 +53,18 @@
this.removeAllElements();
Vector functions;

- if (symbolic) {
- functions = model.getFunctions(selectedDevice);
- } else {
- functions = model.getDescriptions(selectedDevice);
- }
-
+ functions = model.getFunctions(selectedDevice);
+
Vector functions2 = new Vector();
Iterator itf = functions.iterator();
while (itf.hasNext()) {
Command command = (Command) itf.next();
- if (symbolic) {
- String s = command.getFunction();
- s = s.substring(COMMANDPREFIX.length(), s.length());
- s = s.substring(0, s.length() - COMMANDVERSION.length());
- functions2.add(s);
- } else {
- if (command.getDescription() == null) {
- functions2.add(command.getFunction() +
- " :: No description available");
- } else {
- functions2.add(command.getDescription());
- }
- }
+
+ String s = command.getFunction();
+ s = s.substring(COMMANDPREFIX.length(), s.length());
+ s = s.substring(0, s.length() - COMMANDVERSION.length());
+ functions2.add(s);
+
}

Collections.sort(functions2, new StringComparator());
@@ -85,37 +79,110 @@

}

- }
+ }*/

- public void changeSymbolic() {
+ public void initComboBox(List selectedEndpoints) {
+ //System.out.println("Initialising Function Combobox...");
+ //System.out.println("selectedEndpoints: " + selectedEndpoints);
+ //System.out.println("selectedEndpoints size: " +
selectedEndpoints.size());
+
+ this.selectedEndpoints = selectedEndpoints;

- symbolic = !symbolic;
- initComboBox(selectedDevice);
+
+
+ if (selectedEndpoints != null && selectedEndpoints.size() > 0) {
+ //System.out.println("selectedEndpoints is not null and not
empty");
+ this.removeAllElements();
+ Vector functions;
+ Vector functions2 = new Vector();;

- }
+ Iterator<MPDevicePair> pairs = selectedEndpoints.iterator();
+ while (pairs.hasNext()){
+
+ MPDevicePair pair = pairs.next();
+
+ functions = model.getFunctions(pair); //method still to be
implemented
+
+ if (!and) { //OR
+ //System.out.println("Initialising combobox using OR
mode...");
+ functions2 = new Vector();
+ Iterator itf = functions.iterator();
+ while (itf.hasNext()) {
+ Command command = (Command) itf.next();
+
+ String s = command.getFunction();
+ s = s.substring(COMMANDPREFIX.length(), s.length());
+ s = s.substring(0, s.length() -
COMMANDVERSION.length());
+ if (!functions2.contains(s))
+ functions2.add(s);
+ }

- public boolean isSymbolic() {
+ /*Collections.sort(functions2, new StringComparator());
+ Iterator it = functions2.iterator();

- return symbolic;
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ this.addElement(s);
+ }

- }
+ this.setSelectedItem(functions2.firstElement());*/
+ } else { //AND
+ //System.out.println("Initialising combobox using AND
mode...");
+
+ functions2 = new Vector();
+ Iterator itf = functions.iterator();
+ while (itf.hasNext()) {
+ Command command = (Command) itf.next();

- public String getSymbolic(String description, String selectedDevice) {
+ // only add command if it occurs in the devices of
all selected elements
+ Iterator<MPDevicePair> it =
selectedEndpoints.iterator();
+ boolean supportedByAll = true;
+ while (it.hasNext() && supportedByAll){
+ MPDevicePair tempPair = it.next();
+ //System.out.println("Checking if device " +
tempPair + " supports the command...");
+ if (!model.deviceSupportsCommand(tempPair,
command.getFunction())){
+ supportedByAll = false;
+ //System.out.println("Command " +
command.getFunction() + " not supported by all devices");
+ }
+ }
+
+ if (supportedByAll){
+ String s = command.getFunction();
+ s = s.substring(COMMANDPREFIX.length(),
s.length());
+ s = s.substring(0, s.length() -
COMMANDVERSION.length());
+ if (!functions2.contains(s))
+ functions2.add(s);
+ }
+ supportedByAll = true;
+ }

- if (description.contains(" :: No description available")) {
- return description.substring(0, description.indexOf(" :: No
description available"));
- } else {
- Vector descriptions = model.getDescriptions(selectedDevice);
+ /*Collections.sort(functions2, new StringComparator());
+ Iterator it = functions2.iterator();

- Iterator it = descriptions.iterator();
- while (it.hasNext()) {
- Command command = (Command) it.next();
- if (command.getDescription().equalsIgnoreCase(description)) {
- return command.getFunction();
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ this.addElement(s);
+ }
+
+ this.setSelectedItem(functions2.firstElement());*/
}
}
+
+ Collections.sort(functions2, new StringComparator());
+ Iterator it = functions2.iterator();

- return null;
+ while (it.hasNext()) {
+ String s = it.next().toString();
+ this.addElement(s);
+ }
+
+ if (!functions2.isEmpty())
+ this.setSelectedItem(functions2.firstElement());
}
+
}
+
+ public void setAnd (boolean and) {
+ this.and = and;
+ }
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2009-04-01 11:55:50 UTC (rev 5100)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass/model/LookingGlassClientModel.java
2009-04-06 13:30:26 UTC (rev 5101)
@@ -22,8 +22,10 @@
import javax.swing.event.EventListenerList;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
+import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.input.DOMBuilder;
+import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.perfsonarui.lookingglass.MPDevicePair;
import org.w3c.dom.Document;

@@ -43,6 +45,7 @@
private List functions = null;
private List urls = null;
private List<MPDevicePair> selectedEndpoints = null;
+ private Map<MPDevicePair, Vector> commands = null;
private Map<MPDevicePair, String> results = null;
private Map<MPDevicePair, String> stati = null;
private String selectedCommand = null;
@@ -68,6 +71,7 @@
selectedEndpoints = new ArrayList<MPDevicePair>();
results = new HashMap<MPDevicePair, String>();
stati = new HashMap<MPDevicePair, String>();
+ commands = new HashMap<MPDevicePair, Vector>();
}

/**
@@ -103,6 +107,7 @@
metadata.clear();
functions.clear();
devices.clear();
+ commands.clear();
urls.clear();
}

@@ -115,117 +120,160 @@
/**
* Transmits a request towards the selected MP
**/
- public void addMetadataForCurrentMP(Document response)
+ public void addMetadataForCurrentMP(LGEndpoint mp, Document response)
throws Exception {
- //System.out.println("***
LookingGlassClientModel.addMetadataForCurrentMP("+response+") called ***");
+ System.out.println("[LookingGlassClientModel]
LookingGlassClientModel.addMetadataForCurrentMP(" + mp + ", " + response + ")
called ***");

devices.clear();
metadata.clear();
+ Vector tempDevices = new Vector();

- try {
+ System.out.print("[LookingGlassClientModel] The response is:");
+
+ StringWriter sw = new StringWriter();
+ XMLSerializer ser = new XMLSerializer(sw, new OutputFormat(response));
+ ser.serialize(response.getDocumentElement());
+
+ String XMLStr = sw.toString();
+
+ System.out.println("" + XMLStr);
+
+ //try {
DOMBuilder dom = new DOMBuilder();
org.jdom.Document resp = dom.build(response);

org.jdom.Element root = resp.getRootElement();

- List children = root.getChildren();
- Iterator it = children.iterator();
+ if (root.getAttributeValue("type").equals("ErrorResponse")) {
+ Namespace nmwg = Namespace.getNamespace("nmwg",
"http://ggf.org/ns/nmwg/base/2.0/";);
+ Element eventType = root.getChild("metadata",
nmwg).getChild("eventType", nmwg);
+ System.out.println("eventType:" + eventType.getText());
+ if (eventType.getText().equals("error.authn.not_sectoken"))
+ throw new PerfSONARException ("The authentication request
message doesn't include any security token.");
+ else if (eventType.getText().equals("error.authn.soap"))
+ throw new PerfSONARException ("The authentication request
message hasn't\nany <soapenv:Header> element or it hasn't\nbeen sent
following the WS-SEC standard.");
+ else if
(eventType.getText().equals("error.authn.wrong_params"))
+ throw new PerfSONARException ("The received
authentication request message doesn't specify the required parameters.");
+ else if (eventType.getText().equals("error.authn.timestamp"))
+ throw new PerfSONARException ("The AS cannot validate the
timestamp information included in the security token.");
+ else if (eventType.getText().equals("error.authn.wssec"))
+ throw new PerfSONARException ("The AS encountered a
problem while checking the signature of a security token.");
+ else if
(eventType.getText().equals("error.authn.assertion_not_included"))
+ throw new PerfSONARException ("The Security Token is
based on a SAML assertion but the message doesn't include the appropriate
element.");
+ else if
(eventType.getText().equals("error.authn.x509_not_included"))
+ throw new PerfSONARException ("The Security Token is
based on an X.509 certificate but the message doesn't include the appropriate
element.");
+ else if
(eventType.getText().equals("error.authn.x509_not_valid"))
+ throw new PerfSONARException ("The X.509 certificate in
the message is not valid.");
+
+ else throw new PerfSONARException ("An error occured while
getting the metadata.");
+
+ } else {

- while (it.hasNext()) {
- org.jdom.Element next = (org.jdom.Element) it.next();
- //System.out.println(next);
+ List children = root.getChildren();
+ Iterator it = children.iterator();

- if (next.getName().equalsIgnoreCase("metadata")) {
- //System.out.println(next.getAttribute("id"));
- String metadataId = next.getAttributeValue("id");
- if (metadataId.contains("resultCode")) {
- } else {
- metadata.add(metadataId);
- //System.out.println("metadataId: " + metadataId);
- Iterator it2 = next.getChildren().iterator();
- while (it2.hasNext()) {
- org.jdom.Element device = (org.jdom.Element)
it2.next();
- if (device.getName().equalsIgnoreCase("subject"))
{
- //System.out.println("device: " + device);
- devices.add(metadata.indexOf(metadataId),
device.getValue());
- } else {
+ MPDevicePair pair = null;

- Iterator urlpit =
device.getChildren().iterator();
- while (urlpit.hasNext()) {
+ while (it.hasNext()) {
+ org.jdom.Element next = (org.jdom.Element) it.next();
+ //System.out.println(next);

- org.jdom.Element ur = (org.jdom.Element)
urlpit.next();
- urls.add(ur.getAttributeValue("value"));
+ org.jdom.Element device = null;
+ if (next.getName().equalsIgnoreCase("metadata")) {
+ //System.out.println("metadataId:
"+next.getAttributeValue("id"));
+ String metadataId = next.getAttributeValue("id");
+ if (metadataId.contains("resultCode")) {
+ } else {
+ metadata.add(metadataId);
+ //System.out.println("**** Added metadataId: " +
metadataId + " to list of metadata");
+ Iterator it2 = next.getChildren().iterator();
+ while (it2.hasNext()) {
+ device = (org.jdom.Element) it2.next();
+ if
(device.getAttributeValue("id").startsWith("subject")) {
+ devices.add(metadata.indexOf(metadataId),
device.getText());

+ pair = new MPDevicePair(mp,
device.getText());
+ commands.put(pair, new Vector());
+ tempDevices.add(pair);
+
+ //System.out.println("tempDevices: " +
tempDevices);
+
+ //System.out.println("*** Commands added -->
Pair: " + pair);
}
}
}
- functions.add(new Vector());
+ } else if (next.getName().equalsIgnoreCase("data")) {
+ String metadataId =
next.getAttributeValue("metadataIdRef");

- }
- } else if (next.getName().equalsIgnoreCase("data")) {
- String metadataId =
next.getAttributeValue("metadataIdRef");
+ Iterator it2 = next.getChildren().iterator();
+ while (it2.hasNext()) {

- Iterator it2 = next.getChildren().iterator();
- while (it2.hasNext()) {
+ org.jdom.Element datum = (org.jdom.Element)
it2.next();

- org.jdom.Element datum = (org.jdom.Element)
it2.next();
+ Iterator it3 = datum.getChildren().iterator();

- Iterator it3 = datum.getChildren().iterator();
+ String function = null;
+ String command = null;
+ String syntax = null;
+ String description = null;

- String function = null;
- String command = null;
- String syntax = null;
- String description = null;
+ while (it3.hasNext()) {

- while (it3.hasNext()) {
+ org.jdom.Element element = (org.jdom.Element)
it3.next();

- org.jdom.Element element = (org.jdom.Element)
it3.next();
+ //System.out.println("INTERN");
+ if
(element.getName().equalsIgnoreCase("eventType")) {

- //System.out.println("INTERN");
- if
(element.getName().equalsIgnoreCase("eventType")) {
+ function = element.getText();
+ //System.out.println("Function: " + function);

- function = element.getText();
- //System.out.println("Function: " + function);
+ } else if
(element.getName().equalsIgnoreCase("parameters")) {

- } else if
(element.getName().equalsIgnoreCase("parameters")) {
+ Iterator it4 =
element.getChildren().iterator();

- Iterator it4 =
element.getChildren().iterator();
+ while (it4.hasNext()) {

- while (it4.hasNext()) {
-
- org.jdom.Element element2 =
(org.jdom.Element) it4.next();
- if
(element2.getAttributeValue("name").equalsIgnoreCase("command")) {
- command =
element2.getAttributeValue("value");
- } else if
(element2.getAttributeValue("name").equalsIgnoreCase("description")) {
- description =
element2.getAttributeValue("value");
- } else if
(element2.getAttributeValue("name").equalsIgnoreCase("syntax")) {
- syntax =
element2.getAttributeValue("value");
+ org.jdom.Element element2 =
(org.jdom.Element) it4.next();
+ if
(element2.getAttributeValue("name").equalsIgnoreCase("command")) {
+ command =
element2.getAttributeValue("value");
+ } else if
(element2.getAttributeValue("name").equalsIgnoreCase("description")) {
+ description =
element2.getAttributeValue("value");
+ } else if
(element2.getAttributeValue("name").equalsIgnoreCase("syntax")) {
+ syntax =
element2.getAttributeValue("value");
+ }
}
}
}
- }

+ //System.out.println(function + " " + command + "
" + description + " " + syntax);

- Vector v;
+ if (function != null) {
+ //System.out.println("metadataId: " +
metadataId);
+ //System.out.println("indexOf(" + metadataId
+ ") = " + metadata.indexOf(metadataId));
+ //System.out.println("Pair: " +
tempDevices.toArray()[metadata.indexOf(metadataId)]);

- //System.out.println(function + " " + command + " " +
description + " " + syntax);
+ //Collection<Vector> values =
commands.values();

- if (function != null) {
- v = (Vector)
functions.get(metadata.indexOf(metadataId));
- v.add(new Command(function, syntax, description,
command));
- //System.out.println("FUNCTION ADDED:" + function);
+ //Vector cmnds =
(Vector)values.toArray()[metadata.indexOf(metadataId)];
+
+ Vector cmnds =
commands.get(tempDevices.toArray()[metadata.indexOf(metadataId)]);
+
+ //System.out.println("number of commands: " +
cmnds.size());
+
+ cmnds.add(new Command(function, syntax,
description, command));
+ //System.out.println("FUNCTION ADDED:" +
function);
+ }
}
}
}
}
- } catch (Exception e) {
+ /*} catch (Exception e) {
JOptionPane.showMessageDialog(null,
"An error occured while contacting the remote service!",
"Communication Error",
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
- }
-
+ }*/
}

public void setQueryResult(LGEndpoint mp, Document response)
@@ -276,10 +324,10 @@
}
i++;
}
-
+
i = 0;
it = children.iterator();
- while (it.hasNext()){
+ while (it.hasNext()) {
org.jdom.Element message = (org.jdom.Element) it.next();

if (message.getName().contains("meta")) {
@@ -293,9 +341,9 @@
//System.out.println("****** subject:
"+subject.getValue());
if (subject.getName().contains("subject")) {
String metadataIdRef =
subject.getAttributeValue("metadataIdRef");
- for (int j = 0; j < ids.length; j++){
- if (ids[j] != null &&
ids[j].startsWith(metadataIdRef)){
- device[i] = device[j];

+ for (int j = 0; j < ids.length; j++) {
+ if (ids[j] != null &&
ids[j].startsWith(metadataIdRef)) {
+ device[i] = device[j];
}
}
}
@@ -304,7 +352,7 @@
}
i++;
}
-
+
//System.out.println("");
//for (i = 0; i < ids.length; i++) {
// System.out.println("id: " + ids[i] + " --> device: " +
device[i]);
@@ -320,7 +368,7 @@
String nr = name.substring(name.length() - 1);
String metadataIdRef =
message.getAttributeValue("metadataIdRef");
//System.out.println("data block with metadataIdRef:" +
metadataIdRef);
-
+
//Search the corresponding device in the list of metadata
ids
int place = -1;
for (int j = 0; j < ids.length; j++) {
@@ -343,14 +391,14 @@
MPDevicePair pair = new MPDevicePair(mp,
device[place]);
if (!stati.containsKey(pair)) {
stati.put(pair, datum.getValue());
-
//System.out.println("[LookingGlassClientModel] status for " + pair + " is "
+ stati.get(pair));
+
//System.out.println("[LookingGlassClientModel] status for " + pair + " is "
+ stati.get(pair));
}
}
} else {
//System.out.println("Updating result for
device:" + device[place]);
try {
Iterator it2 =
message.getChildren().iterator();
-
+
org.jdom.Element datum = (org.jdom.Element)
it2.next();
//System.out.println("*** DATUM: " + datum);
//System.out.println("*** RESULTSTRING: " +
datum.getValue());
@@ -369,7 +417,7 @@
MPDevicePair pair = new MPDevicePair(mp,
device[place]);
if (!results.containsKey(pair)) {
results.put(pair, "");
-
//System.out.println("[LookingGlassClientModel] result for " + pair + " is "
+ results.get(pair));
+
//System.out.println("[LookingGlassClientModel] result for " + pair + " is "
+ results.get(pair));
}
}
}
@@ -412,6 +460,20 @@

}

+ public List<MPDevicePair> getMPDevicePairs() {
+ List<MPDevicePair> result = new ArrayList<MPDevicePair>();
+
+ Iterator<MPDevicePair> it = commands.keySet().iterator();
+ while (it.hasNext()) {
+ MPDevicePair pair = it.next();
+ System.out.println("Adding Pair for initializing combobox: " +
pair);
+ System.out.println("Number of MPDevicePairs: " + result.size());
+ result.add(pair);
+ }
+
+ return result;
+ }
+
/*private int getDevicePlace(MPDevicePair device) {
//for (int i = 0; i < devicesTable.length; i++) {
//System.out.print("devices: " + devicesTable[i]);
@@ -443,50 +505,28 @@
return devices;
}

- /**
- * Returns a list with all functions supported by a given device
- **/
- public List getFunctions() {
- return functions;
+ public Vector getFunctions(MPDevicePair pair) {
+ Vector v = commands.get(pair);
+ System.out.println("[LookingGlassClientModel] getFunctions(" + pair +
") -> returns " + v.size() + " elements");
+ return v;
}

- /**
- * Returns a list with all functions supported by a given device
- **/
- public Vector getFunctions(String device) {
-
- int index = devices.indexOf(device);
- return (Vector) functions.get(index);
-
- }
-
- /**
- * Returns a list with all descriptions of the functions supported
- * by a given device
- **/
- public Vector getDescriptions(String device) {
-
- int index = devices.indexOf(device);
- return (Vector) functions.get(index);
-
- }
-
- public String getDescription(String function, String device) {
-
+ public String getDescription(String function) {
try {
- int index = devices.indexOf(device);
- Vector v = (Vector) functions.get(index);
+ for (int index = 0; index < commands.size(); index++) {
+ Vector v = (Vector) commands.values().toArray()[index];

- Iterator it = v.iterator();
- while (it.hasNext()) {
- Command command = (Command) it.next();
- if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
- command.getDescription().equalsIgnoreCase(function)))
{
- if (command.getDescription().equalsIgnoreCase("") ||
- command.getDescription() == null) {
- return "N/A";
- } else {
- return command.getDescription();
+ Iterator it = v.iterator();
+ while (it.hasNext()) {
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
+
command.getDescription().equalsIgnoreCase(function))) {
+ if (command.getDescription().equalsIgnoreCase("") ||
+ command.getDescription() == null) {
+ return "N/A";
+ } else {
+ return command.getDescription();
+ }
}
}
}
@@ -496,22 +536,23 @@
}
}

- public String getSyntax(String function, String device) {
+ public String getSyntax(String function) {

try {
- int index = devices.indexOf(device);
- Vector v = (Vector) functions.get(index);
+ for (int index = 0; index < commands.size(); index++) {
+ Vector v = (Vector) commands.values().toArray()[index];

- Iterator it = v.iterator();
- while (it.hasNext()) {
- Command command = (Command) it.next();
- if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
- command.getDescription().equalsIgnoreCase(function)))
{
- if (command.getSyntax().equalsIgnoreCase("") ||
- command.getSyntax() == null) {
- return "N/A";
- } else {
- return command.getSyntax();
+ Iterator it = v.iterator();
+ while (it.hasNext()) {
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
+
command.getDescription().equalsIgnoreCase(function))) {
+ if (command.getSyntax().equalsIgnoreCase("") ||
+ command.getSyntax() == null) {
+ return "N/A";
+ } else {
+ return command.getSyntax();
+ }
}
}
}
@@ -521,25 +562,26 @@
}
}

- public String getCommand(String function, String device) {
+ public String getCommand(String function) {

try {
- int index = devices.indexOf(device);
- if (index > -1) {
- Vector v = (Vector) functions.get(index);
+ for (int index = 0; index < commands.size(); index++) {
+ Vector v = (Vector) commands.values().toArray()[index];

- Iterator it = v.iterator();
- while (it.hasNext()) {
- Command command = (Command) it.next();
- if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
-
command.getDescription().equalsIgnoreCase(function))) {
- if (command.getCommand().equalsIgnoreCase("") ||
- command.getCommand() == null) {
- return "N/A";
- } else {
- return command.getCommand() +
- ((command.getSyntax() != null &&
- !command.getSyntax().equals("")) ? " " +
command.getSyntax() : "");
+ if (v != null) {
+ Iterator it = v.iterator();
+ while (it.hasNext()) {
+ Command command = (Command) it.next();
+ if (function.startsWith(command.getFunction()) ||
(command.getDescription() != null &&
+
command.getDescription().equalsIgnoreCase(function))) {
+ if (command.getCommand().equalsIgnoreCase("") ||
+ command.getCommand() == null) {
+ return "N/A";
+ } else {
+ return command.getCommand() +
+ ((command.getSyntax() != null &&
+ !command.getSyntax().equals("")) ? "
" + command.getSyntax() : "");
+ }
}
}
}
@@ -549,30 +591,24 @@
e.printStackTrace();
return "N/A";
}
+ }

+ public boolean deviceSupportsCommand(MPDevicePair pair, String command) {
+ boolean supported = false;

+ Vector cmnds = commands.get(pair);
+ Iterator it = cmnds.iterator();
+ while (!supported && it.hasNext()) {
+ Command cmd = (Command) it.next();
+ if (cmd.getFunction().equals(command)) {
+ supported = true;
+ }
+
+ }
+
+ return supported;
}

- /*public String getURL(String device) {
- //System.out.println(device);
- int index = devices.indexOf(device);
- //System.out.println(index);
- //System.out.println((String)urls.get(index));
- Iterator it = urls.iterator();
- while (it.hasNext()) {
- //System.out.println((String)it.next());
- }
- return (String)urls.get(index);
- }*/
- /*public String getValue(MPDevicePair device) {
- return results.get(device);
- }*/
- /*public String[] getAllValues() {
- return resultStringTable;
- }*/
- /*public String getSelectedCommand() {
- return selectedCommand;
- }*/
public void setSelectedCommand(String selectedCommand) {
this.selectedCommand = selectedCommand;
}



  • perfsonar: r5101 - in branches/perfsonarui/src/org/perfsonar/perfsonarui/lookingglass: . model, svnlog, 04/06/2009

Archive powered by MHonArc 2.6.16.

Top of Page