if (type != ProgramType.WEBAPP) {
//Runtime info not found. Check to see if the program exists.
String spec = getProgramSpecification(id, type);
if (spec == null || spec.isEmpty()) {
// program doesn't exist
return new ProgramStatus(id.getApplicationId(), id.getId(), HttpResponseStatus.NOT_FOUND.toString());
} else {
// program exists and not running. so return stopped.
return new ProgramStatus(id.getApplicationId(), id.getId(), ProgramController.State.STOPPED.toString());
}
} else {
// TODO: Fetching webapp status is a hack. This will be fixed when webapp spec is added.
Location webappLoc = null;
try {
webappLoc = Programs.programLocation(locationFactory, appFabricDir, id, ProgramType.WEBAPP);
} catch (FileNotFoundException e) {
// No location found for webapp, no need to log this exception
}
if (webappLoc != null && webappLoc.exists()) {
// webapp exists and not running. so return stopped.
return new ProgramStatus(id.getApplicationId(), id.getId(), ProgramController.State.STOPPED.toString());
} else {
// webapp doesn't exist
return new ProgramStatus(id.getApplicationId(), id.getId(), HttpResponseStatus.NOT_FOUND.toString());
}
}
}
String status = controllerStateToString(runtimeInfo.getController().getState());
return new ProgramStatus(id.getApplicationId(), id.getId(), status);
} catch (Throwable throwable) {
LOG.warn(throwable.getMessage(), throwable);
throw new Exception(throwable.getMessage());
}
}