use of com.netsteadfast.greenstep.service.ISysService in project bamboobsc by billchen198318.
the class ApplicationSiteUtils method configureHost.
@SuppressWarnings("unchecked")
public static void configureHost(String sysId, String logConfFileFullPath) {
String logValue = FSUtils.readStr(logConfFileFullPath).trim();
if (!StringUtils.isBlank(logValue) && UPDATE_HOST_ONLY_FIRST_ONE.equals(Constants.getApplicationSiteHostUpdateMode())) {
// has before start log file, and UPDATE_HOST_ONLY_FIRST_ONE mode
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ONLY_FIRST_ONE);
return;
}
ISysService<SysVO, TbSys, String> sysService = (ISysService<SysVO, TbSys, String>) AppContext.getBean("core.service.SysService");
SysVO sys = new SysVO();
sys.setSysId(sysId);
try {
DefaultResult<SysVO> result = sysService.findByUK(sys);
if (result.getValue() == null) {
System.out.println(result.getSystemMessage().getValue());
return;
}
sys = result.getValue();
// 2016-06-29 rem
/*
String port = "";
String tmp[] = sys.getHost().split(":");
if ( tmp!=null && tmp.length==2 ) {
port = tmp[1];
}
*/
// 2016-06-29 add
String port = String.valueOf(HostUtils.getHttpPort());
String hostAddress = HostUtils.getHostAddress();
sys.setHost(hostAddress);
if (!StringUtils.isBlank(port)) {
sys.setHost(hostAddress + ":" + port);
}
sysService.updateObject(sys);
if (UPDATE_HOST_ALWAYS.equals(Constants.getApplicationSiteHostUpdateMode())) {
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ALWAYS);
} else {
FSUtils.writeStr2(logConfFileFullPath, UPDATE_HOST_ONLY_FIRST_ONE);
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.netsteadfast.greenstep.service.ISysService in project bamboobsc by billchen198318.
the class ApplicationSiteUtils method getSystemsCheckCrossSiteWithTestConnection.
@SuppressWarnings("unchecked")
public static List<SysVO> getSystemsCheckCrossSiteWithTestConnection(HttpServletRequest request) {
ISysService<SysVO, TbSys, String> sysService = (ISysService<SysVO, TbSys, String>) AppContext.getBean("core.service.SysService");
List<SysVO> sysList = null;
try {
sysList = sysService.findListVOByParams(null);
for (SysVO sys : sysList) {
if (checkCrossSite(sys.getHost().toLowerCase(), request)) {
sys.setCrossSiteFlag(YesNo.YES);
} else {
sys.setCrossSiteFlag(YesNo.NO);
}
if (checkTestConnection(sys.getHost(), sys.getContextPath(), request)) {
sys.setTestFlag(YesNo.YES);
} else {
sys.setTestFlag(YesNo.NO);
}
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return sysList;
}
use of com.netsteadfast.greenstep.service.ISysService in project bamboobsc by billchen198318.
the class ApplicationSiteUtils method getBasePath.
@SuppressWarnings("unchecked")
public static String getBasePath(String sysId, HttpServletRequest request) {
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
if (StringUtils.isBlank(sysId)) {
return basePath;
}
ISysService<SysVO, TbSys, String> sysService = (ISysService<SysVO, TbSys, String>) AppContext.getBean("core.service.SysService");
SysVO sys = new SysVO();
sys.setSysId(sysId);
try {
DefaultResult<SysVO> result = sysService.findByUK(sys);
if (result.getValue() == null) {
return basePath;
}
sys = result.getValue();
basePath = request.getScheme() + "://" + sys.getHost() + "/" + sys.getContextPath() + "/";
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return basePath;
}
use of com.netsteadfast.greenstep.service.ISysService in project bamboobsc by billchen198318.
the class ApplicationSiteUtils method getContextPath.
@SuppressWarnings("unchecked")
public static String getContextPath(String sysId) {
String contextPath = "";
ISysService<SysVO, TbSys, String> sysService = (ISysService<SysVO, TbSys, String>) AppContext.getBean("core.service.SysService");
SysVO sys = new SysVO();
sys.setSysId(sysId);
try {
DefaultResult<SysVO> result = sysService.findByUK(sys);
if (result.getValue() == null) {
return contextPath;
}
sys = result.getValue();
contextPath = sys.getContextPath();
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return contextPath;
}
use of com.netsteadfast.greenstep.service.ISysService in project bamboobsc by billchen198318.
the class ApplicationSiteUtils method checkLoginUrlWithAllSysHostConfig.
@SuppressWarnings("unchecked")
public static boolean checkLoginUrlWithAllSysHostConfig(HttpServletRequest request) {
boolean pathSuccess = true;
ISysService<SysVO, TbSys, String> sysService = (ISysService<SysVO, TbSys, String>) AppContext.getBean("core.service.SysService");
try {
List<TbSys> sysList = sysService.findListByParams(null);
for (int i = 0; sysList != null && i < sysList.size() && pathSuccess; i++) {
TbSys sys = sysList.get(i);
pathSuccess = !checkCrossSite(sys.getHost().toLowerCase(), request);
if (pathSuccess) {
pathSuccess = checkTestConnection(sys.getHost(), sys.getContextPath(), request);
}
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return pathSuccess;
}
Aggregations