Skip to content

Instantly share code, notes, and snippets.

@zevnull
Created May 17, 2013 06:54
Show Gist options
  • Save zevnull/5597383 to your computer and use it in GitHub Desktop.
Save zevnull/5597383 to your computer and use it in GitHub Desktop.
Get list of Solutions Overview names from config file
/**
* Get list of Solutions Overview names from config file
*
* @return List<String> - Solutions Overview names
* @throws Exception
*/
public List<String> getSolutionsOverviewNamesFromConfig() throws Exception
{
DMLogger.methodStarted();
// TODO add path for QH DM2Web config (system-config.json)
// String jsonTxt = ssh.runCommand( "less /opt/ddn/directmon/web/etc/ddn/directmon/system-config.json" );
String jsonTxt = ssh.runCommand( "less /etc/ddn/directmon/system-config.json" );
JSONObject json = ( JSONObject ) JSONSerializer.toJSON( jsonTxt );
Set<?> s = json.keySet();
List<String> result = new ArrayList<String>();
Iterator<?> it = s.iterator();
while( it.hasNext() )
{
Set<String> keySet = json.getJSONObject( it.next().toString() ).keySet();
result.addAll( keySet );
}
for( int i = 0; i < result.size(); i++ )
{
String element = result.get( i ).toString();
element = element.substring( 0, element.indexOf( ":" ) );
result.set( i, element );
}
DMLogger.methodFinished( result );
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment