diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverter.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverter.java index 4ec1e0533473661cf6b7ba93544578635e539032..e91522e100685940c64a540bd60eeed198bc88c3 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverter.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverter.java @@ -10,8 +10,8 @@ package nl.astron.lofar.sas.otb.jotdb2; +import java.rmi.RemoteException; import java.util.HashMap; -import java.util.Map; /** * @@ -38,61 +38,181 @@ public class jConverter { itsUC = new jUnitConv(); } - public short getClassif(String aConv) { - return itsCC.get(aConv); + public short getClassif(String aConv) throws RemoteException{ + short aS; + try { + aS=itsCC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getClassif(String) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public String getClassif(short aConv) { - return itsCC.get(aConv); + public String getClassif(short aConv) throws RemoteException { + String aS=null; + try { + aS=itsCC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getClassif(Short) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public HashMap<Short,String> getClassif() { - return itsCC.getTypes(); + public HashMap<Short,String> getClassif() throws RemoteException { + HashMap<Short,String> aM=null; + try { + aM = itsCC.getTypes(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getClassif() error"); + anEx.initCause(ex); + throw anEx; + } + return aM; } - public short getParamType(String aConv) { - return itsPTC.get(aConv); + public short getParamType(String aConv) throws RemoteException { + short aS; + try { + aS = itsPTC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getParamType(String) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public String getParamType(short aConv) { - return itsPTC.get(aConv); + public String getParamType(short aConv) throws RemoteException { + String aS=null; + try { + aS = itsPTC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getParamType(Short) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public HashMap<Short,String> getParamType() { - return itsPTC.getTypes(); - } - public short getTreeState(String aConv) { - return itsTSC.get(aConv); + public HashMap<Short,String> getParamType() throws RemoteException { + HashMap<Short,String> aM=null; + try { + aM = itsPTC.getTypes(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getClassif() error"); + anEx.initCause(ex); + throw anEx; + } + return aM; + } + public short getTreeState(String aConv) throws RemoteException { + short aS; + try { + aS = itsTSC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeState(String) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public String getTreeState(short aConv) { - return itsTSC.get(aConv); + public String getTreeState(short aConv) throws RemoteException { + String aS=null; + try { + aS = itsTSC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeState(short) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public HashMap<Short,String> getTreeState() { - return itsTSC.getTypes(); - } - public short getTreeType(String aConv) { - return itsTTC.get(aConv); + public HashMap<Short,String> getTreeState() throws RemoteException { + HashMap<Short,String> aM=null; + try { + aM = itsTSC.getTypes(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeState() error"); + anEx.initCause(ex); + throw anEx; + } + return aM; + } + public short getTreeType(String aConv) throws RemoteException { + short aS; + try { + aS = itsTTC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeType(String) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public String getTreeType(short aConv) { - return itsTTC.get(aConv); + public String getTreeType(short aConv) throws RemoteException { + String aS=null; + try { + aS = itsTTC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeType(short) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public HashMap<Short,String> getTreeType() { - return itsTTC.getTypes(); - } - public short getUnit(String aConv) { - return itsUC.get(aConv); + public HashMap<Short,String> getTreeType() throws RemoteException { + HashMap<Short,String> aM=null; + try { + aM =itsTTC.getTypes(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeType() error"); + anEx.initCause(ex); + throw anEx; + } + return aM; + } + public short getUnit(String aConv) throws RemoteException { + short aS; + try { + aS = itsUC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getUnit(String) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public String getUnit(short aConv) { - return itsUC.get(aConv); + public String getUnit(short aConv) throws RemoteException { + String aS=null; + try { + aS =itsUC.get(aConv); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getUnit(short) error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } - public HashMap<Short,String> getUnit() { - return itsUC.getTypes(); + public HashMap<Short,String> getUnit() throws RemoteException { + HashMap<Short,String> aM=null; + try { + aM =itsUC.getTypes(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getUnit() error"); + anEx.initCause(ex); + throw anEx; + } + return aM; } } diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverterAdapter.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverterAdapter.java index dd56e9ac5cb1716d21003aead60c4cbb1f885b40..2a036b33b994ede58b94a289034296b59f2bc07c 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverterAdapter.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jConverterAdapter.java @@ -36,77 +36,137 @@ public class jConverterAdapter extends UnicastRemoteObject implements jConverter public short getClassif (String aConv) throws RemoteException { - return adaptee.getClassif (aConv); + try { + return adaptee.getClassif (aConv); + } catch (RemoteException ex) { + throw ex; + } } public String getClassif (short aConv) throws RemoteException { - return adaptee.getClassif (aConv); + try { + return adaptee.getClassif (aConv); + } catch (RemoteException ex) { + throw ex; + } } public HashMap<Short,String> getClassif() throws RemoteException { - return adaptee.getClassif(); + try { + return adaptee.getClassif(); + } catch (RemoteException ex) { + throw ex; + } } public short getParamType (String aConv) throws RemoteException { - return adaptee.getParamType (aConv); + try { + return adaptee.getParamType (aConv); + } catch (RemoteException ex) { + throw ex; + } } public String getParamType (short aConv) throws RemoteException { - return adaptee.getParamType (aConv); + try { + return adaptee.getParamType (aConv); + } catch (RemoteException ex) { + throw ex; + } } public HashMap<Short,String> getParamType() throws RemoteException { - return adaptee.getParamType(); + try { + return adaptee.getParamType(); + } catch (RemoteException ex) { + throw ex; + } } public short getTreeState (String aConv) throws RemoteException { - return adaptee.getTreeState (aConv); + try { + return adaptee.getTreeState (aConv); + } catch (RemoteException ex) { + throw ex; + } } public String getTreeState (short aConv) throws RemoteException { - return adaptee.getTreeState (aConv); + try { + return adaptee.getTreeState (aConv); + } catch (RemoteException ex) { + throw ex; + } } public HashMap<Short,String> getTreeState() throws RemoteException { - return adaptee.getTreeState(); + try { + return adaptee.getTreeState(); + } catch (RemoteException ex) { + throw ex; + } } public short getTreeType (String aConv) throws RemoteException { - return adaptee.getTreeType (aConv); + try { + return adaptee.getTreeType (aConv); + } catch (RemoteException ex) { + throw ex; + } } public String getTreeType (short aConv) throws RemoteException { - return adaptee.getTreeType (aConv); + try { + return adaptee.getTreeType (aConv); + } catch (RemoteException ex) { + throw ex; + } } public HashMap<Short,String> getTreeType() throws RemoteException { - return adaptee.getTreeType(); + try { + return adaptee.getTreeType(); + } catch (RemoteException ex) { + throw ex; + } } public short getUnit (String aConv) throws RemoteException { - return adaptee.getUnit (aConv); + try { + return adaptee.getUnit (aConv); + } catch (RemoteException ex) { + throw ex; + } } public String getUnit (short aConv) throws RemoteException { - return adaptee.getUnit (aConv); + try { + return adaptee.getUnit (aConv); + } catch (RemoteException ex) { + throw ex; + } } public HashMap<Short,String> getUnit() throws RemoteException { - return adaptee.getUnit(); + try { + return adaptee.getUnit(); + } catch (RemoteException ex) { + throw ex; + } } diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jInitCPPLogger.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jInitCPPLogger.java index 86c96879049cb62383afea67c881f4ae9b8ade7d..5c2b083b7c1265a6c15073f981a59a76245f3f36 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jInitCPPLogger.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jInitCPPLogger.java @@ -22,13 +22,17 @@ package nl.astron.lofar.sas.otb.jotdb2; +import java.rmi.RemoteException; + public class jInitCPPLogger { - public jInitCPPLogger(String logName) { + public jInitCPPLogger(String logName) throws RemoteException{ try { initLogger(logName); } catch (Exception ex) { - System.out.println("Error during initLogger :" +ex); + RemoteException anEx=new RemoteException("JNI getNames error"); + anEx.initCause(ex); + throw anEx; } } diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBadapter.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBadapter.java index 1874694da709bd6d7edcb342b3eb5e3a8d41ecf3..7531febf86674b13f41f8d462649169b49c7d39d 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBadapter.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBadapter.java @@ -26,58 +26,102 @@ import java.util.Vector; import java.rmi.server.UnicastRemoteObject; import java.rmi.RemoteException; -public class jOTDBadapter extends UnicastRemoteObject implements jOTDBinterface -{ - // Constructor - public jOTDBadapter (jOTDBconnection adaptee) throws RemoteException - { - this.adaptee = adaptee; +public class jOTDBadapter extends UnicastRemoteObject implements jOTDBinterface { + // Constructor + public jOTDBadapter (jOTDBconnection adaptee) throws RemoteException { + this.adaptee = adaptee; } - // To test if we are (still) connected. - public boolean isConnected () throws RemoteException - { - return adaptee.isConnected (); + // To test if we are (still) connected. + public boolean isConnected () throws RemoteException { + boolean aB=false; + try { + aB=adaptee.isConnected (); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI isConnected error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // To connect or reconnect in case the connection was lost - public boolean connect () throws RemoteException - { - return adaptee.connect (); - } + public boolean connect () throws RemoteException { + boolean aB=false; + try { + aB = adaptee.connect (); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI connect error"); + anEx.initCause(ex); + throw anEx; + } + return aB; + } // get OTDBtree of one specific tree - public jOTDBtree getTreeInfo (int atreeID,boolean isMomID) throws RemoteException - { - return adaptee.getTreeInfo (atreeID,isMomID); + public jOTDBtree getTreeInfo (int atreeID,boolean isMomID) throws RemoteException { + jOTDBtree aT=null; + try { + aT = adaptee.getTreeInfo (atreeID,isMomID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeInfo error"); + anEx.initCause(ex); + throw anEx; + } + return aT; + } - // To get a list of all StateChanges - public Vector getStateList (int treeID, boolean isMomID, String beginDate, String endDate) throws RemoteException - { + // To get a list of all StateChanges + public Vector getStateList (int treeID, boolean isMomID, String beginDate, String endDate) throws RemoteException { + Vector aV=null; try { - return adaptee.getStateList (treeID, isMomID, beginDate, endDate); - }catch (Exception e){ - throw new RemoteException(); - } + aV = adaptee.getStateList (treeID, isMomID, beginDate, endDate); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getStateList error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } - // To get a list of all OTDB trees available in the database. - public Vector getTreeList (short treeType, short classifiType) throws RemoteException - { - return adaptee.getTreeList (treeType, classifiType); - } + // To get a list of all OTDB trees available in the database. + public Vector getTreeList (short treeType, short classifiType) throws RemoteException { + Vector aV=null; + try { + aV = adaptee.getTreeList (treeType, classifiType); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTreeList error"); + anEx.initCause(ex); + throw anEx; + } + return aV; + } - public String errorMsg () throws RemoteException - { - return adaptee.errorMsg (); - } + public String errorMsg () throws RemoteException { + String aS=null; + try { + aS = adaptee.errorMsg (); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI errorMsg error"); + anEx.initCause(ex); + throw anEx; + } + return aS; + } - public int getAuthToken () throws RemoteException - { - return adaptee.getAuthToken (); + public int getAuthToken () throws RemoteException { + int anI; + try { + anI = adaptee.getAuthToken (); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getAuthToken error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } protected jOTDBconnection adaptee; diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeMaintenanceAdapter.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeMaintenanceAdapter.java index 4ed4f788fd566e497c7b90b637e145e961dc5e99..4fdb05d65ec940597636f81e0f11721f8ee598e8 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeMaintenanceAdapter.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeMaintenanceAdapter.java @@ -40,47 +40,96 @@ public class jTreeMaintenanceAdapter extends UnicastRemoteObject implements jTre // the master PIC. The master PIC will be in a exported ASCII file, with // loadMasterFile this file can be added. // Returns 0 on failure, otherwise the ID of the new tree is returned. - public int loadMasterFile (String filename) throws RemoteException - { - return adaptee.loadMasterFile(filename); + public int loadMasterFile (String filename) throws RemoteException { + int anI; + try { + anI = adaptee.loadMasterFile(filename); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI loadMasterFile error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } //# --- VIC maintenance : Components --- // A VIC tree is build up from single components. The definitions of the // components can loaded from a file with this call - public int loadComponentFile (String filename) throws RemoteException - { - return adaptee.loadComponentFile(filename); + public int loadComponentFile (String filename) throws RemoteException { + int anI; + try { + anI = adaptee.loadComponentFile(filename); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI loadComponentFile error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Find the top-components in the components table. - public Vector<jVICnodeDef> getComponentList (String name , boolean topOnly) throws RemoteException - { - return adaptee.getComponentList(name,topOnly); + public Vector<jVICnodeDef> getComponentList (String name , boolean topOnly) throws RemoteException { + Vector<jVICnodeDef> aV=null; + try { + aV = adaptee.getComponentList(name,topOnly); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getComponentList error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } // Get the node definition of a VC node - public jVICnodeDef getComponentNode(int aNodeID) throws RemoteException - { - return adaptee.getComponentNode(aNodeID); + public jVICnodeDef getComponentNode(int aNodeID) throws RemoteException { + jVICnodeDef aN=null; + try { + aN = adaptee.getComponentNode(aNodeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getComponentNode error"); + anEx.initCause(ex); + throw anEx; + } + return aN; } // Get parameterlist of the component - public Vector<jOTDBparam> getComponentParams(int aNodeID) throws RemoteException - { - return adaptee.getComponentParams(aNodeID); + public Vector<jOTDBparam> getComponentParams(int aNodeID) throws RemoteException { + Vector<jOTDBparam> aP=null; + try { + aP = adaptee.getComponentParams(aNodeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getComponentsParam error"); + anEx.initCause(ex); + throw anEx; + } + return aP; } // Save new node or update the limits and description fields of the node - public boolean saveComponentNode(jVICnodeDef aNode) throws RemoteException - { - return adaptee.saveComponentNode(aNode); + public boolean saveComponentNode(jVICnodeDef aNode) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.saveComponentNode(aNode); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI saveComponentNode error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // test if component is a top-component - public boolean isTopComponent(int aNodeID) throws RemoteException - { - return adaptee.isTopComponent(aNodeID); + public boolean isTopComponent(int aNodeID) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.isTopComponent(aNodeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI isTopComponent error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } //# --- VIC maintenance : Templates --- @@ -88,168 +137,351 @@ public class jTreeMaintenanceAdapter extends UnicastRemoteObject implements jTre // tree only the structure of the tree is created, there is no replication // of nodes on the same level. // Returns 0 on failure, otherwise the ID of the new tree is returned. - public int buildTemplateTree (int topNodeID, short aClassif) throws RemoteException - { - return adaptee.buildTemplateTree (topNodeID, aClassif); + public int buildTemplateTree (int topNodeID, short aClassif) throws RemoteException { + int anI; + try { + anI = adaptee.buildTemplateTree (topNodeID, aClassif); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI buildTemplateTree error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Create a new OTDBtree record for an Template tree in the database // and return its treeID. - public int newTemplateTree() throws RemoteException - { - return adaptee.newTemplateTree(); + public int newTemplateTree() throws RemoteException { + int anI; + try { + anI = adaptee.newTemplateTree(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI newTemplateTree error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Make a copy of an existing template tree. // Returns 0 on failure, otherwise the ID of the new tree is returned. - public int copyTemplateTree (int aTreeID) throws RemoteException - { - return adaptee.copyTemplateTree (aTreeID); + public int copyTemplateTree (int aTreeID) throws RemoteException { + int anI; + try { + anI = adaptee.copyTemplateTree (aTreeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI copyTemplateTree error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Get a single node from the VIC template tree - public jOTDBnode getNode (int aTreeID, int aNodeID) throws RemoteException - { - return adaptee.getNode (aTreeID, aNodeID); + public jOTDBnode getNode (int aTreeID, int aNodeID) throws RemoteException { + jOTDBnode aN=null; + try { + aN = adaptee.getNode (aTreeID, aNodeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getNode error"); + anEx.initCause(ex); + throw anEx; + } + return aN; } // Get the parameter definition of a node - public jOTDBparam getParam(int aTreeID,int aParamID) throws RemoteException - { - return adaptee.getParam(aTreeID,aParamID); + public jOTDBparam getParam(int aTreeID,int aParamID) throws RemoteException { + jOTDBparam aP=null; + try { + aP = adaptee.getParam(aTreeID,aParamID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getParam error"); + anEx.initCause(ex); + throw anEx; + } + return aP; } // Save the parameter definition - public boolean saveParam(jOTDBparam aParam) throws RemoteException - { - return adaptee.saveParam(aParam); + public boolean saveParam(jOTDBparam aParam) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.saveParam(aParam); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI saveParam error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Get a number of levels of children. - public Vector getItemList (int aTreeID, int topNode, int depth) throws RemoteException - { - return adaptee.getItemList (aTreeID, topNode, depth); + public Vector getItemList (int aTreeID, int topNode, int depth) throws RemoteException { + Vector aV=null; + try { + aV = adaptee.getItemList (aTreeID, topNode, depth); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getItemList error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } // Get a list of nodes based on a namefragment. Use '%' as wildchar. - public Vector getItemList (int aTreeID, String aNameFragment) throws RemoteException - { - return adaptee.getItemList (aTreeID, aNameFragment); + public Vector getItemList (int aTreeID, String aNameFragment) throws RemoteException { + Vector aV=null; + try { + aV = adaptee.getItemList (aTreeID, aNameFragment); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getItemList error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } // Duplicates the given node (and its parameters and children) // in the template database. The duplicate gets the new index. - public int dupNode (int aTreeID, int orgNodeID, short newIndex) throws RemoteException - { - return adaptee.dupNode (aTreeID, orgNodeID, newIndex); + public int dupNode (int aTreeID, int orgNodeID, short newIndex) throws RemoteException { + int anI; + try { + anI = adaptee.dupNode (aTreeID, orgNodeID, newIndex); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI dupNode error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Adds the given VIC Component under the given parent of a // template tree. - public int addComponent (int compID,int treeID,int parentID) throws RemoteException - { - return adaptee.addComponent(compID,treeID,parentID); + public int addComponent (int compID,int treeID,int parentID) throws RemoteException { + int anI; + try { + anI = adaptee.addComponent(compID,treeID,parentID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI addComponent error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Updates the (vector of) OTDBnodes to the database. - public boolean saveNode (jOTDBnode aNode) throws RemoteException - { - return adaptee.saveNode (aNode); + public boolean saveNode (jOTDBnode aNode) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.saveNode (aNode); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI saveNode error"); + anEx.initCause(ex); + throw anEx; + } + return aB; + } - public boolean saveNodeList (Vector aNodeList) throws RemoteException - { - return adaptee.saveNodeList (aNodeList); - } + public boolean saveNodeList (Vector aNodeList) throws RemoteException { + boolean aB = false; + try { + aB = adaptee.saveNodeList (aNodeList); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI saveNodeList error"); + anEx.initCause(ex); + throw anEx; + } + return aB; + } // Updates the (vector of) OTDBnodes to the database. - public boolean deleteNode (jOTDBnode aNode) throws RemoteException - { - return adaptee.deleteNode (aNode); + public boolean deleteNode (jOTDBnode aNode) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.deleteNode (aNode); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI deleteNode error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } - public boolean deleteNodeList (Vector aNodeList) throws RemoteException - { - return adaptee.deleteNodeList (aNodeList); + public boolean deleteNodeList (Vector aNodeList) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.deleteNodeList (aNodeList); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI deleteNodeList error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Evaluate the constraints from a (sub)tree. - public boolean checkTreeConstraints (int aTreeID, int topNode) throws RemoteException - { - return adaptee.checkTreeConstraints (aTreeID, topNode); + public boolean checkTreeConstraints (int aTreeID, int topNode) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.checkTreeConstraints (aTreeID, topNode); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI checkTreeConstraints error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } //# --- VIC maintenance : Hierarchical trees --- // From a template tree a fully instanciated tree can be build. // Returns 0 on failure, otherwise the ID of the new tree is returned. - public int instanciateTree (int baseTree) throws RemoteException - { - return adaptee.instanciateTree (baseTree); + public int instanciateTree (int baseTree) throws RemoteException { + int anI; + try { + anI = adaptee.instanciateTree (baseTree); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI instantiateTree error"); + anEx.initCause(ex); + throw anEx; + } + return anI; } // Prune an instanciated tree to get loss of depricated values. - public boolean pruneTree (int aTreeID, short pruningLevel) throws RemoteException - { - return adaptee.pruneTree (aTreeID, pruningLevel); + public boolean pruneTree (int aTreeID, short pruningLevel) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.pruneTree (aTreeID, pruningLevel); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI pruneTree error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Export a VIC (sub)tree to a file. The user may choose in which format // the tree is exported: HTML, KeyValue List. - public boolean exportTree (int aTreeID,int topItem,String filename,int outputFormat,boolean folded) throws RemoteException - { - return adaptee.exportTree(aTreeID,topItem,filename,outputFormat,folded); + public boolean exportTree (int aTreeID,int topItem,String filename,int outputFormat,boolean folded) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.exportTree(aTreeID,topItem,filename,outputFormat,folded); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI exportTree error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } //# --- Finally some general tree maintenance --- // Delete a tree (of any kind) from the database. - public boolean deleteTree (int aTreeID) throws RemoteException - { - return adaptee.deleteTree (aTreeID); + public boolean deleteTree (int aTreeID) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.deleteTree (aTreeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI deleteTree error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Retrieve the topNode of any tree - public jOTDBnode getTopNode (int aTreeID) throws RemoteException - { - return adaptee.getTopNode (aTreeID); + public jOTDBnode getTopNode (int aTreeID) throws RemoteException { + jOTDBnode aN=null; + try { + aN = adaptee.getTopNode (aTreeID); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getTopNode error"); + anEx.initCause(ex); + throw anEx; + } + return aN; } - public boolean setMomInfo(int aTreeID, int momID, String campaign) throws RemoteException - { - return adaptee.setMomInfo(aTreeID, momID, campaign); + public boolean setMomInfo(int aTreeID, int momID, String campaign) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.setMomInfo(aTreeID, momID, campaign); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI setMomInfo error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Set the classification of any tree. - public boolean setClassification (int aTreeID, short aClassification) throws RemoteException - { - return adaptee.setClassification (aTreeID, aClassification); + public boolean setClassification (int aTreeID, short aClassification) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.setClassification (aTreeID, aClassification); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI setClassification error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Set the state of any tree. When changing the state of a tree all // constraints/validations for the current type must be fulfilled. // When errors occur these can be retrieved with the errorMsg function. - public boolean setTreeState (int aTreeID, short aState) throws RemoteException - { - return adaptee.setTreeState (aTreeID, aState); + public boolean setTreeState (int aTreeID, short aState) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.setTreeState (aTreeID, aState); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI setTreeState error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Update the description of a tree. - public boolean setDescription(int aTreeID,String aDescription) throws RemoteException - { - return adaptee.setDescription( aTreeID,aDescription); + public boolean setDescription(int aTreeID,String aDescription) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.setDescription( aTreeID,aDescription); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI setDescription error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Set the scheduling times of the tree - public boolean setSchedule(int aTreeID, String aStartTime,String aStopTime) throws RemoteException - { - return adaptee.setSchedule(aTreeID,aStartTime,aStopTime); + public boolean setSchedule(int aTreeID, String aStartTime,String aStopTime) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.setSchedule(aTreeID,aStartTime,aStopTime); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI setSchedule error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } // Whenever an error occurs in one the OTDB functions the message can // be retrieved with this function. - public String errorMsg() throws RemoteException - { - return adaptee.errorMsg(); + public String errorMsg() throws RemoteException { + String aS=null; + try { + aS = adaptee.errorMsg(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI errorMsg error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } protected jTreeMaintenance adaptee; diff --git a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeValueAdapter.java b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeValueAdapter.java index a3c5989b7169dda61ef5297b03161a94dca7ecd3..d17bb01be010e72a25a38e74cef01be84160b95b 100644 --- a/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeValueAdapter.java +++ b/SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jTreeValueAdapter.java @@ -38,40 +38,89 @@ public class jTreeValueAdapter extends UnicastRemoteObject implements jTreeValue adaptee.setTreeID(aTreeID); } - public boolean addKVT( String key, String value, String time) throws RemoteException - { - return adaptee.addKVT( key, value, time) ; + public boolean addKVT( String key, String value, String time) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.addKVT( key, value, time) ; + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI addKVT error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } - public boolean addKVT(jOTDBvalue aKVT) throws RemoteException - { - return adaptee.addKVT(aKVT); + public boolean addKVT(jOTDBvalue aKVT) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.addKVT(aKVT); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI addKVT error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } - public boolean addKVTlist(Vector<jOTDBvalue> aValueList) throws RemoteException - { - return adaptee.addKVTlist(aValueList); + public boolean addKVTlist(Vector<jOTDBvalue> aValueList) throws RemoteException { + boolean aB=false; + try { + aB = adaptee.addKVTlist(aValueList); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI addKVTlist error"); + anEx.initCause(ex); + throw anEx; + } + return aB; } - // public boolean addKVTparamSet(jParamterSet aPS) throws RemoteException - // { - // return adaptee.addKVTparamSet(aPS); + // public boolean addKVTparamSet(jParamterSet aPS) throws RemoteException { + // boolean aB=false; + // try { + // aB = adaptee.addKVTparamSet(aPS); + // } catch (Exception ex) { + // RemoteException anEx=new RemoteException("JNI addKVTparamSet error"); + // anEx.initCause(ex); + // throw anEx; + // } + // return aB; // } public Vector searchInPeriod (int topNode, int depth, String beginDate, - String endDate, boolean mostRecentlyOnly) throws RemoteException - { - return adaptee.searchInPeriod (topNode, depth, beginDate, endDate, mostRecentlyOnly); + String endDate, boolean mostRecentlyOnly) throws RemoteException { + Vector aV=null; + try { + aV = adaptee.searchInPeriod (topNode, depth, beginDate, endDate, mostRecentlyOnly); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI searchInPeriod error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } - public Vector<jOTDBvalue> getSchedulableItems (int topNode) throws RemoteException - { - return adaptee.getSchedulableItems(topNode); + public Vector<jOTDBvalue> getSchedulableItems (int topNode) throws RemoteException { + Vector<jOTDBvalue> aV=null; + try { + aV = adaptee.getSchedulableItems(topNode); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI getSchedulableItems error"); + anEx.initCause(ex); + throw anEx; + } + return aV; } - public String errorMsg() throws RemoteException - { - return errorMsg(); + public String errorMsg() throws RemoteException { + String aS=null; + try { + aS = errorMsg(); + } catch (Exception ex) { + RemoteException anEx=new RemoteException("JNI errorMsg error"); + anEx.initCause(ex); + throw anEx; + } + return aS; } protected jTreeValue adaptee; diff --git a/SAS/OTB/jOTDB2/test/tConnection.java b/SAS/OTB/jOTDB2/test/tConnection.java index d32da33da244c3bc96819cce8e41eaed0363d86c..f9bc46e96f1c719fe3209937992a3986b3e1bcc6 100644 --- a/SAS/OTB/jOTDB2/test/tConnection.java +++ b/SAS/OTB/jOTDB2/test/tConnection.java @@ -19,48 +19,50 @@ class tConnection tconn.test(); } - public void test() - { - // do the test - System.out.println("Starting... "); + public void test() { + try { + // do the test + System.out.println("Starting... "); - // create a jOTDBconnection - jOTDBconnection conn = new jOTDBconnection("paulus","boskabouter","otdbtest"); + // create a jOTDBconnection + jOTDBconnection conn = new jOTDBconnection("paulus","boskabouter","otdbtest"); - System.out.println("Trying to connect to the database"); - assert conn.connect() : "Connection failed"; - assert conn.isConnected() : "Connnection flag failed"; + System.out.println("Trying to connect to the database"); + assert conn.connect() : "Connection failed"; + assert conn.isConnected() : "Connnection flag failed"; - System.out.println("Connection succesful!"); + System.out.println("Connection succesful!"); - System.out.println("getTreeList(0,0)"); - Vector treeList; - treeList = conn.getTreeList((short)0, (short)0); - if (treeList.size() == 0) { - System.out.println("Error:" + conn.errorMsg()); - } - else { - System.out.println("Collected tree list"); - //showTreeList(treeList); - } + System.out.println("getTreeList(0,0)"); + Vector treeList; + treeList = conn.getTreeList((short)0, (short)0); + if (treeList.size() == 0) { + System.out.println("Error:" + conn.errorMsg()); + } else { + System.out.println("Collected tree list"); + //showTreeList(treeList); + } - System.out.println("getTreeInfo(treeList.elementAt(1))"); - jOTDBtree tInfo = (jOTDBtree)treeList.elementAt(1); - if (tInfo.treeID()==0) { - System.out.println("NOT SUCH TREE FOUND!"); - } - else { - System.out.println(tInfo.classification); - System.out.println(tInfo.creator); - System.out.println(tInfo.creationDate); - System.out.println(tInfo.type); - System.out.println(tInfo.state); - System.out.println(tInfo.originalTree); - System.out.println(tInfo.campaign); - System.out.println(tInfo.starttime); - System.out.println(tInfo.stoptime); - System.out.println(tInfo.treeID()); - } + System.out.println("getTreeInfo(treeList.elementAt(1))"); + jOTDBtree tInfo = (jOTDBtree)treeList.elementAt(1); + if (tInfo.treeID()==0) { + System.out.println("NOT SUCH TREE FOUND!"); + } else { + System.out.println(tInfo.classification); + System.out.println(tInfo.creator); + System.out.println(tInfo.creationDate); + System.out.println(tInfo.type); + System.out.println(tInfo.state); + System.out.println(tInfo.originalTree); + System.out.println(tInfo.campaign); + System.out.println(tInfo.starttime); + System.out.println(tInfo.stoptime); + System.out.println(tInfo.treeID()); + } + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } } diff --git a/SAS/OTB/jOTDB2/test/tConverter.java b/SAS/OTB/jOTDB2/test/tConverter.java index c28e7afe91dfefb19d09746749268c1b1efe16db..70e96b40295b8c8f901f4aa7cef6eab81bc8fc2f 100644 --- a/SAS/OTB/jOTDB2/test/tConverter.java +++ b/SAS/OTB/jOTDB2/test/tConverter.java @@ -28,119 +28,116 @@ class tConverter tconv.test(); } - public void test() - { - // do the test - System.out.println("Starting... using Database: "+dbName); + public void test() { + try { + // do the test + System.out.println("Starting... using Database: "+dbName); - - // create a jOTDBconnection - jOTDBconnection conn = new jOTDBconnection("paulus","boskabouter",dbName); + // create a jOTDBconnection + jOTDBconnection conn = new jOTDBconnection("paulus","boskabouter",dbName); - System.out.println("Trying to connect to the database"); - assert conn.connect() : "Connection failed"; - assert conn.isConnected() : "Connnection flag failed"; + System.out.println("Trying to connect to the database"); + assert conn.connect() : "Connection failed"; + assert conn.isConnected() : "Connnection flag failed"; - System.out.println("Connection succesful!"); + System.out.println("Connection succesful!"); - System.out.println("Constructing a Classif-type converter"); - jClassifConv cf = new jClassifConv(); + System.out.println("Constructing a Classif-type converter"); + jClassifConv cf = new jClassifConv(); - System.out.println("Converting 2: "+ cf.get((short)2)); + System.out.println("Converting 2: "+ cf.get((short)2)); - System.out.println("Converting test: "+ cf.get("test")); + System.out.println("Converting test: "+ cf.get("test")); - System.out.println("Reset the list:"); + System.out.println("Reset the list:"); - System.out.println("getTypes Map"); - aM=cf.getTypes(); - it = aM.keySet().iterator(); - while (it.hasNext()) { - Short key = (Short)it.next(); - System.out.println(key.toString() + " <-> " + aM.get(key)); - } + System.out.println("getTypes Map"); + aM=cf.getTypes(); + it = aM.keySet().iterator(); + while (it.hasNext()) { + Short key = (Short)it.next(); + System.out.println(key.toString() + " <-> " + aM.get(key)); + } - System.out.println("Constructing a ParamType converter"); - jParamTypeConv ptf = new jParamTypeConv(); + System.out.println("Constructing a ParamType converter"); + jParamTypeConv ptf = new jParamTypeConv(); - System.out.println("Converting 101: "+ ptf.get((short)101)); + System.out.println("Converting 101: "+ ptf.get((short)101)); - System.out.println("Converting text: "+ ptf.get("text")); + System.out.println("Converting text: "+ ptf.get("text")); - System.out.println("Reset the list:"); + System.out.println("Reset the list:"); - ptf.top(); - System.out.println("getTypes Map"); - aM=ptf.getTypes(); - it = aM.keySet().iterator(); - while (it.hasNext()) { - Short key = (Short)it.next(); - System.out.println(key.toString() + " <-> " + aM.get(key)); - } + ptf.top(); + System.out.println("getTypes Map"); + aM=ptf.getTypes(); + it = aM.keySet().iterator(); + while (it.hasNext()) { + Short key = (Short)it.next(); + System.out.println(key.toString() + " <-> " + aM.get(key)); + } - System.out.println("Constructing a TreeState-type converter"); - jTreeStateConv ts = new jTreeStateConv(); + System.out.println("Constructing a TreeState-type converter"); + jTreeStateConv ts = new jTreeStateConv(); - System.out.println("Converting 1100: "+ ts.get((short)1100)); + System.out.println("Converting 1100: "+ ts.get((short)1100)); - System.out.println("Converting active: "+ ts.get("active")); + System.out.println("Converting active: "+ ts.get("active")); - System.out.println("Reset the list:"); + System.out.println("Reset the list:"); - ts.top(); - System.out.println("getTypes Map"); - aM=ts.getTypes(); - it = aM.keySet().iterator(); - while (it.hasNext()) { - Short key = (Short)it.next(); - System.out.println(key.toString() + " <-> " + aM.get(key)); - } + ts.top(); + System.out.println("getTypes Map"); + aM=ts.getTypes(); + it = aM.keySet().iterator(); + while (it.hasNext()) { + Short key = (Short)it.next(); + System.out.println(key.toString() + " <-> " + aM.get(key)); + } - System.out.println("Constructing a TreeType-type converter"); - jTreeTypeConv tt = new jTreeTypeConv(); + System.out.println("Constructing a TreeType-type converter"); + jTreeTypeConv tt = new jTreeTypeConv(); - System.out.println("Converting 30: "+ tt.get((short)30)); + System.out.println("Converting 30: "+ tt.get((short)30)); - System.out.println("Converting hardware: "+ tt.get("hardware")); + System.out.println("Converting hardware: "+ tt.get("hardware")); - System.out.println("Reset the list:"); + System.out.println("Reset the list:"); - tt.top(); - System.out.println("getTypes Map"); - aM=tt.getTypes(); - it = aM.keySet().iterator(); - while (it.hasNext()) { - Short key = (Short)it.next(); - System.out.println(key.toString() + " <-> " + aM.get(key)); - } + tt.top(); + System.out.println("getTypes Map"); + aM=tt.getTypes(); + it = aM.keySet().iterator(); + while (it.hasNext()) { + Short key = (Short)it.next(); + System.out.println(key.toString() + " <-> " + aM.get(key)); + } - System.out.println("Constructing a Unit-type converter"); - jUnitConv ut = new jUnitConv(); + System.out.println("Constructing a Unit-type converter"); + jUnitConv ut = new jUnitConv(); - System.out.println("Converting 7: "+ ut.get((short)7)); + System.out.println("Converting 7: "+ ut.get((short)7)); - System.out.println("Converting RAM: "+ ut.get("RAM")); + System.out.println("Converting RAM: "+ ut.get("RAM")); - System.out.println("Reset the list:"); + System.out.println("Reset the list:"); - ut.top(); - System.out.println("getTypes Map"); - aM=ut.getTypes(); - it = aM.keySet().iterator(); - while (it.hasNext()) { - Short key = (Short)it.next(); - System.out.println(key.toString() + " <-> " + aM.get(key)); - } - - - - - + ut.top(); + System.out.println("getTypes Map"); + aM=ut.getTypes(); + it = aM.keySet().iterator(); + while (it.hasNext()) { + Short key = (Short)it.next(); + System.out.println(key.toString() + " <-> " + aM.get(key)); + } + + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } - - } diff --git a/SAS/OTB/jOTDB2/test/tRemoteConnection.java b/SAS/OTB/jOTDB2/test/tRemoteConnection.java index c1259c9f8f59872f01f4e5b0e2a236ca8e0de5d5..73ef455081326dcff645f7ef33450370580486cf 100644 --- a/SAS/OTB/jOTDB2/test/tRemoteConnection.java +++ b/SAS/OTB/jOTDB2/test/tRemoteConnection.java @@ -59,9 +59,9 @@ class tRemoteConnection { System.out.println(tInfo.stoptime); System.out.println(tInfo.treeID()); } - } catch (Exception e) { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } - + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } } diff --git a/SAS/OTB/jOTDB2/test/tRemoteConverter.java b/SAS/OTB/jOTDB2/test/tRemoteConverter.java index d7f1b1d53e0f43930bb08facf86b9283756f1406..f89f0c35fb199c2a50c70ec26ebbafd62660543a 100644 --- a/SAS/OTB/jOTDB2/test/tRemoteConverter.java +++ b/SAS/OTB/jOTDB2/test/tRemoteConverter.java @@ -20,8 +20,7 @@ class tRemoteConverter public static void main (String[] args) { - try - { + try { System.out.println("Starting... "); @@ -102,12 +101,9 @@ class tRemoteConverter Short key = (Short)it.next(); System.out.println(key.toString() + " <-> " + aM.get(key)); } - - } - catch (Exception e) - { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } - + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } } diff --git a/SAS/OTB/jOTDB2/test/tRemoteTreeMaintenance.java b/SAS/OTB/jOTDB2/test/tRemoteTreeMaintenance.java index 3c00c5bb6bfe330cf6bd0edf450c4efa8dfb0639..626e081afed904119fbacfa6487d0698b8e19ae6 100644 --- a/SAS/OTB/jOTDB2/test/tRemoteTreeMaintenance.java +++ b/SAS/OTB/jOTDB2/test/tRemoteTreeMaintenance.java @@ -38,11 +38,10 @@ class tRemoteTreeMaintenance System.out.println (); } System.out.println (trees.size () + " records\n"); - } - catch (Exception e) - { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } public static void showNodeList (Vector nodes) @@ -63,11 +62,11 @@ class tRemoteTreeMaintenance System.out.println (); } System.out.println (nodes.size () + " records\n"); - } - catch (Exception e) - { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } + } public static void showValueList (Vector items) @@ -86,11 +85,11 @@ class tRemoteTreeMaintenance System.out.println (); } System.out.println (items.size() + " records\n"); - } - catch (Exception e) - { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } + } @@ -295,11 +294,11 @@ class tRemoteTreeMaintenance showValueList (valueList); } - } - catch (Exception e) - { - System.out.println ("Remote OTDB via RMI and JNI failed: " + e); - } + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } + } } diff --git a/SAS/OTB/jOTDB2/test/tTreeMaintenance.java b/SAS/OTB/jOTDB2/test/tTreeMaintenance.java index f35313ea6399ece2ec4ab5bb381bcb07c4475d5e..0e21251039aeed21f502ede84c4d708e85c112ff 100644 --- a/SAS/OTB/jOTDB2/test/tTreeMaintenance.java +++ b/SAS/OTB/jOTDB2/test/tTreeMaintenance.java @@ -1,3 +1,4 @@ +import java.rmi.RemoteException; import java.util.Vector; import nl.astron.lofar.sas.otb.jotdb2.jClassifConv; import nl.astron.lofar.sas.otb.jotdb2.jOTDBconnection; @@ -19,7 +20,12 @@ class tTreeMaintenance public static void main (String[] args) { String logConfig="tTreeMaintenance.log_prop"; - jInitCPPLogger aCPPLogger= new jInitCPPLogger(logConfig); + try { + jInitCPPLogger aCPPLogger= new jInitCPPLogger(logConfig); + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } tTreeMaintenance ttreemain = new tTreeMaintenance (); ttreemain.test (); } @@ -77,221 +83,225 @@ class tTreeMaintenance } - public void test () - { - // do the test - System.out.println ("Starting... "); + public void test () { + try { + // do the test + System.out.println ("Starting... "); - // create a jOTDBconnection - jOTDBconnection conn = new jOTDBconnection ("paulus","boskabouter","otdbtest"); + // create a jOTDBconnection + jOTDBconnection conn = new jOTDBconnection ("paulus","boskabouter","otdbtest"); - System.out.println ("Trying to connect to the database"); - assert conn.connect () : "Connection failed"; - assert conn.isConnected () : "Connnection flag failed"; + System.out.println ("Trying to connect to the database"); + assert conn.connect () : "Connection failed"; + assert conn.isConnected () : "Connnection flag failed"; - System.out.println ("Connection succesful!"); + System.out.println ("Connection succesful!"); - System.out.println ("Trying to construct a TreeMaintenance object"); - jTreeMaintenance tm = new jTreeMaintenance (); - assert tm!=null : "Creation of treeMaintenance Failed!"; + System.out.println ("Trying to construct a TreeMaintenance object"); + jTreeMaintenance tm = new jTreeMaintenance (); + assert tm!=null : "Creation of treeMaintenance Failed!"; - // used Converters: - jTreeTypeConv TTconv = new jTreeTypeConv(); - jTreeStateConv TSconv = new jTreeStateConv(); - jClassifConv CTconv = new jClassifConv(); + // used Converters: + jTreeTypeConv TTconv = new jTreeTypeConv(); + jTreeStateConv TSconv = new jTreeStateConv(); + jClassifConv CTconv = new jClassifConv(); - System.out.println ("Trying to load the componentfile: tVTtree.in"); - int topNodeID = tm.loadComponentFile ("tTreeMaintenance.in"); - assert topNodeID!=0 : "Loading of componentfile failed"; + System.out.println ("Trying to load the componentfile: tVTtree.in"); + int topNodeID = tm.loadComponentFile ("tTreeMaintenance.in"); + assert topNodeID!=0 : "Loading of componentfile failed"; - System.out.println("Building a template tree"); - int treeID = tm.buildTemplateTree(topNodeID,CTconv.get("test")); - assert treeID!=0 : "Creation of template tree failed"; - System.out.println("TreeID = " + treeID); + System.out.println("Building a template tree"); + int treeID = tm.buildTemplateTree(topNodeID,CTconv.get("test")); + assert treeID!=0 : "Creation of template tree failed"; + System.out.println("TreeID = " + treeID); - System.out.println ("Searching for a Template tree"); - Vector treeList = conn.getTreeList (TTconv.get("VItemplate"), CTconv.get("test")); - showTreeList (treeList, conn); - assert treeList.size()!=0 : "No template tree found!"; + System.out.println ("Searching for a Template tree"); + Vector treeList = conn.getTreeList (TTconv.get("VItemplate"), CTconv.get("test")); + showTreeList (treeList, conn); + assert treeList.size()!=0 : "No template tree found!"; - int VTtreeID=((jOTDBtree)treeList.elementAt(treeList.size()-1)).treeID(); - System.out.println("Using tree " + VTtreeID + " for the tests"); - jOTDBtree treeInfo = conn.getTreeInfo(VTtreeID,false); - showTree(treeInfo,true); + int VTtreeID=((jOTDBtree)treeList.elementAt(treeList.size()-1)).treeID(); + System.out.println("Using tree " + VTtreeID + " for the tests"); + jOTDBtree treeInfo = conn.getTreeInfo(VTtreeID,false); + showTree(treeInfo,true); - System.out.println("Changing the description to 'test_tree'"); - tm.setDescription(VTtreeID, "test_tree"); - treeInfo = conn.getTreeInfo(VTtreeID, false); - showTree(treeInfo,true); + System.out.println("Changing the description to 'test_tree'"); + tm.setDescription(VTtreeID, "test_tree"); + treeInfo = conn.getTreeInfo(VTtreeID, false); + showTree(treeInfo,true); - System.out.println("Trying to get the topnode of the tree"); - jOTDBnode topNode = tm.getTopNode (treeInfo.treeID()); - showNode(topNode,true); + System.out.println("Trying to get the topnode of the tree"); + jOTDBnode topNode = tm.getTopNode (treeInfo.treeID()); + showNode(topNode,true); - System.out.println("Trying to get a collection of items on depth=1"); - Vector nodeList = tm.getItemList (VTtreeID, topNode.nodeID(), 1); - showNodeList (nodeList); + System.out.println("Trying to get a collection of items on depth=1"); + Vector nodeList = tm.getItemList (VTtreeID, topNode.nodeID(), 1); + showNodeList (nodeList); - System.out.println("Trying to get a collection of items on depth=2"); - nodeList = tm.getItemList (VTtreeID, topNode.nodeID(), 2); - showNodeList (nodeList); + System.out.println("Trying to get a collection of items on depth=2"); + nodeList = tm.getItemList (VTtreeID, topNode.nodeID(), 2); + showNodeList (nodeList); - int elemNr = nodeList.size () - 1; - System.out.println ("Zooming in on last element : "+ elemNr); - jOTDBnode aNode = tm.getNode (VTtreeID, ((jOTDBnode)nodeList.elementAt(elemNr)).nodeID()); - showNode(aNode, true); + int elemNr = nodeList.size () - 1; + System.out.println ("Zooming in on last element : "+ elemNr); + jOTDBnode aNode = tm.getNode (VTtreeID, ((jOTDBnode)nodeList.elementAt(elemNr)).nodeID()); + showNode(aNode, true); - System.out.println ("Trying to classify the tree to: "+CTconv.get("operational")); - boolean actionOK =tm.setClassification(VTtreeID,CTconv.get("operational")); - if (actionOK) { - System.out.println("Setting classification was succesful"); - } else { - System.out.println("Setting classification was NOT succesful"); - } - treeInfo = conn.getTreeInfo(VTtreeID,false); - showTree(treeInfo,true); + System.out.println ("Trying to classify the tree to: "+CTconv.get("operational")); + boolean actionOK =tm.setClassification(VTtreeID,CTconv.get("operational")); + if (actionOK) { + System.out.println("Setting classification was succesful"); + } else { + System.out.println("Setting classification was NOT succesful"); + } + treeInfo = conn.getTreeInfo(VTtreeID,false); + showTree(treeInfo,true); - short aTreeState = TSconv.get("active"); - System.out.println ("Trying to change the state of the tree to "+ aTreeState); - actionOK = tm.setTreeState (VTtreeID, aTreeState); - assert actionOK : "Changing the state to active should have NOT have failed!"; - treeInfo = conn.getTreeInfo (VTtreeID, false); - showTree(treeInfo,true); + short aTreeState = TSconv.get("active"); + System.out.println ("Trying to change the state of the tree to "+ aTreeState); + actionOK = tm.setTreeState (VTtreeID, aTreeState); + assert actionOK : "Changing the state to active should have NOT have failed!"; + treeInfo = conn.getTreeInfo (VTtreeID, false); + showTree(treeInfo,true); - System.out.println ("========== Testing manipulation of nodes =========="); + System.out.println ("========== Testing manipulation of nodes =========="); - System.out.println ("Searching for node 'Virt Telescope'"); - Vector VtelCol = tm.getItemList (VTtreeID, "%Telescope"); - System.out.println ("Found " + VtelCol.size () + " nodes"); - jOTDBnode VtelDef = (jOTDBnode)VtelCol.firstElement (); - assert VtelDef.nodeID () != 0 : "Node 'Virt Telescope' not found"; - System.out.println ("Found definition: " ); - showNode(VtelDef,true); + System.out.println ("Searching for node 'Virt Telescope'"); + Vector VtelCol = tm.getItemList (VTtreeID, "%Telescope"); + System.out.println ("Found " + VtelCol.size () + " nodes"); + jOTDBnode VtelDef = (jOTDBnode)VtelCol.firstElement (); + assert VtelDef.nodeID () != 0 : "Node 'Virt Telescope' not found"; + System.out.println ("Found definition: " ); + showNode(VtelDef,true); - // Test the manipulations on the VT - System.out.println ("Trying to duplicate the subtree"); - int nodeID = tm.dupNode (VTtreeID, VtelDef.nodeID (), (short)1); - System.out.println ("New subtree starts at node: " + nodeID); + // Test the manipulations on the VT + System.out.println ("Trying to duplicate the subtree"); + int nodeID = tm.dupNode (VTtreeID, VtelDef.nodeID (), (short)1); + System.out.println ("New subtree starts at node: " + nodeID); - System.out.println ("Trying to retrieve one node"); - aNode = tm.getNode (VTtreeID, nodeID); - showNode(aNode,true); - System.out.println ("Modifying the instances and limits"); - aNode.instances = 5; - aNode.limits = "no more limits"; - tm.saveNode (aNode); - showNode(aNode,true); + System.out.println ("Trying to retrieve one node"); + aNode = tm.getNode (VTtreeID, nodeID); + showNode(aNode,true); + System.out.println ("Modifying the instances and limits"); + aNode.instances = 5; + aNode.limits = "no more limits"; + tm.saveNode (aNode); + showNode(aNode,true); - System.out.println ("Trying to retrieve one node"); - aNode = tm.getNode (VTtreeID, nodeID); - showNode(aNode, true); - System.out.println ("Removing the just created subtree"); - System.out.println ("nodeID before removal: " + aNode.nodeID ()); - int orgNodeID = aNode.nodeID(); - tm.deleteNode (aNode); - System.out.println ("nodeID after removal : " + aNode.nodeID ()); + System.out.println ("Trying to retrieve one node"); + aNode = tm.getNode (VTtreeID, nodeID); + showNode(aNode, true); + System.out.println ("Removing the just created subtree"); + System.out.println ("nodeID before removal: " + aNode.nodeID ()); + int orgNodeID = aNode.nodeID(); + tm.deleteNode (aNode); + System.out.println ("nodeID after removal : " + aNode.nodeID ()); - System.out.println ("Trying to retrieve the deleted node"); - aNode = tm.getNode (VTtreeID, orgNodeID); - showNode(aNode,true); + System.out.println ("Trying to retrieve the deleted node"); + aNode = tm.getNode (VTtreeID, orgNodeID); + showNode(aNode,true); - // Test the manipulations off the parameters - System.out.println ("Duplicating node Beamformer for index=3"); - Vector BformCol = tm.getItemList (VTtreeID, "Beamformer"); - jOTDBnode BformDef = (jOTDBnode)BformCol.firstElement (); - System.out.println ("Beamformer has ID " + BformDef.nodeID()); - System.out.println (VTtreeID +" " + BformDef.nodeID ()); - int dupNodeID = tm.dupNode (VTtreeID, BformDef.nodeID (), (short)3); - System.out.println ("New subtree starts at node: " + dupNodeID); + // Test the manipulations off the parameters + System.out.println ("Duplicating node Beamformer for index=3"); + Vector BformCol = tm.getItemList (VTtreeID, "Beamformer"); + jOTDBnode BformDef = (jOTDBnode)BformCol.firstElement (); + System.out.println ("Beamformer has ID " + BformDef.nodeID()); + System.out.println (VTtreeID +" " + BformDef.nodeID ()); + int dupNodeID = tm.dupNode (VTtreeID, BformDef.nodeID (), (short)3); + System.out.println ("New subtree starts at node: " + dupNodeID); - System.out.println ("Getting param info for " + dupNodeID+2 + " and " + dupNodeID+3); - jOTDBnode param1 = tm.getNode (VTtreeID, dupNodeID+2); - jOTDBnode param2 = tm.getNode (VTtreeID, dupNodeID+3); - showNode(param1,true); - showNode(param2,true); - param1.limits = "1.33333"; - param2.limits = "---1---"; - System.out.println ("Changing param " + param1.name + " to " + param1.limits); - System.out.println ("Changing param " + param2.name + " to " + param2.limits); - tm.saveNode (param1); - tm.saveNode (param2); + System.out.println ("Getting param info for " + dupNodeID+2 + " and " + dupNodeID+3); + jOTDBnode param1 = tm.getNode (VTtreeID, dupNodeID+2); + jOTDBnode param2 = tm.getNode (VTtreeID, dupNodeID+3); + showNode(param1,true); + showNode(param2,true); + param1.limits = "1.33333"; + param2.limits = "---1---"; + System.out.println ("Changing param " + param1.name + " to " + param1.limits); + System.out.println ("Changing param " + param2.name + " to " + param2.limits); + tm.saveNode (param1); + tm.saveNode (param2); - // Setting nr instances to some nice values - System.out.println ("Setting up tree counts"); - Vector aNodeCol = tm.getItemList (VTtreeID, "RFI dete%"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 40; - tm.saveNode (aNode); - System.out.println ("RFI detectors : 40"); - aNodeCol = tm.getItemList (VTtreeID, "Correlator%"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 130; - tm.saveNode (aNode); - System.out.println ("Correlators : 130"); - aNodeCol = tm.getItemList (VTtreeID, "Storage"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 86; - tm.saveNode (aNode); - System.out.println ("Storage : 86"); - aNodeCol = tm.getItemList (VTtreeID, "Visua%"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 24; - tm.saveNode (aNode); - System.out.println ("Visualisation : 24"); - aNodeCol = tm.getItemList (VTtreeID, "Virt Tel%"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 8; - tm.saveNode (aNode); - System.out.println ("Virt.Telescopes: 8"); - aNodeCol = tm.getItemList (VTtreeID, "Beamfor%"); - aNode = (jOTDBnode)aNodeCol.firstElement (); - aNode.instances = 4; - tm.saveNode (aNode); - System.out.println ("Beamformers : 4"); + // Setting nr instances to some nice values + System.out.println ("Setting up tree counts"); + Vector aNodeCol = tm.getItemList (VTtreeID, "RFI dete%"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 40; + tm.saveNode (aNode); + System.out.println ("RFI detectors : 40"); + aNodeCol = tm.getItemList (VTtreeID, "Correlator%"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 130; + tm.saveNode (aNode); + System.out.println ("Correlators : 130"); + aNodeCol = tm.getItemList (VTtreeID, "Storage"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 86; + tm.saveNode (aNode); + System.out.println ("Storage : 86"); + aNodeCol = tm.getItemList (VTtreeID, "Visua%"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 24; + tm.saveNode (aNode); + System.out.println ("Visualisation : 24"); + aNodeCol = tm.getItemList (VTtreeID, "Virt Tel%"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 8; + tm.saveNode (aNode); + System.out.println ("Virt.Telescopes: 8"); + aNodeCol = tm.getItemList (VTtreeID, "Beamfor%"); + aNode = (jOTDBnode)aNodeCol.firstElement (); + aNode.instances = 4; + tm.saveNode (aNode); + System.out.println ("Beamformers : 4"); - // Test copying a template - System.out.println ("Trying to copy the template tree"); - int secondVTtreeID = tm.copyTemplateTree (VTtreeID); - System.out.println ("ID of new tree is " + secondVTtreeID); - if (secondVTtreeID == 0) { - System.out.println (tm.errorMsg()); - } - jOTDBtree VTtree = conn.getTreeInfo (secondVTtreeID,false); - showTree(VTtree,true); + // Test copying a template + System.out.println ("Trying to copy the template tree"); + int secondVTtreeID = tm.copyTemplateTree (VTtreeID); + System.out.println ("ID of new tree is " + secondVTtreeID); + if (secondVTtreeID == 0) { + System.out.println (tm.errorMsg()); + } + jOTDBtree VTtree = conn.getTreeInfo (secondVTtreeID,false); + showTree(VTtree,true); - // Test creating a full tree of the template tree - System.out.println ("Trying to instanciate the copied tree"); - int VHtreeID = tm.instanciateTree (secondVTtreeID); - System.out.println ("ID of new tree is " + VHtreeID); - if (VHtreeID == 0) { - System.out.println (tm.errorMsg()); - } - jOTDBtree VHtree = conn.getTreeInfo (VHtreeID,false); - showTree(VHtree,true); + // Test creating a full tree of the template tree + System.out.println ("Trying to instanciate the copied tree"); + int VHtreeID = tm.instanciateTree (secondVTtreeID); + System.out.println ("ID of new tree is " + VHtreeID); + if (VHtreeID == 0) { + System.out.println (tm.errorMsg()); + } + jOTDBtree VHtree = conn.getTreeInfo (VHtreeID,false); + showTree(VHtree,true); - // Test deleting an active tree - System.out.println("Trying to delete original template tree " + VTtreeID); - try { - tm.deleteTree(VTtreeID); - assert false : "DELETING AN ACTIVE TREE IS NOT ALLOWED!"; - } catch (Exception e) { - System.out.println("EXPECTED exception: " + e); - } + // Test deleting an active tree + System.out.println("Trying to delete original template tree " + VTtreeID); + try { + tm.deleteTree(VTtreeID); + assert false : "DELETING AN ACTIVE TREE IS NOT ALLOWED!"; + } catch (Exception e) { + System.out.println("EXPECTED exception: " + e); + } - aTreeState = TSconv.get("obsolete"); - System.out.println("Trying to change the state of the tree to " +aTreeState); - actionOK = tm.setTreeState(VTtreeID, aTreeState); - assert actionOK : "Changing the state to " + aTreeState + " should have NOT have failed!"; + aTreeState = TSconv.get("obsolete"); + System.out.println("Trying to change the state of the tree to " +aTreeState); + actionOK = tm.setTreeState(VTtreeID, aTreeState); + assert actionOK : "Changing the state to " + aTreeState + " should have NOT have failed!"; - // Test deleting a tree - System.out.println("Retrying to delete original template tree " + VTtreeID); - assert tm.deleteTree(VTtreeID) : "Deletion of original tree went wrong:" + tm.errorMsg(); - System.out.println("Deletion of original tree was succesful"); + // Test deleting a tree + System.out.println("Retrying to delete original template tree " + VTtreeID); + assert tm.deleteTree(VTtreeID) : "Deletion of original tree went wrong:" + tm.errorMsg(); + System.out.println("Deletion of original tree was succesful"); - System.out.println ("Terminated succesfully: "); + System.out.println ("Terminated succesfully: "); + } catch (Exception ex) { + System.out.println("Error: "+ ex); + ex.printStackTrace(); + } } }