Author: dam...@jb... Date: 2005-12-12 10:38:25 -0500 (Mon, 12 Dec 2005) New Revision: 1781 Modified: qa/forge/portal-extensions/forge-kosmos/maven.xml qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/MediaDataSource.java qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/GetRefsFromPagePlugin.java qa/forge/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/management/WikiService.java Log: MERGED: -r 1691:1718 https://svn.labs.jboss.com/trunk/forge into qa. This fixes the forge-kosmos services not running. This will be for the 1.0.7 release... again. Modified: qa/forge/portal-extensions/forge-kosmos/maven.xml =================================================================== --- qa/forge/portal-extensions/forge-kosmos/maven.xml 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/forge-kosmos/maven.xml 2005-12-12 15:38:25 UTC (rev 1781) @@ -47,7 +47,7 @@ <!-- Deploying new packages --> <ant:copy todir="../${forge.ear.dir}/target/${forge.ear.name}" overwrite="true"> <ant:fileset dir="target"> - <ant:filename name="kosmos**/*" /> + <ant:filename name="kosmos*/**" /> </ant:fileset> </ant:copy> </goal> Modified: qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -50,12 +50,13 @@ */ public class Status extends AbstractDescriptor { - private final static String PLUGIN_ELEMENT = "plugin"; + private final static String PLUGIN_ELEMENT = "plugin"; - private final static String PLUGIN_ID_ELEMENT = "id"; - private final static String PLUGIN_NAME_ELEMENT = "name"; - private final static String PLUGIN_CLASS_ELEMENT = "class"; - private final static String PLUGIN_WEIGHT_ELEMENT = "weight"; + private final static String PLUGIN_ID_ELEMENT = "id"; + private final static String PLUGIN_NAME_ELEMENT = "name"; + private final static String PLUGIN_CLASS_ELEMENT = "class"; + private final static String PLUGIN_WEIGHT_ELEMENT = "weight"; + private final static String PLUGIN_PROPERTIES_ELEMENT = "properties"; private String portalName; private ScoreAlgorithmFactory scoreAlgorithm; @@ -64,12 +65,15 @@ private List<StatusPlugin> plugins; private Logger log; + + private HashSet<String> pluginsElements; Status(String portalName, Node pluginsRoot, ScoreAlgorithmFactory scoreAlgorithm) { this.portalName = portalName; this.scoreAlgorithm = scoreAlgorithm; log = Logger.getLogger(this.getClass()); + initPluginElements(); // Get the projects projects = ProjectsHelper.getProjects(portalName); @@ -81,8 +85,18 @@ plugins = getPlugins(pluginsNodes); } + private void initPluginElements() { + pluginsElements = new HashSet<String>(); + + pluginsElements.add(PLUGIN_ID_ELEMENT); //TODO currently id is NOT used!! + pluginsElements.add(PLUGIN_NAME_ELEMENT); + pluginsElements.add(PLUGIN_CLASS_ELEMENT); + pluginsElements.add(PLUGIN_WEIGHT_ELEMENT); + pluginsElements.add(PLUGIN_PROPERTIES_ELEMENT); + } + - + /** * Fills the given context with podcast information. * @@ -146,51 +160,73 @@ } } - List<StatusPlugin> getPlugins(Set<Node> pluginsNodes) { + private List<StatusPlugin> getPlugins(Set<Node> pluginsNodes) { ArrayList<StatusPlugin> plugins = new ArrayList<StatusPlugin>(); - - HashSet<String> pluginsElements = new HashSet<String>(); - pluginsElements.add(PLUGIN_ID_ELEMENT); - pluginsElements.add(PLUGIN_NAME_ELEMENT); - pluginsElements.add(PLUGIN_CLASS_ELEMENT); - pluginsElements.add(PLUGIN_WEIGHT_ELEMENT); - + for (Iterator iter = pluginsNodes.iterator(); iter.hasNext();) { Node pluginNode = (Node) iter.next(); - Map<String,Node> pluginProperties = getChildNodesMap(pluginNode, pluginsElements); + StatusPlugin plugin = getPlugin(pluginNode); - // Get plugin name - String pluginClassString = XmlTools.unmarshallText(pluginProperties.get("class")); - System.out.println("pluginClassString " + pluginClassString); - - // Get plugin class - - Class pluginClass = null; - try { - pluginClass = Class.forName(pluginClassString); - } catch (ClassNotFoundException e) { - log.error("Plugin class not found: " + pluginClassString); - continue; - } - - // Get plugin instance - StatusPlugin plugin = null; - try { - plugin = (StatusPlugin) pluginClass.newInstance(); - } catch (Exception e) { - log.error("Plugin class: " + pluginClassString + ". Instantination failed.", e); - continue; - } - - // Initialize plugin and add it to the plugins set - plugin.init(projects); - plugins.add(plugin); + if (plugin != null) { + plugins.add(plugin); + } } return plugins; } + private StatusPlugin getPlugin(Node pluginNode) { + Map<String,Node> pluginProperties = getChildNodesMap(pluginNode, pluginsElements); + + // Get plugin name + String pluginClassString = XmlTools.unmarshallText(pluginProperties.get("class")); + System.out.println("pluginClassString " + pluginClassString); + + // Get plugin class + Class pluginClass = null; + try { + pluginClass = Class.forName(pluginClassString); + } catch (ClassNotFoundException e) { + log.error("Plugin class not found: " + pluginClassString); + return null; + } + + // Get plugin instance + StatusPlugin plugin = null; + try { + plugin = (StatusPlugin) pluginClass.newInstance(); + } catch (Exception e) { + log.error("Plugin class: " + pluginClassString + ". Instantination failed.", e); + return null; + } + + // Get plugin properies node + Node pluginSpecificPropertiesNode = pluginProperties.get("properties"); + Map<String,String> pluginSpecificPropertiesMap = getChildNodesStringMap(pluginSpecificPropertiesNode); + + // Initialize plugin + plugin.init(projects, pluginSpecificPropertiesMap); + + return plugin; + } + + + + private Map<String,String> getChildNodesStringMap(Node root) { + HashMap<String,String> ret = new HashMap<String,String>(); + NodeList list = root.getChildNodes(); + + for (int i = 0; i < list.getLength(); i++) { + Node n = list.item(i); + if (n.getNodeType() == Node.ELEMENT_NODE) { + ret.put(n.getNodeName(),XmlTools.unmarshallText(n)); + } + } + + return ret; + } + private int calculateScore(String projectId) { return scoreAlgorithm.calculateScore(projectId, plugins); } Modified: qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java =================================================================== --- qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/StatusPlugin.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -22,6 +22,8 @@ package org.jboss.forge.status.plugins; +import java.util.Map; + import org.jboss.forge.common.projects.Projects; /** @@ -31,9 +33,11 @@ public abstract class StatusPlugin { protected Projects projects; + protected Map properties; - public void init(Projects projects) { + public void init(Projects projects, Map<String,String> properties) { this.projects = projects; + this.properties = properties; } public abstract String getId(); Modified: qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java =================================================================== --- qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -22,6 +22,7 @@ package org.jboss.forge.status.plugins.svn; +import org.jboss.forge.common.projects.Projects; import org.jboss.forge.status.plugins.StatusPlugin; import java.net.MalformedURLException; @@ -47,9 +48,8 @@ private Logger log; - private final static String KOSMOS_SVN_SERVICE_URL = - "http://localhost:8080/kosmos-server/kosmos-services/svn-service"; - //TODO shoud be parameter in xml config file + private String serviceURL; + //"http://localhost:8080/kosmos-server/kosmos-services/svn-service"; public SvnStatusPlugin() { super(); @@ -58,6 +58,12 @@ log = Logger.getLogger(this.getClass()); } + public void init(Projects projects, Map<String,String> properties) { + super.init(projects,properties); + serviceURL = properties.get("svn-service"); + System.out.println("service-url " + serviceURL); + } + protected abstract int getPluginSpecyficValue(Map projectMap); protected abstract int getPluginSpecyficDefaultValue(); @@ -78,15 +84,21 @@ SvnService service; try { - service = (SvnService) factory.create(SvnService.class, - KOSMOS_SVN_SERVICE_URL); + service = (SvnService) factory.create(SvnService.class, serviceURL); } catch (MalformedURLException e) { - log.error("Can not connect to kosmos svn service: " + KOSMOS_SVN_SERVICE_URL); + log.error("Can not connect to kosmos svn service: " + serviceURL); return null; } // Get repository map - List repositories = service.getRepositories(repoURL); + List repositories = null; + try { + repositories = service.getRepositories(repoURL); + } catch (Exception e) { + log.error("Can not analyze repo: " + repoURL, e); + return null; + } + repositoryMap = (Map) repositories.get(0); //printRepo(repositoryMap); Modified: qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -82,7 +82,7 @@ private File pageDictionaryFile; private WikiEngine wikiEngine; - + private Logger log; public void setWikiEngine(WikiEngine wikiEngine) { @@ -91,7 +91,7 @@ public FileDataSource() { log = Logger.getLogger(FileDataSource.class); - + log.info("Looking for props file !"); Properties fileDSProps = new Properties(); @@ -102,21 +102,20 @@ .getResourceAsStream(propFileName)); } catch (IOException ioe) { - log.error("Can't load the file " + propFileName + "\n" - , ioe); + log.error("Can't load the file " + propFileName + "\n", ioe); } loadProperties(fileDSProps); File mainWikiDir = new File(pathToMedia); File attWikiDir = new File(pathToAttachments); - + if (!mainWikiDir.exists()) mainWikiDir.mkdirs(); - + if (!attWikiDir.exists()) attWikiDir.mkdirs(); - + pageModProps = new Properties(); modFile = new File(pathToMedia + "/" + propModFileName); @@ -132,13 +131,12 @@ pageModProps.load(fis); } catch (IOException ioe) { - log.error("Can't load the file " + propModFileName + "\n" - , ioe); + log.error("Can't load the file " + propModFileName + "\n", ioe); } finally { try { fis.close(); } catch (IOException ioe) { - log.error("Can't close input stream \n" , ioe); + log.error("Can't close input stream \n", ioe); } } @@ -174,7 +172,7 @@ try { pageDictionaryFile.createNewFile(); } catch (IOException e) { - log.error("Cannot create dictionary file: ",e); + log.error("Cannot create dictionary file: ", e); } } else { // there is dictionary file. Load props from it @@ -250,10 +248,9 @@ } log.info("Opening files"); - File pageFile = new File(pathToMedia + "/OLD/" + uid - + "/" + (page.getLastVersion() - 1) + ".txt"); - File pageOldFile = new File(pathToMedia + "/" + uid - + ".txt"); + File pageFile = new File(pathToMedia + "/OLD/" + uid + "/" + + (page.getLastVersion() - 1) + ".txt"); + File pageOldFile = new File(pathToMedia + "/" + uid + ".txt"); FileOutputStream pageFileWriter; FileInputStream pageFileReader; @@ -285,11 +282,9 @@ pageFileWriter.close(); status = true; } catch (FileNotFoundException fnfe) { - log.error("[FILEDATASOURCE]: Cannot save page: " - , fnfe); + log.error("[FILEDATASOURCE]: Cannot save page: ", fnfe); } catch (IOException ioe) { - log.error("[FILEDATASOURCE]: Cannot save page: " - , ioe); + log.error("[FILEDATASOURCE]: Cannot save page: ", ioe); } } else { // there is no page on disk. We have to create new one. @@ -297,8 +292,7 @@ try { // create needed dirs - File newPageFile = new File(pathToMedia + "/OLD/" - + uid); + File newPageFile = new File(pathToMedia + "/OLD/" + uid); newPageFile.mkdirs(); // write the page @@ -388,8 +382,9 @@ } } catch (IOException e) { - log.error("Cannot create page props file for page: " - + pageName,e); + log.error( + "Cannot create page props file for page: " + pageName, + e); } return pageProps; } @@ -448,33 +443,34 @@ } } - - public void saveRolesSet(String uid, Set<String> roles, int action) throws DataSourceException { + + public void saveRolesSet(String uid, Set<String> roles, int action) + throws DataSourceException { File rolesFile; try { rolesFile = getRolesFile(uid, action); - + if (rolesFile == null) throw new DataSourceException("Wrong action number"); - + } catch (IOException e) { throw new DataSourceException(e); } - + FileOutputStream fos = null; try { fos = new FileOutputStream(rolesFile); - + Properties roleProps = new Properties(); - + int i = 1; - + for (String roleName : roles) { - roleProps.setProperty("Role."+i++, roleName); + roleProps.setProperty("Role." + i++, roleName); } - + roleProps.store(fos, SAVE_COMMENT); - + fos.close(); } catch (FileNotFoundException e) { throw new DataSourceException(e); @@ -486,47 +482,49 @@ } throw new DataSourceException(e); } - + } - + private File getRolesFile(String uid, int action) throws IOException { - String fileName = (action == MediaDataSource.EDITABLE) ? "editRoles" : (action == MediaDataSource.VIEWABLE) ? "viewRoles" : null; - + String fileName = (action == MediaDataSource.EDITABLE) ? "editRoles" + : (action == MediaDataSource.VIEWABLE) ? "viewRoles" : null; + if (fileName == null) return null; - - File rolesFile = new File(pathToMedia + "/OLD/" + uid + "/" + fileName + ".properties"); - + + File rolesFile = new File(pathToMedia + "/OLD/" + uid + "/" + fileName + + ".properties"); + if (!rolesFile.exists()) { rolesFile.createNewFile(); } - + return rolesFile; } - + private Set<String> getRoles(String uid, int action) throws IOException { Set<String> set = new TreeSet<String>(); - + File rolesFile = getRolesFile(uid, action); - + if (rolesFile == null) return null; - + FileInputStream rolesFileIs = new FileInputStream(rolesFile); - + Properties roleProps = new Properties(); - + roleProps.load(rolesFileIs); - + int i = 1; - - while (roleProps.getProperty("Role."+i) != null) { - set.add(roleProps.getProperty("Role."+i)); + + while (roleProps.getProperty("Role." + i) != null) { + set.add(roleProps.getProperty("Role." + i)); i++; } - + rolesFileIs.close(); - + return set; } @@ -577,20 +575,26 @@ (pageMods & EDITABLE) == EDITABLE); page.setLength(pageFile.length()); - + try { page.setEditRoles(getRoles(pageName, EDITABLE)); } catch (IOException e) { - log.error("Couldn't read edit roles for page: "+pageName, e); + log.error("Couldn't read edit roles for page: " + pageName, + e); } try { page.setViewRoles(getRoles(pageName, VIEWABLE)); } catch (IOException e) { - log.error("Couldn't read view roles for page: "+pageName, e); + log.error("Couldn't read view roles for page: " + pageName, + e); } } } + // get Metadata props. + if (page != null) // page exists at all + page.setMetaDataProps(getMetadataProps(pageName)); + return page; } @@ -601,7 +605,8 @@ public WikiPage getPage(String pageName, String languageCode) { if (languageCode != null) { - log.info("As for now, languages aren't supported in the wiki. Please do not use language codes"); + log + .info("As for now, languages aren't supported in the wiki. Please do not use language codes"); } return getPage(pageName); } @@ -609,7 +614,8 @@ public WikiPage getPageAtVersion(WikiPage originPage, boolean loadContent, String languageCode, int version) { if (languageCode != null) { - log.info("As for now, languages aren't supported in the wiki. Please do not use language codes"); + log + .info("As for now, languages aren't supported in the wiki. Please do not use language codes"); } return getPageAtVersion(originPage, loadContent, version); @@ -633,8 +639,8 @@ if (page != null) { if (page.getLastVersion() < version) { - log.info("There is no version " + version - + " of page " + page.getName()); + log.info("There is no version " + version + " of page " + + page.getName()); return null; } @@ -651,8 +657,8 @@ /* * cal.setTime(new Date()); * - * log.info("PAGE "+page.getName()+" loaded in: - * "+(cal.getTimeInMillis() - oldMilis)); + * log.info("PAGE "+page.getName()+" loaded in: "+(cal.getTimeInMillis() - + * oldMilis)); */ return page; } @@ -717,8 +723,8 @@ } } - public void addAttachment(InputStream attFile, String attName, WikiPage page, - String user) { + public void addAttachment(InputStream attFile, String attName, + WikiPage page, String user) { String pageName = page.getName(); Properties attProps = getAttProps(pageName, attName, true); @@ -880,15 +886,13 @@ FileInputStream fis; try { fis = new FileInputStream(file); - return new WikiAttachment(attachementName, - new Date(file.lastModified()), user, file.length(), fis, - version); + return new WikiAttachment(attachementName, new Date(file + .lastModified()), user, file.length(), fis, version); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } - - + } public int getLastAttachmentVersion(String pageName, String attachementName) { @@ -973,12 +977,12 @@ fos = new FileOutputStream(modFile); pageModProps.store(fos, SAVE_COMMENT); } catch (IOException ioe) { - log.error("Couldn't store mod props: ",ioe); + log.error("Couldn't store mod props: ", ioe); } finally { try { fos.close(); } catch (IOException ioe) { - log.error("Can't close input stream \n",ioe); + log.error("Can't close input stream \n", ioe); } } } @@ -1106,8 +1110,8 @@ } if (!attFile.renameTo(attTrashFile)) { - log.error("[ATTACHMENT DS]:Problems with moving " - + attName + " to " + attTrashName); + log.error("[ATTACHMENT DS]:Problems with moving " + attName + + " to " + attTrashName); return false; } @@ -1148,8 +1152,8 @@ } if (!attFile.renameTo(new File(attTrashName))) { - log.error("[ATTACHMENT DS]:Problems with moving " - + attName + " to " + attTrashName); + log.error("[ATTACHMENT DS]:Problems with moving " + attName + + " to " + attTrashName); return false; } @@ -1179,14 +1183,14 @@ public synchronized void rename(String uid, String newName) throws PageRenamingException { - + if (wikiEngine.pageExists(newName)) { throw new PageRenamingException( "Page with the name you're trying rename to already exists."); } - + lock = true; - + pageDictionary.setProperty(uid, newName); pageRevDictionary.setProperty(newName, uid); @@ -1194,7 +1198,7 @@ // find apropriate uid int i = 2; - + while ((pageExists(uid + String.valueOf(i))) || (pageDictionary.containsKey(uid + String.valueOf(i)))) { log.info(i++); @@ -1203,11 +1207,11 @@ // add maping for new (to be done) with name translated to old uid pageDictionary.setProperty(uid + String.valueOf(i), uid); pageRevDictionary.setProperty(uid, uid + String.valueOf(i)); - + saveDictionary(); - log.info("Renamed (uid) "+uid+" to "+newName); - + log.info("Renamed (uid) " + uid + " to " + newName); + lock = false; } @@ -1242,7 +1246,8 @@ return pageRevDictionary.contains(realName); } - public synchronized void removeDictForPage(String uid) throws PageRenamingException { + public synchronized void removeDictForPage(String uid) + throws PageRenamingException { if (!pageDictionary.contains(uid)) { throw new PageRenamingException( "There is no dictionary entry for uid: " + uid); @@ -1253,7 +1258,78 @@ // remove all dict entries pageDictionary.remove(uid); pageRevDictionary.remove(realName); - + saveDictionary(); } + + public Properties getMetadataProps(String uid) { + + if (!pageExists(uid)) { + // don't get matedata props for nonexisting page + return new Properties(); + } + + File propsFile = new File(pathToMedia + "/OLD/" + uid + + "/metadata.properties"); + + if (!propsFile.exists()) { + + // create file if it doesn't exist yet + try { + propsFile.createNewFile(); + } catch (IOException e) { + log.error(e); + } + } + + Properties props = new Properties(); + FileInputStream fis = null; + + try { + fis = new FileInputStream(propsFile); + } catch (FileNotFoundException e1) { + log.error(e1); + } + + try { + props.load(fis); + } catch (IOException e) { + log.error(e); + } + + try { + fis.close(); + } catch (IOException e) { + log.error(e); + } + + return props; + } + + public void saveMetadataProps(String uid, Properties props) { + getMetadataProps(uid); //this will create file if needed. + + File propsFile = new File(pathToMedia + "/OLD/" + uid + + "/metadata.properties"); + + FileOutputStream fos = null; + + try { + fos = new FileOutputStream(propsFile); + } catch (FileNotFoundException e) { + log.error(e); + } + + try { + props.store(fos, SAVE_COMMENT); + } catch (IOException e) { + log.error(e); + } + + try { + fos.close(); + } catch (IOException e) { + log.error(e); + } + } } Modified: qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/MediaDataSource.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/MediaDataSource.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/MediaDataSource.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -21,6 +21,8 @@ */ package org.jboss.wiki; +import java.util.HashMap; +import java.util.Properties; import java.util.Set; import org.jboss.wiki.exceptions.DataSourceException; @@ -214,4 +216,16 @@ * @param action can be MediaDataSource.EDITABLE or MediaDataSource.VIEWABLE */ public void saveRolesSet(String uid, Set<String> roles, int action) throws DataSourceException; + + /**Save metadata properties for given page. + * @param uid Page uid to save properties to. + */ + public void saveMetadataProps(String uid, Properties props); + + /**Gets metadata properties for given page. + * @param uid Page uid to get properties for. + * @return + */ + public Properties getMetadataProps(String uid); + } Modified: qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -1529,4 +1529,15 @@ // TODO Auto-generated method stub } + + public void saveMetadataProps(String uid, Properties props) { + // TODO Auto-generated method stub + + } + + public Properties getMetadataProps(String uid) { + // TODO Auto-generated method stub + return null; + } + } Modified: qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/WikiPage.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -27,6 +27,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Properties; import java.util.Set; import java.util.TreeSet; @@ -49,6 +50,7 @@ */ public class WikiPage implements Serializable, WikiProperties, Cloneable { + public static final String METADATA = "MetaData:Properties"; /** * */ @@ -88,21 +90,6 @@ private Logger log; - /** - * <p> - * Represents ... - * </p> - * - * WikiPage This class is _abstract_ and has to be extended by the class - * that we're willing to show our content - * - * functions to be extended: WikiPage(...) - constructor getAttributes() - - * gets set of atributes to be send to the appropriate JSP page - * saveThisPage(data:Object) - saves next version of this page with new data - * getJSPPath() - gets apropriate JSP page to show plugin - * getDataProviderName - gets name of the plugin _must_ be the same as in - * the plugin name in plugin.xml - */ private Credentials lastAuthor; /** @@ -539,7 +526,10 @@ } public void addPermVariable(String key, Object value) { - permVariables.put(key, value); + //TODO - cannot add METADATA property - tho must be thrown an Exception or sth. + if (!key.equals(WikiPage.METADATA)) { + permVariables.put(key, value); + } } public Object getPermVariable(String key) { @@ -623,4 +613,11 @@ public void setTempVariables(HashMap<String, Object> tempVariables) { this.tempVariables = tempVariables; } + + /**Has to be executed explicitely - so user knows he IS changing metaProps + * @param metaProps + */ + public void setMetaDataProps(Properties metaProps) { + permVariables.put(METADATA, metaProps); + } } Modified: qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/GetRefsFromPagePlugin.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/GetRefsFromPagePlugin.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/plugins/GetRefsFromPagePlugin.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -49,13 +49,10 @@ pageUid = pageUid.substring(1, pageUid.indexOf(']')); - if (!HTMLTranslatorParts.checkImageLink(pageUid) && !HTMLTranslatorParts.isExternalLink(pageUid) && !HTMLTranslatorParts.isNumber(pageUid)) { - pageUid = HTMLTranslatorParts.cleanLink(pageUid); - - if (pageUid != null && !HTMLTranslatorParts.isNumber(pageUid) ) { - refs.add(wikiEngine.getRealName(pageUid)); - } - } + pageUid = checkRef(pageUid); + + if (pageUid != null) + refs.add(wikiEngine.getRealName(pageUid)); } matcher = Pattern.compile(pattern2).matcher(pageContent); @@ -67,16 +64,28 @@ pageUid = pageUid.substring(pageUid.indexOf('|') + 1, pageUid .indexOf(']')); - if (!HTMLTranslatorParts.checkImageLink(pageUid) && !HTMLTranslatorParts.isExternalLink(pageUid) && !HTMLTranslatorParts.isNumber(pageUid)) { - pageUid = HTMLTranslatorParts.cleanLink(pageUid); - - if (pageUid != null && !HTMLTranslatorParts.isNumber(pageUid)) { - refs.add(wikiEngine.getRealName(pageUid)); - } - } + pageUid = checkRef(pageUid); + + if (pageUid != null) + refs.add(wikiEngine.getRealName(pageUid)); } return refs; } + + private String checkRef(String pageUid) { + + pageUid = pageUid.trim(); + + if (!HTMLTranslatorParts.checkImageLink(pageUid) && !HTMLTranslatorParts.isExternalLink(pageUid) && !HTMLTranslatorParts.isNumber(pageUid)) { + pageUid = HTMLTranslatorParts.cleanLink(pageUid); + if (pageUid != null && !HTMLTranslatorParts.isNumber(pageUid)) { + return pageUid; + } + } + + return null; + } + } Modified: qa/forge/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/management/WikiService.java =================================================================== --- qa/forge/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/management/WikiService.java 2005-12-12 15:27:32 UTC (rev 1780) +++ qa/forge/portal-extensions/jbosswiki/wiki-management/src/java/org/jboss/wiki/management/WikiService.java 2005-12-12 15:38:25 UTC (rev 1781) @@ -23,6 +23,7 @@ import javax.ejb.Local; import javax.ejb.Remote; + import org.jboss.annotation.ejb.Management; import org.jboss.annotation.ejb.Service; import org.jboss.logging.Logger; @@ -30,15 +31,17 @@ import org.jboss.wiki.WikiEngine; import org.jboss.wiki.management.WikiServiceMenagement; -@Service (objectName = WikiCommon.WIKI_SERVICE_NAME) +@Service(objectName = WikiCommon.WIKI_SERVICE_NAME) @Local(WikiServiceLocal.class) @Remote(WikiServiceRemote.class) @Management(WikiServiceMenagement.class) - public class WikiService implements WikiServiceLocal, WikiServiceRemote, WikiServiceMenagement { - +public class WikiService implements WikiServiceLocal, WikiServiceRemote, + WikiServiceMenagement { + private WikiEngine wikiEngine; + private Logger log = Logger.getLogger(WikiService.class); - + public synchronized WikiEngine getWikiEngine() { if (wikiEngine == null) { wikiEngine = new WikiEngine(); @@ -61,6 +64,5 @@ public void destroy() { log.info("WikiService - Destroying"); } - - + } |