|
From: Alexander G. <gaf...@us...> - 2006-02-02 17:17:00
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1740/src/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.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- PortalManagerImpl.java 2 Feb 2006 11:39:26 -0000 1.74 +++ PortalManagerImpl.java 2 Feb 2006 17:16:52 -0000 1.75 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2006 Cobricks Group. All rights reserved. + * Copyright (c) 2003-2005 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software @@ -13,7 +13,6 @@ package org.cobricks.portal; import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FilenameFilter; @@ -23,7 +22,6 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.URL; -import java.net.URLConnection; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -37,8 +35,8 @@ import java.util.Set; import java.util.StringTokenizer; import java.util.regex.*; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; +import javax.servlet.*; +import javax.servlet.http.*; import org.apache.log4j.Logger; import org.apache.velocity.VelocityContext; @@ -517,26 +515,30 @@ String pageName = page.getPageName(); String lang = portalRequest.getLang(); - // language of the page + //Versionid of the page + Integer versionid = null; + //Language of the page String pageLanguage = null; - pageLanguage = (String)portalRequest.getRequestParameter("lang"); + + String itemclass = null; + + Ontology ontology = null; + OntologyClass ontologyClass = null; + OntologyClassAttr ontologyAttr = null; - // versionid of the page (if versioned) - Integer versionid = null; - boolean isVersioned = false; try { - String itemclass = (String)page.getAttribute("itemclass"); - // check if the content is versioned - Ontology ontology = itemManager.getOntology(); - OntologyClass ontologyClass= ontology.getClass(itemclass); - OntologyClassAttr ontologyAttr = - ontologyClass.getAttribute("content"); - if ((ontologyAttr != null) && ontologyAttr.isVersioned()) { - isVersioned = true; - } - // get versionid of page - versionid = Integer. - valueOf(portalRequest.getRequestParameter("versionid")); + itemclass = (String)page.getAttribute("itemclass"); + + //Check if the content is versioend + ontology = itemManager.getOntology(); + ontologyClass= ontology.getClass(itemclass); + ontologyAttr = ontologyClass.getAttribute("content"); + + //Get verseionid of page + versionid = Integer.valueOf( + portalRequest.getRequestParameter("versionid")); + //Get language of the page + pageLanguage = (String)portalRequest.getRequestParameter("lang"); } catch (Exception e) { versionid = null; } @@ -552,32 +554,36 @@ Map pc = null; - if (isVersioned) { + //Get all childs of 'wikipage' + OntologyClass wikiOntologyClass = ontology.getClass("wikipage"); + Set wikiVersionedPages = ontology.getChildren(ontologyClass, true); + wikiVersionedPages.add(wikiOntologyClass); + + if(wikiVersionedPages.contains(ontologyClass)) { pc = new HashMap(); String content = null; if (versionid != null) { - content = itemManager. - getContentVersion(page.getLocalId(), pageLanguage, - versionid.intValue()); - if (content == null) { + content = itemManager.getContentVersion( + page.getLocalId(), pageLanguage, versionid.intValue()); + if(content == null) { pageLanguage = defaultLanguage; - content = itemManager. - getContentVersion(page.getLocalId(), defaultLanguage, - versionid.intValue()); + content = itemManager.getContentVersion( + page.getLocalId(), defaultLanguage, versionid.intValue()); } } else { - content = this. - getHighestContentVersion(page.getLocalId(), pageLanguage); + content = this.getHighestContentVersion( + page.getLocalId(), pageLanguage); if(content == null) { pageLanguage = defaultLanguage; - content = this. - getHighestContentVersion(page.getLocalId(), - defaultLanguage); + content = this.getHighestContentVersion( + page.getLocalId(), defaultLanguage); } } if (content != null) { + //Parse the content content = Utility.parse(content); + pc.put(pageLanguage, content); } } else { @@ -586,8 +592,9 @@ } if (pc == null || pc.size()<1) { - logger.warn("Failed getting content for page "+pagePath+pageName - +","+lang+" - loading "+notFoundPath); + if (!pageName.equals("favicon.ico")) + logger.warn("Failed getting content for page "+pagePath+pageName + +","+lang+" - loading "+notFoundPath); pagePath = notFoundPath; pageName = "notfound.html"; int pos = pagePath.indexOf("/"); @@ -614,15 +621,6 @@ String pageLang = (String)pc.keySet().iterator().next(); String pageContent = (String)pc.get(pageLang); portalRequest.setPageLang(pageLang); - - // if it is a wiki page, then parse the content - String itemclass = ""; - if (page != null) itemclass = page.getItemClass(); - if (itemclass!=null && itemclass.equals("wikipage")) { - pageContent = Utility.parse(pageContent); - } - - // finally parse the page via Velocity and print it try { // parse Velocity template Velocity.evaluate(portalRequest.getVelocityContext(), out, @@ -639,14 +637,13 @@ } } - /** * Gets the highest content version to the itemid. * @param itemid The id for the content version. * @param lang Language for the content. - * @return Returns the content of the highest versionid if exist, - * otherwise null. + * @return Returns the content of the highest versionid if exist, otherwise + * null. */ private String getHighestContentVersion(int itemid, String lang) { @@ -676,7 +673,6 @@ } return content; } - /* -------------------------------------------------------------------- */ /* database access @@ -1109,6 +1105,9 @@ { super.init(componentId, managerId, properties, coreManager, dbAccess); + //Set properties + Utility.setProperties(properties); + // portal properties webspaceDir = properties.getProperty("portal.webspace.dir"); defaultLanguage = properties.getProperty("default.language", "en"); |