|
From: Michael K. <ko...@us...> - 2004-05-28 08:08:56
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26840/org/cobricks/portal Modified Files: PortalManagerImpl.java Log Message: Index: PortalManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalManagerImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- PortalManagerImpl.java 31 Mar 2004 12:05:37 -0000 1.8 +++ PortalManagerImpl.java 28 May 2004 08:08:47 -0000 1.9 @@ -107,10 +107,12 @@ protected String adminPermissionAction = null; protected Category rootPortalFolder = null; + /** * Map holding all portal folders indexed by categoryid */ protected Map portalFolders; + /** * Map holding all portal folders indexed by path */ @@ -444,9 +446,14 @@ // and now look for a portalpage item that has the portalfolder // category assigned - - // tbd - + String xpath = "/item[itemclass='portalpagehtml' and " + +"name='"+pageName+"'] and " + +"folders/category/id="+Integer.toString(c.getId()); + List p = itemManager.searchItems(xpath); + if (p != null && p.size()>0) { + Item i = (Item)p.iterator().next(); + itemid = new Integer(i.getId()); + } if (itemid!=null) { pageItemIdCache.put(key, itemid); return itemid.intValue(); @@ -464,18 +471,25 @@ public Map getPageContents(int itemid) { Map result = new HashMap(); - Map conditions = new HashMap(); - conditions.put("itemid", new Integer(itemid)); - - // tbd - // result.put(lang, m.get("content")); - + try { + PortalPage page = (PortalPage)itemManager.getItem(itemid); + Set langs = page.getUsedLanguages(); + Iterator i = langs.iterator(); + while (i.hasNext()) { + String lang = (String)i.next(); + String content = page.getDescription(lang); + if (content != null) + result.put(lang, content); + } + } catch (CobricksException e) { + logger.warn("failed loading page item for id="+itemid); + } return result; } /** - * Create a new portalpage item with the given attributes + * Create a new portal page item with the given attributes */ public int createPage(String pagePath, String pageName, String lang, String title, String content, boolean fullcontext, @@ -496,19 +510,27 @@ // check if the page already exits // item aus klasse "portalpagehtml" mit bestimmtem namen - List items = itemManager.searchItems(""); - // tbd + String xpath = "/item[itemclass='portalpagehtml' and " + +"name='"+pageName+"'] and " + +"folders/category/id="+Integer.toString(c.getId()); + List items = itemManager.searchItems(xpath); + if (items != null && items.size()>0) + throw new CobricksException("portal", "exists", ""); // create new item object Map attrs = new HashMap(); Item item = null; try { attrs.put("itemclass", "portalpagehtml"); - attrs.put("name", ""); // tbd + attrs.put("name", pageName); attrs.put("mimetype", "text/html"); - attrs.put("title_en", ""); - attrs.put("folders", ""); // tbd + attrs.put("title_en", title); + Set folders = new HashSet(); + folders.add(c); + attrs.put("folders", folders); + logger.info("creating page item ..."); item = itemManager.createItem(attrs); + logger.info("created page item ..."); } catch (Exception e) { logger.error(LogUtil.ex("failed creating item", e)); throw new CobricksException("portal", "", ""); |