/*---------------------------------------------------------------*/
/* STANFORD UNIVERSITY NOTICES FOR SLAC SOFTWARE */
/* ON WHICH COPYRIGHT IS DISCLAIMED */
/* */
/* AUTHORSHIP */
/* This software was created by Mohammad Asif, Stanford Linear */
/* Accelerator Center, Stanford University. */
/* */
/* ACKNOWLEDGEMENT OF SPONSORSHIP */
/* This software was produced by the Stanford Linear Accelerator */
/* Center, Stanford University, under Contract DE-AC03-76SFO0515 */
/* with the Department of Energy. */
/* */
/* GOVERNMENT DISCLAIMER OF LIABILITY */
/* Neither the United States nor the United States Department of */
/* Energy, nor any of their employees, makes any warranty, */
/* express or implied, or assumes any legal liability or */
/* responsibility for the accuracy, completeness, or usefulness */
/* of any data, apparatus, product, or process disclosed, or */
/* represents that its use would not infringe privately owned */
/* rights. */
/* */
/* STANFORD DISCLAIMER OF LIABILITY */
/* Stanford University makes no representations or warranties, */
/* express or implied, nor assumes any liability for the use of */
/* this software. */
/* */
/* STANFORD DISCLAIMER OF COPYRIGHT */
/* Stanford University, owner of the copyright, hereby disclaims */
/* its copyright and all other rights in this software. Hence, */
/* anyone may freely use it for any purpose without restriction. */
/* */
/* */
/* MAINTENANCE OF NOTICES */
/* In the interest of clarity regarding the origin and status of */
/* this SLAC software, this and all the preceding Stanford */
/* University notices are to remain affixed to any copy or */
/* derivative of this software made or distributed by the */
/* recipient and are to be affixed to any copy of software made */
/* or distributed by the recipient that contains a copy or */
/* derivative of this software. */
/* */
/* SLAC Software Notices, Set 4 (OTT.002a, 2004 FEB 03) */
/*---------------------------------------------------------------*/
/* Utility.java
*
* Created on March 28, 2007, 11:43 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package org.perfsonar.client.util;
import java.io.*;
import java.util.*;
/*
* @author Mohammad Asif
* Created on March 28, 2007, 11:43 AM
*/
public class Utility {
static Hashtable ma_map = new Hashtable();
static {
File f = new File ("MAs.conf");
if (! f.exists() )
{
System.out.println ("File ma.conf doesn't exists\n");
System.exit(0);
}
String line = new String ();
try {
BufferedReader br = new BufferedReader(new FileReader(f));
while ((line = br.readLine()) != null) {
line.replace(";",",");
String str[] = line.trim().split(",",3);
if ( str[0].startsWith(";"))
{
str[0] = str[0].substring(1);
}
ma_map.put(str[0], str[1]);
}
}
catch (IOException e) {
System.err.println("Error: " + e);
}
}
public static Vector getKeys (Hashtable ht)
{
Vector keys = new Vector ();
Enumeration enums = ht.keys();
while (enums.hasMoreElements())
{
keys.addElement(enums.nextElement());
}
return keys;
}
public static String getMAEndPoint (String cannonical_name)
{
if ( cannonical_name.trim().toLowerCase().endsWith("es.net"))
{
return ma_map.get("ESNET").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("cesnet.cz"))
{
return ma_map.get("CESNET").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("fnal.gov"))
{
return ma_map.get("FERMILAB").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("geant2.net"))
{
return ma_map.get("GEANT2").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("garr.it"))
{
return ma_map.get("GARR").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("grnet.gr"))
{
return ma_map.get("GRNET").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("carnet.hr"))
{
return ma_map.get("CARNET").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("pionier.gov.pl"))
{
return ma_map.get("PIONIER-RRD").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("seeren.org"))
{
return ma_map.get("SEEREN").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("surfnet.nl") ||
cannonical_name.trim().toLowerCase().endsWith("surf.net"))
{
return ma_map.get("SURFNET").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("switch.ch"))
{
return ma_map.get("SWITCH").toString();
}
else if ( cannonical_name.trim().toLowerCase().endsWith("renater.fr"))
{
return ma_map.get("RENATER").toString();
}
return null;
}
public static void main (String []arg)
{
}
}
|