class SystemService extends BasicService {

	@GET
	@Path("/info")
	@Produces(MediaType.APPLICATION_JSON)
	public SystemInfo getSytemInfo() {
		SystemInfo result = new SystemInfo();

		String userId = userUtil.getLoggedInDBUser(request).getUserId();
		String infoCondition = ConfigUtil.getProperty(Consts.APP, Consts.PROP_INFOCONDITION);

		result.setBuildTime(ConfigUtil.getProperty(Consts.APP, Consts.PROP_BUILDTIME));
		result.setCurrentTime(new Date());
		result.setDefaultTimezone(Calendar.getInstance().getTimeZone().getID());
		result.setDateFormat(Consts.DATEFORMAT);
		result.setVersion(Consts.VERSION);
		result.setAnalyticsToken(ConfigUtil.getProperty(Consts.APP, Consts.PROP_ANALYTICSTOKEN));
		result.setxDim(Consts.xDim);
		result.setyDim(Consts.yDim);
		result.setCurrentUser(userId);
		result.setAdminMode(isAdmin() && userUtil.isImpersonating(request) == null);
		result.setDbAdminMode(isDBAdmin() && userUtil.isImpersonating(request) == null);
		result.setImpersonation(userUtil.isImpersonating(request));
		result.setLogoutUrl(ConfigUtil.getProperty(Consts.APP, Consts.PROP_LOGOUTURL));
		result.setGettingStartedUrl(ConfigUtil.getProperty(Consts.APP, Consts.PROP_GETTINGSTARTEDURL));
		result.setDevelopmentUrl(ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL));
		result.setNewsUrl(ConfigUtil.getProperty(Consts.APP, Consts.PROP_NEWSURL));
		result.setAdministrators(ConfigUtil.getProperty(Consts.APP, Consts.PROP_ADMINISTRATORS));
		result.setFileSupport(ConfigUtil.getBooleanProperty(Consts.APP, Consts.PROP_FILESUPPORT));
		result.setRecommendedAppleTVAppVersion(
				ConfigUtil.getProperty(Consts.APP, Consts.PROP_RECOMMENDEDAPPLETVAPPVERSION));
		result.setInfoCondition(infoCondition);
		result.setInfoConditionMet(StringUtils.isNotBlank(infoCondition) && userId.matches(infoCondition));
		result.setInfoText(ConfigUtil.getProperty(Consts.APP, Consts.PROP_INFOTEXT));
		result.setInfoLink(ConfigUtil.getProperty(Consts.APP, Consts.PROP_INFOLINK));
		result.setConfigRefreshInterval(ConfigUtil.getIntProperty(Consts.APPLIANCE, Consts.PROP_CONFIGREFRESHINTERVAL));
		result.setReloadInterval(ConfigUtil.getIntProperty(Consts.APPLIANCE, Consts.PROP_RELOADINTERVAL));
		result.setScreenshotInterval(ConfigUtil.getIntProperty(Consts.APPLIANCE, Consts.PROP_SCREENSHOTINTERVAL));
		result.setTechnicalUser(ConfigUtil.getProperty(Consts.APPLIANCE, Consts.PROP_TECHNICALUSER));
		result.setAutoScreenshotInstances(ScreenDAO.getScreenshotInstances(true).size());
		result.setStats_playlists(new PlaylistDAO().getCount());
		result.setStats_pages(new PageDAO().getCount());
		result.setStats_files(new FileDAO().getCount());
		result.setStats_screens(new ScreenDAO().getCount());
		result.setStats_activescreens(ScreenDAO.getActiveScreens().size());

		return result;
	}

}