@Override public PortalDeployDefinition parseModule(String modulePath) { LfwLogger.info("Parsing modules in directory '" + modulePath + "'"); try { PortalDeployDefinition define = new PortalDeployDefinition(); PortalModule pm = parsePortalModule(modulePath); String moduleName = pm.getModule(); define.setModule(moduleName); define.setPortalModule(pm); /*Portal*/ PortletApplicationDefinition pad = parsePortlets(modulePath, define, moduleName); define.setPortletDefineModule(pad); /* 加入Portal页面 */ Page[] pages = PmlUtil.getPages(modulePath + "/portalspec/pml"); if (pages != null) { define.setPages(pages); } /*Portlet分组信息*/ Reader displayins = null; try { File f = new File(modulePath + "/portalspec/display.xml"); if (f.exists()) { String xmlText = FileUtils.readFileToString(f, "UTF-8"); displayins = new StringReader(xmlText); Display display = XmlUtil.readDisplay(displayins); if (display != null) define.setDisplay(display); } } catch (JAXBException e) { LfwLogger.error(e.getMessage(), e); } catch (FileNotFoundException e) { LfwLogger.error(e.getMessage(), e); } finally { IOUtils.closeQuietly(displayins); } /*Portal插件*/ PtPlugin plugin = PluginDefParser.reader(modulePath + "/portalspec/plugin.xml"); define.setPlugin(plugin); // /*skin信息*/ // PtSkinVo[] ptSkinVo = parseSkinVo(modulePath,moduleName); // define.setPtSkinVo(ptSkinVo); /*将模块的实际路径放入缓存中*/ IPtPortletRegistryService portletReg = PortalServiceUtil.getPortletRegistryService(); File moduleDir = new File(modulePath); String moduleFolder = moduleDir.getName(); portletReg.addModuleFolder(moduleName, moduleFolder); return define; } catch (Throwable e) { LfwLogger.error("error occurred while parsing module:" + modulePath, e); return null; } }
private PortletApplicationDefinition parsePortlets( String modulePath, PortalDeployDefinition define, String moduleName) throws FileNotFoundException, IOException { FileInputStream input = null; try { File f = new File(modulePath + "/portalspec/portlet.xml"); if (!f.exists()) return null; input = new FileInputStream(f); PortletApplicationDefinition pad = (PortletApplicationDefinition) PortalServiceUtil.getPortletAppDescriptorService().read(moduleName, input); List<PortletDefinition> pList = pad.getPortlets(); Iterator<PortletDefinition> pit = pList.iterator(); while (pit.hasNext()) { PortletDefinition p = pit.next(); ContainerRuntimeOption cr = new ContainerRuntimeOption(); cr.setName(ContainerRuntimeOption.MODULE); cr.addValue(moduleName); p.getContainerRuntimeOptions().add(cr); } return pad; } finally { if (input != null) try { input.close(); } catch (IOException e) { LfwLogger.error(e.getMessage(), e); } } }
public void onDataLoad(DataLoadEvent se) { Dataset ds = se.getSource(); String keys = ds.getReqParameters().getParameterValue("query_param_keys"); String values = null; if (keys != null && !keys.equals("")) { values = ds.getReqParameters().getParameterValue("query_param_values"); } int userType = 0; CpMenuItemVO[] menuitems = null; ICpMenuQry service = CpbServiceFacility.getMenuQry(); try { menuitems = service.getMenuItemsByCategory(values); if (userType == 2 /* CpUserVO.USERTYPE_SYSADMIN */) { // menuitems = service.getMenuItemsByCategory(values); } else if (userType == 3 /* CpUserVO.USERTYPE_GROUPADMIN */) { // appsNodes = // CpbServiceFacility.getFunQryService().getNodeByUser(values, // userVo.getCuserid(), ""); } } catch (CpbBusinessException e) { // TODO Auto-generated catch block LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e.getMessage()); } if (ArrayUtils.isEmpty(menuitems)) { return; } new SuperVO2DatasetSerializer().serialize(menuitems, ds, Row.STATE_NORMAL); postProcessRowSelect(ds); }
protected void onVoSave(SuperVO[] pvos) { try { CpbServiceFacility.getCpSuperVOBill().insertSuperVOs(pvos); } catch (CpbBusinessException e) { LfwLogger.error(e.getMessage(), e); } }
@Override public PortalDeployDefinition[] getPortalModules() { List<PortalDeployDefinition> moduleList = new ArrayList<PortalDeployDefinition>(); String dir = RuntimeEnv.getInstance().getNCHome() + PortalEnv.PORTAL_HOME_DIR; File f = new File(dir); File[] fs = f.listFiles(); for (int i = 0; i < fs.length; i++) { File mDir = fs[i]; if (mDir.isDirectory()) { File specDir = new File(mDir.getAbsolutePath() + "/portalspec"); if (specDir.exists() && specDir.isDirectory()) { File specFile = new File(specDir.getAbsolutePath() + "/portal.xml"); if (specFile.exists() && specFile.isFile()) { PortalDeployDefinition definition = parseModule(mDir.getAbsolutePath()); if (definition != null) moduleList.add(definition); } } } } try { return PortalModuleUtil.sortDefinition(moduleList); } catch (PortalServiceException e) { LfwLogger.info("Error:" + e.getMessage()); return new PortalDeployDefinition[0]; } }
private void doDeleteVO(SuperVO vo) { try { CRUDHelper.getCRUDService().deleteVo(vo); } catch (LfwBusinessException e) { LfwLogger.error(e.getMessage(), e); } }
@Override public List<Display> getAllDisplays(String projectPath, String projectModuleName) { String runtimeDir = RuntimeEnv.getInstance().getNCHome() + PortalEnv.PORTAL_HOME_DIR; List<Display> displays = new ArrayList<Display>(); InputStream is = null; // 取项目自身displays String displayFile = getPortalSpecPath(projectPath, projectModuleName) + "/display.xml"; try { is = new FileInputStream(displayFile); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line); } String xml = buffer.toString(); Display display = JaxbMarshalFactory.newIns().encodeXML(Display.class, xml); displays.add(display); } catch (IOException e) { LfwLogger.error(e.getMessage(), e); } // 获得所有依赖的module List<String> modules = new ArrayList<String>(); PortalModule portalModule = getPortal(projectPath, projectModuleName); getDependModules(modules, portalModule, projectModuleName, projectPath, runtimeDir); for (String module : modules) { String file = runtimeDir + "/" + module + "/portalspec/display.xml"; try { is = new FileInputStream(file); BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8")); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line); } String xml = buffer.toString(); Display display = JaxbMarshalFactory.newIns().encodeXML(Display.class, xml); displays.add(display); } catch (IOException e) { LfwLogger.error(e.getMessage(), e); } } return displays; }
@Override public void deploySkin(String projectModuleName) { try { new PtLookAndFeelDeploy().scanSkins(projectModuleName); } catch (PortalServiceException e) { LfwLogger.error(e.getMessage(), e); } }
private void doInit() { try { System.out.println("\nInitializing master portal server......"); if (Logger.isDebugEnabled()) LfwLogger.debug("===PortalBizServerListener类:Begin to initialize Portal!"); String portalDs = PortalDsnameFetcher.getPortalDsName(); if (portalDs == null || portalDs.equals("")) { LfwLogger.error("没有获取到NC数据源,不做初始化"); return; } String oldDs = null; if (portalDs != null) { oldDs = InvocationInfoProxy.getInstance().getUserDataSource(); LfwRuntimeEnvironment.setDatasource(portalDs); } /* 初始化配置信息*/ // try { initConfig(); } catch (Throwable e) { LfwLogger.error("===PortalBizServerListener类:initConfig error!" + e.getMessage(), e); } try { initCtx(); } catch (Throwable e) { LfwLogger.error("===PortalBizServerListener类:initCtx error!" + e.getMessage(), e); } /* 部署Portal */ initDeploy(); /** 吊销登陆令牌* */ destoryToken(); /** Portal定时任务调度器初始化 */ // new Executor(new PtTimer(LfwRuntimeEnvironment.getDatasource())).start(); if (oldDs != null) LfwRuntimeEnvironment.setDatasource(oldDs); System.out.println("master portal server is successfully initialized"); } catch (Exception e) { System.out.println("master portal server is not successfully initialized"); Logger.error("error occurred while initializing portal container!", e); } }
/** 吊销登陆令牌 */ private void destoryToken() { try { if (!LfwRuntimeEnvironment.isDevelopMode()) { NCLocator.getInstance().lookup(ILfwSsoService.class).destoryAllToken(); } } catch (LfwBusinessException e) { LfwLogger.error("吊销登陆令牌时出现异常", e); } }
@Override public void updateTemplate(CpGzTemplateVO templateVo) throws TplBusinessException { BaseDAO dao = new BaseDAO(); try { dao.updateVO(templateVo); } catch (DAOException e) { LfwLogger.error(e); throw new TplBusinessException(e.getMessage(), e); } }
public Object download(Serializable fileVO, OutputStream output, long begin) throws Exception { if (fileVO instanceof LfwFileVO) { LfwFileVO fileInfo = (LfwFileVO) fileVO; String path = createFilePath(fileInfo); if (path == null) throw new LfwRuntimeException("文件路径错误", new FileNotFoundException()); // 从本地磁盘读取文件,写入output InputStream input = null; try { input = new FileInputStream(path); if (begin > 0) { long actualnum = input.skip(begin); if (actualnum < 0) { throw new BusinessException("掉过字节数为负数"); } else { if (begin > actualnum) { throw new BusinessException("实际掉过字节数小于开始值"); } } } // 每次读本地文件块 byte[] buf = new byte[BUFSIZE]; int len = -1; while ((len = input.read(buf)) != -1) { output.write(buf, 0, len); output.flush(); } } catch (Exception e) { LfwLogger.error(e.getMessage(), e); // 将异常写入输出流 throw e; } finally { try { if (input != null) { input.close(); } } catch (Exception e2) { LfwLogger.error(e2.getMessage(), e2); } } } return null; }
@Override public void update(PtSsopropVO ssoProp) { PtBaseDAO dao = new PtBaseDAO(); try { dao.updateVO(ssoProp); } catch (DAOException e) { LfwLogger.error(e.getMessage(), e); } PortalCacheManager.notify( CacheKeys.PORTAL_SSO_PROVIDER_CACHE, CacheKeys.PORTAL_SSO_PROVIDER_MAP_CACHE); }
@Override public void deleteTemplate(String pk_template) throws TplBusinessException { try { BaseDAO dao = new BaseDAO(); dao.deleteByPK(CpGzTemplateVO.class, pk_template); dao.deleteByClause(CpGzConditionVO.class, "pk_gz_template='" + pk_template + "'"); } catch (DAOException e) { LfwLogger.error(e); throw new TplBusinessException(e.getMessage(), e); } }
@Override public void delete(String systemCode) { PtBaseDAO dao = new PtBaseDAO(); try { dao.deleteByClause(PtSsopropVO.class, " systemcode = '" + systemCode + "'"); } catch (DAOException e) { LfwLogger.error(e.getMessage(), e); } PortalCacheManager.notify( CacheKeys.PORTAL_SSO_PROVIDER_CACHE, CacheKeys.PORTAL_SSO_PROVIDER_MAP_CACHE); }
@Override public Page getPage(String projectPath, String projectModuleName, String PageName) { String filePath = getPortalSpecPath(projectPath, projectModuleName) + "/pml"; String fileName = PageName; File f = new File(filePath + "/" + fileName + ".pml"); try { return PmlUtil.parser(f); } catch (PortalServiceException e) { LfwLogger.error(e.getMessage(), e); return null; } }
@Override public PortalModule getPortal(String projectPath, String projectModuleName) { try { PortalModule pm = PortalModuleUtil.parsePortalModule( new File(getPortalSpecPath(projectPath, projectModuleName) + "/portal.xml")); return pm; } catch (PortalServiceException e) { LfwLogger.error(e.getMessage(), e); } return null; }
@Override public void add(SSOProviderVO provider) { PtBaseDAO dao = new PtBaseDAO(); PtSsopropVO vo = SSOUtil.provider2prop(provider); try { dao.insertVO(vo); } catch (DAOException e) { LfwLogger.error(e.getMessage(), e); } PortalCacheManager.notify( CacheKeys.PORTAL_SSO_PROVIDER_CACHE, CacheKeys.PORTAL_SSO_PROVIDER_MAP_CACHE); }
public MenuAdapterVO[] getAllMenuCategorys() throws CpbBusinessException { PtBaseDAO dao = new PtBaseDAO(); String sql = "select a.pk_menucategory,a.id,a.title from cp_menucategory a"; List<MenuAdapterVO> list; try { list = (List<MenuAdapterVO>) dao.executeQuery(sql, new MenuCategoryAdapterVOProcessor()); } catch (DAOException e) { LfwLogger.error(e.getMessage(), e); throw new CpbBusinessException(e); } return list.toArray(new MenuAdapterVO[0]); }
@Override public void deleteThemeFolder(String projectPath, String projectModuleName, String themeId) { String filePath = getPortalSpecPath(projectPath, projectModuleName) + "/ftl/portaldefine/skin/" + themeId; File file = new File(filePath); try { FileUtils.deleteDirectory(file); } catch (IOException e) { LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e); } }
@Override public void savePageToXml( String projectPath, String projectModuleName, String fileName, String xml) { String filePath = getPortalSpecPath(projectPath, projectModuleName) + "/pml"; File file = new File(filePath + "/" + fileName + ".pml"); try { FileUtils.writeStringToFile(file, xml, "UTF-8"); } catch (Exception e) { LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e); } }
@Override public PtPlugin getPtPlugin(String projectPath, String projectModuleName) { String file = getPortalSpecPath(projectPath, projectModuleName) + "/plugin.xml"; File f = new File(file); try { String xml = FileUtils.readFileToString(f, "UTF-8"); PtPlugin ptPlugin = JaxbMarshalFactory.newIns().encodeXML(PtPlugin.class, xml); return ptPlugin; } catch (IOException e) { LfwLogger.error(e.getMessage(), e); return null; } }
@Override public LookAndFeel getLookAndFeel(String projectPath, String projectModuleName) { String file = projectPath + "/web/WEB-INF/conf/look-and-feel.xml"; File f = new File(file); try { String xml = FileUtils.readFileToString(f, "UTF-8"); LookAndFeel lookAndFeel = JaxbMarshalFactory.newIns().encodeXML(LookAndFeel.class, xml); return lookAndFeel; } catch (IOException e) { LfwLogger.error(e.getMessage(), e); return null; } }
@Override public PortletApplicationDefinition getPortletApp(String projectPath, String projectModuleName) { File file = new File(getPortalSpecPath(projectPath, projectModuleName) + "/portlet.xml"); try { String xml = FileUtils.readFileToString(file, "UTF-8"); PortletApplicationDefinition portletApp = JaxbMarshalFactory.newIns().encodeXML(PortletApplicationDefinition.class, xml); return portletApp; } catch (IOException e) { LfwLogger.error(e.getMessage(), e); return null; } }
/** * 扫描文件 * * @param dir * @param tp * @return */ private void scanf(List<Skin> skins, String module, File dir, String tp) { String file = dir + "/" + tp + "/description.xml"; File f = new File(file); try { String xml = FileUtils.readFileToString(f, "UTF-8"); SkinDescription skinDescription = JaxbMarshalFactory.newIns().encodeXML(SkinDescription.class, xml); for (Skin skin : skinDescription.getSkin()) { skins.add(skin); } } catch (IOException e) { LfwLogger.error(e.getMessage(), e); } }
@Override public PtSessionBean restoreSsoSign(String sysid) { try { if (LfwRuntimeEnvironment.getWebContext() != null) { String token = LfwRuntimeEnvironment.getWebContext().getParameter("token"); if (token == null || token.equals("")) return null; getLoginHelper().processLogin(); } } catch (LoginInterruptedException e) { LfwLogger.error("登陆过程出现异常", e); throw new LfwRuntimeException("登陆过程出现异常"); } return (PtSessionBean) LfwRuntimeEnvironment.getLfwSessionBean(); }
@Override public void initConditons(String pk_template, CpGzConditionVO[] conditions) throws TplBusinessException { try { BaseDAO dao = new BaseDAO(); // List<CpQueryConditionVO> list = (List<CpQueryConditionVO>) // dao.retrieveByClause(CpQueryConditionVO.class, "pkTemplet='" + pk_template + "'"); // Iterator<CpQueryConditionVO> it = list.iterator(); dao.deleteByClause(CpGzConditionVO.class, "pk_gz_template='" + pk_template + "'"); if (null != conditions) dao.insertVOArray(conditions); } catch (DAOException e) { LfwLogger.error(e); throw new TplBusinessException(e.getMessage(), e); } }
public void afterLogin(LfwSessionBean sbean) { PtSessionBean ptBean = (PtSessionBean) sbean; IUserVO userVO = (IUserVO) ptBean.getUser(); try { /** License检查 */ // checkLicense(userVO.getPk_user(), userVO.getPassword()); /** 初始化用户信息 */ initUser(ptBean); UFBoolean loginResult = UFBoolean.TRUE; doLoginLog(sbean, loginResult); } catch (Exception e) { LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e.getMessage()); } }
@Override public void saveDisplayToXml(String projectPath, String projectModuleName, Display display) { String filePath = getPortalSpecPath(projectPath, projectModuleName); File f = new File(filePath); if (!f.exists()) f.mkdirs(); File file = new File(filePath + "/display.xml"); String d = JaxbMarshalFactory.newIns().decodeXML(display); try { FileUtils.writeStringToFile(file, d, "UTF-8"); } catch (Exception e) { LfwLogger.error(e.getMessage(), e); throw new LfwRuntimeException(e); } }
@Override public void deleteSkinFile( String projectPath, String projectModuleName, String type, String themeId, String fileName) { String filePath = getPortalSpecPath(projectPath, projectModuleName) + "/ftl/portaldefine/skin/" + themeId + "/" + type; File file = new File(filePath + "/" + fileName); try { file.delete(); } catch (Exception e) { LfwLogger.error(e.getMessage(), e); } }