From: zapata Date: Mon, 21 Apr 2003 02:58:29 +0000 (+0000) Subject: cos is gone woohee X-Git-Tag: BEFORE_MERGE_1_1~149 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=87809334c4eaf3955a1cfe609425ad2f07a26351;p=mir.git cos is gone woohee --- diff --git a/lib/cos-05Nov2002.jar b/lib/cos-05Nov2002.jar deleted file mode 100755 index a0e34a79..00000000 Binary files a/lib/cos-05Nov2002.jar and /dev/null differ diff --git a/source/Mir.java b/source/Mir.java index ea6a9f35..9a93a655 100755 --- a/source/Mir.java +++ b/source/Mir.java @@ -29,50 +29,48 @@ * not wish to do so, delete this exception statement from your version. */ -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.Method; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Vector; -import javax.servlet.ServletException; -import javax.servlet.UnavailableException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.struts.util.MessageResources; -import freemarker.template.SimpleHash; -import freemarker.template.SimpleList; -import freemarker.template.SimpleScalar; -import freemarker.template.TemplateModel; -import mir.config.MirPropertiesConfiguration; -import mir.generator.FreemarkerGenerator; -import mir.log.LoggerWrapper; -import mir.misc.HTMLTemplateProcessor; -import mir.misc.StringUtil; -import mir.servlet.AbstractServlet; -import mir.servlet.ServletModule; -import mir.servlet.ServletModuleDispatch; -import mir.servlet.ServletModuleExc; -import mir.servlet.ServletModuleUserExc; -import mir.util.ExceptionFunctions; -import mir.util.StringRoutines; -import mir.util.*; -import mir.entity.*; -import mir.entity.adapter.*; -import mircoders.entity.EntityUsers; -import mircoders.global.MirGlobal; -import mircoders.module.ModuleMessage; -import mircoders.module.ModuleUsers; -import mircoders.storage.DatabaseArticleType; -import mircoders.storage.DatabaseMessages; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.GregorianCalendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; +import javax.servlet.ServletException; +import javax.servlet.UnavailableException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.util.MessageResources; +import freemarker.template.SimpleHash; +import freemarker.template.SimpleList; +import freemarker.template.SimpleScalar; +import freemarker.template.TemplateModel; + +import mir.config.MirPropertiesConfiguration; +import mir.entity.adapter.EntityIteratorAdapter; +import mir.generator.FreemarkerGenerator; +import mir.log.LoggerWrapper; +import mir.misc.HTMLTemplateProcessor; +import mir.misc.StringUtil; +import mir.servlet.AbstractServlet; +import mir.servlet.ServletModule; +import mir.servlet.ServletModuleDispatch; +import mir.servlet.ServletModuleExc; +import mir.servlet.ServletModuleUserExc; +import mir.util.CachingRewindableIterator; +import mir.util.ExceptionFunctions; +import mir.util.StringRoutines; +import mircoders.entity.EntityUsers; +import mircoders.global.MirGlobal; +import mircoders.module.ModuleMessage; +import mircoders.module.ModuleUsers; +import mircoders.servlet.ServletHelper; import mircoders.storage.DatabaseUsers; -import mircoders.servlet.*; @@ -81,7 +79,7 @@ import mircoders.servlet.*; * Mir.java - main servlet, that dispatches to servletmodules * * @author $Author: zapata $ - * @version $Id: Mir.java,v 1.43 2003/04/12 15:29:43 zapata Exp $ + * @version $Id: Mir.java,v 1.44 2003/04/21 02:58:29 zapata Exp $ * */ public class Mir extends AbstractServlet { diff --git a/source/mir/misc/FileExtFilter.java b/source/mir/misc/FileExtFilter.java deleted file mode 100755 index 5a54ee1e..00000000 --- a/source/mir/misc/FileExtFilter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - -import java.io.File; -import java.io.FilenameFilter; - - -public class FileExtFilter implements FilenameFilter -{ - - static String _SEP_EXT; - - public FileExtFilter(String ext) { - _SEP_EXT = ext; - } - - public boolean accept(File dir, String name) { - System.out.println("NAME: "+name+" "+_SEP_EXT); - return name.endsWith("."+_SEP_EXT); - } - -} - - diff --git a/source/mir/misc/FileHandler.java b/source/mir/misc/FileHandler.java deleted file mode 100755 index a7a6ec89..00000000 --- a/source/mir/misc/FileHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - -import java.util.Map; - -import multex.Exc; -import multex.Failure; - -import com.oreilly.servlet.multipart.FilePart; - - -/** - * Interface that classes wishing to be used as a callback on FileParts for the - * WebdbMultipartRequest class should implement this interface. - * - * @author mh - * @version $Id: FileHandler.java,v 1.6 2003/03/09 19:14:21 idfx Exp $ - * @see mir.misc.WebdbMultipartRequest - * - */ - -public interface FileHandler { - - public void setFile (FilePart filePart, int fileNum, Map Params) throws FileHandlerExc, FileHandlerFailure; - - public static class FileHandlerExc extends Exc { - public FileHandlerExc(String aMessage) { - - super(aMessage); - } - } - - public static class FileHandlerFailure extends Failure { - - public FileHandlerFailure(String msg, Throwable cause) { - super(msg, cause); - } - - public FileHandlerFailure(Throwable aCause) { - this(aCause.getMessage(), aCause); - } - } - -} - - - - diff --git a/source/mir/misc/HTMLTemplateProcessor.java b/source/mir/misc/HTMLTemplateProcessor.java index 5b842a25..1f40e510 100755 --- a/source/mir/misc/HTMLTemplateProcessor.java +++ b/source/mir/misc/HTMLTemplateProcessor.java @@ -31,35 +31,33 @@ package mir.misc; -import java.io.PrintWriter; -import java.net.URLEncoder; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletResponse; - -import org.apache.struts.util.MessageResources; - -import freemarker.template.FileTemplateCache; -import freemarker.template.SimpleHash; -import freemarker.template.SimpleList; -import freemarker.template.SimpleScalar; -import freemarker.template.Template; -import freemarker.template.TemplateModelRoot; - -import mir.config.MirPropertiesConfiguration; -import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; -import mir.entity.Entity; -import mir.entity.EntityList; -import mir.generator.FreemarkerGenerator; -import mir.log.LoggerWrapper; -import mir.storage.StorageObjectFailure; -import mir.util.GeneratorHTMLFunctions; -import mir.util.GeneratorIntegerFunctions; -import mir.util.*; +import java.io.PrintWriter; +import java.net.URLEncoder; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.util.MessageResources; +import freemarker.template.FileTemplateCache; +import freemarker.template.SimpleHash; +import freemarker.template.SimpleList; +import freemarker.template.SimpleScalar; +import freemarker.template.Template; +import freemarker.template.TemplateModelRoot; + +import mir.config.MirPropertiesConfiguration; +import mir.config.MirPropertiesConfiguration$PropertiesConfigExc; +import mir.entity.Entity; +import mir.entity.EntityList; +import mir.generator.FreemarkerGenerator; +import mir.log.LoggerWrapper; +import mir.storage.StorageObjectFailure; +import mir.util.GeneratorHTMLFunctions; +import mir.util.GeneratorIntegerFunctions; +import mir.util.ResourceBundleGeneratorFunction; /** * Hilfsklasse zum Mergen von Template und Daten diff --git a/source/mir/misc/Helper.java b/source/mir/misc/Helper.java deleted file mode 100755 index 9dda35cc..00000000 --- a/source/mir/misc/Helper.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - -import java.io.IOException; - -import mir.config.MirPropertiesConfiguration; -import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; - -/** - * Title: Indy - * Description: This class provides some satic help methods - * Copyright: Copyright (c) 2001 - * Company: indymedia.de - * @author idfx - * @version 1.0 - */ - -public class Helper { - - /** - * rsync the webrepository - * needs a rsyncscript - * returns the exit-code - * returns 255 if rsync should not be used - */ - public static int rsync(){ - MirPropertiesConfiguration configuration = null; - try { - configuration = MirPropertiesConfiguration.instance(); - } catch (PropertiesConfigExc e) { - e.printStackTrace(); - return 255; - } - - if(!configuration.getString("Rsync").toLowerCase().equals("yes")){ - return 255; - } - - Process p; - int returnValue = -1; - try { - Runtime run = Runtime.getRuntime(); - p = run.exec(configuration.getString("Rsync.Script.Path")); - returnValue = p.waitFor(); - } catch (IOException e) { - return returnValue; - } catch (InterruptedException e) { - return returnValue; - } - return returnValue; - } -} diff --git a/source/mir/misc/ListOfFiles.java b/source/mir/misc/ListOfFiles.java deleted file mode 100755 index 35403e9a..00000000 --- a/source/mir/misc/ListOfFiles.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -/* taken largely from the java tutorial --- pretty much wholesale, - * except modified to take a list rather than an array --jd - */ - -package mir.misc; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.ListIterator; -import java.util.NoSuchElementException; - -public class ListOfFiles implements Enumeration { - - private LinkedList listOfFiles; - private ListIterator listOfFilesIterator; - - - public ListOfFiles(LinkedList listOfFiles) { - this.listOfFiles = listOfFiles; - this.listOfFilesIterator = listOfFiles.listIterator(); - } - - public boolean hasMoreElements() { - return listOfFilesIterator.hasNext(); - } - - public Object nextElement() { - InputStream in = null; - - if (!hasMoreElements()) - throw new NoSuchElementException("No more files."); - else { - String nextElement = (String) listOfFilesIterator.next(); - try { - in = new FileInputStream(nextElement); - } catch (FileNotFoundException e) { - System.err.println("ListOfFiles: Can't open " + nextElement); - } - } - return in; - } -} - - - - - diff --git a/source/mir/misc/WebdbMultipartRequest.java b/source/mir/misc/WebdbMultipartRequest.java deleted file mode 100755 index 4be6c031..00000000 --- a/source/mir/misc/WebdbMultipartRequest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mir.misc; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Map; -import java.util.Vector; - -import javax.servlet.http.HttpServletRequest; - -import mir.config.MirPropertiesConfiguration; -import mir.config.MirPropertiesConfiguration.PropertiesConfigExc; - -import com.oreilly.servlet.multipart.FilePart; -import com.oreilly.servlet.multipart.MultipartParser; -import com.oreilly.servlet.multipart.ParamPart; -import com.oreilly.servlet.multipart.Part; - -/** - * Title: - * Description: - * Copyright: Copyright (c) 2001 - * Company: Indymedia - * @author - * @version 1.0 - */ - -public class WebdbMultipartRequest -{ - HttpServletRequest req=null; - Hashtable parameters = new Hashtable(); - MultipartParser mp=null; - FileHandler _fHandler; - - public WebdbMultipartRequest(HttpServletRequest theReq, FileHandler handler) - throws FileHandler.FileHandlerExc, FileHandler.FileHandlerFailure, IOException, PropertiesConfigExc - { - req=theReq; - int maxSize; - try { - maxSize = MirPropertiesConfiguration.instance().getInt("MaxMediaUploadSize"); - } - catch (PropertiesConfigExc e) { - maxSize = 1024; - throw e; - } - mp = new MultipartParser(req, 1024*maxSize); - _fHandler = handler; - _evaluateRequest(); - } - - - /** - * The following comment and some code was adapted from the Oreilley cos.jar - * package. -mh 2001.09.20 - * - * Returns all the parameters as a Map of Strings, any parameter - * that sent without a value will be null. A value - * is guaranteed to be in its normal, decoded form. If A parameter - * has multiple values, only the last one is returned (for backward - * compatibility). For parameters with multiple values, it's possible - * the last "value" may be null. - * - * @return A Map of String representations of the parameter values. - */ - public Map getParameters(){ - Map pHash = new HashMap(); - String value = new String(); - - Enumeration Keys = parameters.keys(); - while(Keys.hasMoreElements()) { - String KeyNm = (String)Keys.nextElement(); - Vector values = (Vector)parameters.get(KeyNm); - - if (values == null || values.size() == 0) { - value = null; - } - else { - value = (String)values.elementAt(values.size() - 1); - } - - pHash.put(KeyNm, value); - } - - return pHash; - } - - /** - * The following code and comment stolen from oreilley cos.jar. - * -mh. 2001.09.20 - * - * Returns the values of the named parameter as a String array, or null if - * the parameter was not sent. The array has one entry for each parameter - * field sent. If any field was sent without a value that entry is stored - * in the array as a null. The values are guaranteed to be in their - * normal, decoded form. A single value is returned as a one-element array. - * - * @param name the parameter name. - * @return the parameter values. - */ - public String[] getParameterValues(String name) { - try { - Vector values = (Vector)parameters.get(name); - if (values == null || values.size() == 0) { - return null; - } - String[] valuesArray = new String[values.size()]; - values.copyInto(valuesArray); - return valuesArray; - } - catch (Exception e) { - return null; - } - } - - private void _evaluateRequest() throws FileHandler.FileHandlerExc, - FileHandler.FileHandlerFailure, IOException { - - Part part; - int i = 1; - while ((part = mp.readNextPart()) != null) { - String name = part.getName(); - if (part.isParam()) { - // It's a parameter part, add it to the vector of values - ParamPart paramPart = (ParamPart) part; - String value = paramPart.getStringValue(); - Vector existingValues = (Vector)parameters.get(name); - if (existingValues == null) { - existingValues = new Vector(); - parameters.put(name, existingValues); - } - existingValues.addElement(value); - } - else if (part.isFile()) { - // nur das erste uploadfile beruecksichtigen - FilePart filePart = (FilePart) part; - String fn = filePart.getFileName(); - if (filePart.getFileName() != null) { - if (_fHandler != null) - _fHandler.setFile(filePart, i, getParameters()); - i++; - } - } - } // while */ - } - -} diff --git a/source/mir/session/CommonsUploadedFileAdapter.java b/source/mir/session/CommonsUploadedFileAdapter.java index 869f7b3d..925e2d8c 100755 --- a/source/mir/session/CommonsUploadedFileAdapter.java +++ b/source/mir/session/CommonsUploadedFileAdapter.java @@ -31,8 +31,9 @@ package mir.session; -import org.apache.commons.fileupload.*; -import java.io.*; +import java.io.InputStream; + +import org.apache.commons.fileupload.FileItem; public class CommonsUploadedFileAdapter implements UploadedFile { private FileItem fileItem; diff --git a/source/mir/session/Request.java b/source/mir/session/Request.java index e0709bd9..16679f8b 100755 --- a/source/mir/session/Request.java +++ b/source/mir/session/Request.java @@ -31,7 +31,7 @@ package mir.session; -import java.util.*; +import java.util.List; public interface Request { public String getParameter(String aName); diff --git a/source/mir/session/SessionHandler.java b/source/mir/session/SessionHandler.java index 87b38013..a7ee1f78 100755 --- a/source/mir/session/SessionHandler.java +++ b/source/mir/session/SessionHandler.java @@ -1,3 +1,34 @@ +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + package mir.session; public interface SessionHandler { diff --git a/source/mir/session/SimpleResponse.java b/source/mir/session/SimpleResponse.java index 3dcadf51..85613f9f 100755 --- a/source/mir/session/SimpleResponse.java +++ b/source/mir/session/SimpleResponse.java @@ -1,32 +1,64 @@ -package mir.session; - -import java.util.*; - -public class SimpleResponse implements Response { - private String generator; - private Map values; - - public SimpleResponse() { - values = new HashMap(); - } - - public SimpleResponse(Map aMap) { - values = aMap; - } - - public void setResponseValue(String aName, Object aValue) { - values.put(aName, aValue); - } - - public Map getResponseValues() { - return values; - } - - public void setResponseGenerator(String aGenerator) { - generator = aGenerator; - } - - public String getResponseGenerator() { - return generator; - } +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mir.session; + +import java.util.HashMap; +import java.util.Map; + +public class SimpleResponse implements Response { + private String generator; + private Map values; + + public SimpleResponse() { + values = new HashMap(); + } + + public SimpleResponse(Map aMap) { + values = aMap; + } + + public void setResponseValue(String aName, Object aValue) { + values.put(aName, aValue); + } + + public Map getResponseValues() { + return values; + } + + public void setResponseGenerator(String aGenerator) { + generator = aGenerator; + } + + public String getResponseGenerator() { + return generator; + } } \ No newline at end of file diff --git a/source/mir/storage/store/test/TestStore.java b/source/mir/storage/store/test/TestStore.java index e9a1e4d1..d10f06be 100755 --- a/source/mir/storage/store/test/TestStore.java +++ b/source/mir/storage/store/test/TestStore.java @@ -42,7 +42,7 @@ package mir.storage.store.test; import mir.storage.store.ObjectStore; import mir.storage.store.StorableObject; -import mir.storage.store.*; +import mir.storage.store.StoreIdentifier; public class TestStore { diff --git a/source/mir/util/PropertiesManipulator.java b/source/mir/util/PropertiesManipulator.java index 194f31b6..daf90ecb 100755 --- a/source/mir/util/PropertiesManipulator.java +++ b/source/mir/util/PropertiesManipulator.java @@ -35,7 +35,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.io.OutputStream; -import java.io.*; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; import java.util.HashMap; import java.util.Iterator; import java.util.List; diff --git a/source/mircoders/global/Abuse.java b/source/mircoders/global/Abuse.java index b3e18550..f67524a6 100755 --- a/source/mircoders/global/Abuse.java +++ b/source/mircoders/global/Abuse.java @@ -31,33 +31,33 @@ package mircoders.global; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Vector; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.collections.ExtendedProperties; - -import gnu.regexp.RE; - -import mir.entity.Entity; -import mir.log.LoggerWrapper; -import mir.util.DateToMapAdapter; -import mir.util.InternetFunctions; -import mir.util.StringRoutines; -import mir.session.*; -import mircoders.entity.EntityComment; -import mircoders.entity.EntityContent; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Vector; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.collections.ExtendedProperties; +import gnu.regexp.RE; + +import mir.entity.Entity; +import mir.log.LoggerWrapper; +import mir.session.HTTPAdapters; +import mir.session.Request; +import mir.util.DateToMapAdapter; +import mir.util.InternetFunctions; +import mir.util.StringRoutines; +import mircoders.entity.EntityComment; +import mircoders.entity.EntityContent; import mircoders.localizer.MirAdminInterfaceLocalizer; diff --git a/source/mircoders/localizer/MirOpenPostingLocalizer.java b/source/mircoders/localizer/MirOpenPostingLocalizer.java index b3232751..6af0292f 100755 --- a/source/mircoders/localizer/MirOpenPostingLocalizer.java +++ b/source/mircoders/localizer/MirOpenPostingLocalizer.java @@ -31,13 +31,10 @@ package mircoders.localizer; -import java.util.Arrays; -import java.util.List; - -import mir.session.Request; -import mir.session.Response; -import mir.session.*; -import mircoders.entity.EntityComment; +import mir.session.Request; +import mir.session.Session; +import mir.session.SessionHandler; +import mircoders.entity.EntityComment; import mircoders.entity.EntityContent; public interface MirOpenPostingLocalizer { diff --git a/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java index 522f1165..0b687368 100755 --- a/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java +++ b/source/mircoders/localizer/basic/MirBasicCommentPostingSessionHandler.java @@ -31,18 +31,27 @@ package mircoders.localizer.basic; -import java.util.*; -import mir.log.LoggerWrapper; -import mir.session.*; -import mir.config.*; -import mir.util.*; -import mir.entity.*; -import mircoders.storage.*; -import mircoders.global.*; -import mircoders.localizer.*; -import mircoders.entity.*; -import mircoders.module.*; -import mircoders.media.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import mir.entity.Entity; +import mir.session.Request; +import mir.session.Response; +import mir.session.Session; +import mir.session.SessionExc; +import mir.session.SessionFailure; +import mir.session.UploadedFile; +import mir.util.ExceptionFunctions; +import mircoders.entity.EntityComment; +import mircoders.global.MirGlobal; +import mircoders.media.MediaUploadProcessor; +import mircoders.module.ModuleComment; +import mircoders.storage.DatabaseComment; +import mircoders.storage.DatabaseCommentToMedia; +import mircoders.storage.DatabaseContent; /** * diff --git a/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java b/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java index 67d5ca95..666bcf49 100755 --- a/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicGeneratorLocalizer.java @@ -34,7 +34,7 @@ package mircoders.localizer.basic; import mir.generator.FreemarkerGenerator; import mir.generator.Generator; import mir.generator.GeneratorLibraryRepository; -import mir.generator.*; +import mir.generator.WriterEngine; import mir.log.LoggerWrapper; import mircoders.global.MirGlobal; import mircoders.localizer.MirGeneratorLocalizer; diff --git a/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java new file mode 100755 index 00000000..245e6b3a --- /dev/null +++ b/source/mircoders/localizer/basic/MirBasicPostingSessionHandler.java @@ -0,0 +1,372 @@ +/* + * Copyright (C) 2001, 2002 The Mir-coders group + * + * This file is part of Mir. + * + * Mir is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Mir 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Mir; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, The Mir-coders gives permission to link + * the code of this program with the com.oreilly.servlet library, any library + * licensed under the Apache Software License, The Sun (tm) Java Advanced + * Imaging library (JAI), The Sun JIMI library (or with modified versions of + * the above that use the same license as the above), and distribute linked + * combinations including the two. You must obey the GNU General Public + * License in all respects for all of the code used other than the above + * mentioned libraries. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If you do + * not wish to do so, delete this exception statement from your version. + */ + +package mircoders.localizer.basic; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Vector; + +import mir.config.MirPropertiesConfiguration; +import mir.entity.Entity; +import mir.log.LoggerWrapper; +import mir.session.Request; +import mir.session.Response; +import mir.session.Session; +import mir.session.SessionExc; +import mir.session.SessionFailure; +import mir.session.SessionHandler; +import mir.session.UploadedFile; +import mir.storage.StorageObject; +import mir.util.ExceptionFunctions; +import mircoders.entity.EntityComment; +import mircoders.global.MirGlobal; +import mircoders.media.MediaUploadProcessor; +import mircoders.module.ModuleComment; +import mircoders.storage.DatabaseComment; +import mircoders.storage.DatabaseCommentToMedia; +import mircoders.storage.DatabaseContent; + +/** + * + *

Title: Experimental session handler for comment postings

+ *

Description:

+ *

Copyright: Copyright (c) 2003

+ *

Company:

+ * @author not attributable + * @version 1.0 + */ + +public class MirBasicPostingSessionHandler implements SessionHandler { + protected LoggerWrapper logger; + protected MirPropertiesConfiguration configuration; + protected ModuleComment commentModule; + protected DatabaseCommentToMedia commentToMedia = DatabaseCommentToMedia.getInstance(); + + public MirBasicPostingSessionHandler() { + logger = new LoggerWrapper("Localizer.OpenPosting"); + try { + configuration = MirPropertiesConfiguration.instance(); + } + catch (Throwable t) { + logger.fatal("Cannot load configuration: " + t.toString()); + + throw new RuntimeException("Cannot load configuration: " + t.toString()); + } + commentModule= new ModuleComment(DatabaseComment.getInstance()); + } + + public void processRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { + if (aSession.getAttribute("initialRequest")==null) { + initialRequest(aRequest, aSession, aResponse); + aSession.setAttribute("initialRequest", "no"); + } + else { + subsequentRequest(aRequest, aSession, aResponse); + } + }; + + protected Map getIntersectingValues(Request aRequest, StorageObject aStorage) throws SessionExc, SessionFailure { + Map result = new HashMap(); + + Iterator i = aStorage.getFields().iterator(); + + while (i.hasNext()) { + String fieldName = (String) i.next(); + Object value = aRequest.getParameter(fieldName); + if (value != null) + result.put(fieldName, value); + } + + return result; + } + + + protected String generateOnetimePassword() { + Random r = new Random(); + int random = r.nextInt(); + + long l = System.currentTimeMillis(); + + l = (l*l*l*l)/random; + if (l<0) + l = l * -1; + + String returnString = ""+l; + + return returnString.substring(5); + } + + protected void initializeResponseData(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { + if (MirGlobal.abuse().getOpenPostingPassword()) { + String password = (String) aSession.getAttribute("password"); + if (password==null) { + password = generateOnetimePassword(); + aSession.setAttribute("password", password); + } + aResponse.setResponseValue("password", password); + } + else { + aResponse.setResponseValue("password", null); + aSession.deleteAttribute("password"); + } + + aResponse.setResponseValue("errors", null); + }; + + protected void initialRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure{ + Iterator i = DatabaseComment.getInstance().getFields().iterator(); + while (i.hasNext()) { + aResponse.setResponseValue( (String) i.next(), null); + } + + String articleId = aRequest.getParameter("to_media"); + + if (articleId == null) + throw new SessionExc("MirBasicPostingSessionHandler.initialRequest: article id not set!"); + + aSession.setAttribute("to_media", articleId); + + initializeResponseData(aRequest, aSession, aResponse); + + try { + aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate")); + } + catch (Throwable e) { + throw new SessionFailure("Can't get configuration: " + e.getMessage(), e); + } + + } + + protected boolean testFieldEntered(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) { + Object value = aRequest.getParameter(aFieldName); + if (value==null || !(value instanceof String) || ((String) value).trim().length()==0) { + logger.debug(" missing field " + aFieldName + " value = " + value); + aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource)); + return false; + } + else + return true; + } + + protected boolean testFieldIsNumeric(Request aRequest, String aFieldName, String anErrorMessageResource, List aValidationResults) { + Object value = aRequest.getParameter(aFieldName); + if (value!=null) { + try { + Integer.parseInt((String) value); + return true; + } + catch (Throwable t) { + logger.debug(" field not numeric: " + aFieldName + " value = " + value); + aValidationResults.add(new ValidationError(aFieldName, anErrorMessageResource)); + return false; + } + } + return true; + } + + public void validate(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { + + } + + public List validate(Request aRequest, Session aSession) throws SessionExc, SessionFailure { + List result = new Vector(); + + testFieldEntered(aRequest, "title", "validationerror.missing", result); + testFieldEntered(aRequest, "description", "validationerror.missing", result); + testFieldEntered(aRequest, "creator", "validationerror.missing", result); + + return result; + } + + public void subsequentRequest(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { + try { + Map commentFields = new HashMap(); + + Iterator i = DatabaseContent.getInstance().getFields().iterator(); + while (i.hasNext()) { + String field = (String) i.next(); + aResponse.setResponseValue(field, aRequest.getParameter(field)); + if (aRequest.getParameter(field)!=null) { + commentFields.put(field, aRequest.getParameter(field)); + } + } + + initializeResponseData(aRequest, aSession, aResponse); + + List validationErrors = validate(aRequest, aSession); + + if (validationErrors != null && validationErrors.size()>0) { + returnValidationErrors(aRequest, aSession, aResponse, validationErrors); + } + else { +// finish(aRequest, aSession, aResponse); + + EntityComment comment = (EntityComment) commentModule.createNew (); +// comment.setValues(getIntersectingValues(aRequest, )); + + finishComment(aRequest, aSession, comment); + + String id = comment.insert(); + if(id==null){ + afterDuplicateCommentPosting(aRequest, aSession, aResponse, comment); + logger.info("Dupe comment rejected"); + aSession.terminate(); + } + else { + i = aRequest.getUploadedFiles().iterator(); + while (i.hasNext()) { + UploadedFile file = (UploadedFile) i.next(); + processMediaFile(aRequest, aSession, comment, file); + } + + afterCommentPosting(aRequest, aSession, aResponse, comment); + MirGlobal.abuse().checkComment(comment, aRequest, null); + MirGlobal.localizer().openPostings().afterCommentPosting(comment); + logger.info("Comment posted"); + aSession.terminate(); + } + } + } + catch (Throwable t) { + ExceptionFunctions.traceCauseException(t).printStackTrace(); + + throw new SessionFailure("MirBasicPostingSessionHandler.subsequentRequest: " + t.getMessage(), t); + } + } + + public void initializeCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionFailure, SessionExc { + String articleId = aRequest.getParameter("to_media"); + if (articleId==null) + articleId = aRequest.getParameter("aid"); + + if (articleId==null) + throw new SessionExc("initializeCommentPosting: article id not set!"); + + aSession.setAttribute("to_media", articleId); + processCommentPosting(aRequest, aSession, aResponse); + }; + + public void returnValidationErrors(Request aRequest, Session aSession, Response aResponse, List aValidationErrors) throws SessionFailure, SessionExc { + aResponse.setResponseValue("errors", aValidationErrors); + aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate")); + }; + + public void processCommentPosting(Request aRequest, Session aSession, Response aResponse) throws SessionExc, SessionFailure { + if (MirGlobal.abuse().getOpenPostingPassword()) { + String password = generateOnetimePassword(); + aSession.setAttribute("password", password); + aResponse.setResponseValue("password", password); + aResponse.setResponseValue("passwd", password); + } + else { + aResponse.setResponseValue("password", null); + } + + aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.EditTemplate")); + }; + + public void processMediaFile(Request aRequest, Session aSession, EntityComment aComment, UploadedFile aFile) throws SessionExc, SessionFailure { + try { + Entity mediaItem = MediaUploadProcessor.processMediaUpload(aFile, new HashMap()); + finishMedia(aRequest, aSession, aFile, mediaItem); + mediaItem.update(); + commentToMedia.addMedia(aComment.getId(), mediaItem.getId()); + } + catch (Throwable t) { + throw new SessionFailure(t); + } + } + + public void finishMedia(Request aRequest, Session aSession, UploadedFile aFile, Entity aMedia) throws SessionExc, SessionFailure { + } + + public void finishComment(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure { + if (aSession.getAttribute("to_media") == null) + throw new SessionExc("missing to_media"); + + aComment.setValueForProperty("is_published", "1"); + aComment.setValueForProperty("to_comment_status", "1"); + aComment.setValueForProperty("is_html","0"); + aComment.setValueForProperty("to_media", (String) aSession.getAttribute("to_media")); + }; + + public void addMedia(Request aRequest, Session aSession, EntityComment aComment) throws SessionExc, SessionFailure { + } + + public void afterCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) { + DatabaseContent.getInstance().setUnproduced("id=" + aComment.getValue("to_media")); + aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DoneTemplate")); + }; + + public void afterDuplicateCommentPosting(Request aRequest, Session aSession, Response aResponse, EntityComment aComment) { + aResponse.setResponseGenerator(configuration.getString("Localizer.OpenSession.comment.DupeTemplate")); + }; + + public class ValidationError { + private String field; + private String message; + private List parameters; + + public ValidationError(String aField, String aMessage) { + this (aField, aMessage, new String[] {}); + } + + public ValidationError(String aField, String aMessage, Object aParameter) { + this (aField, aMessage, new Object[] {aParameter}); + } + + public ValidationError(String aField, String aMessage, Object[] aParameters) { + field = aField; + message = aMessage; + parameters = Arrays.asList(aParameters); + } + + public String getMessage() { + return message; + } + + public String getField() { + return field; + } + + public List getParameters() { + return parameters; + } + } + + + +} diff --git a/source/mircoders/media/MediaRequest.java b/source/mircoders/media/MediaRequest.java deleted file mode 100755 index 473051cb..00000000 --- a/source/mircoders/media/MediaRequest.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright (C) 2001, 2002 The Mir-coders group - * - * This file is part of Mir. - * - * Mir is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Mir 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Mir; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with the com.oreilly.servlet library, any library - * licensed under the Apache Software License, The Sun (tm) Java Advanced - * Imaging library (JAI), The Sun JIMI library (or with modified versions of - * the above that use the same license as the above), and distribute linked - * combinations including the two. You must obey the GNU General Public - * License in all respects for all of the code used other than the above - * mentioned libraries. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If you do - * not wish to do so, delete this exception statement from your version. - */ - -package mircoders.media; - -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.Map; - -import javax.servlet.ServletContext; - -import mir.config.MirPropertiesConfiguration; -import mir.entity.Entity; -import mir.entity.EntityList; -import mir.log.LoggerWrapper; -import mir.media.MediaHelper; -import mir.media.MirMedia; -import mir.misc.FileHandler; -import mir.misc.StringUtil; -import mir.storage.Database; -import mir.storage.StorageObjectFailure; -import mircoders.storage.DatabaseMediaType; - -import com.oreilly.servlet.multipart.FilePart; - - -/* - * MediaRequest.java - - * Takes an HTTPServletRequest from a mutltipart form and finds the files - * uploaded via the com.oreilly.servlet.multipart package. Finally the - * appropriate media objects are set. - * - * @author mh - * @version $Id: MediaRequest.java,v 1.18 2003/03/09 19:14:21 idfx Exp $ - * - */ - -public class MediaRequest implements FileHandler -{ - private String _user; - private EntityList _returnList = new EntityList(); - private boolean _publish; - private LoggerWrapper logger; - - public MediaRequest(String user, boolean publish) { - _user = user; - _publish = publish; - logger = new LoggerWrapper("Media.Request"); - } - - public EntityList getEntityList() { - return _returnList; - } - - /* - * parses the files in the uploaded media and creates media Entity's out of - * them. Produces them if the "produce" argument is true. The "publish" - * parameter determines if it should publish per default in the case where no - * is_published parameter (from the upload form) is supplied. (for backwards - * compatibility.) - */ - public void setFile(FilePart filePart, int fileNum, Map mediaValues) throws FileHandlerExc, FileHandlerFailure { - - String mediaId=null; - MirMedia mediaHandler; - Database mediaStorage = null; - - try { - String fileName = filePart.getFileName(); - - //get the content-type from what the client browser - //sends us. (the "Oreilly method") - String contentType = filePart.getContentType(); - - //theLog.printInfo("FROM BROWSER: "+contentType); - - //if the client browser sent us unknown (text/plain is default) - //or if we got application/octet-stream, it's possible that - //the browser is in error, better check against the file extension - if (contentType.equals("text/plain") || - contentType.equals("application/octet-stream")) { - /** - * Fallback to finding the mime-type through the standard ServletApi - * ServletContext getMimeType() method. - * - * This is a way to get the content-type via the .extension, - * we could maybe use a magic method as an additional method of - * figuring out the content-type, by looking at the header (first - * few bytes) of the file. (like the file(1) command). We could - * also call the "file" command through Runtime. This is an - * option that I almost prefer as it is already implemented and - * exists with an up-to-date map on most modern Unix like systems. - * I haven't found a really nice implementation of the magic method - * in pure java yet. - * - * The first method we try thought is the "Oreilly method". It - * relies on the content-type that the client browser sends and - * that sometimes is application-octet stream with - * broken/mis-configured browsers. - * - * The map file we use for the extensions is the standard web-app - * deployment descriptor file (web.xml). See Mir's web.xml or see - * your Servlet containers (most likely Tomcat) documentation. - * So if you support a new media type you have to make sure that - * it is in this file -mh - */ - ServletContext ctx = MirPropertiesConfiguration.getContext(); - contentType = ctx.getMimeType(fileName); - if (contentType==null) - contentType = "text/plain"; // rfc1867 says this is the default - } - //theLog.printInfo("CONTENT TYPE IS: "+contentType); - - if (contentType.equals("text/plain") || - contentType.equals("application/octet-stream")) { - _throwBadContentType(fileName, contentType); - } - - // call the routines that escape html - for (Iterator i=mediaValues.keySet().iterator(); i.hasNext(); ){ - String k=(String)i.next(); - String v=(String)mediaValues.get(k); - - if (k.equals("description")) { - String tmp = StringUtil.deleteForbiddenTags(v); - mediaValues.put(k,StringUtil.deleteHTMLTableTags(tmp)); - } else { - //we don't want people fucking with the author/title, etc.. - mediaValues.put(k,StringUtil.removeHTMLTags(v)); - } - - } - - String mediaTitle = (String)mediaValues.get("media_title"+fileNum); - if ( (mediaTitle == null) || (mediaTitle.length() == 0)) { - // uncomment the next line and comment out the exception throw - // if you'd rather just assign missing media titles automatically - // mediaTitle="media item "+fileNum; -// throw new FileHandlerUserException("Missing field: media title "+mediaTitle+fileNum); - } - - // TODO: need to add all the extra fields that can be present in the - // admin upload form. -mh - mediaValues.put("title", mediaTitle); - mediaValues.put("date", StringUtil.date2webdbDate( - new GregorianCalendar())); - mediaValues.put("to_publisher", _user); - //mediaValues.put("to_media_folder", "7"); // op media_folder - mediaValues.put("is_produced", "0"); - - // icky backwards compatibility code -mh - if (_publish == true) { - mediaValues.put("is_published", "1"); - } else { - if (!mediaValues.containsKey("is_published")) - mediaValues.put("is_published", "0"); - } - - // @todo this should probably be moved to DatabaseMediaType -mh - String[] cTypeSplit = StringUtil.split(contentType, "/"); - String wc = " mime_type LIKE '"+cTypeSplit[0]+"%'"; - - DatabaseMediaType mediaTypeStor = DatabaseMediaType.getInstance(); - EntityList mediaTypesList = mediaTypeStor.selectByWhereClause(wc); - - String mediaTypeId = null; - - //if we didn't find an entry matching the - //content-type int the table. - if (mediaTypesList.size() == 0) { - _throwBadContentType(fileName, contentType); - } - - Entity mediaType = null; - Entity mediaType2 = null; - - // find out if we an exact content-type match if so take it. - // otherwise try to match majortype/* - // @todo this should probably be moved to DatabaseMediaType -mh - for(int j=0;j Integer.parseInt(maxMedia)) { - numOfMedia = maxMedia; - } - - int mediaNum = Integer.parseInt(numOfMedia); - SimpleList mediaFields = new SimpleList(); - for(int i =0; i Integer.parseInt(maxMedia)) { + numOfMedia = maxMedia; + } + + int mediaNum = Integer.parseInt(numOfMedia); + SimpleList mediaFields = new SimpleList(); + for(int i =0; i -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -    - - ${lang("media.created")}: ${data.webdb_create} - / ${lang("media.changed")} ${data.webdb_lastchange}
- ${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}
- ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}
- ${lang("media.size")}: ${data.human_readable_size}
- ${lang("media.rights")}: ${data.rightsHashdata[to_rights]["name"]}
-
- ${lang("media.mediafolder")}: - - -
 
- ${lang("media.is_published")} : - - checked> -
 
- ${lang("media.title")}: - - -
-   - -
-
- ${lang("media.title")}: - - -
- - - - ${lang("media.is_published")} checked> -    - -
- -

[<] ${lang("list")}  

- - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +    + + ${lang("media.created")}: ${data.webdb_create} + / ${lang("media.changed")} ${data.webdb_lastchange}
+ ${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}
+ ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}
+ ${lang("media.size")}: ${data.human_readable_size}
+ ${lang("media.rights")}: ${data.rightsHashdata[to_rights]["name"]}
+
+ ${lang("media.mediafolder")}: + + +
 
+ ${lang("media.is_published")} : + + checked> +
 
+ ${lang("media.title")}: + + +
+   + +
+
+ + + + ${lang("media.is_published")} checked> +    + +
+
+ +

[<] ${lang("list")}  

+ + + diff --git a/templates/admin/image.template b/templates/admin/image.template index 872fc1ed..e4a40605 100755 --- a/templates/admin/image.template +++ b/templates/admin/image.template @@ -85,14 +85,14 @@ function openWin(url) { - - + + + + - - - - + +   @@ -123,19 +123,10 @@ function openWin(url) {   -
+
- - - - ${lang("media.title")}: - - - - - diff --git a/templates/admin/media.template b/templates/admin/media.template index bcb86c07..897f852a 100755 --- a/templates/admin/media.template +++ b/templates/admin/media.template @@ -82,14 +82,14 @@ function openWin(url) { - - - - - - - - + + + + + + + +   @@ -119,19 +119,10 @@ function openWin(url) {   -
+
- - - - ${lang("media.title")}: - - - - - diff --git a/templates/admin/video.template b/templates/admin/video.template index 7728b221..126bdf5b 100755 --- a/templates/admin/video.template +++ b/templates/admin/video.template @@ -35,116 +35,108 @@ function openWin(url) { -
- - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - -
- -    - - ${lang("media.created")}: ${data.webdb_create} - / ${lang("media.changed")} ${data.webdb_lastchange}
- ${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}
- ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}
- ${lang("media.size")}: ${data.human_readable_size}
- ${lang("media.rights")}: ${data.rightsHashdata[to_rights]["name"]}
-
- ${lang("media.mediafolder")}: - - -
 
- ${lang("media.is_published")} : - - checked> -
 
- ${lang("media.title")}: - - -
-   - -
-
- ${lang("media.title")}: - - -
- - - - ${lang("media.is_published")} checked> -    - -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +    + + ${lang("media.created")}: ${data.webdb_create} + / ${lang("media.changed")} ${data.webdb_lastchange}
+ ${lang("media.published")}: ${data.publish_date} / ${data.publish_server}${data.publish_path}
+ ${lang("media.format")}: ${data.mimetype} / ${data.media_descr}
+ ${lang("media.size")}: ${data.human_readable_size}
+ ${lang("media.rights")}: ${data.rightsHashdata[to_rights]["name"]}
+
+ ${lang("media.mediafolder")}: + + +
 
+ ${lang("media.is_published")} : + + checked> +
 
+ ${lang("media.title")}: + + +
+   + +
+
+ + + + ${lang("media.is_published")} checked> +    + +
+ -

[<] ${lang("list")}  

+

[<] ${lang("list")}  

- + - +