use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class JReportUtils method fillReportToResponse.
public static void fillReportToResponse(String reportId, Map<String, Object> paramMap, HttpServletResponse response) throws ServiceException, Exception {
if (StringUtils.isBlank(reportId)) {
throw new java.lang.IllegalArgumentException("error, reportId is blank");
}
TbSysJreport sysJreport = new TbSysJreport();
sysJreport.setReportId(reportId);
DefaultResult<TbSysJreport> result = sysJreportService.findEntityByUK(sysJreport);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
sysJreport = result.getValue();
String jasperFileFullPath = Constants.getDeployJasperReportDir() + "/" + sysJreport.getReportId() + "/" + sysJreport.getReportId() + ".jasper";
File jasperFile = new File(jasperFileFullPath);
if (!jasperFile.exists()) {
jasperFile = null;
throw new Exception("error, Files are missing : " + jasperFileFullPath);
}
InputStream reportSource = new FileInputStream(jasperFile);
Connection conn = null;
try {
conn = DataUtils.getConnection();
ServletOutputStream ouputStream = response.getOutputStream();
JasperPrint jasperPrint = JasperFillManager.fillReport(reportSource, paramMap, conn);
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline; filename=" + sysJreport.getReportId() + ".pdf");
JRPdfExporter jrPdfExporter = new JRPdfExporter();
jrPdfExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
jrPdfExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(ouputStream));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
jrPdfExporter.setConfiguration(configuration);
configuration.setOwnerPassword(Constants.getEncryptorKey1());
jrPdfExporter.exportReport();
ouputStream.flush();
ouputStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
DataUtils.doReleaseConnection(conn);
if (null != reportSource) {
try {
reportSource.close();
} catch (IOException e) {
e.printStackTrace();
}
}
reportSource = null;
jasperFile = null;
}
}
use of com.netsteadfast.greenstep.base.exception.ServiceException 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.base.exception.ServiceException 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.base.exception.ServiceException in project bamboobsc by billchen198318.
the class BusinessProcessManagementUtils method isRoleAllowApproval.
public static boolean isRoleAllowApproval(String resourceId, String roleId, String taskName) throws ServiceException, Exception {
if (StringUtils.isBlank(resourceId) || StringUtils.isBlank(roleId) || StringUtils.isBlank(taskName)) {
throw new Exception(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
TbSysBpmnResourceRole resourceRole = new TbSysBpmnResourceRole();
resourceRole.setId(resourceId);
resourceRole.setRole(roleId);
resourceRole.setTaskName(taskName);
if (sysBpmnResourceRoleService.countByEntityUK(resourceRole) > 0) {
return true;
}
return false;
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class MenuSupportUtils method loadSysMenuData.
protected static List<SysMenuVO> loadSysMenuData(String system) throws ServiceException, Exception {
List<SysMenuVO> menuList = null;
TbSys sys = new TbSys();
sys.setSysId(system);
if (sysService.countByEntityUK(sys) != 1) {
// 必需要有 TB_SYS 資料
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
Subject subject = SecurityUtils.getSubject();
String account = (String) subject.getPrincipal();
if (StringUtils.isBlank(account)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
if (subject.hasRole(Constants.SUPER_ROLE_ADMIN) || subject.hasRole(Constants.SUPER_ROLE_ALL)) {
account = null;
}
DefaultResult<List<SysMenuVO>> result = sysMenuService.findForMenuGenerator(system, account);
if (result.getValue() != null) {
menuList = result.getValue();
}
if (menuList == null) {
menuList = new ArrayList<SysMenuVO>();
}
return menuList;
}
Aggregations