|
From: Wolfgang W. <wo...@us...> - 2007-12-19 15:00:56
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5213/src/org/cobricks/portal Modified Files: PortalManager.java PortalManagerImpl.java PortalPresenter.java Log Message: Index: PortalPresenter.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalPresenter.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- PortalPresenter.java 14 Nov 2007 14:03:49 -0000 1.63 +++ PortalPresenter.java 19 Dec 2007 15:00:40 -0000 1.64 @@ -239,7 +239,7 @@ } return ""; } - + public String parse(String filename, PortalRequest portalRequest, String defaultfilename) { @@ -260,6 +260,22 @@ } return ""; } + + public String parseURL(String urlname, PortalRequest portalRequest) + { + logger.debug("parseURL("+urlname+")"); + String pageContent = + portalManager.getPageContentURL(urlname, portalRequest); + try { + StringWriter sw = new StringWriter(); + Velocity.evaluate(portalRequest.getVelocityContext(), sw, + "", pageContent); + return sw.toString(); + } catch (Exception e) { + logger.error(LogUtil.ex("Failed parsing URL template.", e)); + } + return ""; + } /** Index: PortalManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalManager.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- PortalManager.java 4 Mar 2007 12:49:47 -0000 1.24 +++ PortalManager.java 19 Dec 2007 15:00:40 -0000 1.25 @@ -48,6 +48,8 @@ public PortalObject getObject(String pagePath, String pageName); public PortalObject getObject(int itemid); public String getPageContent(String filename, PortalRequest portalRequest); + public String getPageContentURL(String urlname, PortalRequest portalRequest); + public void saveFileToFilesystem(String pagepath, String pagename, byte barr[]); Index: PortalManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalManagerImpl.java,v retrieving revision 1.99 retrieving revision 1.100 diff -u -d -r1.99 -r1.100 --- PortalManagerImpl.java 4 Mar 2007 12:49:48 -0000 1.99 +++ PortalManagerImpl.java 19 Dec 2007 15:00:40 -0000 1.100 @@ -315,7 +315,7 @@ pageName = filename; } } - PortalObject o = getObject(pagePath, pageName); + PortalObject o = getObject(pagePath, pageName); if (!(o instanceof PortalPage)) { logger.warn("Wrong type of portal object for " +pagePath+pageName+": "+o.getClass().getName()); @@ -329,6 +329,42 @@ return (String)pc.get(pageLang); } + /** + * Quick&dirty method to read page from a URL, instead of file + */ + public String getPageContentURL(String urlname, PortalRequest portalRequest) + { + String res = ""; + + try + { + URL url = new URL(urlname); + URLConnection urlconnection = url.openConnection(); + InputStream is = urlconnection.getInputStream(); + InputStreamReader isr = new InputStreamReader ( is ); + BufferedReader bufRead = new BufferedReader ( isr ); + + String s = null; + do + { + s = bufRead.readLine(); + if (s != null) + { + res = res + s; + } + } while (s != null); + + bufRead.close(); + isr.close(); + } + catch (Exception e) + { + logger.warn(LogUtil.ex("Failed reading URL template", e)); + } + + return res; + } + /** * Try to load the contents for the given itemid from the database. |