コード例 #1
0
 @Override
 public PortletApplicationDefinition getPortletApp(
     String projectPath, String projectModuleName, String portletAppText) {
   PortletApplicationDefinition portletApp =
       JaxbMarshalFactory.newIns().encodeXML(PortletApplicationDefinition.class, portletAppText);
   return portletApp;
 }
コード例 #2
0
  @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;
  }
コード例 #3
0
 @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;
   }
 }
コード例 #4
0
 @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;
   }
 }
コード例 #5
0
 @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;
   }
 }
コード例 #6
0
 /**
  * 扫描文件
  *
  * @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);
   }
 }
コード例 #7
0
  @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);
    }
  }
コード例 #8
0
  @Override
  public void savePortalToXml(
      String projectPath, String projectModuleName, PortalModule portalModule) {

    String filePath = getPortalSpecPath(projectPath, projectModuleName);
    File f = new File(filePath);
    if (!f.exists()) f.mkdirs();
    File file = new File(filePath + File.separatorChar + "portal.xml");
    String pt = JaxbMarshalFactory.newIns().decodeXML(portalModule);
    try {
      FileUtils.writeStringToFile(file, pt, "UTF-8");
    } catch (IOException e) {
      LfwLogger.error(e.getMessage(), e);
      throw new LfwRuntimeException(e);
    }
  }
コード例 #9
0
  @Override
  public void savePortletAppToXml(
      String projectPath, String projectModuleName, PortletApplicationDefinition portletApp) {
    //		String runtimeDir = RuntimeEnv.getInstance().getNCHome() + PortalEnv.PORTAL_HOME_DIR + "/" +
    // projectModuleName;
    String filePath = getPortalSpecPath(projectPath, projectModuleName);
    File f = new File(filePath);
    if (!f.exists()) f.mkdirs();
    File file = new File(filePath + "/portlet.xml");
    String d = JaxbMarshalFactory.newIns().decodeXML(portletApp);
    try {
      FileUtils.writeStringToFile(file, d, "UTF-8");

    } catch (Exception e) {
      LfwLogger.error(e.getMessage(), e);
      throw new LfwRuntimeException(e);
    }
  }
コード例 #10
0
 @Override
 public SkinDescription getSkinDescription(
     String projectPath, String projectModuleName, String type, String themeId) {
   String filePath =
       getPortalSpecPath(projectPath, projectModuleName)
           + "/ftl/portaldefine/skin/"
           + themeId
           + "/"
           + type;
   File f = new File(filePath + "/description.xml");
   try {
     String xml = FileUtils.readFileToString(f, "UTF-8");
     SkinDescription skinDescription =
         JaxbMarshalFactory.newIns().encodeXML(SkinDescription.class, xml);
     return skinDescription;
   } catch (IOException e) {
     LfwLogger.error(e.getMessage(), e);
     return null;
   }
 }
コード例 #11
0
 @Override
 public Display getDisplay(String projectPath, String projectModuleName) {
   InputStream is = null;
   String file = getPortalSpecPath(projectPath, projectModuleName) + "/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);
     return display;
   } catch (IOException e) {
     LfwLogger.error(e.getMessage(), e);
     return null;
   }
 }
コード例 #12
0
 @Override
 public void saveSkinDescription(
     String projectPath,
     String projectModuleName,
     String type,
     String themeId,
     SkinDescription skinDescription) {
   String filePath =
       getPortalSpecPath(projectPath, projectModuleName)
           + "/ftl/portaldefine/skin/"
           + themeId
           + "/"
           + type;
   File f = new File(filePath);
   if (!f.exists()) f.mkdirs();
   File file = new File(filePath + "/description.xml");
   String xml = JaxbMarshalFactory.newIns().decodeXML(skinDescription);
   try {
     FileUtils.writeStringToFile(file, xml, "UTF-8");
   } catch (Exception e) {
     LfwLogger.error(e.getMessage(), e);
   }
 }
コード例 #13
0
  @Override
  public void saveLookAndFeelToXml(
      String projectPath, String projectModuleName, LookAndFeel lookAndFeel) {
    String runtimeDir =
        RuntimeEnv.getInstance().getNCHome() + PortalEnv.PORTAL_HOME_DIR + "/" + projectModuleName;
    String filePath = projectPath + "/web/WEB-INF/conf";
    File f = new File(filePath);
    if (!f.exists()) f.mkdirs();
    File file = new File(filePath + "/look-and-feel.xml");
    String d = JaxbMarshalFactory.newIns().decodeXML(lookAndFeel);
    try {
      if (!file.exists()) file.createNewFile();
      FileUtils.writeStringToFile(file, d, "UTF-8");

      /* 重新部署*/
      File runtimePath = new File(runtimeDir + "/portalspec");
      if (runtimePath.exists()) {
        deployLookAndFeel();
      }
    } catch (Exception e) {
      LfwLogger.error(e.getMessage(), e);
      throw new LfwRuntimeException(e);
    }
  }
コード例 #14
0
 @Override
 public Page stringToPage(String xml) {
   Page page = JaxbMarshalFactory.newIns().encodeXML(Page.class, xml);
   return (Page) page;
 }