<%
String defaultDescription="More information about this type of server is found at "
+ "GitHub."
+ " This implementation of the HAPI server uses plug-in readers to load data. Discussion and more about this "
+ " server can be found here.";
%>
<%= about.optString("description",defaultDescription) %>
Some example requests:
AboutMore about this server, like contact info. CapabilitiesCapabilities of the server. CatalogShow the catalog of available data sets.
<%
try {
JSONObject catalog= HapiServerSupport.getCatalog(HAPI_HOME);
JSONArray dss= catalog.getJSONArray("catalog");
if ( dss.length()>1 ) {
out.println("This server provides "+dss.length()+" datasets, examples follow.");
}
// There is a method for including sparklines on the landing page, where an "AutoplotServer" is called
// to generate graphics for each dataset. Please ignore this if sparklines=false.
String autoplotServer= "https://cottagesystems.com/AutoplotServlet";
//String autoplotServer= "http://localhost:8084/AutoplotServlet";
String me= "http://spot9/hapi"; // TODO: address this, what is the public name for the server
boolean sparklines= false; // don't draw sparklines using external server.
int numDataSets= Math.min( dss.length(), landingConfig.optInt( "x-landing-count", MAX_DATASETS ) );
Pattern[] incl;
if ( landingConfig.has("x-landing-include") ) {
JSONArray inclRegex= landingConfig.getJSONArray("x-landing-include");
incl= new Pattern[inclRegex.length()];
for ( int i=0; i ids= new ArrayList<>();
List titles= new ArrayList<>();
for ( int i=0; i0 ) {
if ( !title.equals(id) ) {
title= id + ": "+ title;
}
} else {
title= id;
}
try {
JSONObject info= HapiServerSupport.getInfo( HAPI_HOME, id );
int[] availableRange= HapiServerSupport.getRange(info);
int[] exampleRange= HapiServerSupport.getExampleRange(info);
if ( exampleRange!=null ) {
title= title+ " (available "+ TimeUtil.formatIso8601TimeRange(availableRange)
+ ", example range "+TimeUtil.formatIso8601TimeRange(exampleRange) +
( sparklines ? " shown)" : ")" );
}
String exampleTimeRange= exampleRange==null ? null :
String.format( "start=%s&stop=%s",
TimeUtil.formatIso8601TimeBrief(exampleRange),
TimeUtil.formatIso8601TimeBrief( TimeUtil.getStopTime(exampleRange) ) );
out.println( String.format( "
("+(dss.length()-numDataSets)+" additional dataset" + pps +" can be accessed using a HAPI client.)
" );
}
} catch ( JSONException ex ) {
out.print("
Something has gone wrong, see logs or send an email to faden at cottagesystems.com");
//out.println(" "+ex.getMessage()); //TODO: security
Util.logError(ex);
}
out.println("
build id: "+Util.buildTime()+"");
JSONObject footer= (JSONObject)landingConfig.opt("x_footer");
if ( footer!=null ) {
String s= footer.optString( "classpath", footer.optString("x_classpath","") );
String clas= footer.getString("x_class");
String method= footer.getString("x_method");
if ( clas!=null && method!=null ) {
s= SpawnRecordSource.doMacros( HAPI_HOME, "", s );
ClassLoader cl= new URLClassLoader( new URL[] { new URL( s ) }, SourceRegistry.class.getClassLoader() );
cl.getParent();
Class c= Class.forName(clas,true,cl);
Method m = c.getMethod( method );
String sfooter= (String)m.invoke(null);
out.println(""+sfooter+"");
}
}
%>