@@ -43,7 +43,10 @@ public class FlowvisorImpl implements Flowvisor {
4343 private static String GLOGFACILITY = "SELECT " + LOGFACILITY + " FROM FlowVisor WHERE id = ?" ;
4444 private static String GTOPO = "SELECT " + TOPO + " FROM Flowvisor WHERE id = ?" ;
4545 private static String GFSTIME = "SELECT " + FSCACHE + " FROM Flowvisor WHERE id = ?" ;
46-
46+ private static String GCONFIG = "SELECT " + CONFIG + " FROM Flowvisor WHERE id = ?" ;
47+ private static String GVERSION = "SELECT " + VERSION + " FROM Flowvisor WHERE id = ?" ;
48+ private static String GHOST = "SELECT " + HOST + " FROM Flowvisor WHERE id = ?" ;
49+ private static String GDBVERSION = "SELECT " + DB_VERSION + " FROM Flowvisor WHERE id = ?" ;
4750
4851 private static String STRACKID = "UPDATE Flowvisor SET " + TRACK + " = ? WHERE id = ?" ;
4952 private static String SSTATSID = "UPDATE Flowvisor SET " + STATS + " = ? WHERE id = ?" ;
@@ -56,6 +59,10 @@ public class FlowvisorImpl implements Flowvisor {
5659 private static String SAPIPORT = "UPDATE Flowvisor SET " + APIPORT + " = ? WHERE id = ?" ;
5760 private static String SJETTYPORT = "UPDATE Flowvisor SET " + JETTYPORT + " = ? WHERE id = ?" ;
5861 private static String SFSTIME = "UPDATE Flowvisor SET " + FSCACHE + " = ? WHERE id = ?" ;
62+ private static String SCONFIG = "UPDATE Flowvisor SET " + CONFIG + " = ? WHERE id = ?" ;
63+ private static String SVERSION = "SELECT " + VERSION + " FROM Flowvisor WHERE id = ?" ;
64+ private static String SHOST = "SELECT " + HOST + " FROM Flowvisor WHERE id = ?" ;
65+ private static String SDBVERSION = "SELECT " + DB_VERSION + " FROM Flowvisor WHERE id = ?" ;
5966
6067 private static String INSERT = "INSERT INTO " + FLOWVISOR + "(" + APIPORT + "," +
6168 JETTYPORT + "," + CHECKPOINT + "," + LISTEN + "," + TRACK + "," +
@@ -218,6 +225,120 @@ public Integer getAPIWSPort(Integer id) throws ConfigError {
218225 public Integer getAPIWSPort () throws ConfigError {
219226 return getAPIWSPort (1 );
220227 }
228+
229+ //Additions for get config
230+
231+ public String getConfigName (Integer id ) throws ConfigError {
232+ Connection conn = null ;
233+ PreparedStatement ps = null ;
234+ ResultSet set = null ;
235+ try {
236+ conn = settings .getConnection ();
237+ ps = conn .prepareStatement (GCONFIG );
238+ ps .setInt (1 , id );
239+ set = ps .executeQuery ();
240+ if (set .next ())
241+ return set .getString (CONFIG );
242+ else
243+ throw new ConfigError ("Config Name not found" );
244+ } catch (SQLException e ) {
245+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
246+ } finally {
247+
248+ close (set );
249+ close (ps );
250+ close (conn );
251+
252+ }
253+ return null ;
254+ }
255+ public String getConfigName () throws ConfigError {
256+ return getConfigName (1 );
257+ }
258+
259+ public String getVersion (Integer id ) throws ConfigError {
260+ Connection conn = null ;
261+ PreparedStatement ps = null ;
262+ ResultSet set = null ;
263+ try {
264+ conn = settings .getConnection ();
265+ ps = conn .prepareStatement (GVERSION );
266+ ps .setInt (1 , id );
267+ set = ps .executeQuery ();
268+ if (set .next ())
269+ return set .getString (VERSION );
270+ else
271+ throw new ConfigError ("Version not found" );
272+ } catch (SQLException e ) {
273+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
274+ } finally {
275+
276+ close (set );
277+ close (ps );
278+ close (conn );
279+
280+ }
281+ return null ;
282+ }
283+ public String getVersion () throws ConfigError {
284+ return getVersion (1 );
285+ }
286+
287+ public String getDBVersion (Integer id ) throws ConfigError {
288+ Connection conn = null ;
289+ PreparedStatement ps = null ;
290+ ResultSet set = null ;
291+ try {
292+ conn = settings .getConnection ();
293+ ps = conn .prepareStatement (GDBVERSION );
294+ ps .setInt (1 , id );
295+ set = ps .executeQuery ();
296+ if (set .next ())
297+ return set .getString (DB_VERSION );
298+ else
299+ throw new ConfigError ("DBVersion not found" );
300+ } catch (SQLException e ) {
301+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
302+ } finally {
303+
304+ close (set );
305+ close (ps );
306+ close (conn );
307+
308+ }
309+ return null ;
310+ }
311+ public String getDBVersion () throws ConfigError {
312+ return getDBVersion (1 );
313+ }
314+
315+ public String getHost (Integer id ) throws ConfigError {
316+ Connection conn = null ;
317+ PreparedStatement ps = null ;
318+ ResultSet set = null ;
319+ try {
320+ conn = settings .getConnection ();
321+ ps = conn .prepareStatement (GHOST );
322+ ps .setInt (1 , id );
323+ set = ps .executeQuery ();
324+ if (set .next ())
325+ return set .getString (HOST );
326+ else
327+ throw new ConfigError ("Host not found" );
328+ } catch (SQLException e ) {
329+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
330+ } finally {
331+
332+ close (set );
333+ close (ps );
334+ close (conn );
335+
336+ }
337+ return null ;
338+ }
339+ public String getHost () throws ConfigError {
340+ return getHost (1 );
341+ }
221342
222343 public Integer getJettyPort (Integer id ) throws ConfigError {
223344 Connection conn = null ;
@@ -690,6 +811,117 @@ public void setAPIWSPort(Integer id, Integer port) throws ConfigError {
690811 }
691812 }
692813
814+ //Additions for get config
815+ @ Override
816+ public void setConfigName (String config ) throws ConfigError {
817+ setConfigName (1 , config );
818+ }
819+
820+ @ Override
821+ public void setConfigName (Integer id , String config ) throws ConfigError {
822+ Connection conn = null ;
823+ PreparedStatement ps = null ;
824+ ResultSet set = null ;
825+ try {
826+ conn = settings .getConnection ();
827+ ps = conn .prepareStatement (SCONFIG );
828+ ps .setString (1 , config );
829+ ps .setInt (2 , id );
830+ if (ps .executeUpdate () == 0 )
831+ FVLog .log (LogLevel .WARN , null , "Unable to set the config name." );
832+ } catch (SQLException e ) {
833+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
834+
835+ } finally {
836+ close (set );
837+ close (ps );
838+ close (conn );
839+ }
840+ }
841+
842+ @ Override
843+ public void setVersion (String version ) throws ConfigError {
844+ setVersion (1 , version );
845+ }
846+
847+ @ Override
848+ public void setVersion (Integer id , String version ) throws ConfigError {
849+ Connection conn = null ;
850+ PreparedStatement ps = null ;
851+ ResultSet set = null ;
852+ try {
853+ conn = settings .getConnection ();
854+ ps = conn .prepareStatement (SVERSION );
855+ ps .setString (1 , version );
856+ ps .setInt (2 , id );
857+ if (ps .executeUpdate () == 0 )
858+ FVLog .log (LogLevel .WARN , null , "Unable to set the version." );
859+ } catch (SQLException e ) {
860+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
861+
862+ } finally {
863+ close (set );
864+ close (ps );
865+ close (conn );
866+ }
867+ }
868+
869+ @ Override
870+ public void setHost (String host ) throws ConfigError {
871+ setHost (1 , host );
872+ }
873+
874+ @ Override
875+ public void setHost (Integer id , String host ) throws ConfigError {
876+ Connection conn = null ;
877+ PreparedStatement ps = null ;
878+ ResultSet set = null ;
879+ try {
880+ conn = settings .getConnection ();
881+ ps = conn .prepareStatement (SHOST );
882+ ps .setString (1 , host );
883+ ps .setInt (2 , id );
884+ if (ps .executeUpdate () == 0 )
885+ FVLog .log (LogLevel .WARN , null , "Unable to set the host." );
886+ } catch (SQLException e ) {
887+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
888+
889+ } finally {
890+ close (set );
891+ close (ps );
892+ close (conn );
893+ }
894+ }
895+
896+ @ Override
897+ public void setDBVersion (Integer dbVersion ) throws ConfigError {
898+ setDBVersion (1 , dbVersion );
899+ }
900+
901+ @ Override
902+ public void setDBVersion (Integer id , Integer dbVersion ) throws ConfigError {
903+ Connection conn = null ;
904+ PreparedStatement ps = null ;
905+ ResultSet set = null ;
906+ try {
907+ conn = settings .getConnection ();
908+ ps = conn .prepareStatement (SDBVERSION );
909+ ps .setInt (1 , dbVersion );
910+ ps .setInt (2 , id );
911+ if (ps .executeUpdate () == 0 )
912+ FVLog .log (LogLevel .WARN , null , "Unable to set the dbVersion." );
913+ } catch (SQLException e ) {
914+ FVLog .log (LogLevel .WARN , null , e .getMessage ());
915+
916+ } finally {
917+ close (set );
918+ close (ps );
919+ close (conn );
920+ }
921+ }
922+
923+
924+
693925 @ Override
694926 public void setJettyPort (Integer port ) throws ConfigError {
695927 setJettyPort (1 , port );
0 commit comments