Author: szimano Date: 2005-11-04 18:59:52 -0500 (Fri, 04 Nov 2005) New Revision: 1518 Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/etc/shotoku.properties trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/exceptions/DataSourceException.java Modified: trunk/forge/portal-extensions/jbosswiki/common.xml trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java Log: GetPage working with shotoku :) http://jira.jboss.com/jira/browse/JBWIKI-67 Modified: trunk/forge/portal-extensions/jbosswiki/common.xml =================================================================== --- trunk/forge/portal-extensions/jbosswiki/common.xml 2005-11-04 22:51:31 UTC (rev 1517) +++ trunk/forge/portal-extensions/jbosswiki/common.xml 2005-11-04 23:59:52 UTC (rev 1518) @@ -42,6 +42,24 @@ <version>1.0</version> <jar>portal-portlet-lib.jar</jar> </dependency> + + <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-base</artifactId> + <version>1.0</version> + <jar>shotoku-base.jar</jar> + <properties> + <ejb.manifest.classpath>true</ejb.manifest.classpath> + </properties> + </dependency> + + <dependency> + <groupId>shotoku</groupId> + <artifactId>shotoku-aop</artifactId> + <version>1.0</version> + <jar>shotoku-aop.jar</jar> + </dependency> + </dependencies> <build> Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/etc/shotoku.properties =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/etc/shotoku.properties 2005-11-04 22:51:31 UTC (rev 1517) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/etc/shotoku.properties 2005-11-04 23:59:52 UTC (rev 1518) @@ -0,0 +1,4 @@ +#Shotoku properties file + +# folder where wiki content is placed +shotokuPrefix = wiki-content/ Modified: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2005-11-04 22:51:31 UTC (rev 1517) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/FileDataSource.java 2005-11-04 23:59:52 UTC (rev 1518) @@ -106,6 +106,15 @@ 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); Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-04 22:51:31 UTC (rev 1517) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/ShotokuDataSource.java 2005-11-04 23:59:52 UTC (rev 1518) @@ -0,0 +1,260 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.wiki; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; +import java.util.TreeSet; + +import org.jboss.logging.Logger; +import org.jboss.shotoku.ContentManager; +import org.jboss.shotoku.Node; +import org.jboss.shotoku.exceptions.ResourceDoesNotExist; +import org.jboss.wiki.exceptions.DataSourceException; +import org.jboss.wiki.exceptions.PageRenamingException; + +import sun.security.krb5.internal.p; + +/** + * <p> + * </p> + * + */ +public class ShotokuDataSource implements MediaDataSource, + AttachmentDataSource, WikiPageDictionary { + + private WikiEngine wikiEngine; + + private ContentManager contentManager = null; + + private final String propsName = "shotoku.properties"; + + public ShotokuDataSource() throws DataSourceException { + Properties shotokuProps = new Properties(); + + try { + shotokuProps.load(ShotokuDataSource.class.getResourceAsStream("/" + + propsName)); + + contentManager = ContentManager.getContentManager(shotokuProps + .getProperty("shotokuPrefix")); + + } catch (IOException e) { + throw new DataSourceException(e.getMessage()); + } + + } + + public boolean preSave() { + // TODO Auto-generated method stub + return false; + } + + public boolean savePage(String uid, WikiPage page, String languageCode) { + // TODO Auto-generated method stub + return false; + } + + public boolean postSave() { + // TODO Auto-generated method stub + return false; + } + + public boolean preGet() { + return true; + } + + public WikiPage getPage(String pageName) { + StringBuffer pageContent = new StringBuffer(); + + try { + Node page = contentManager.getNode(pageName + ".txt"); + + InputStream is = page.getContentInputStream(); + + while (is.available() > 0) { + pageContent.append((char)is.read()); + } + + is.close(); + + return new WikiPage(pageName, new SimpleCredentials("someone"), + pageContent.toString(), 1, 1, new Date(page + .getLastModfication()), wikiEngine, true, true); + + } catch (ResourceDoesNotExist e) { + return null; + } + catch (IOException ee) { + return null; + } + } + + public boolean postGet() { + return true; + } + + public WikiPage getPage(String pageName, String languageCode) { + // TODO Auto-generated method stub + return null; + } + + public WikiPage getPageAtVersion(WikiPage originPage, boolean loadContent, + String languageCode, int version) { + // TODO Auto-generated method stub + return null; + } + + public WikiPage getPageAtVersion(WikiPage originPage, boolean loadContent, + int version) { + // TODO Auto-generated method stub + return null; + } + + public boolean pageExists(String pageName) { + try { + contentManager.getNode(pageName+".txt"); + return true; + } + catch (ResourceDoesNotExist e) { + return false; + } + } + + public void getContentAtVersion(WikiPage page, boolean loadContent, + int version) { + // TODO Auto-generated method stub + + } + + public Set<String> getAllPageNames() { + // TODO Auto-generated method stub + return null; + } + + public Set<String> getPagesFor(String pageName) { + // TODO Auto-generated method stub + return new TreeSet<String>(); + } + + public int getPageMod(String pageName) { + // TODO Auto-generated method stub + return 0; + } + + public void setPageMod(String pageName, int mods) { + // TODO Auto-generated method stub + + } + + public boolean deletePage(String pageName) { + // TODO Auto-generated method stub + return false; + } + + public void setWikiEngine(WikiEngine wikiEngine) { + this.wikiEngine = wikiEngine; + } + + public void addAttachment(File attFile, String attName, WikiPage page, + String user) { + // TODO Auto-generated method stub + + } + + public Set<String> getAttachmentsSet(WikiPage page) { + // TODO Auto-generated method stub + return null; + } + + public WikiAttachment getAttachment(String pageName, String attachmentName) { + // TODO Auto-generated method stub + return null; + } + + public WikiAttachment getAttachment(String pageName, String attachmentName, + int version) { + // TODO Auto-generated method stub + return null; + } + + public int getLastAttachmentVersion(String pageName, String attachmentName) { + // TODO Auto-generated method stub + return 0; + } + + public long getAttachmentSize(String pageName, String attachmentName, + int version) { + // TODO Auto-generated method stub + return 0; + } + + public boolean deleteAttachment(String pageName, String attachmentName) { + // TODO Auto-generated method stub + return false; + } + + public boolean deleteAttachments(String pageName) { + // TODO Auto-generated method stub + return false; + } + + public String getRealName(String uid) { + // TODO Auto-generated method stub + return null; + } + + public String getUid(String realName) { + // TODO Auto-generated method stub + return null; + } + + public void rename(String uid, String newName) throws PageRenamingException { + // TODO Auto-generated method stub + + } + + public boolean uidInDictionary(String uid) { + // TODO Auto-generated method stub + return false; + } + + public boolean realNameInDictionary(String realName) { + // TODO Auto-generated method stub + return false; + } + + public void removeDictForPage(String uid) throws PageRenamingException { + // TODO Auto-generated method stub + + } + +} Added: trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/exceptions/DataSourceException.java =================================================================== --- trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/exceptions/DataSourceException.java 2005-11-04 22:51:31 UTC (rev 1517) +++ trunk/forge/portal-extensions/jbosswiki/wiki-common/src/java/org/jboss/wiki/exceptions/DataSourceException.java 2005-11-04 23:59:52 UTC (rev 1518) @@ -0,0 +1,12 @@ +package org.jboss.wiki.exceptions; + +public class DataSourceException extends WikiException { + /** + * + */ + private static final long serialVersionUID = 1L; + + public DataSourceException(String msg) { + super(msg); + } +} |