From: <jbo...@li...> - 2005-08-23 13:29:49
|
Author: szimano Date: 2005-08-23 09:29:37 -0400 (Tue, 23 Aug 2005) New Revision: 921 Added: trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletDiskFileUpload.java trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUpload.java trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUploadBase.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/plugins/AttachementListPlugin.java Removed: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPluginChain.java Modified: trunk/forge/portal-extensions/forge-wiki/project.xml trunk/forge/portal-extensions/forge-wiki/src/etc/org/jboss/wiki/WikiTypes.xml trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/FileDataSource.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/MediaDataSource.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPage.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiType.java trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java trunk/forge/portal-extensions/forge-wiki/src/web/WEB-INF/jsp/Wiki.jsp Log: attachements working so-so Modified: trunk/forge/portal-extensions/forge-wiki/project.xml =================================================================== --- trunk/forge/portal-extensions/forge-wiki/project.xml 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/project.xml 2005-08-23 13:29:37 UTC (rev 921) @@ -60,6 +60,14 @@ <version>1.0</version> <jar>activation.jar</jar> </dependency> + + <dependency> + <groupId>commons-fileupload</groupId> + <artifactId>commons-fileupload.jar</artifactId> + <version>1.0</version> + <jar>commons-fileupload-1.0.jar</jar> + </dependency> + </dependencies> <build> Modified: trunk/forge/portal-extensions/forge-wiki/src/etc/org/jboss/wiki/WikiTypes.xml =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/etc/org/jboss/wiki/WikiTypes.xml 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/etc/org/jboss/wiki/WikiTypes.xml 2005-08-23 13:29:37 UTC (rev 921) @@ -13,6 +13,10 @@ <class>org.jboss.wiki.plugins.TrailPlugin</class> </plugin> <plugin> + <name>attachementList</name> + <class>org.jboss.wiki.plugins.AttachementListPlugin</class> + </plugin> + <plugin> <name>wikiToHtmlTranslator</name> <class>org.jboss.wiki.plugins.HTMLTranslator</class> </plugin> Added: trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletDiskFileUpload.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletDiskFileUpload.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletDiskFileUpload.java 2005-08-23 13:29:37 UTC (rev 921) @@ -0,0 +1,249 @@ +/* + * $Header: /cvsroot/director168/director_standard_portlets/src/org/apache/commons/fileupload/PortletDiskFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + * $Revision: 1.1 $ + * $Date: 2003/10/01 22:21:43 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact ap...@ap.... + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + + +package org.apache.commons.fileupload; + + +import java.io.File; +import java.util.List; +import javax.portlet.ActionRequest; + + +/** + * <p>High level API for processing file uploads.</p> + * + * <p>This class handles multiple files per single HTML widget, sent using + * <code>multipart/mixed</code> encoding type, as specified by + * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link + * #parseRequest(HttpServletRequest)} to acquire a list of {@link + * org.apache.commons.fileupload.FileItem}s associated with a given HTML + * widget.</p> + * + * <p>Individual parts will be stored in temporary disk storage or in memory, + * depending on their size, and will be available as {@link + * org.apache.commons.fileupload.FileItem}s.</p> + * + * @author <a href="mailto:Raf...@e-...">Rafal Krzewski</a> + * @author <a href="mailto:dl...@co...">Daniel Rall</a> + * @author <a href="mailto:jv...@ap...">Jason van Zyl</a> + * @author <a href="mailto:jmc...@co...">John McNally</a> + * @author <a href="mailto:ma...@ap...">Martin Cooper</a> + * @author Sean C. Sullivan + * + * @version $Id: PortletDiskFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + */ +public class PortletDiskFileUpload + extends PortletFileUploadBase + { + + // ----------------------------------------------------------- Data members + + + /** + * The factory to use to create new form items. + */ + private DefaultFileItemFactory fileItemFactory; + + + // ----------------------------------------------------------- Constructors + + + /** + * Constructs an instance of this class which uses the default factory to + * create <code>FileItem</code> instances. + * + * @see #DiskFileUpload(DefaultFileItemFactory fileItemFactory) + */ + public PortletDiskFileUpload() + { + super(); + this.fileItemFactory = new DefaultFileItemFactory(); + } + + + /** + * Constructs an instance of this class which uses the supplied factory to + * create <code>FileItem</code> instances. + * + * @see #DiskFileUpload() + */ + public PortletDiskFileUpload(DefaultFileItemFactory fileItemFactory) + { + super(); + this.fileItemFactory = fileItemFactory; + } + + + // ----------------------------------------------------- Property accessors + + + /** + * Returns the factory class used when creating file items. + * + * @return The factory class for new file items. + */ + public FileItemFactory getFileItemFactory() + { + return fileItemFactory; + } + + + /** + * Sets the factory class to use when creating file items. The factory must + * be an instance of <code>DefaultFileItemFactory</code> or a subclass + * thereof, or else a <code>ClassCastException</code> will be thrown. + * + * @param factory The factory class for new file items. + */ + public void setFileItemFactory(FileItemFactory factory) + { + this.fileItemFactory = (DefaultFileItemFactory) factory; + } + + + /** + * Returns the size threshold beyond which files are written directly to + * disk. + * + * @return The size threshold, in bytes. + * + * @see #setSizeThreshold(int) + */ + public int getSizeThreshold() + { + return fileItemFactory.getSizeThreshold(); + } + + + /** + * Sets the size threshold beyond which files are written directly to disk. + * + * @param sizeThreshold The size threshold, in bytes. + * + * @see #getSizeThreshold() + */ + public void setSizeThreshold(int sizeThreshold) + { + fileItemFactory.setSizeThreshold(sizeThreshold); + } + + + /** + * Returns the location used to temporarily store files that are larger + * than the configured size threshold. + * + * @return The path to the temporary file location. + * + * @see #setRepositoryPath(String) + */ + public String getRepositoryPath() + { + return fileItemFactory.getRepository().getPath(); + } + + + /** + * Sets the location used to temporarily store files that are larger + * than the configured size threshold. + * + * @param repositoryPath The path to the temporary file location. + * + * @see #getRepositoryPath() + */ + public void setRepositoryPath(String repositoryPath) + { + fileItemFactory.setRepository(new File(repositoryPath)); + } + + + // --------------------------------------------------------- Public methods + + + /** + * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> + * compliant <code>multipart/form-data</code> stream. If files are stored + * on disk, the path is given by <code>getRepository()</code>. + * + * @param req The servlet request to be parsed. Must be non-null. + * @param sizeThreshold The max size in bytes to be stored in memory. + * @param sizeMax The maximum allowed upload size, in bytes. + * @param path The location where the files should be stored. + * + * @return A list of <code>FileItem</code> instances parsed from the + * request, in the order that they were transmitted. + * + * @exception FileUploadException if there are problems reading/parsing + * the request or storing files. + */ + public List /* FileItem */ parseRequest(ActionRequest req, + int sizeThreshold, + long sizeMax, String path) + throws FileUploadException + { + setSizeThreshold(sizeThreshold); + setSizeMax(sizeMax); + setRepositoryPath(path); + return parseRequest(req); + } + +} + Added: trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUpload.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUpload.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUpload.java 2005-08-23 13:29:37 UTC (rev 921) @@ -0,0 +1,156 @@ +/* + * $Header: /cvsroot/director168/director_standard_portlets/src/org/apache/commons/fileupload/PortletFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + * $Revision: 1.1 $ + * $Date: 2003/10/01 22:21:43 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact ap...@ap.... + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + + +package org.apache.commons.fileupload; + + +/** + * <p>High level API for processing file uploads.</p> + * + * <p>This class handles multiple files per single HTML widget, sent using + * <code>multipart/mixed</code> encoding type, as specified by + * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link + * #parseRequest(HttpServletRequest)} to acquire a list of {@link + * org.apache.commons.fileupload.FileItem}s associated with a given HTML + * widget.</p> + * + * <p>How the data for individual parts is stored is determined by the factory + * used to create them; a given part may be in memory, on disk, or somewhere + * else.</p> + * + * @author <a href="mailto:Raf...@e-...">Rafal Krzewski</a> + * @author <a href="mailto:dl...@co...">Daniel Rall</a> + * @author <a href="mailto:jv...@ap...">Jason van Zyl</a> + * @author <a href="mailto:jmc...@co...">John McNally</a> + * @author <a href="mailto:ma...@ap...">Martin Cooper</a> + * @author Sean C. Sullivan + * + * @version $Id: PortletFileUpload.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + */ +public class PortletFileUpload + extends PortletFileUploadBase + { + + // ----------------------------------------------------------- Data members + + + /** + * The factory to use to create new form items. + */ + private FileItemFactory fileItemFactory; + + + // ----------------------------------------------------------- Constructors + + + /** + * Constructs an instance of this class which uses the default factory to + * create <code>FileItem</code> instances. + * + * @see #FileUpload(FileItemFactory) + */ + public PortletFileUpload() + { + super(); + } + + + /** + * Constructs an instance of this class which uses the supplied factory to + * create <code>FileItem</code> instances. + * + * @see #FileUpload() + */ + public PortletFileUpload(FileItemFactory fileItemFactory) + { + super(); + this.fileItemFactory = fileItemFactory; + } + + + // ----------------------------------------------------- Property accessors + + + /** + * Returns the factory class used when creating file items. + * + * @return The factory class for new file items. + */ + public FileItemFactory getFileItemFactory() + { + return fileItemFactory; + } + + + /** + * Sets the factory class to use when creating file items. + * + * @param factory The factory class for new file items. + */ + public void setFileItemFactory(FileItemFactory factory) + { + this.fileItemFactory = factory; + } + + +} + Added: trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUploadBase.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUploadBase.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/apache/commons/fileupload/PortletFileUploadBase.java 2005-08-23 13:29:37 UTC (rev 921) @@ -0,0 +1,685 @@ +/* + * $Header: /cvsroot/director168/director_standard_portlets/src/org/apache/commons/fileupload/PortletFileUploadBase.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + * $Revision: 1.1 $ + * $Date: 2003/10/01 22:21:43 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact ap...@ap.... + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + + +package org.apache.commons.fileupload; + + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.portlet.ActionRequest; + + +/** + * <p>High level API for processing file uploads.</p> + * + * <p>This class handles multiple files per single HTML widget, sent using + * <code>multipart/mixed</code> encoding type, as specified by + * <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use {@link + * #parseRequest(HttpServletRequest)} to acquire a list of {@link + * org.apache.commons.fileupload.FileItem}s associated with a given HTML + * widget.</p> + * + * <p>How the data for individual parts is stored is determined by the factory + * used to create them; a given part may be in memory, on disk, or somewhere + * else.</p> + * + * @author <a href="mailto:Raf...@e-...">Rafal Krzewski</a> + * @author <a href="mailto:dl...@co...">Daniel Rall</a> + * @author <a href="mailto:jv...@ap...">Jason van Zyl</a> + * @author <a href="mailto:jmc...@co...">John McNally</a> + * @author <a href="mailto:ma...@ap...">Martin Cooper</a> + * @author Sean C. Sullivan + * + * @version $Id: PortletFileUploadBase.java,v 1.1 2003/10/01 22:21:43 jsackett Exp $ + */ +public abstract class PortletFileUploadBase +{ + + // ---------------------------------------------------------- Class methods + + + /** + * Utility method that determines whether the request contains multipart + * content. + * + * @param req The servlet request to be evaluated. Must be non-null. + * + * @return <code>true</code> if the request is multipart; + * <code>false</code> otherwise. + */ + public static final boolean isMultipartContent(ActionRequest req) + { + String contentType = req.getContentType(); + if (contentType == null) + { + return false; + } + if (contentType.startsWith(MULTIPART)) + { + return true; + } + return false; + } + + + // ----------------------------------------------------- Manifest constants + + + /** + * HTTP content type header name. + */ + public static final String CONTENT_TYPE = "Content-type"; + + + /** + * HTTP content disposition header name. + */ + public static final String CONTENT_DISPOSITION = "Content-disposition"; + + + /** + * Content-disposition value for form data. + */ + public static final String FORM_DATA = "form-data"; + + + /** + * Content-disposition value for file attachment. + */ + public static final String ATTACHMENT = "attachment"; + + + /** + * Part of HTTP content type header. + */ + public static final String MULTIPART = "multipart/"; + + + /** + * HTTP content type header for multipart forms. + */ + public static final String MULTIPART_FORM_DATA = "multipart/form-data"; + + + /** + * HTTP content type header for multiple uploads. + */ + public static final String MULTIPART_MIXED = "multipart/mixed"; + + + /** + * The maximum length of a single header line that will be parsed + * (1024 bytes). + */ + public static final int MAX_HEADER_SIZE = 1024; + + + // ----------------------------------------------------------- Data members + + + /** + * The maximum size permitted for an uploaded file. A value of -1 indicates + * no maximum. + */ + private long sizeMax = -1; + + + /** + * The content encoding to use when reading part headers. + */ + private String headerEncoding; + + + // ----------------------------------------------------- Property accessors + + + /** + * Returns the factory class used when creating file items. + * + * @return The factory class for new file items. + */ + public abstract FileItemFactory getFileItemFactory(); + + + /** + * Sets the factory class to use when creating file items. + * + * @param factory The factory class for new file items. + */ + public abstract void setFileItemFactory(FileItemFactory factory); + + + /** + * Returns the maximum allowed upload size. + * + * @return The maximum allowed size, in bytes. + * + * @see #setSizeMax(long) + * + */ + public long getSizeMax() + { + return sizeMax; + } + + + /** + * Sets the maximum allowed upload size. If negative, there is no maximum. + * + * @param sizeMax The maximum allowed size, in bytes, or -1 for no maximum. + * + * @see #getSizeMax() + * + */ + public void setSizeMax(long sizeMax) + { + this.sizeMax = sizeMax; + } + + + /** + * Retrieves the character encoding used when reading the headers of an + * individual part. When not specified, or <code>null</code>, the platform + * default encoding is used. + * + * @return The encoding used to read part headers. + */ + public String getHeaderEncoding() + { + return headerEncoding; + } + + + /** + * Specifies the character encoding to be used when reading the headers of + * individual parts. When not specified, or <code>null</code>, the platform + * default encoding is used. + * + * @param encoding The encoding used to read part headers. + */ + public void setHeaderEncoding(String encoding) + { + headerEncoding = encoding; + } + + + // --------------------------------------------------------- Public methods + + + /** + * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> + * compliant <code>multipart/form-data</code> stream. If files are stored + * on disk, the path is given by <code>getRepository()</code>. + * + * @param req The servlet request to be parsed. + * + * @return A list of <code>FileItem</code> instances parsed from the + * request, in the order that they were transmitted. + * + * @exception FileUploadException if there are problems reading/parsing + * the request or storing files. + */ + public List /* FileItem */ parseRequest(ActionRequest req) + throws FileUploadException + { + if (null == req) + { + throw new NullPointerException("req parameter"); + } + + ArrayList items = new ArrayList(); + String contentType = req.getContentType(); + + if ((null == contentType) || (!contentType.startsWith(MULTIPART))) + { + throw new InvalidContentTypeException( + "the request doesn't contain a " + + MULTIPART_FORM_DATA + + " or " + + MULTIPART_MIXED + + " stream, content type header is " + + contentType); + } + int requestSize = req.getContentLength(); + + if (requestSize == -1) + { + throw new UnknownSizeException( + "the request was rejected because it's size is unknown"); + } + + if (sizeMax >= 0 && requestSize > sizeMax) + { + throw new SizeLimitExceededException( + "the request was rejected because " + + "it's size exceeds allowed range"); + } + + try + { + int boundaryIndex = contentType.indexOf("boundary="); + if (boundaryIndex < 0) + { + throw new FileUploadException( + "the request was rejected because " + + "no multipart boundary was found"); + } + byte[] boundary = contentType.substring( + boundaryIndex + 9).getBytes(); + + InputStream input = req.getPortletInputStream(); + + MultipartStream multi = new MultipartStream(input, boundary); + multi.setHeaderEncoding(headerEncoding); + + boolean nextPart = multi.skipPreamble(); + while (nextPart) + { + Map headers = parseHeaders(multi.readHeaders()); + String fieldName = getFieldName(headers); + if (fieldName != null) + { + String subContentType = getHeader(headers, CONTENT_TYPE); + if (subContentType != null && subContentType + .startsWith(MULTIPART_MIXED)) + { + // Multiple files. + byte[] subBoundary = + subContentType.substring( + subContentType + .indexOf("boundary=") + 9).getBytes(); + multi.setBoundary(subBoundary); + boolean nextSubPart = multi.skipPreamble(); + while (nextSubPart) + { + headers = parseHeaders(multi.readHeaders()); + if (getFileName(headers) != null) + { + FileItem item = + createItem(headers, false); + OutputStream os = item.getOutputStream(); + try + { + multi.readBodyData(os); + } + finally + { + os.close(); + } + items.add(item); + } + else + { + // Ignore anything but files inside + // multipart/mixed. + multi.discardBodyData(); + } + nextSubPart = multi.readBoundary(); + } + multi.setBoundary(boundary); + } + else + { + if (getFileName(headers) != null) + { + // A single file. + FileItem item = createItem(headers, false); + OutputStream os = item.getOutputStream(); + try + { + multi.readBodyData(os); + } + finally + { + os.close(); + } + items.add(item); + } + else + { + // A form field. + FileItem item = createItem(headers, true); + OutputStream os = item.getOutputStream(); + try + { + multi.readBodyData(os); + } + finally + { + os.close(); + } + items.add(item); + } + } + } + else + { + // Skip this part. + multi.discardBodyData(); + } + nextPart = multi.readBoundary(); + } + } + catch (IOException e) + { + throw new FileUploadException( + "Processing of " + MULTIPART_FORM_DATA + + " request failed. " + e.getMessage()); + } + + return items; + } + + + // ------------------------------------------------------ Protected methods + + + /** + * Retrieves the file name from the <code>Content-disposition</code> + * header. + * + * @param headers A <code>Map</code> containing the HTTP request headers. + * + * @return The file name for the current <code>encapsulation</code>. + */ + protected String getFileName(Map /* String, String */ headers) + { + String fileName = null; + String cd = getHeader(headers, CONTENT_DISPOSITION); + if (cd.startsWith(FORM_DATA) || cd.startsWith(ATTACHMENT)) + { + int start = cd.indexOf("filename=\""); + int end = cd.indexOf('"', start + 10); + if (start != -1 && end != -1) + { + fileName = cd.substring(start + 10, end).trim(); + } + } + return fileName; + } + + + /** + * Retrieves the field name from the <code>Content-disposition</code> + * header. + * + * @param headers A <code>Map</code> containing the HTTP request headers. + * + * @return The field name for the current <code>encapsulation</code>. + */ + protected String getFieldName(Map /* String, String */ headers) + { + String fieldName = null; + String cd = getHeader(headers, CONTENT_DISPOSITION); + if (cd != null && cd.startsWith(FORM_DATA)) + { + int start = cd.indexOf("name=\""); + int end = cd.indexOf('"', start + 6); + if (start != -1 && end != -1) + { + fieldName = cd.substring(start + 6, end); + } + } + return fieldName; + } + + + /** + * Creates a new {@link FileItem} instance. + * + * @param headers A <code>Map</code> containing the HTTP request + * headers. + * @param isFormField Whether or not this item is a form field, as + * opposed to a file. + * + * @return A newly created <code>FileItem</code> instance. + * + * @exception FileUploadException if an error occurs. + */ + protected FileItem createItem(Map /* String, String */ headers, + boolean isFormField) + throws FileUploadException + { + return getFileItemFactory().createItem(getFieldName(headers), + getHeader(headers, CONTENT_TYPE), + isFormField, + getFileName(headers)); + } + + + /** + * <p> Parses the <code>header-part</code> and returns as key/value + * pairs. + * + * <p> If there are multiple headers of the same names, the name + * will map to a comma-separated list containing the values. + * + * @param headerPart The <code>header-part</code> of the current + * <code>encapsulation</code>. + * + * @return A <code>Map</code> containing the parsed HTTP request headers. + */ + protected Map /* String, String */ parseHeaders(String headerPart) + { + Map headers = new HashMap(); + char buffer[] = new char[MAX_HEADER_SIZE]; + boolean done = false; + int j = 0; + int i; + String header, headerName, headerValue; + try + { + while (!done) + { + i = 0; + // Copy a single line of characters into the buffer, + // omitting trailing CRLF. + while (i < 2 || buffer[i - 2] != '\r' || buffer[i - 1] != '\n') + { + buffer[i++] = headerPart.charAt(j++); + } + header = new String(buffer, 0, i - 2); + if (header.equals("")) + { + done = true; + } + else + { + if (header.indexOf(':') == -1) + { + // This header line is malformed, skip it. + continue; + } + headerName = header.substring(0, header.indexOf(':')) + .trim().toLowerCase(); + headerValue = + header.substring(header.indexOf(':') + 1).trim(); + if (getHeader(headers, headerName) != null) + { + // More that one heder of that name exists, + // append to the list. + headers.put(headerName, + getHeader(headers, headerName) + ',' + + headerValue); + } + else + { + headers.put(headerName, headerValue); + } + } + } + } + catch (IndexOutOfBoundsException e) + { + // Headers were malformed. continue with all that was + // parsed. + } + return headers; + } + + + /** + * Returns the header with the specified name from the supplied map. The + * header lookup is case-insensitive. + * + * @param headers A <code>Map</code> containing the HTTP request headers. + * @param name The name of the header to return. + * + * @return The value of specified header, or a comma-separated list if + * there were multiple headers of that name. + */ + protected final String getHeader(Map /* String, String */ headers, + String name) + { + return (String) headers.get(name.toLowerCase()); + } + + + /** + * Thrown to indicate that the request is not a multipart request. + */ + public static class InvalidContentTypeException + extends FileUploadException + { + /** + * Constructs a <code>InvalidContentTypeException</code> with no + * detail message. + */ + public InvalidContentTypeException() + { + super(); + } + + /** + * Constructs an <code>InvalidContentTypeException</code> with + * the specified detail message. + * + * @param message The detail message. + */ + public InvalidContentTypeException(String message) + { + super(message); + } + } + + + /** + * Thrown to indicate that the request size is not specified. + */ + public static class UnknownSizeException + extends FileUploadException + { + /** + * Constructs a <code>UnknownSizeException</code> with no + * detail message. + */ + public UnknownSizeException() + { + super(); + } + + /** + * Constructs an <code>UnknownSizeException</code> with + * the specified detail message. + * + * @param message The detail message. + */ + public UnknownSizeException(String message) + { + super(message); + } + } + + + /** + * Thrown to indicate that the request size exceeds the configured maximum. + */ + public static class SizeLimitExceededException + extends FileUploadException + { + /** + * Constructs a <code>SizeExceededException</code> with no + * detail message. + */ + public SizeLimitExceededException() + { + super(); + } + + /** + * Constructs an <code>SizeExceededException</code> with + * the specified detail message. + * + * @param message The detail message. + */ + public SizeLimitExceededException(String message) + { + super(message); + } + } + +} \ No newline at end of file Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/FileDataSource.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/FileDataSource.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/FileDataSource.java 2005-08-23 13:29:37 UTC (rev 921) @@ -13,10 +13,10 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.lang.reflect.Array; -import java.util.Calendar; import java.util.Date; +import java.util.HashSet; import java.util.Properties; +import java.util.Set; /** * <p> @@ -35,8 +35,12 @@ private String pathToMedia; + private String pathToAttachements; + private Properties fileDSProps; + private final int BUF_SIZE = 32768; + public FileDataSource() { System.out.println("Looking for props file"); @@ -58,6 +62,9 @@ if (fileDSProps.getProperty("pathToMedia") != null) { pathToMedia = fileDSProps.getProperty("pathToMedia"); System.out.println("Path to media is: " + pathToMedia); + pathToAttachements = fileDSProps.getProperty("pathToAttachements"); + System.out + .println("Path to attachements is: " + pathToAttachements); } else { System.err .println("Your properties file lacks of pathToMedia property. It will not run properly ! Please update " @@ -205,6 +212,53 @@ return pageProps; } + public Properties getAttProps(String pageName, String attName) { + Properties attProps = new Properties(); + + File propFile = new File(pathToAttachements + "/" + pageName + "-att/" + + attName + "-dir/"); + + if (!propFile.exists()) { + // create dirs for this property file + propFile.mkdirs(); + } + + propFile = new File(pathToAttachements + "/" + pageName + "-att/" + + attName + "-dir/attachement.properties"); + + try { + attProps.load(new FileInputStream(propFile)); + } catch (IOException ioe) { + System.err + .println("Cannot read attachement.properties for attachement: " + + pathToAttachements + + "/" + + pageName + + "-att/" + + attName + "-dir/attachements.properties\n" + ioe); + } + + return attProps; + } + + public void saveAttProps(Properties props, String pageName, String attName) { + try { + props.store(new FileOutputStream(new File(pathToAttachements + "/" + + pageName + "-att/" + attName + + "-dir/attachement.properties")), + "Saved by FileDataSource of JBoss Wiki"); + } catch (Exception ioe) { + System.err + .println("Cannot store attachement.properties for attachement: " + + pathToAttachements + + "/" + + pageName + + "-att/" + + attName + "-dir/attachements.properties\n" + ioe); + } + + } + public WikiPage getPage(String pageName) { System.out.println("[WIKI:FileDataSource]: Getting new page: " + pageName); @@ -246,7 +300,7 @@ page = new WikiPage(pageName, author, pageContent, i, i, new Date(pageFile.lastModified()), this); - + page.setLength(pageFile.length()); } } @@ -345,10 +399,10 @@ ret += (char) nextChr; nextChr = input.read(); } - + page.setPageContent(ret); page.setLength(ret.length()); - + } catch (IOException ioe) { System.err.println(ioe); } @@ -356,7 +410,7 @@ page.setLength(pageFile.length()); page.setPageContent(null); } - + } public Date getDateAtVersion(String pageName, int version) { @@ -375,34 +429,6 @@ version + ".author")); } - /* - * public static void main(String[] args) { MediaDataSource fds = new - * FileDataSource(); - * - * String[] pageName = { "Rali", "Tomek", "Adam", "Dupa", "WhatIsJBossForge" }; - * - * for (int i = 0; i < Array.getLength(pageName); i++) { WikiPage page = - * fds.getPage(pageName[i]); - * - * if (page != null) { page.showPage(); } else { System.out.println("Page " + - * pageName[i] + " doesn't exist"); } } - * - * WikiPage page = fds.getPageAtVersion("WhatIsJBossForge", 7); - * - * if (page != null) { page.showPage(); } else { System.out .println("Page - * WhatIsJBossForge doesn't exist at version 7"); } - * - * page = fds.getPageAtVersion("Dupa", 7); - * - * if (page != null) { page.showPage(); } else { System.out.println("Page - * Dupa doesn't exist at version 7"); } - * - * page = fds.getPageAtVersion("WhatIsJBossForge", 70); - * - * if (page != null) { page.showPage(); } else { System.out .println("Page - * WhatIsJBossForge doesn't exist at version 70"); } } - */ - public boolean pageExists(String pageName) { File pageFile = new File(pathToMedia + "/" + pageName + ".txt"); @@ -413,4 +439,88 @@ } } + public void addAtachement(File attFile, String attName, WikiPage page, String user) { + String pageName = page.getName(); + Properties attProps = getAttProps(pageName, attName); + + int lastVersion = 1; + + if (attProps.size() > 0) { + // find last version of this file + while (attProps.getProperty(lastVersion + ".author") != null) { + lastVersion++; + } + } + + String[] extension = attName.split("\\."); + String fileName = pathToAttachements + + "/" + + pageName + + "-att/" + + attName + + "-dir/" + + lastVersion + + "." + + ((attName.indexOf('.') != -1) ? extension[extension.length - 1] + : "bin"); + + FileInputStream oldFile = null; + FileOutputStream newFile = null; + + try { + newFile = new FileOutputStream(new File(fileName)); + oldFile = new FileInputStream(attFile); + } catch (FileNotFoundException e) { + System.err.println(e); + } + + // writing old file to new one + try { + byte[] buffer = new byte[BUF_SIZE]; + int read; + while ((read = oldFile.read(buffer)) != -1) + newFile.write(buffer, 0, read); + } catch (Exception e2) { + // Nothing that we can really do. Just send an incomplete + // file. + } finally { + try { + newFile.close(); + oldFile.close(); + } catch (IOException e) { + System.err.println(e); + } + } + + // at the end delete the temp file + attFile.delete(); + + attProps.setProperty(lastVersion + ".author", user); + + saveAttProps(attProps, pageName, attName); + } + + public Set<String> getAttachementsSet(WikiPage page) { + Set<String> attSet = new HashSet<String>(); + + File attDir = new File(pathToAttachements+"/"+page.getName()+"-att"); + + if (attDir.exists()) { + File[] attachements = attDir.listFiles(); + + for (int i = 0; i < attachements.length; i++) { + if ((attachements[i].isDirectory())&&(attachements[i].getName().endsWith("-dir"))) { + String[] tokens = attachements[i].getName().split("/"); + attSet.add(tokens[tokens.length - 1].substring(0, tokens[tokens.length - 1].length()-4)); + } + } + } + else { + // page has no attachements + return null; + } + + return attSet; + } + } Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/MediaDataSource.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/MediaDataSource.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/MediaDataSource.java 2005-08-23 13:29:37 UTC (rev 921) @@ -7,6 +7,10 @@ * * *************************************************/ package org.jboss.wiki; + +import java.io.File; +import java.util.Set; + /** * <p></p> * @@ -84,6 +88,10 @@ public void getContentAtVersion(WikiPage page, boolean loadContent, int version); + + public void addAtachement(File attFile, String attName, WikiPage page, String user); + + public Set<String> getAttachementsSet(WikiPage page); } Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPage.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPage.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPage.java 2005-08-23 13:29:37 UTC (rev 921) @@ -8,10 +8,12 @@ *************************************************/ package org.jboss.wiki; +import java.io.File; import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Set; import org.jboss.portal.core.model.User; @@ -375,4 +377,12 @@ public void setLength(long length) { this.length = length; } + + public void addAttachement(File attFile, String attName, String user) { + mediaDataSource.addAtachement(attFile, attName, this, user); + } + + public Set<String> getAttachementsSet() { + return mediaDataSource.getAttachementsSet(this); + } } Deleted: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPluginChain.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPluginChain.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPluginChain.java 2005-08-23 13:29:37 UTC (rev 921) @@ -1,64 +0,0 @@ -/************************************************** - * * - * JBoss Labs: Creating Professional Open Source * - * * - * Distributable under LGPL license. * - * See terms of license at gnu.org. * - * * - *************************************************/ - package org.jboss.wiki; - -import java.util.List; - -/** - * <p></p> - * - */ - /** - * - * @author <a href="mailto:ds...@jb...">Damon Sicore</a> - * @author <a href="mailto:tom...@jb...">Tomasz Szymanski</a> - * @version $Id$ - */ -public class WikiPluginChain { - -/** - * <p>Represents ...</p> - * - */ - private List pluginList; -/** - * <p></p> - * - */ - public WikiType wikiType; - -/** - * <p>Does ...</p> - * - * - * @return - * @param wikiPlugin - */ - public void addPlugin(WikiPlugin wikiPlugin) { - // your code here - //return null; - } - -/** - * <p>Does ...</p> - * - * - * @return - * @param pluginDescriptor - */ - public void init(PluginDescriptor pluginDescriptor) { - // your code here - //return null; - } -/** - * <p></p> - * - */ - public WikiPlugin wikiPlugin; - } Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiPortlet.java 2005-08-23 13:29:37 UTC (rev 921) @@ -8,12 +8,17 @@ *************************************************/ package org.jboss.wiki; -import java.util.Calendar; +import java.io.File; import java.util.Date; -import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import javax.portlet.*; import org.jboss.portlet.*; +import org.apache.commons.fileupload.PortletDiskFileUpload; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.FileItem; /** * The WikiPortlet. @@ -42,6 +47,69 @@ WikiContext wikiContext = null; + if (PortletDiskFileUpload.isMultipartContent(rReq)) { + PortletDiskFileUpload dfu = new PortletDiskFileUpload(); + + // maximum allowed file upload size (10 MB) + dfu.setSizeMax(10 * 1000 * 1000); + + // maximum size in memory (vs disk) (100 KB) + dfu.setSizeThreshold(100 * 1000); + + try { + // get the FileItems + List fileItems = dfu.parseRequest(rReq); + Iterator iter = fileItems.iterator(); + while (iter.hasNext()) { + FileItem item = (FileItem) iter.next(); + if (item.isFormField()) { + // pass along to render request + String fieldName = item.getFieldName(); + String value = item.getString(); + rResp.setRenderParameter(fieldName, value); + } else { + // write the uploaded file to a new location + String fieldName = item.getFieldName(); + String fileName = item.getName(); + String contentType = item.getContentType(); + long size = item.getSize(); + /* + * rResp .setRenderParameter("size", + * Long.toString(size)); + * rResp.setRenderParameter("contentType", contentType); + */ + String tempDir = System.getProperty("java.io.tmpdir"); + String serverFileName = fieldName + "-portlet.tmp"; + + File serverFile = new File(tempDir, serverFileName); + + item.write(serverFile); + /* + * rResp.setRenderParameter("serverFileName", + * serverFileName); + */ + getPortletContext().log( + "serverFileName : " + tempDir + "/" + + serverFileName + " filename: " + + fileName); + + WikiPage pageWithAtt = wikiEngine.getByName(rReq + .getParameter("page"), null); + pageWithAtt.addAttachement(serverFile, fileName, rReq + .getUser().getUserName()); + } + } + } catch (FileUploadException fue) { + String msg = "File Upload Exception: " + fue.getMessage(); + rResp.setRenderParameter("error", msg); + getPortletContext().log(msg, fue); + } catch (Exception e) { + String msg = "Exception: " + e.getMessage(); + rResp.setRenderParameter("error", msg); + getPortletContext().log(msg, e); + } + } + if (rReq.getParameter("action") != null) { rResp.setRenderParameter("action", rReq.getParameter("action")); } @@ -49,7 +117,7 @@ if (rReq.getParameter("type") != null) { rResp.setRenderParameter("type", rReq.getParameter("type")); } - + if (rReq.getParameter("version") != null) { System.out.println("[process action]Getting page " + rReq.getParameter("page") + " at version " @@ -138,19 +206,19 @@ page = "Edit.jsp"; pageToShow = wikiEngine.getByName(wikiPage, null); - + if (rReq.getParameter("version") != null) { // show previous version of page System.out.println("Getting page " + wikiPage + " at version " + rReq.getParameter("version")); - pageToShow = wikiEngine.getByName(wikiPage, null, - Integer.valueOf(rReq.getParameter("version"))); + pageToShow = wikiEngine.getByName(wikiPage, null, Integer + .valueOf(rReq.getParameter("version"))); rReq.setAttribute("showedVersion", Integer.valueOf(rReq .getParameter("version"))); } else { pageToShow = wikiEngine.getByName(wikiPage, null); } - + if (pageToShow == null) { // start editing new page // wikiPage = defaultPage; @@ -181,7 +249,7 @@ pageToShow = wikiEngine.getByName(wikiPage, null); if (pageToShow == null) { // if somebody entered a link to info - // non-existing page + // non-existing page page = "Wiki.jsp"; try { pageToShow = (WikiPage) noSuchPage.clone(); @@ -198,16 +266,16 @@ page = "Wiki.jsp"; String type = "HTML"; - + if (rReq.getParameter("type") != null) { type = rReq.getParameter("type"); - System.out.println("Getting type: "+type); + System.out.println("Getting type: " + type); } - + wikiContext = new WikiContext(rReq.getUser(), wikiEngine - .getWikiType(type), new PortletWikiSession(rReq.getPortletSession())); + .getWikiType(type), new PortletWikiSession(rReq + .getPortletSession())); - if (rReq.getParameter("version") != null) { // show previous version of page System.out.println("Getting page " + wikiPage + " at version " Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiType.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiType.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/WikiType.java 2005-08-23 13:29:37 UTC (rev 921) @@ -49,13 +49,6 @@ * </p> * */ - protected WikiPluginChain wikiPluginChain; - - /** - * <p> - * </p> - * - */ protected WikiContext wikiContext; protected Vector<WikiPlugin> plugins = new Vector<WikiPlugin>(); Modified: trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java =================================================================== --- trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2005-08-23 09:08:00 UTC (rev 920) +++ trunk/forge/portal-extensions/forge-wiki/src/java/org/jboss/wiki/fileaccess/WikiFileAccessFilter.java 2005-08-23 13:29:37 UTC (rev 921) @@ -13,7 +13,6 @@ import java.io.IOException; import java.util.Properties; - import javax.activation.MimetypesFileTypeMap; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -43,36 +42,36 @@ private final int BUF_SIZE = 32768; private String attachementsPath; - + /* * private ForgeHelper forgeHelper; private ContentManager contentManager; - */ - private MimetypesFileTypeMap mimeTypes; - + */ + private MimetypesFileTypeMap mimeTypes; public void init(FilterConfig conf) { // load mime types map - - mimeTypes = new MimetypesFileTypeMap(WikiFileAccessFilter.class.getResourceAsStream("mime.types")); - + + mimeTypes = new MimetypesFileTypeMap(WikiFileAccessFilter.class + .getResourceAsStream("mime.types")); + // load path to attachements from filedatasource.properties - + Properties props = new Properties(); - + try { - props.load(FileDataSource.class.getResourceAsStream("filedatasource.properties")); - } - catch (IOException e) { + props.load(FileDataSource.class + .getResourceAsStream("filedatasource.properties")); + } catch (IOException e) { System.err.println(e); } - + // get the apropriate property attachementsPath = props.getProperty("pathToAttachements"); - - System.out.println("[WikiFileAccess]Loaded attachements path: "+attachementsPath); + + System.out.println("[WikiFileAccess]Loaded attachements path: " + + attachementsPath); } - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException { @@ -87,19 +86,26 @@ // get fileName of attachement and page which is connected to String fileName = tokens[tokens.length - 1]; String pageName = tokens[tokens.length - 2]; - - System.out.println("[WikiFileAccess]Getting file: "+fileName+" of page: "+pageName); - + + System.out.println(... [truncated message content] |