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);
       }
   }
 }
 /**
  * 初始化用户信息
  *
  * @param sbean
  * @throws PortalServiceException
  */
 public void initUser(LfwSessionBean sbean) throws PortalServiceException {
   String groupId = sbean.getPk_unit();
   String userId = sbean.getPk_user();
   Integer userType = ((PtSessionBean) sbean).getUserType();
   IPtPortalPageQryService ppq = NCLocator.getInstance().lookup(IPtPortalPageQryService.class);
   PtPageVO[] currPages = new PtPageVO[0];
   if (userType.equals(IUserVO.USERTYPE_GROUP)) {
     currPages = ppq.getGroupsPage(groupId);
     /** 过滤掉非用户类型Page */
     currPages = PortalPageDataWrap.filterPagesByUserType(currPages, userType);
   } else {
     currPages = PortalServiceUtil.getPageQryService().getPageByLevel(userType);
   }
   PtPageVO[] userPages = ppq.getUserPages(userId);
   /** 对比是否有新增加 */
   PtPageVO[] newPages = PortalPageDataWrap.checkNews(userPages, currPages);
   /** 生成缓存对象 */
   List<Page> userPageList = PortalPageDataWrap.praseUserPages(userPages);
   /** 有页面 */
   if (newPages != null && newPages.length > 0) {
     /** 追加到缓存对象 */
     userPageList.addAll(PortalPageDataWrap.praseUserPages(newPages));
     /** 追加到数据库中 */
     IPtPortalPageService pageService = NCLocator.getInstance().lookup(IPtPortalPageService.class);
     pageService.addUserNewPages(userId, groupId, newPages);
   }
   /** 转换为用户缓存 */
   Map<String, Page> userPagesCache =
       PortalPageDataWrap.praseUserPages(userPageList.toArray(new Page[0]));
   PortalCacheManager.getUserPageCache().clear();
   PortalCacheManager.getUserPageCache().putAll(userPagesCache);
 }
  @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;
    }
  }
Example #4
0
  @Action
  public void doPost() throws ServletException, IOException, PortalServiceException {

    response.setCharacterEncoding("utf-8");
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String pk_group = request.getParameter("pk_group");
    PtPageVO[] pages = new PtPageVO[] {};
    pages = PortalServiceUtil.getPageQryService().getPageByGroup(pk_group);
    Document doc = buildXml(pages);
    XMLUtil.printDOMTree(out, doc, 0, "UTF-8");
    out.println();
  }
  @Override
  public void onDataLoad(DataLoadEvent se) {
    WebSession ses = getGlobalContext().getWebSession();
    String cmd = (String) ses.getAttribute("cmd");
    String pk_message = (String) ses.getAttribute("pk_message");
    LfwWidget widget = getGlobalContext().getPageMeta().getWidget("main");
    Dataset ds = widget.getViewModels().getDataset("msgds");

    /** 初始化数据集 */
    ds.setCurrentKey(Dataset.MASTER_KEY);
    Row row = ds.getEmptyRow();
    ds.addRow(row);
    ds.setSelectedIndex(ds.getRowIndex(row));
    ds.setEnabled(true);

    /** 撰写 */
    if (cmd.equals("compose")) {
      return;
    }
    PtMessageVO vo = null;
    try {
      vo = PortalServiceUtil.getMessageQryService().getMessageByPK(pk_message);
    } catch (PortalServiceException e) {
      LfwLogger.error(e.getMessage(), e);
    }

    if (vo == null || vo.getPk_message() == null) return;

    /** 转发 */
    if (cmd.equals("fwd")) {
      row.setString(ds.nameToIndex("title"), "转发:" + vo.getTitle());
      row.setString(ds.nameToIndex("content"), vo.doGetContent());
    }
    /** 回复 */
    if (cmd.equals("reply")) {
      if (!MCConstant.PERSON_MESSAGE.equals(vo.getSystemcode()))
        throw new LfwRuntimeException("无法回复非私人信息!");
      row.setString(ds.nameToIndex("title"), "回复:" + vo.getTitle());
      row.setString(ds.nameToIndex("pk_user"), vo.getPk_sender());
      row.setString(ds.nameToIndex("username"), vo.getSendername());
    }
  }
  /**
   * 初始化相关环境信息
   *
   * @throws BusinessException
   */
  private void initCtx() throws BusinessException {
    ServletContext ctx = getCtx();
    // Initialize
    //		WebApplicationContext springContext =
    // WebApplicationContextUtils.getWebApplicationContext(ctx);
    //		SpringUtil.setContext(springContext);

    //		PortalContextImpl portalCtx = new PortalContextImpl();
    //		ctx.setAttribute(WebKeys.PORTALCTX, portalCtx);
    // 设置产品多语资源目录
    ctx.setAttribute(WebConstant.MULTILANGE_PRODUCT_CODE, "portal");

    String domain = PortalServiceUtil.getConfigRegistryService().get(APP_DOMAIN);
    if (domain != null && !domain.trim().equals(""))
      ctx.setAttribute(WebConstant.DOMAIN_KEY, domain);

    // 设置system.properties中配置的服务地址地址,ca登陆等需要 gd 2007-11-29
    //
    //	LfwRuntimeEnvironment.setServerAddr(PortalServiceUtil.getConfigRegistryService().get(SERVER_ADDR));
  }