-import freemarker.template.SimpleHash;\r
-import freemarker.template.SimpleList;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateModel;\r
-\r
-import mir.config.MirPropertiesConfiguration;\r
-\r
-import mir.generator.FreemarkerGenerator;\r
-\r
-import mir.misc.HTMLTemplateProcessor;\r
-import mir.misc.StringUtil;\r
-\r
-import mir.servlet.AbstractServlet;\r
-import mir.servlet.ServletModule;\r
-import mir.servlet.ServletModuleDispatch;\r
-import mir.servlet.ServletModuleException;\r
-import mir.servlet.ServletModuleUserException;\r
-\r
-import mir.util.StringRoutines;\r
-\r
-import mircoders.entity.EntityUsers;\r
-\r
-import mircoders.global.MirGlobal;\r
-\r
-import mircoders.module.ModuleMessage;\r
-import mircoders.module.ModuleUsers;\r
-\r
-import mircoders.storage.DatabaseArticleType;\r
-import mircoders.storage.DatabaseMessages;\r
-import mircoders.storage.DatabaseUsers;\r
-\r
-import org.apache.struts.util.MessageResources;\r
-\r
/*\r
* Copyright (C) 2001, 2002 The Mir-coders group\r
*\r
* to your version of the file, but you are not obligated to do so. If you do\r
* not wish to do so, delete this exception statement from your version.\r
*/\r
+\r
import java.io.IOException;\r
import java.io.PrintWriter;\r
\r
import javax.servlet.http.HttpServletResponse;\r
import javax.servlet.http.HttpSession;\r
\r
+import org.apache.struts.util.MessageResources;\r
+\r
+\r
+import freemarker.template.SimpleHash;\r
+import freemarker.template.SimpleList;\r
+import freemarker.template.SimpleScalar;\r
+import freemarker.template.TemplateModel;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.generator.FreemarkerGenerator;\r
+import mir.misc.HTMLTemplateProcessor;\r
+import mir.misc.StringUtil;\r
+import mir.servlet.AbstractServlet;\r
+import mir.servlet.ServletModule;\r
+import mir.servlet.ServletModuleDispatch;\r
+import mir.servlet.ServletModuleException;\r
+import mir.servlet.ServletModuleUserException;\r
+import mir.util.StringRoutines;\r
+\r
+import mircoders.entity.EntityUsers;\r
+import mircoders.global.MirGlobal;\r
+import mircoders.module.ModuleMessage;\r
+import mircoders.module.ModuleUsers;\r
+import mircoders.storage.DatabaseArticleType;\r
+import mircoders.storage.DatabaseMessages;\r
+import mircoders.storage.DatabaseUsers;\r
+\r
+\r
\r
/**\r
* Mir.java - main servlet, that dispatches to servletmodules\r
*\r
- * @author $Author: idfx $\r
- * @version $Id: Mir.java,v 1.28 2003/01/28 23:37:08 idfx Exp $\r
+ * @author $Author: zapata $\r
+ * @version $Id: Mir.java,v 1.29 2003/02/23 05:00:10 zapata Exp $\r
*\r
*/\r
public class Mir extends AbstractServlet {\r
private static ModuleMessage messageModule = null;\r
private final static HashMap servletModuleInstanceHash = new HashMap();\r
\r
- //I don't know about making this static cause it removes the \r
+ //I don't know about making this static cause it removes the\r
//possibility to change the config on the fly.. -mh\r
private static List loginLanguages = null;\r
public HttpSession session;\r
}\r
}\r
\r
- // FIXME: this should probalby go into AbstractServlet so it can be used in \r
+ // FIXME: this should probalby go into AbstractServlet so it can be used in\r
// OpenMir as well -mh\r
protected String getDefaultLanguage(HttpServletRequest req) {\r
String defaultlanguage =\r
//make sure client browsers don't cache anything\r
setNoCaching(res);\r
\r
- //FIXME: this seems kind of hackish and only here because we can have \r
+ //FIXME: this seems kind of hackish and only here because we can have\r
// default other than the one that the browser is set to.\r
Locale locale = new Locale(getDefaultLanguage(req), "");\r
MessageResources messageResources =\r
MirPropertiesConfiguration.instance().getString("Mir.ErrorTemplate"),\r
modelRoot, out, getLocale(req));\r
out.close();\r
- } catch (Exception e) {\r
- e.printStackTrace(System.out);\r
- System.err.println("Error in ErrorTemplate: " + e.getMessage());\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("Error in ErrorTemplate: " + e.getMessage());\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
}\r
}\r
\r
MirPropertiesConfiguration.instance().getString("Mir.UserErrorTemplate"),\r
modelRoot, out, getLocale(req));\r
out.close();\r
- } catch (Exception e) {\r
- System.err.println("Error in UserErrorTemplate");\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("Error in UserErrorTemplate");\r
}\r
}\r
\r
\r
HTMLTemplateProcessor.process(res, startTemplate, mergeData, out,\r
getLocale(req));\r
- } catch (Exception e) {\r
- e.printStackTrace(System.out);\r
- handleError(req, res, out,\r
- "error while trying to send startpage. " + e.getMessage());\r
+ }\r
+ catch (Exception e) {\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+ handleError(req, res, out, "error while trying to send startpage. " + e.getMessage());\r
}\r
}\r
\r
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleScalar;
+
import mir.config.MirPropertiesConfiguration;
import mir.misc.HTMLTemplateProcessor;
import mir.misc.StringUtil;
import mir.servlet.ServletModuleException;
import mir.servlet.ServletModuleUserException;
import mircoders.servlet.ServletModuleOpenIndy;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleScalar;
/**
* OpenMir.java - main servlet for open posting and comment feature to articles
*
* @author RK 1999-2001, the mir-coders group
- * @version $Id: OpenMir.java,v 1.19 2003/01/25 17:50:34 idfx Exp $
+ * @version $Id: OpenMir.java,v 1.20 2003/02/23 05:00:10 zapata Exp $
*
*/
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
- long startTime = (new java.util.Date()).getTime();
- long sessionConnectTime=0;
-
+ long startTime = System.currentTimeMillis();
+ long sessionConnectTime=0;
+
session = req.getSession();
if(session.getAttribute("Language")==null){
handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.getMessage());
}
// timing...
- sessionConnectTime = new java.util.Date().getTime() - startTime;
+ sessionConnectTime = System.currentTimeMillis() - startTime;
logger.debug("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
}
out.close();
}
catch (Exception e) {
- System.err.println("Error in UserErrorTemplate");
+ logger.error("Error in UserErrorTemplate");
}
}
out.close();
}
catch (Exception e) {
- System.err.println("Error in ErrorTemplate");
+ logger.error("Error in ErrorTemplate");
}
}
+++ /dev/null
-/*
- * 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.config;
-
-import mir.config.exceptions.ConfigFailure;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-
-public class ConfigChecker {
- public final static int STRING = 0;
- public final static int INTEGER = 1;
- public final static int BOOLEAN = 2;
- public final static int DOUBLE = 3;
- public final static int PATH = 4;
-
- // public final static int ABSOLUTEPATH = 5;
- // public final static int ABSOLUTEURL = 6;
- private Node rootNode;
-
- public ConfigChecker() {
- super();
-
- rootNode = new Node();
- }
-
- public Node getRootNode() {
- return rootNode;
- }
-
- public void check(ConfigNode aNode) throws ConfigFailure {
- getRootNode().check(aNode);
- }
-
- public class Node {
- private Map subNodes;
- private Vector constraints;
-
- public Node() {
- subNodes = new HashMap();
- constraints = new Vector();
- }
-
- public Node getSubNode(String aName) {
- Node subNode = (Node) subNodes.get(aName);
-
- if (subNode == null) {
- subNode = new Node();
- subNodes.put(aName, subNode);
- }
-
- return subNode;
- }
-
- public void addExistenceConstraint(String aPropertyName) {
- constraints.add(new ExistenceConstraint(aPropertyName));
- }
-
- public void addTypeConstraint(String aPropertyName, int aType) {
- constraints.add(new TypeConstraint(aPropertyName, aType));
- }
-
- public void addExistenceAndTypeConstraint(String aPropertyName, int aType) {
- addExistenceConstraint(aPropertyName);
- addTypeConstraint(aPropertyName, aType);
- }
-
- public void check(ConfigNode aNode) throws ConfigFailure {
- Iterator iterator;
-
- iterator = constraints.iterator();
-
- while (iterator.hasNext()) {
- ((Constraint) iterator.next()).check(aNode);
- }
-
- iterator = subNodes.keySet().iterator();
-
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- ((Node) entry.getValue()).check(aNode.getSubNode(
- (String) entry.getKey()));
- }
- }
-
- private class Constraint {
- protected String propertyName;
-
- Constraint(String aPropertyName) {
- propertyName = aPropertyName;
- }
-
- public void check(ConfigNode aNode) throws ConfigFailure {
- }
- }
-
- private class ExistenceConstraint extends Constraint {
- ExistenceConstraint(String aPropertyName) {
- super(aPropertyName);
- }
-
- public void check(ConfigNode aNode) throws ConfigFailure {
- aNode.getRequiredStringProperty(propertyName);
- }
- }
-
- private class TypeConstraint extends Constraint {
- private int type;
-
- TypeConstraint(String aPropertyName, int aType) {
- super(aPropertyName);
-
- type = aType;
- }
-
- public void check(ConfigNode aNode) throws ConfigFailure {
- switch (type) {
- case INTEGER:
- aNode.getOptionalIntegerProperty(propertyName, new Integer(0));
-
- break;
-
- case STRING:
- aNode.getOptionalStringProperty(propertyName, "");
-
- break;
-
- case DOUBLE:
- aNode.getOptionalDoubleProperty(propertyName, new Double(0.0));
-
- break;
-
- case BOOLEAN:
- aNode.getOptionalBooleanProperty(propertyName, Boolean.FALSE);
-
- break;
-
- default:
- throw new ConfigFailure("Invalid value for type in type constraint: " +
- new Integer(type).toString());
- }
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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.config;
-
-import mir.config.exceptions.ConfigFailure;
-
-
-public interface ConfigNode {
- public String getLocationDescription();
-
- public ConfigNode getSubNode(String aSubNodeName);
-
- public Boolean getRequiredBooleanProperty(String aPropertyName)
- throws ConfigFailure;
-
- public Integer getRequiredIntegerProperty(String aPropertyName)
- throws ConfigFailure;
-
- public String getRequiredStringProperty(String aPropertyName)
- throws ConfigFailure;
-
- public Double getRequiredDoubleProperty(String aPropertyName)
- throws ConfigFailure;
-
- public Boolean getOptionalBooleanProperty(String aPropertyName,
- Boolean aDefaultValue) throws ConfigFailure;
-
- public Integer getOptionalIntegerProperty(String aPropertyName,
- Integer aDefaultValue) throws ConfigFailure;
-
- public String getOptionalStringProperty(String aPropertyName,
- String aDefaultValue) throws ConfigFailure;
-
- public Double getOptionalDoubleProperty(String aPropertyName,
- Double aDefaultValue) throws ConfigFailure;
-}
+++ /dev/null
-/*
- * 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.config;
-
-public interface ConfigNodeBuilder {
- public ConfigNodeBuilder makeSubNode(String aName, String aLocationDescription);
-
- public void addProperty(String aName, String aValue,
- String aValueDescription, String aLocationDescription);
-}
+++ /dev/null
-/*
- * 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.config;
-
-import mir.config.exceptions.ConfigDefineNotKnownException;
-import mir.config.exceptions.ConfigFailure;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-
-public class ConfigReader {
- final static String propertyTagName = "property";
- final static String propertyNameAttribute = "name";
- final static String propertyValueAttribute = "value";
- final static String defineTagName = "define";
- final static String defineNameAttribute = "name";
- final static String defineValueAttribute = "value";
- final static String includeTagName = "include";
- final static String includeFileAttribute = "file";
-
- public ConfigReader() {
- super();
- }
-
- public void parseFile(String aFileName, ConfigNodeBuilder aRootNode)
- throws ConfigFailure {
- try {
- SAXParserFactory parserFactory = SAXParserFactory.newInstance();
-
- parserFactory.setNamespaceAware(false);
- parserFactory.setValidating(true);
-
- ConfigReaderHandler handler =
- new ConfigReaderHandler(aRootNode, parserFactory);
-
- handler.includeFile(aFileName);
- } catch (Throwable e) {
- if (e instanceof SAXParseException &&
- ((SAXParseException) e).getException() instanceof ConfigFailure) {
- throw (ConfigFailure) ((SAXParseException) e).getException();
- } else {
- e.printStackTrace();
- throw new ConfigFailure(e.getMessage());
- }
- }
- }
-
- private class ConfigReaderHandler extends DefaultHandler {
- ConfigNodeBuilder builder;
- Stack nodeStack;
- Locator locator;
- DefinesManager definesManager;
- int level;
- Stack includeFileStack;
- SAXParserFactory parserFactory;
-
- public ConfigReaderHandler(ConfigNodeBuilder aBuilder,
- SAXParserFactory aParserFactory) {
- super();
-
- builder = aBuilder;
- nodeStack = new Stack();
- includeFileStack = new Stack();
- definesManager = new DefinesManager();
- parserFactory = aParserFactory;
- level = 0;
- }
-
- public String getLocatorDescription(Locator aLocator) {
- return aLocator.getPublicId() + " (" + aLocator.getLineNumber() + ")";
- }
-
- public void setDocumentLocator(Locator aLocator) {
- locator = aLocator;
- }
-
- private void includeFile(String aFileName)
- throws ConfigFailure, SAXParseException, SAXException {
- File file;
- SAXParser parser;
- InputSource inputSource;
- System.err.println("about to include " + aFileName);
-
- try {
- if (!includeFileStack.empty()) {
- file =
- new File(new File((String) includeFileStack.peek()).getParent(),
- aFileName);
- } else {
- file = new File(aFileName);
- }
-
- System.err.println("about to include " + file.getCanonicalPath());
-
- if (includeFileStack.contains(file.getCanonicalPath())) {
- throw new ConfigFailure("recursive inclusion of file " +
- file.getCanonicalPath(), getLocatorDescription(locator));
- }
-
- parser = parserFactory.newSAXParser();
-
- inputSource = new InputSource(new FileInputStream(file));
- inputSource.setPublicId(file.getCanonicalPath());
-
- includeFileStack.push(file.getCanonicalPath());
-
- try {
- parser.parse(inputSource, this);
- } finally {
- includeFileStack.pop();
- }
- } catch (ParserConfigurationException e) {
- throw new ConfigFailure("Internal exception while including \"" +
- aFileName + "\": " + e.getMessage(), e, getLocatorDescription(locator));
- } catch (SAXParseException e) {
- throw e;
- } catch (ConfigFailure e) {
- throw e;
- } catch (FileNotFoundException e) {
- throw new ConfigFailure("Include file \"" + aFileName +
- "\" not found: " + e.getMessage(), e, getLocatorDescription(locator));
- } catch (IOException e) {
- throw new ConfigFailure("unable to open include file \"" + aFileName +
- "\": " + e.getMessage(), e, getLocatorDescription(locator));
- }
- }
-
- public void startElement(String aUri, String aTag, String aQualifiedName,
- Attributes anAttributes) throws SAXException {
- nodeStack.push(builder);
- level++;
-
- try {
- if (builder == null) {
- throw new ConfigFailure("define, include and property tags cannot have content",
- getLocatorDescription(locator));
- }
-
- if (aQualifiedName.equals(propertyTagName)) {
- String name = anAttributes.getValue(propertyNameAttribute);
- String value = anAttributes.getValue(propertyValueAttribute);
-
- if (name == null) {
- throw new ConfigFailure("property has no name attribute",
- getLocatorDescription(locator));
- } else if (value == null) {
- throw new ConfigFailure("property \"" + name +
- "\" has no value attribute", getLocatorDescription(locator));
- }
-
- builder.addProperty(name,
- definesManager.resolve(value, getLocatorDescription(locator)),
- value, getLocatorDescription(locator));
- builder = null;
- } else if (aQualifiedName.equals(defineTagName)) {
- String name = anAttributes.getValue(defineNameAttribute);
- String value = anAttributes.getValue(defineValueAttribute);
-
- if (name == null) {
- throw new ConfigFailure("define has no name attribute",
- getLocatorDescription(locator));
- } else if (value == null) {
- throw new ConfigFailure("define \"" + name +
- "\" has no value attribute", getLocatorDescription(locator));
- }
-
- definesManager.addDefine(name,
- definesManager.resolve(value, getLocatorDescription(locator)));
- builder = null;
- } else if (aQualifiedName.equals(includeTagName)) {
- String fileName = anAttributes.getValue(includeFileAttribute);
-
- if (fileName == null) {
- throw new ConfigFailure("include has no file attribute",
- getLocatorDescription(locator));
- }
-
- includeFile(definesManager.resolve(fileName,
- getLocatorDescription(locator)));
- builder = null;
- } else {
- builder =
- builder.makeSubNode(aQualifiedName, getLocatorDescription(locator));
- }
- } catch (ConfigFailure e) {
- throw new SAXParseException(e.getMessage(), locator, e);
- }
- }
-
- public void endElement(String aUri, String aTag, String aQualifiedName)
- throws SAXParseException {
- builder = (ConfigNodeBuilder) nodeStack.pop();
- level--;
- }
-
- public void characters(char[] aBuffer, int aStart, int anEnd)
- throws SAXParseException {
- String text = new String(aBuffer, aStart, anEnd).trim();
-
- if (text.length() > 0) {
- throw new SAXParseException("Text not allowed", locator,
- new ConfigFailure("text not allowed", getLocatorDescription(locator)));
- }
- }
- }
-
- private class DefinesManager {
- Map defines;
-
- public DefinesManager() {
- defines = new HashMap();
- }
-
- public void addDefine(String aName, String anExpression) {
- defines.put(aName, anExpression);
- }
-
- public String resolve(String anExpression, String aLocation)
- throws ConfigFailure {
- int previousPosition = 0;
- int position;
- int endOfNamePosition;
- String name;
-
- StringBuffer result = new StringBuffer();
-
- while ((position = anExpression.indexOf("$", previousPosition)) >= 0) {
- result.append(anExpression.substring(previousPosition, position));
-
- if (position >= (anExpression.length() - 1)) {
- result.append(anExpression.substring(position, anExpression.length()));
- previousPosition = anExpression.length();
- } else {
- if (anExpression.charAt(position + 1) == '{') {
- endOfNamePosition = anExpression.indexOf('}', position);
-
- if (endOfNamePosition >= 0) {
- name = anExpression.substring(position + 2, endOfNamePosition);
-
- if (defines.containsKey(name)) {
- result.append((String) defines.get(name));
- previousPosition = endOfNamePosition + 1;
- } else {
- throw new ConfigDefineNotKnownException("Variable \"" + name +
- "\" not defined", aLocation);
- }
- } else {
- throw new ConfigFailure("Missing }", aLocation);
- }
- } else {
- previousPosition = position + 2;
- result.append(anExpression.charAt(position + 1));
- }
- }
- }
-
- result.append(anExpression.substring(previousPosition,
- anExpression.length()));
-
- return result.toString();
- }
- }
-}
+++ /dev/null
-/*
- * 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.config;
-
-import mir.config.exceptions.ConfigInvalidPropertyTypeException;
-import mir.config.exceptions.ConfigMissingPropertyException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class ConfigSimpleNode implements ConfigNode, ConfigNodeBuilder {
- private Map properties;
- private Map subNodes;
- private String locationDescription;
- private String path;
-
- public ConfigSimpleNode() {
- this("", "");
- }
-
- public ConfigSimpleNode(String aLocationDescription) {
- this("", aLocationDescription);
- }
-
- public ConfigSimpleNode(String aPath, String aLocationDescription) {
- super();
-
- path = aPath;
- locationDescription = aLocationDescription;
- properties = new HashMap();
- subNodes = new HashMap();
- }
-
- // ConfigNodeBuilder helpers:
- private String makeSubNodePath(String aSubNode) {
- if ((path != null) && (path.length() > 0)) {
- return path + "/" + aSubNode;
- } else {
- return aSubNode;
- }
- }
-
- private String makePropertyPath(String aProperty) {
- if ((path != null) && (path.length() > 0)) {
- return path + "/" + aProperty;
- } else {
- return aProperty;
- }
- }
-
- public ConfigNodeBuilder mimicSubNode(String aName,
- String aLocationDescription) {
- ConfigNodeBuilder result =
- new ConfigSimpleNode(makeSubNodePath(aName), aLocationDescription);
-
- return result;
- }
-
- // ConfigNodeBuilder methods:
- public ConfigNodeBuilder makeSubNode(String aName, String aLocationDescription) {
- if (subNodes.containsKey(aName)) {
- return (ConfigNodeBuilder) subNodes.get(aName);
- } else {
- ConfigNodeBuilder result = mimicSubNode(aName, aLocationDescription);
- subNodes.put(aName, result);
-
- return result;
- }
- }
-
- public void addProperty(String aName, String aValue,
- String anUnexpandedValue, String aLocationDescription) {
- properties.put(aName,
- new property(aValue, anUnexpandedValue, aLocationDescription,
- makePropertyPath(aName)));
- }
-
- // ConfigNode helpers
- public boolean hasProperty(String aPropertyName) {
- return properties.containsKey(aPropertyName);
- }
-
- public property getProperty(String aPropertyName) {
- return (property) properties.get(aPropertyName);
- }
-
- private property getRequiredProperty(String aPropertyName)
- throws ConfigMissingPropertyException {
- if (!hasProperty(aPropertyName)) {
- throw new ConfigMissingPropertyException("required property \"" +
- aPropertyName + "\" not found", getLocationDescription());
- }
-
- return getProperty(aPropertyName);
- }
-
- // ConfigNode methods:
- public String getLocationDescription() {
- return getPath() + " (" + locationDescription + ")";
- }
-
- public String getPath() {
- return path;
- }
-
- public ConfigNode getSubNode(String aSubNodeName) {
- if (subNodes.containsKey(aSubNodeName)) {
- return (ConfigNode) subNodes.get(aSubNodeName);
- } else {
- return (ConfigNode) mimicSubNode(aSubNodeName, locationDescription);
- }
- }
-
- public Boolean getRequiredBooleanProperty(String aPropertyName)
- throws ConfigMissingPropertyException, ConfigInvalidPropertyTypeException {
- return getRequiredProperty(aPropertyName).interpretAsBoolean();
- }
-
- public Integer getRequiredIntegerProperty(String aPropertyName)
- throws ConfigMissingPropertyException, ConfigInvalidPropertyTypeException {
- return getRequiredProperty(aPropertyName).interpretAsInteger();
- }
-
- public String getRequiredStringProperty(String aPropertyName)
- throws ConfigMissingPropertyException, ConfigInvalidPropertyTypeException {
- return getRequiredProperty(aPropertyName).interpretAsString();
- }
-
- public Double getRequiredDoubleProperty(String aPropertyName)
- throws ConfigMissingPropertyException, ConfigInvalidPropertyTypeException {
- return getRequiredProperty(aPropertyName).interpretAsDouble();
- }
-
- public Boolean getOptionalBooleanProperty(String aPropertyName,
- Boolean aDefaultValue) throws ConfigInvalidPropertyTypeException {
- if (!hasProperty(aPropertyName)) {
- return aDefaultValue;
- } else {
- return getProperty(aPropertyName).interpretAsBoolean();
- }
- }
-
- public Integer getOptionalIntegerProperty(String aPropertyName,
- Integer aDefaultValue) throws ConfigInvalidPropertyTypeException {
- if (!hasProperty(aPropertyName)) {
- return aDefaultValue;
- } else {
- return getProperty(aPropertyName).interpretAsInteger();
- }
- }
-
- public String getOptionalStringProperty(String aPropertyName,
- String aDefaultValue) throws ConfigInvalidPropertyTypeException {
- if (!hasProperty(aPropertyName)) {
- return aDefaultValue;
- } else {
- return getProperty(aPropertyName).interpretAsString();
- }
- }
-
- public Double getOptionalDoubleProperty(String aPropertyName,
- Double aDefaultValue) throws ConfigInvalidPropertyTypeException {
- if (!hasProperty(aPropertyName)) {
- return aDefaultValue;
- } else {
- return getProperty(aPropertyName).interpretAsDouble();
- }
- }
-
- // property helper class
- private class property {
- private String value;
- private String unexpandedValue;
- private String path;
- private String locationDescription;
-
- public property(String aValue, String anUnexpandedValue,
- String aLocationDescription, String aPath) {
- value = aValue;
- unexpandedValue = anUnexpandedValue;
- locationDescription = aLocationDescription;
- path = aPath;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getUnexpandedValue() {
- return unexpandedValue;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getLocationDescription() {
- return getPath() + " (" + locationDescription + ")";
- }
-
- public String getValueDescription() {
- return "\"" + value + "\" (\"" + unexpandedValue + "\")";
- }
-
- public Boolean interpretAsBoolean()
- throws ConfigInvalidPropertyTypeException {
- if (value.equals("1")) {
- return Boolean.TRUE;
- } else if (value.equals("0")) {
- return Boolean.FALSE;
- } else {
- throw new ConfigInvalidPropertyTypeException(getValueDescription() +
- " is not a boolean", getLocationDescription());
- }
- }
-
- public String interpretAsString() throws ConfigInvalidPropertyTypeException {
- return value;
- }
-
- public Integer interpretAsInteger()
- throws ConfigInvalidPropertyTypeException {
- try {
- return Integer.valueOf(value);
- } catch (Throwable e) {
- throw new ConfigInvalidPropertyTypeException("\"" + value + "\" (\"" +
- unexpandedValue + "\") is not an integer", getLocationDescription());
- }
- }
-
- public Double interpretAsDouble() throws ConfigInvalidPropertyTypeException {
- try {
- return Double.valueOf(value);
- } catch (Throwable e) {
- throw new ConfigInvalidPropertyTypeException("\"" + value + "\" (\"" +
- unexpandedValue + "\") is not a double", getLocationDescription());
- }
- }
- }
-}
+++ /dev/null
-/*
- * 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.config;
-
-
-//import java.net.*;
-//import java.io.*;
-//import java.util.*;
-//import java.lang.*;
-import mir.config.exceptions.ConfigFailure;
-
-
-public class MirConfiguration {
- private ConfigNode rootNode;
-
- public MirConfiguration(ConfigNode aRootNode) {
- super();
- rootNode = aRootNode;
- }
-
- public MirConfiguration(String aFileName) throws ConfigFailure {
- super();
- rootNode = new ConfigSimpleNode();
-
- (new ConfigReader()).parseFile(aFileName, (ConfigNodeBuilder) rootNode);
- }
-
- public ConfigNode getRootNode() {
- return rootNode;
- }
-}
+++ /dev/null
-/*
- * 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.config.exceptions;
-
-public class ConfigDefineNotKnownException extends ConfigFailure {
- public ConfigDefineNotKnownException(String aMessage, String aLocation) {
- super(aMessage, aLocation);
- }
-}
+++ /dev/null
-/*
- * 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.config.exceptions;
-
-import multex.Failure;
-
-
-public class ConfigFailure extends Failure {
- private String locationDescription;
- private Throwable cause;
-
- public ConfigFailure(String aMessage, Throwable aCause,
- String aLocationDescription) {
- super("Configuration error at " + aLocationDescription + ": " + aMessage,
- aCause);
-
- locationDescription = aLocationDescription;
- cause = aCause;
- }
-
- public ConfigFailure(String aMessage, String aLocationDescription) {
- this(aMessage, (Throwable) null, aLocationDescription);
- }
-
- public ConfigFailure(String aMessage) {
- this(aMessage, (Throwable) null, "?");
- }
-}
+++ /dev/null
-/*
- * 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.config.exceptions;
-
-public class ConfigInvalidPropertyTypeException extends ConfigFailure {
- public ConfigInvalidPropertyTypeException(String aMessage, String aLocation) {
- super(aMessage, aLocation);
- }
-}
+++ /dev/null
-/*
- * 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.config.exceptions;
-
-public class ConfigMissingPropertyException extends ConfigFailure {
- public ConfigMissingPropertyException(String aMessage, String aLocation) {
- super(aMessage, aLocation);
- }
-}
import java.util.Iterator;\r
import java.util.Set;\r
\r
+import freemarker.template.SimpleScalar;\r
+import freemarker.template.TemplateHashModel;\r
+import freemarker.template.TemplateModel;\r
+import freemarker.template.TemplateModelException;\r
+import freemarker.template.TemplateModelRoot;\r
+\r
import mir.config.MirPropertiesConfiguration;\r
import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
-import mir.misc.Logfile;\r
+import mir.log.LoggerWrapper;\r
import mir.misc.StringUtil;\r
import mir.storage.StorageObject;\r
import mir.storage.StorageObjectExc;\r
import mir.storage.StorageObjectFailure;\r
-import freemarker.template.SimpleScalar;\r
-import freemarker.template.TemplateHashModel;\r
-import freemarker.template.TemplateModel;\r
-import freemarker.template.TemplateModelException;\r
-import freemarker.template.TemplateModelRoot;\r
\r
/**\r
* Base Class of Entities\r
* Interfacing TemplateHashModel and TemplateModelRoot to be freemarker compliant\r
*\r
- * @version $Id: Entity.java,v 1.14 2003/02/20 16:05:32 zapata Exp $\r
+ * @version $Id: Entity.java,v 1.15 2003/02/23 05:00:11 zapata Exp $\r
* @author rk\r
*\r
*/\r
public class Entity implements TemplateHashModel, TemplateModelRoot\r
{\r
protected static MirPropertiesConfiguration configuration;\r
- protected static Logfile theLog;\r
\r
private boolean changed;\r
protected HashMap theValuesHash; // tablekey / value\r
protected StorageObject theStorageObject;\r
protected List streamedInput = null;\r
+ protected LoggerWrapper logger;\r
\r
static {\r
try {\r
configuration = MirPropertiesConfiguration.instance();\r
}\r
catch (PropertiesConfigExc e) {\r
- e.printStackTrace();\r
+ throw new RuntimeException(e.getMessage());\r
}\r
- theLog = Logfile.getInstance(configuration.getStringWithHome(\r
- "Entity.Logfile"));\r
}\r
\r
public Entity() {\r
+ logger = new LoggerWrapper("Entity");\r
+\r
this.changed = false;\r
}\r
\r
}\r
}\r
else\r
- theLog.printWarning("Entity.setValues called with null HashMap");\r
+ logger.warn("Entity.setValues called with null HashMap");\r
}\r
\r
/**\r
* @exception StorageObjectException\r
*/\r
public String insert() throws StorageObjectExc {\r
- theLog.printDebugInfo("Entity: trying to insert ...");\r
+ logger.debug("Entity: trying to insert ...");\r
if (theStorageObject != null) {\r
return theStorageObject.insert( (Entity)this);\r
}\r
else\r
- throw new StorageObjectExc("Kein StorageObject gesetzt!");\r
+ throw new StorageObjectExc("theStorageObject == null!");\r
}\r
\r
/**\r
if (isField(theProp))\r
theValuesHash.put(theProp, theValue);\r
else {\r
- theLog.printWarning("Property not found: " + theProp + theValue);\r
+ logger.warn("Entity.setValueForProperty: Property not found: " + theProp + " (" + theValue + ")");\r
}\r
\r
}\r
* be used in the same way as SimpleHash.\r
*/\r
public HashMap getValues() {\r
- theLog.printWarning(\r
- "## using deprecated Entity.getValues() - a waste of resources");\r
+ logger.warn("using deprecated Entity.getValues() - a waste of resources");\r
return theValuesHash;\r
}\r
\r
return theStorageObject.getFields().contains(fieldName);\r
}\r
\r
- protected void throwStorageObjectFailure(Exception e, String wo) throws\r
+ protected void throwStorageObjectFailure(Throwable e, String wo) throws\r
StorageObjectFailure {\r
- theLog.printError(e.toString() + " Funktion: " + wo);\r
- e.printStackTrace(System.out);\r
+ logger.error(e.toString() + " function: " + wo);\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+\r
throw new StorageObjectFailure("Storage Object Exception in entity", e);\r
}\r
\r
// putting should only take place via setValue and is limited to the\r
// database fields associated with the entity. no additional freemarker\r
// stuff will be available via Entity.\r
- theLog.printWarning(\r
- "### put is called on entity! - the values will be lost!");\r
+ logger.warn("put is called on entity! - the values will be lost!");\r
}\r
\r
public void remove(java.lang.String key) {\r
import java.util.ArrayList;
import java.util.Set;
+import freemarker.template.TemplateListModel;
+import freemarker.template.TemplateModel;
+
+import mir.log.LoggerWrapper;
import mir.config.MirPropertiesConfiguration;
import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.misc.Logfile;
import mir.storage.StorageObject;
import mir.storage.store.StorableObject;
import mir.storage.store.StoreContainerType;
import mir.storage.store.StoreIdentifier;
import mir.storage.store.StoreUtil;
-import freemarker.template.TemplateListModel;
-import freemarker.template.TemplateModel;
/**
*
* @version 1.0 (freemarker compliant & and storable in ObjectStore)
*/
public class EntityList implements TemplateListModel, StorableObject {
-
- private static Logfile theLog;
protected static MirPropertiesConfiguration configuration;
+ protected LoggerWrapper logger;
private ArrayList theEntityArrayList = new ArrayList();
private String whereClause, orderClause;
private StorageObject theStorage;
static {
try {
configuration = MirPropertiesConfiguration.instance();
- } catch (PropertiesConfigExc e) {
- e.printStackTrace();
}
- theLog = Logfile.getInstance(configuration.getStringWithHome("Entity.Logfile"));
+ catch (PropertiesConfigExc e) {
+ throw new RuntimeException("Unable to get configuration: " + e.getMessage());
+ }
}
/**
* Constructor.
*/
- public EntityList(){ }
+ public EntityList(){
+ logger = new LoggerWrapper("Entity.List");
+ }
/* get/set EntityClass of Objects stored in EntityList */
public void setStorage(StorageObject storage) { this.theStorage=storage; }
if (anEntity!=null)
theEntityArrayList.add(anEntity);
else
- theLog.printWarning("EntityList: add called with empty Entity");
+ logger.warn("EntityList: add called with empty Entity");
}
StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),
whereClause, orderClause, offset, limit ));
}
- theLog.printWarning("EntityList could not return StoreIdentifier");
+ logger.warn("EntityList could not return StoreIdentifier");
return null;
}
import java.util.Map;
import mir.util.SimpleParser;
+import mir.log.LoggerWrapper;
public class GeneratorLibraryRepository {
private Map factories;
+ private LoggerWrapper logger;
public GeneratorLibraryRepository() {
factories = new HashMap();
+ logger = new LoggerWrapper("TemplateEngine");
}
public void registerLibraryFactory(String aName, Generator.GeneratorLibraryFactory aFactory) {
private final static String SEMICOLON = ";";
public Generator.GeneratorLibrary constructCompositeLibrary(String aSpecification) throws GeneratorExc, GeneratorFailure {
- //main=freemarker(path=/var/www/test); test=freemarker(path=/var/www/test2)
String identifier;
String factory;
String factoryParameters;
}
}
catch (Exception e) {
- e.printStackTrace(System.out);
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));
throw new GeneratorFailure("Failed to construct generator library: " + e.getMessage(), e);
}
-package mir.log;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-
-public class Log {
-
- private static Logger myLogger;
-
- static {
- try {
- String loggerClass =
- MirPropertiesConfiguration.instance().getString("Log.LogClass");
- myLogger = (Logger)Class.forName(loggerClass).newInstance();
- } catch (java.lang.ClassNotFoundException cnfe) {
- System.err.println("Log was not able to initialize: class not found");
- cnfe.printStackTrace(System.err);
- } catch (java.lang.InstantiationException ie) {
- System.err.println("Log was not able to initialize: could not initialize class");
- ie.printStackTrace(System.err);
- } catch (java.lang.IllegalAccessException iae) {
- System.err.println("Log was not able to initialize: illegal access");
- iae.printStackTrace(System.err);
- } catch (PropertiesConfigExc e) {
- e.printStackTrace(System.err);
- }
- }
-
- public static void debug( Object o, String s) {
- myLogger.debug( o, s );
- }
-
- public static void info( Object o, String s) {
- myLogger.info( o, s );
- }
-
- public static void warn( Object o, String s) {
- myLogger.warn( o, s );
- }
-
- public static void error( Object o, String s) {
- myLogger.error( o, s );
- }
-
- public static void fatal( Object o, String s) {
- myLogger.fatal( o, s );
- }
-}
+package mir.log;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+\r
+public class Log {\r
+\r
+ private static Logger myLogger;\r
+\r
+ static {\r
+ try {\r
+ String loggerClass = MirPropertiesConfiguration.instance().getString("Log.LogClass");\r
+ myLogger = (Logger) Class.forName(loggerClass).newInstance();\r
+ }\r
+ catch (java.lang.ClassNotFoundException cnfe) {\r
+ System.err.println("Log was not able to initialize: class not found");\r
+ cnfe.printStackTrace(System.err);\r
+ }\r
+ catch (java.lang.InstantiationException ie) {\r
+ System.err.println(\r
+ "Log was not able to initialize: could not initialize class");\r
+ ie.printStackTrace(System.err);\r
+ }\r
+ catch (java.lang.IllegalAccessException iae) {\r
+ System.err.println("Log was not able to initialize: illegal access");\r
+ iae.printStackTrace(System.err);\r
+ }\r
+ catch (PropertiesConfigExc e) {\r
+ e.printStackTrace(System.err);\r
+ }\r
+ }\r
+\r
+ public static void debug(Object o, String s) {\r
+ myLogger.debug(o, s);\r
+ }\r
+\r
+ public static void info(Object o, String s) {\r
+ myLogger.info(o, s);\r
+ }\r
+\r
+ public static void warn(Object o, String s) {\r
+ myLogger.warn(o, s);\r
+ }\r
+\r
+ public static void error(Object o, String s) {\r
+ myLogger.error(o, s);\r
+ }\r
+\r
+ public static void fatal(Object o, String s) {\r
+ myLogger.fatal(o, s);\r
+ }\r
+}\r
private static Map loggers = new HashMap();\r
\r
public LoggerImpl() throws PropertiesConfigExc {\r
- System.setProperty("log.home", \r
- MirPropertiesConfiguration.instance().getStringWithHome("Log.Home"));\r
- PropertyConfigurator.configure(MirPropertiesConfiguration.instance()\r
- .getStringWithHome("Log.log4j.ConfigurationFile").trim());\r
+ System.setProperty("log.home",\r
+ MirPropertiesConfiguration.instance().getStringWithHome("Log.Home"));\r
+ PropertyConfigurator.configure(\r
+ MirPropertiesConfiguration.instance().getStringWithHome("Log.log4j.ConfigurationFile").trim());\r
}\r
\r
public void debug(Object o, String s) {\r
\r
package mir.misc;\r
\r
+import java.io.PrintWriter;\r
+import java.net.URLEncoder;\r
+import java.util.*;\r
+\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.apache.struts.util.MessageResources;\r
+\r
import freemarker.template.*;\r
+\r
+import mir.log.LoggerWrapper;\r
import mir.util.*;\r
import mir.generator.*;\r
import mir.config.MirPropertiesConfiguration;\r
import mir.entity.Entity;\r
import mir.entity.EntityList;\r
import mir.storage.StorageObjectFailure;\r
-import org.apache.struts.util.MessageResources;\r
-\r
-import javax.servlet.http.HttpServletResponse;\r
-import java.io.PrintWriter;\r
-import java.net.URLEncoder;\r
-import java.util.*;\r
-\r
\r
/**\r
* Hilfsklasse zum Mergen von Template und Daten\r
public static String templateDir;\r
private static MirPropertiesConfiguration configuration;\r
private static FileTemplateCache templateCache;\r
- private static Logfile theLog;\r
private static String docRoot;\r
private static String actionRoot;\r
+ private static LoggerWrapper logger;\r
\r
static {\r
+ // ML: configuration is not thread safe: it's risky to use it like this\r
+ // actually I don't see why HTMLTemplateProcessor needs to be a\r
+ // class with static methods. This causes more problems than it solves.\r
try {\r
configuration = MirPropertiesConfiguration.instance();\r
- } catch (PropertiesConfigExc e) {\r
+ }\r
+ catch (PropertiesConfigExc e) {\r
e.printStackTrace();\r
}\r
- theLog = Logfile.getInstance(\r
- configuration.getStringWithHome("HTMLTemplateProcessor.Logfile"));\r
- templateDir = \r
- configuration.getStringWithHome("HTMLTemplateProcessor.Dir");\r
- theLog.printDebugInfo("templateDir: " + templateDir);\r
+\r
+ logger = new LoggerWrapper("TemplateEngine");\r
+\r
+ templateDir =\r
+ configuration.getStringWithHome("HTMLTemplateProcessor.Dir");\r
templateCache = new FileTemplateCache(templateDir);\r
templateCache.setLoadingPolicy(FileTemplateCache.LOAD_ON_DEMAND);\r
// gone in freemarker 1.7.1: templateCache.startAutoUpdate();\r
public static void process(HttpServletResponse res, String templateFilename,\r
TemplateModelRoot tmr, TemplateModelRoot extra,\r
PrintWriter out, Locale locale, String bundles,\r
- String bundles2) throws\r
- HTMLParseException {\r
+ String bundles2) throws HTMLParseException {\r
if (out == null)\r
throw new HTMLParseException("no outputstream");\r
Template tmpl = getTemplateFor(templateFilename);\r
while (it.hasNext()) {\r
key = (String) it.next();\r
configHash.put(key, new SimpleScalar(\r
- configuration.getString(key))\r
+ configuration.getString(key))\r
);\r
}\r
\r
\r
if (extra != null) {\r
outPutHash.put("extra", extra);\r
- try {\r
- while ( ( (SimpleList) extra).hasNext()) {\r
- theLog.printDebugInfo( ( (SimpleList) extra).next().toString());\r
- }\r
- }\r
- catch (Exception e) {\r
- }\r
}\r
outPutHash.put("data", tmr);\r
outPutHash.put("config", configHash);\r
*\r
* @deprecated EntityLists comply with TemplateListModel now.\r
*/\r
- public static SimpleList makeSimpleList(EntityList aList) throws\r
- StorageObjectFailure {\r
- theLog.printWarning(\r
- "## using deprecated makeSimpleList(entityList) - a waste of resources");\r
+ public static SimpleList makeSimpleList(EntityList aList) throws StorageObjectFailure {\r
+ logger.warn("using deprecated makeSimpleList(entityList) - a waste of resources");\r
SimpleList simpleList = new SimpleList();\r
if (aList != null) {\r
for (int i = 0; i < aList.size(); i++) {\r
"template");\r
\r
if (returnTemplate == null) {\r
- theLog.printError("CACHE (ERR): Unknown template: " + templateFilename);\r
- throw new HTMLParseException("Templatefile: " + templateFilename +\r
- " not found.");\r
+ logger.error("CACHE (ERR): Unknown template: " + templateFilename);\r
+ throw new HTMLParseException("Templatefile: " + templateFilename + " not found.");\r
}\r
\r
return returnTemplate;\r
+++ /dev/null
-/*
- * 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.IOException;
-import java.io.RandomAccessFile;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-
-
-/**
- * Hilfs-Klasse, die in Logfiles schreibt.
- *
- */
-public final class Logfile {
- public static final int LOG_INFO = 0;
- public static final int LOG_WARNING = 1;
- public static final int LOG_ERROR = 2;
- public static final int LOG_DEBINFO = 3;
-
- private static String lineSeparator;
-
- private static HashMap /* filename / instance */ instanceRepository;
- private RandomAccessFile raf;
- private String fileName;
-
- /**
- * lineSeparator ermitteln und Repository anlegen
- */
- static {
- // System.runFinalizersOnExit(true);
- lineSeparator = System.getProperty("line.separator");
- instanceRepository = new HashMap();
- }
-
- /**
- * Singleton zurueckliefern, anhand des Filenamens,
- * also pro <code>fileName</code> wird eine Instanz der Logfileklassen
- * angelegt.
- *
- * @param fileName
- * @return Logfile
- */
- public static Logfile getInstance(String fileName) {
- Logfile returnLogfile = null;
- System.err.println(fileName);
- if (fileName != null) {
- if (instanceRepository.containsKey(fileName)) {
- returnLogfile = (Logfile) instanceRepository.get(fileName);
- } else {
- returnLogfile = new Logfile(fileName);
- instanceRepository.put(fileName, returnLogfile);
- }
- } else {
- System.err.println("Fehler bei Instantiierung von Logfile");
- }
- return returnLogfile;
- }
-
- /**
- * Privater Konstruktor
- * @param String fileName
- */
- private Logfile(String fileName){
- this.fileName = fileName;
- try {
- File f = new File(fileName);
- File dir = new File(f.getParent());
- dir.mkdirs();
- raf = new RandomAccessFile(fileName, "rw");
- } catch (IOException e) {
- System.err.println("Could not open logfile '"+fileName+"'");
- }
- }
-
- /**
- * Private Methode, um eine Zeile auszugeben
- *
- * @param type Typ der Logfilezeile (INFO, WARNING, ERROR, DEBUG)
- * @param text Lognachricht
- * @todo an dieser Stelle koennte statt in das File in die Datenbank geloggt werden.
- */
- private void print(int type, String text) {
- if (text == null) text = "null";
- text = text.replace('\n', ' ');
-
- String typeText =
- type == LOG_DEBINFO ? "DEBINFO " :
- type == LOG_INFO ? "INFO " :
- type == LOG_WARNING ? "WARNING " :
- type == LOG_ERROR ? "ERROR " :
- "? ";
-
- String sectionText = text;
- GregorianCalendar date = new GregorianCalendar();
-
- String line = StringUtil.pad2(date.get(Calendar.DATE))+"-"+
- StringUtil.pad2(date.get(Calendar.MONTH)+1)+"-"+
- StringUtil.pad2(date.get(Calendar.YEAR) % 100)+" ";
- int hour = date.get(Calendar.HOUR);
- if (date.get(Calendar.AM_PM) == Calendar.PM) hour+=12;
- line += StringUtil.pad2(hour)+":"+
- StringUtil.pad2(date.get(Calendar.MINUTE))+":"+
- StringUtil.pad2(date.get(Calendar.SECOND))+" "+
- typeText+sectionText;
-
- print(line);
- }
-
- /**
- * Interne Ausgabeprozedur.
- * Erfordert etwas Handarbeit, da PrintStream nicht mit RandomAcccessFile
- * kooperiert. Und ein RandomAccessFile brauchen wir, weil FileOutputStream
- * kein "append" zul??t.
- *
- */
- private void print(String line) {
- if (raf == null) return;
- line += lineSeparator;
- // byte[] buf = new byte[line.length()];
- //line.getBytes(0, line.length(), buf, 0);
-
- byte[] buf = line.getBytes();
-
- try {
- raf.seek(raf.length());
- raf.write(buf, 0, line.length());
- } catch (IOException e) {
- System.err.print("Could not write logfile line: "+line);
- }
- }
-
- /**
- * Schreibt Information <code>text</code> ins Logfil.
- * @param text
- */
- public void printInfo (String text) {
- print(LOG_INFO, text);
- }
-
- /**
- * Schreibt Warnung <code>text</code> ins Logfile.
- * @param text
- */
- public void printWarning (String text) {
- print(LOG_WARNING, text);
- }
-
- /**
- * Schreibt Fehlermeldung <code>text</code> ins Logfile.
- * @param text
- */
- public void printError (String text) {
- print(LOG_ERROR, text);
- }
-
- /**
- * Schreibt Debuginformation <code>text</code> ins Logfile.
- * @param text
- */
- public void printDebugInfo (String text) {
- print(LOG_DEBINFO, text);
- }
-
- /**
- * Finalize-Methode, die alle offenen Dateien schliesst.
- */
- public void finalize () {
- if (raf != null) {
- try {
- raf.close();
- } catch (IOException e) { ; }
- raf = null;
- }
- staticFinalize(fileName);
- try {
- super.finalize();
- } catch (Throwable t) {
- ;
- }
- }
-
- /**
- * Static-Finalizer
- * @param fileName
- */
- private static synchronized void staticFinalize (String fileName) {
- instanceRepository.remove(fileName);
- }
-}
-
-
-
import java.sql.SQLException;
import java.util.HashMap;
+import freemarker.template.SimpleHash;
+
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
-import freemarker.template.SimpleHash;
/**
return theEntity.getId();
}
catch (StorageObjectExc e){
- e.printStackTrace(System.err);
throw new ModuleException(e.toString());
}
}
private String whereClause;
private String orderByClause;
-
public EntityEnumeratingProducerNode(
String aKey,
EntityAdapterModel aModel, String aDefinition,
public ServletModule(){\r
try {\r
configuration = MirPropertiesConfiguration.instance();\r
- } catch (PropertiesConfigExc e) {\r
- e.printStackTrace(System.err);\r
+ }\r
+ catch (PropertiesConfigExc e) {\r
+ throw new RuntimeException("Can't get configuration: " + e.getMessage());\r
}\r
}\r
\r
for (int i = 0; i < theFieldList.size(); i++) {\r
aField = (String) theFieldList.get(i);\r
\r
- System.out.println("field " + aField + " = " + parser.getParameter(aField));\r
+ logger.debug("field " + aField + " = " + parser.getParameter(aField));\r
\r
aValue = parser.getParameter(aField);\r
if (aValue != null)\r
return withValues;\r
}\r
catch (Throwable e) {\r
- e.printStackTrace(System.out);\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
throw new ServletModuleException(\r
"ServletModule.getIntersectingValues: " + e.getMessage());\r
}\r
* Treiber, Host, User und Passwort, ueber den der Zugriff auf die\r
* Datenbank erfolgt.\r
*\r
- * @version $Id: Database.java,v 1.33 2003/02/20 16:05:33 zapata Exp $\r
+ * @version $Id: Database.java,v 1.34 2003/02/23 05:00:12 zapata Exp $\r
* @author rk\r
*\r
*/\r
\r
/** @todo count sql string should only be assembled if we really count\r
* see below at the end of method //rk */\r
- if ((wc != null) && (wc.length() == 0)) {\r
+ if ((wc != null) && (wc.trim().length() == 0)) {\r
wc = null;\r
}\r
\r
countSql.append(" where ").append(wc);\r
}\r
\r
- if ((ob != null) && !(ob.length() == 0)) {\r
+ if ((ob != null) && !(ob.trim().length() == 0)) {\r
selectSql.append(" order by ").append(ob);\r
}\r
\r
}\r
catch (SQLException e) {\r
logger.error("could not connect to the database " + e.getMessage());\r
- System.err.println("could not connect to the database " + e.getMessage());\r
+\r
throw new StorageObjectFailure("Could not connect to the database", e);\r
}\r
\r
\r
import javax.servlet.http.HttpServletRequest;\r
\r
-import mir.misc.Logfile;\r
import mir.misc.StringUtil;\r
\r
public class StoreContainer {\r
-\r
private final static int DEFAULT_SIZE = 10;\r
- private static Logfile storeLog;\r
private static int uniqueCounter = 10000;\r
\r
private LinkedList container;\r
-/*
- * 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.storage.store;
-
-/**
- * Title: StoreContainerType
- *
- * Description: StoreContainerTypes are uniqe Objects and are generated
- * via @see valueOf(Class stocClass, int stocType).
- * For every combination of stocClass and stocType there is
- * only one Object instantiated.
- *
- * Copyright: Copyright (c) 2002
- * Company: indy
- *
- * @author rk
- * @version 1.0
- */
-
-import java.util.HashMap;
-
-import mir.misc.Logfile;
-import mir.misc.StringUtil;
-
-public class StoreContainerType {
-
- public final static int STOC_TYPE_UNKNOWN=-1;
- public final static int STOC_TYPE_ENTITY=0;
- public final static int STOC_TYPE_ENTITYLIST=1;
- public final static int STOC_TYPE_MAX=STOC_TYPE_ENTITYLIST;
-
- private static HashMap[] uniqueTypes=new HashMap[STOC_TYPE_MAX+1];
- private static ObjectStore o_store=ObjectStore.getInstance();
- private static Logfile storeLog;
- private Class stocClass=null;
- private int stocType=STOC_TYPE_UNKNOWN;
-
- static {
- uniqueTypes[STOC_TYPE_ENTITY]= new HashMap();
- uniqueTypes[STOC_TYPE_ENTITYLIST]=new HashMap();
- }
-
- private StoreContainerType() {}
-
- private StoreContainerType(Class stocClass, int stocType) {
- this.stocClass=stocClass;
- this.stocType=stocType;
- }
-
- public static StoreContainerType valueOf(Class stoc_class, int stoc_type) {
- StoreContainerType returnStocType=null;
- if (stoc_type>=0 && stoc_type <= STOC_TYPE_MAX) {
- HashMap current = uniqueTypes[stoc_type];
- if ( current.containsKey(stoc_class) )
- returnStocType=(StoreContainerType)current.get(stoc_class);
- else {
- returnStocType=new StoreContainerType(stoc_class,stoc_type);
- current.put(stoc_class,returnStocType);
- }
- }
- return returnStocType;
- }
-
- public int getStocType() { return stocType; }
- public Class getStocClass() { return stocClass; }
- public String getConfPrefix() {
- return StoreUtil.getPropNameFor(stocClass)+"."+stringForStoreType(stocType);
- }
- public int getDefaultSize() {
- String confProperty= "StoreContainer."+stringForStoreType(stocType)+".DefaultSize";
- return
- StringUtil.parseInt( o_store.getConfProperty(confProperty),10 );
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(this.stocClass.toString());
- sb.append("@").append(stringForStoreType(stocType));
- return sb.toString();
- }
-
- private static String stringForStoreType(int stocType) {
- switch(stocType) {
- case STOC_TYPE_ENTITY: return "Entity";
- case STOC_TYPE_ENTITYLIST: return "EntityList";
- default: return "UNKNOWN";
- }
- }
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.storage.store;\r
+\r
+/**\r
+ * Title: StoreContainerType\r
+ *\r
+ * Description: StoreContainerTypes are uniqe Objects and are generated\r
+ * via @see valueOf(Class stocClass, int stocType).\r
+ * For every combination of stocClass and stocType there is\r
+ * only one Object instantiated.\r
+ *\r
+ * Copyright: Copyright (c) 2002\r
+ * Company: indy\r
+ *\r
+ * @author rk\r
+ * @version 1.0\r
+ */\r
+\r
+import java.util.HashMap;\r
+\r
+import mir.misc.StringUtil;\r
+\r
+public class StoreContainerType {\r
+\r
+ public final static int STOC_TYPE_UNKNOWN = -1;\r
+ public final static int STOC_TYPE_ENTITY = 0;\r
+ public final static int STOC_TYPE_ENTITYLIST = 1;\r
+ public final static int STOC_TYPE_MAX = STOC_TYPE_ENTITYLIST;\r
+\r
+ private static HashMap[] uniqueTypes = new HashMap[STOC_TYPE_MAX + 1];\r
+ private static ObjectStore o_store = ObjectStore.getInstance();\r
+ private Class stocClass = null;\r
+ private int stocType = STOC_TYPE_UNKNOWN;\r
+\r
+ static {\r
+ uniqueTypes[STOC_TYPE_ENTITY] = new HashMap();\r
+ uniqueTypes[STOC_TYPE_ENTITYLIST] = new HashMap();\r
+ }\r
+\r
+ private StoreContainerType() {}\r
+\r
+ private StoreContainerType(Class stocClass, int stocType) {\r
+ this.stocClass = stocClass;\r
+ this.stocType = stocType;\r
+ }\r
+\r
+ public static StoreContainerType valueOf(Class stoc_class, int stoc_type) {\r
+ StoreContainerType returnStocType = null;\r
+ if (stoc_type >= 0 && stoc_type <= STOC_TYPE_MAX) {\r
+ HashMap current = uniqueTypes[stoc_type];\r
+ if (current.containsKey(stoc_class))\r
+ returnStocType = (StoreContainerType) current.get(stoc_class);\r
+ else {\r
+ returnStocType = new StoreContainerType(stoc_class, stoc_type);\r
+ current.put(stoc_class, returnStocType);\r
+ }\r
+ }\r
+ return returnStocType;\r
+ }\r
+\r
+ public int getStocType() {\r
+ return stocType;\r
+ }\r
+\r
+ public Class getStocClass() {\r
+ return stocClass;\r
+ }\r
+\r
+ public String getConfPrefix() {\r
+ return StoreUtil.getPropNameFor(stocClass) + "." +\r
+ stringForStoreType(stocType);\r
+ }\r
+\r
+ public int getDefaultSize() {\r
+ String confProperty = "StoreContainer." + stringForStoreType(stocType) +\r
+ ".DefaultSize";\r
+ return\r
+ StringUtil.parseInt(o_store.getConfProperty(confProperty), 10);\r
+ }\r
+\r
+ public String toString() {\r
+ StringBuffer sb = new StringBuffer(this.stocClass.toString());\r
+ sb.append("@").append(stringForStoreType(stocType));\r
+ return sb.toString();\r
+ }\r
+\r
+ private static String stringForStoreType(int stocType) {\r
+ switch (stocType) {\r
+ case STOC_TYPE_ENTITY:\r
+ return "Entity";\r
+ case STOC_TYPE_ENTITYLIST:\r
+ return "EntityList";\r
+ default:\r
+ return "UNKNOWN";\r
+ }\r
+ }\r
}
\ No newline at end of file
-/*
- * 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.storage.store;
-
-/**
- * Title: Class StoreIdentifier
- * Description: StoreIdentifier has two functions.
- * A) StoreIdenfier holds a reference to a @see StorableObject
- * or B) StoreIdentifier is used too search for a @see StorableObject
- * in the @see StoreContainer that matches its
- *
- * Copyright: Copyright (c) 2002
- * Company: indy
- * @author rk
- * @version 1.0
- */
-import java.util.Iterator;
-import java.util.Set;
-
-import mir.entity.EntityList;
-import mir.misc.Logfile;
-
-public class StoreIdentifier {
-
- /** @todo check if invalidating already to avoid deadlocks
- * what about concurrency? */
-
- private static Logfile storeLog;
- private static ObjectStore o_store = ObjectStore.getInstance();
-
- private StoreContainerType stocType=null;
- private StorableObject reference=null;
- private String uniqueIdentifier=null; // id for Entity & sql for EntityList
- private long timesUsed;
- private boolean invalidating=false;
-
- /** @todo initialize logfile */
-
- private StoreIdentifier() {}
-
- public StoreIdentifier(StorableObject reference, int storeType, String uniqueIdentifier) {
- Class theClass;
- if (reference instanceof EntityList)
- theClass=((EntityList)reference).getStorage().getEntityClass();
- else
- theClass=reference.getClass();
- this.uniqueIdentifier=uniqueIdentifier;
- this.stocType = StoreContainerType.valueOf(theClass, storeType);
- this.reference=reference;
- }
-
- public StoreIdentifier(StorableObject reference, String uniqueIdentifier) {
- this(reference, StoreContainerType.STOC_TYPE_ENTITY, uniqueIdentifier);
- }
-
- public StoreIdentifier(Class theClass, String uniqueIdentifier) {
- this(theClass, StoreContainerType.STOC_TYPE_ENTITY,uniqueIdentifier);
- }
-
- public StoreIdentifier(Class theClass, int storeType, String uniqueIdentifier) {
- this.uniqueIdentifier=uniqueIdentifier;
- this.stocType = StoreContainerType.valueOf(theClass, storeType);
- }
- /**
- * Method: ivalidate
- * Description:
- *
- * @return
- */
- public void invalidate() {
- System.out.println("Invalidating: " + toString());
- // avoid deadlock due to propagation.
- if (!invalidating) {
- invalidating=true;
- if ( stocType!=null &&
- stocType.getStocType()==StoreContainerType.STOC_TYPE_ENTITY )
- {
- System.out.println("Propagating invalidation to EntityList for " + toString());
- // we should invalidate related ENTITY_LIST
- StoreContainerType entityListStocType =
- StoreContainerType.valueOf( stocType.getStocClass(),
- StoreContainerType.STOC_TYPE_ENTITYLIST );
- o_store.invalidate(entityListStocType);
- }
-
- // propagate invalidation to Set
- Set set = reference.getNotifyOnReleaseSet();
- if (set!=null) {
- for (Iterator it = set.iterator(); it.hasNext(); ) {
- Object o = it.next();
- if ( o instanceof StoreIdentifier ) {
- System.out.println("Propagating invalidation to StoreIdentifier: " + o.toString());
- // propagate invalidation to a specific StoreIdentifier in cache
- o_store.invalidate((StoreIdentifier)o);
- } else if ( o instanceof StoreContainerType ) {
- System.out.println("Propagating invalidation to StoreContainer: " + o.toString());
- // propagate invalidation to a whole StoreContainer
- o_store.invalidate((StoreContainerType)o);
- }
-
- }
- }
- release();
- }
- }
-
- public void release() {
- this.reference=null;
- this.uniqueIdentifier=null;
- this.stocType=null;
- }
-
- public StorableObject use() {
- timesUsed++;
- return reference;
- }
-
- /**
- * Method equals for comparison between two identifier
- *
- * @return true if yes otherwise false
- *
- */
- public boolean equals(Object sid) {
- if ( !(sid instanceof StoreIdentifier) ) return false;
- if ( ((StoreIdentifier)sid).getStoreContainerType()==stocType &&
- ((StoreIdentifier)sid).getUniqueIdentifier().equals(uniqueIdentifier) ) {
- return true;
- }
- return false;
- }
-
- public StoreContainerType getStoreContainerType() { return stocType; }
- public String getUniqueIdentifier() { return uniqueIdentifier; }
- public boolean hasReference() { return (reference==null) ? false:true; }
-
- public String toString() {
- StringBuffer id = new StringBuffer(uniqueIdentifier);
- id.append("@storetype: ").append(stocType.toString());
- if (reference != null) id.append(" ("+timesUsed).append(") times used.");
- return id.toString();
- }
-
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mir.storage.store;\r
+\r
+/**\r
+ * Title: Class StoreIdentifier\r
+ * Description: StoreIdentifier has two functions.\r
+ * A) StoreIdenfier holds a reference to a @see StorableObject\r
+ * or B) StoreIdentifier is used too search for a @see StorableObject\r
+ * in the @see StoreContainer that matches its\r
+ *\r
+ * Copyright: Copyright (c) 2002\r
+ * Company: indy\r
+ * @author rk\r
+ * @version 1.0\r
+ */\r
+import java.util.Iterator;\r
+import java.util.Set;\r
+\r
+import mir.entity.EntityList;\r
+\r
+public class StoreIdentifier {\r
+\r
+ /** @todo check if invalidating already to avoid deadlocks\r
+ * what about concurrency? */\r
+\r
+ private static ObjectStore o_store = ObjectStore.getInstance();\r
+\r
+ private StoreContainerType stocType = null;\r
+ private StorableObject reference = null;\r
+ private String uniqueIdentifier = null; // id for Entity & sql for EntityList\r
+ private long timesUsed;\r
+ private boolean invalidating = false;\r
+\r
+ /** @todo initialize logfile */\r
+\r
+ private StoreIdentifier() {}\r
+\r
+ public StoreIdentifier(StorableObject reference, int storeType,\r
+ String uniqueIdentifier) {\r
+ Class theClass;\r
+ if (reference instanceof EntityList)\r
+ theClass = ( (EntityList) reference).getStorage().getEntityClass();\r
+ else\r
+ theClass = reference.getClass();\r
+ this.uniqueIdentifier = uniqueIdentifier;\r
+ this.stocType = StoreContainerType.valueOf(theClass, storeType);\r
+ this.reference = reference;\r
+ }\r
+\r
+ public StoreIdentifier(StorableObject reference, String uniqueIdentifier) {\r
+ this(reference, StoreContainerType.STOC_TYPE_ENTITY, uniqueIdentifier);\r
+ }\r
+\r
+ public StoreIdentifier(Class theClass, String uniqueIdentifier) {\r
+ this(theClass, StoreContainerType.STOC_TYPE_ENTITY, uniqueIdentifier);\r
+ }\r
+\r
+ public StoreIdentifier(Class theClass, int storeType, String uniqueIdentifier) {\r
+ this.uniqueIdentifier = uniqueIdentifier;\r
+ this.stocType = StoreContainerType.valueOf(theClass, storeType);\r
+ }\r
+\r
+ /**\r
+ * Method: ivalidate\r
+ * Description:\r
+ *\r
+ * @return\r
+ */\r
+ public void invalidate() {\r
+ System.out.println("Invalidating: " + toString());\r
+ // avoid deadlock due to propagation.\r
+ if (!invalidating) {\r
+ invalidating = true;\r
+ if (stocType != null &&\r
+ stocType.getStocType() == StoreContainerType.STOC_TYPE_ENTITY) {\r
+ System.out.println("Propagating invalidation to EntityList for " +\r
+ toString());\r
+ // we should invalidate related ENTITY_LIST\r
+ StoreContainerType entityListStocType =\r
+ StoreContainerType.valueOf(stocType.getStocClass(),\r
+ StoreContainerType.STOC_TYPE_ENTITYLIST);\r
+ o_store.invalidate(entityListStocType);\r
+ }\r
+\r
+ // propagate invalidation to Set\r
+ Set set = reference.getNotifyOnReleaseSet();\r
+ if (set != null) {\r
+ for (Iterator it = set.iterator(); it.hasNext(); ) {\r
+ Object o = it.next();\r
+ if (o instanceof StoreIdentifier) {\r
+ System.out.println("Propagating invalidation to StoreIdentifier: " +\r
+ o.toString());\r
+ // propagate invalidation to a specific StoreIdentifier in cache\r
+ o_store.invalidate( (StoreIdentifier) o);\r
+ }\r
+ else if (o instanceof StoreContainerType) {\r
+ System.out.println("Propagating invalidation to StoreContainer: " +\r
+ o.toString());\r
+ // propagate invalidation to a whole StoreContainer\r
+ o_store.invalidate( (StoreContainerType) o);\r
+ }\r
+\r
+ }\r
+ }\r
+ release();\r
+ }\r
+ }\r
+\r
+ public void release() {\r
+ this.reference = null;\r
+ this.uniqueIdentifier = null;\r
+ this.stocType = null;\r
+ }\r
+\r
+ public StorableObject use() {\r
+ timesUsed++;\r
+ return reference;\r
+ }\r
+\r
+ /**\r
+ * Method equals for comparison between two identifier\r
+ *\r
+ * @return true if yes otherwise false\r
+ *\r
+ */\r
+ public boolean equals(Object sid) {\r
+ if (! (sid instanceof StoreIdentifier))\r
+ return false;\r
+ if ( ( (StoreIdentifier) sid).getStoreContainerType() == stocType &&\r
+ ( (StoreIdentifier) sid).getUniqueIdentifier().equals(uniqueIdentifier)) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public StoreContainerType getStoreContainerType() {\r
+ return stocType;\r
+ }\r
+\r
+ public String getUniqueIdentifier() {\r
+ return uniqueIdentifier;\r
+ }\r
+\r
+ public boolean hasReference() {\r
+ return (reference == null) ? false : true;\r
+ }\r
+\r
+ public String toString() {\r
+ StringBuffer id = new StringBuffer(uniqueIdentifier);\r
+ id.append("@storetype: ").append(stocType.toString());\r
+ if (reference != null)\r
+ id.append(" (" + timesUsed).append(") times used.");\r
+ return id.toString();\r
+ }\r
+\r
+\r
}
\ No newline at end of file
String result = request.getParameter(aName);\r
\r
if (result != null && encoding!=null && !encoding.equals(request.getCharacterEncoding())) {\r
- System.out.println("recoding");\r
result = new String(result.getBytes(request.getCharacterEncoding()), encoding);\r
}\r
\r
return result;\r
}\r
catch (Throwable t) {\r
- t.printStackTrace(System.out);\r
throw new RuntimeException("HTTPRequestParser.getParameter: " + t.getMessage());\r
}\r
}\r
else\r
file = new File(aFileName);\r
\r
- System.err.println("about to include "+file.getCanonicalPath());\r
-\r
if (includeFileStack.contains(file.getCanonicalPath())) {\r
throw new XMLReaderExc("recursive inclusion of file "+file.getCanonicalPath());\r
}\r
-/*
- * 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.entity;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-
-/**
- * This class handles storage of audio data and meta data
- *
- * @author mh
- * @version $Id: EntityAudio.java,v 1.5 2003/01/25 17:50:34 idfx Exp $
- */
-
-
-public class EntityAudio extends EntityUploadedMedia
-{
- public EntityAudio()
- {
- super();
- }
-
- public EntityAudio(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- public void update() throws StorageObjectFailure {
- super.update();
- try {
- theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId());
- } catch (SQLException e) {
- throwStorageObjectFailure(e, "EntityAudio :: update :: failed!! ");
- }
- }
-
- public void setValues(HashMap theStringValues)
- {
- if (theStringValues != null) {
- if (!theStringValues.containsKey("is_published"))
- theStringValues.put("is_published","0");
- }
- super.setValues(theStringValues);
- }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.entity;\r
+\r
+import java.sql.SQLException;\r
+import java.util.HashMap;\r
+\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+/**\r
+ * This class handles storage of audio data and meta data\r
+ *\r
+ * @author mh\r
+ * @version $Id: EntityAudio.java,v 1.6 2003/02/23 05:00:13 zapata Exp $\r
+ */\r
+\r
+\r
+public class EntityAudio extends EntityUploadedMedia\r
+{\r
+ public EntityAudio() {\r
+ super();\r
+ }\r
+\r
+ public EntityAudio(StorageObject theStorage) {\r
+ this();\r
+ setStorage(theStorage);\r
+ }\r
+\r
+ public void update() throws StorageObjectFailure {\r
+ super.update();\r
+ try {\r
+ theStorageObject.executeUpdate("update content set is_produced='0' where existto_media=" + getId());\r
+ }\r
+ catch (SQLException e) {\r
+ throwStorageObjectFailure(e, "EntityAudio :: update :: failed!! ");\r
+ }\r
+ }\r
+\r
+ public void setValues(HashMap theStringValues) {\r
+ if (theStringValues != null) {\r
+ if (!theStringValues.containsKey("is_published"))\r
+ theStringValues.put("is_published", "0");\r
+ }\r
+ super.setValues(theStringValues);\r
+ }\r
+\r
+}\r
import java.sql.Statement;
import java.util.HashMap;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
+import mir.log.LoggerWrapper;
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.storage.StorageObject;
import mircoders.storage.DatabaseContent;
import mircoders.storage.DatabaseContentToMedia;
import mircoders.storage.DatabaseContentToTopics;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
/**
* this class implements mapping of one line of the database table content
* to a java object
*
- * @version $Id: EntityContent.java,v 1.14 2003/01/25 17:50:34 idfx Exp $
+ * @version $Id: EntityContent.java,v 1.15 2003/02/23 05:00:13 zapata Exp $
* @author mir-coders group
*
*/
public EntityContent()
{
super();
- //content_data is now filed-type "text"
- //streamedInput = new ArrayList();
- //streamedInput.add("content_data");
+
+ logger = new LoggerWrapper("Entity.Content");
}
public EntityContent(StorageObject theStorage) {
}
//set Content to unproduced
setProduced(false);
- } else {
- theLog.printError("EntityContent: attach without mid");
+ }
+ else {
+ logger.error("EntityContent: attach without mid");
}
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getComments: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getComments: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getImagesForContent: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getImagesForContent: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getAudioForContent: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getAudioForContent: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getVideoForContent: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getVideoForContent: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getOtherMediaForContent: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getOtherMediaForContent: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
}
return (TemplateModel)_entCache.get(key);
}
catch (Exception ex) {
- theLog.printWarning("-- getTopics: could not fetch data " + ex.toString());
+ logger.warn("EntityContent.getTopics: could not fetch data " + ex.toString());
throw new TemplateModelException(ex.toString());
}
}
-/*
- * 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.entity;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.misc.FileUtil;
-import mir.misc.WebdbImage;
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-
-import org.postgresql.largeobject.BlobInputStream;
-import org.postgresql.largeobject.LargeObject;
-import org.postgresql.largeobject.LargeObjectManager;
-
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK, mh, mir-coders
- * @version $Id: EntityImages.java,v 1.14 2003/01/25 17:50:34 idfx Exp $
- */
-
-
-public class EntityImages extends EntityUploadedMedia
-{
-
- public EntityImages()
- {
- super();
- }
-
- public EntityImages(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- //
- // methods
-
-
- public InputStream getImage() throws StorageObjectFailure
- {
- theLog.printDebugInfo("--getimage started");
- java.sql.Connection con=null;Statement stmt=null;
- BlobInputStream in; InputStream img_in = null;
-
- try {
- con = theStorageObject.getPooledCon();
- con.setAutoCommit(false);
- LargeObjectManager lom;
- java.sql.Connection jCon;
- stmt = con.createStatement();
- ResultSet rs = theStorageObject.executeSql(stmt,
- "select image_data from images where id="+getId());
- jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
- .getNativeConnection();
- lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
- if(rs!=null) {
- if (rs.next()) {
- LargeObject lob = lom.open(rs.getInt(1));
- in = (BlobInputStream)lob.getInputStream();
- img_in = new ImageInputStream(in, con, stmt);
- }
- rs.close();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- theLog.printError("EntityImages -- getImage failed"+e.toString());
- try {
- con.setAutoCommit(true);
- } catch (Exception e2) {
- e.printStackTrace();
- theLog.printError(
- "EntityImages -- getImage reseting transaction mode failed"
- +e2.toString());
- }
- theStorageObject.freeConnection(con,stmt);
- throwStorageObjectFailure(e, "EntityImages -- getImage failed: ");
- }
- //}
- return img_in;
- }
-
- public void setImage(InputStream in, String type)
- throws StorageObjectFailure {
-
- if (in!=null) {
- java.sql.Connection con=null;PreparedStatement pstmt=null;
- File f = null;
- try {
-
- theLog.printDebugInfo("settimage :: making internal representation of image");
-
- File tempDir = new File(MirPropertiesConfiguration.instance().getString("TempDir"));
- f = File.createTempFile("mir", ".tmp", tempDir);
- FileUtil.write(f, in);
- WebdbImage webdbImage= new WebdbImage(f, type);
- theLog.printDebugInfo("settimage :: made internal representation of image");
-
- con = theStorageObject.getPooledCon();
- con.setAutoCommit(false);
- theLog.printDebugInfo("settimage :: trying to insert image");
-
- // setting values
- LargeObjectManager lom;
- java.sql.Connection jCon;
- jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
- .getNativeConnection();
-
- lom = ((org.postgresql.Connection) jCon).getLargeObjectAPI();
-
- int oidImage = lom.create();
- int oidIcon = lom.create();
- LargeObject lobImage = lom.open(oidImage);
- LargeObject lobIcon = lom.open(oidIcon);
- webdbImage.setImage(lobImage.getOutputStream());
- webdbImage.setIcon(lobIcon.getOutputStream());
- lobImage.close();
- lobIcon.close();
-
- setValueForProperty("img_height",
- new Integer(webdbImage.getImageHeight()).toString());
- setValueForProperty("img_width",
- new Integer(webdbImage.getImageWidth()).toString());
- setValueForProperty("icon_height",
- new Integer(webdbImage.getIconHeight()).toString());
- setValueForProperty("icon_width",
- new Integer(webdbImage.getIconWidth()).toString());
- setValueForProperty("image_data", new Integer(oidImage).toString());
- setValueForProperty("icon_data", new Integer(oidIcon).toString());
- update();
- }
- catch (Exception e) {
- throwStorageObjectFailure(e, "settimage :: setImage gescheitert: ");
- }
- finally {
- try {
- if (con!=null)
- con.setAutoCommit(true);
- // get rid of the temp. file
- f.delete();
- }
- catch (Exception e) {
- }
-
- if (con!=null)
- theStorageObject.freeConnection(con,pstmt);
- }
- }
- }
-
- /**
- * Takes an OutputStream as an argument and reads in the data
- * from the DB and writes it to the OutputStream.
- *
- * It will also take care of closing the OutputStream.
- */
- public InputStream getIcon() throws StorageObjectFailure
- {
- java.sql.Connection con=null;Statement stmt=null;
- BlobInputStream in=null;ImageInputStream img_in=null;
-
- try {
- con = theStorageObject.getPooledCon();
- con.setAutoCommit(false);
- LargeObjectManager lom;
- java.sql.Connection jCon;
- stmt = con.createStatement();
- ResultSet rs = theStorageObject.executeSql(stmt,
- "select icon_data from images where id="+getId());
- jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
- .getNativeConnection();
- lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
- if(rs!=null) {
- if (rs.next()) {
- LargeObject lob = lom.open(rs.getInt(1));
- in = (BlobInputStream)lob.getInputStream();
- img_in = new ImageInputStream( in, con ,stmt);
- //img_data = rs.getBytes(1);
- }
- rs.close();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- theLog.printError("EntityImages -- getIcon failed"+e.toString());
- try {
- con.setAutoCommit(true);
- }
- catch (Exception e2) {
- e.printStackTrace();
- theLog.printError(
- "EntityImages -- getIcon reseting transaction mode failed"
- +e2.toString());
- }
- theStorageObject.freeConnection(con,stmt);
- throwStorageObjectFailure(e, "EntityImages -- getIcon failed:");
- }
-
- return img_in;
- }
-
- /**
- * a small wrapper class that allows us to store the DB connection resources
- * that the BlobInputStream is using and free them upon closing of the stream
- */
- private class ImageInputStream extends InputStream {
-
- InputStream _in;
- java.sql.Connection _con;
- Statement _stmt;
-
- public ImageInputStream(BlobInputStream in, java.sql.Connection con,
- Statement stmt )
- {
- _in = in;
- _con = con;
- _stmt = stmt;
- }
-
- public void close () throws IOException {
- _in.close();
-
- try {
- _con.setAutoCommit(true);
- theStorageObject.freeConnection(_con,_stmt);
- }
- catch (Exception e) {
- throw new IOException("close(): "+e.toString());
- }
- }
-
- public int read() throws IOException {
- return _in.read();
- }
-
- }
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.entity;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.sql.PreparedStatement;\r
+import java.sql.ResultSet;\r
+import java.sql.Statement;\r
+\r
+import org.postgresql.largeobject.BlobInputStream;\r
+import org.postgresql.largeobject.LargeObject;\r
+import org.postgresql.largeobject.LargeObjectManager;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.misc.FileUtil;\r
+import mir.misc.WebdbImage;\r
+import mir.log.LoggerWrapper;\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+\r
+/**\r
+ * Diese Klasse enth?lt die Daten eines MetaObjekts\r
+ *\r
+ * @author RK, mh, mir-coders\r
+ * @version $Id: EntityImages.java,v 1.15 2003/02/23 05:00:13 zapata Exp $\r
+ */\r
+\r
+\r
+public class EntityImages extends EntityUploadedMedia\r
+{\r
+\r
+ public EntityImages()\r
+ {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("Entity.UploadedMedia.Images");\r
+ }\r
+\r
+ public EntityImages(StorageObject theStorage) {\r
+ this();\r
+ setStorage(theStorage);\r
+ }\r
+\r
+ //\r
+ // methods\r
+\r
+\r
+ public InputStream getImage() throws StorageObjectFailure\r
+ {\r
+ logger.debug("EntityImages.getimage started");\r
+ java.sql.Connection con=null;Statement stmt=null;\r
+ BlobInputStream in; InputStream img_in = null;\r
+\r
+ try {\r
+ con = theStorageObject.getPooledCon();\r
+ con.setAutoCommit(false);\r
+ LargeObjectManager lom;\r
+ java.sql.Connection jCon;\r
+ stmt = con.createStatement();\r
+ ResultSet rs = theStorageObject.executeSql(stmt,\r
+ "select image_data from images where id="+getId());\r
+ jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)\r
+ .getNativeConnection();\r
+ lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();\r
+ if(rs!=null) {\r
+ if (rs.next()) {\r
+ LargeObject lob = lom.open(rs.getInt(1));\r
+ in = (BlobInputStream)lob.getInputStream();\r
+ img_in = new ImageInputStream(in, con, stmt);\r
+ }\r
+ rs.close();\r
+ }\r
+ }\r
+ catch (Exception e) {\r
+ logger.error("EntityImages.getImage failed: "+e.toString());\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+ try {\r
+ con.setAutoCommit(true);\r
+ }\r
+ catch (Exception e2) {\r
+ logger.error("EntityImages.getImage reseting transaction mode failed: " + e2.toString());\r
+ e2.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+ }\r
+\r
+ try {\r
+ theStorageObject.freeConnection(con, stmt);\r
+ }\r
+ catch (Throwable t) {\r
+ }\r
+\r
+ throwStorageObjectFailure(e, "EntityImages -- getImage failed: ");\r
+ }\r
+ //}\r
+ return img_in;\r
+ }\r
+\r
+ public void setImage(InputStream in, String type)\r
+ throws StorageObjectFailure {\r
+\r
+ if (in!=null) {\r
+ java.sql.Connection con=null;PreparedStatement pstmt=null;\r
+ File f = null;\r
+ try {\r
+ logger.debug("EntityImages.settimage :: making internal representation of image");\r
+\r
+ File tempDir = new File(MirPropertiesConfiguration.instance().getString("TempDir"));\r
+ f = File.createTempFile("mir", ".tmp", tempDir);\r
+ FileUtil.write(f, in);\r
+ WebdbImage webdbImage= new WebdbImage(f, type);\r
+ logger.debug("EntityImages.settimage :: made internal representation of image");\r
+\r
+ con = theStorageObject.getPooledCon();\r
+ con.setAutoCommit(false);\r
+ logger.debug("EntityImages.settimage :: trying to insert image");\r
+\r
+ // setting values\r
+ LargeObjectManager lom;\r
+ java.sql.Connection jCon;\r
+ jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)\r
+ .getNativeConnection();\r
+\r
+ lom = ((org.postgresql.Connection) jCon).getLargeObjectAPI();\r
+\r
+ int oidImage = lom.create();\r
+ int oidIcon = lom.create();\r
+ LargeObject lobImage = lom.open(oidImage);\r
+ LargeObject lobIcon = lom.open(oidIcon);\r
+ webdbImage.setImage(lobImage.getOutputStream());\r
+ webdbImage.setIcon(lobIcon.getOutputStream());\r
+ lobImage.close();\r
+ lobIcon.close();\r
+\r
+ setValueForProperty("img_height", new Integer(webdbImage.getImageHeight()).toString());\r
+ setValueForProperty("img_width", new Integer(webdbImage.getImageWidth()).toString());\r
+ setValueForProperty("icon_height", new Integer(webdbImage.getIconHeight()).toString());\r
+ setValueForProperty("icon_width", new Integer(webdbImage.getIconWidth()).toString());\r
+ setValueForProperty("image_data", new Integer(oidImage).toString());\r
+ setValueForProperty("icon_data", new Integer(oidIcon).toString());\r
+ update();\r
+ }\r
+ catch (Exception e) {\r
+ throwStorageObjectFailure(e, "settimage :: setImage gescheitert: ");\r
+ }\r
+ finally {\r
+ try {\r
+ if (con!=null)\r
+ con.setAutoCommit(true);\r
+ // get rid of the temp. file\r
+ f.delete();\r
+ }\r
+ catch (Exception e) {\r
+ }\r
+\r
+ if (con!=null)\r
+ theStorageObject.freeConnection(con,pstmt);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Takes an OutputStream as an argument and reads in the data\r
+ * from the DB and writes it to the OutputStream.\r
+ *\r
+ * It will also take care of closing the OutputStream.\r
+ */\r
+ public InputStream getIcon() throws StorageObjectFailure\r
+ {\r
+ java.sql.Connection con=null;Statement stmt=null;\r
+ BlobInputStream in=null;ImageInputStream img_in=null;\r
+\r
+ try {\r
+ con = theStorageObject.getPooledCon();\r
+ con.setAutoCommit(false);\r
+ LargeObjectManager lom;\r
+ java.sql.Connection jCon;\r
+ stmt = con.createStatement();\r
+ ResultSet rs = theStorageObject.executeSql(stmt, "select icon_data from images where id="+getId());\r
+ jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)\r
+ .getNativeConnection();\r
+ lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();\r
+ if(rs!=null) {\r
+ if (rs.next()) {\r
+ LargeObject lob = lom.open(rs.getInt(1));\r
+ in = (BlobInputStream)lob.getInputStream();\r
+ img_in = new ImageInputStream( in, con ,stmt);\r
+ //img_data = rs.getBytes(1);\r
+ }\r
+ rs.close();\r
+ }\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("EntityImages.getIcon failed: "+e.toString());\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+ try {\r
+ con.setAutoCommit(true);\r
+ }\r
+ catch (Throwable e2) {\r
+ logger.error("EntityImages.getIcon reseting transaction mode failed: " + e2.toString());\r
+ e2.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
+ }\r
+\r
+ try {\r
+ theStorageObject.freeConnection(con, stmt);\r
+ }\r
+ catch (Throwable t) {\r
+ }\r
+\r
+ throwStorageObjectFailure(e, "EntityImages -- getIcon failed:");\r
+ }\r
+\r
+ return img_in;\r
+ }\r
+\r
+ /**\r
+ * a small wrapper class that allows us to store the DB connection resources\r
+ * that the BlobInputStream is using and free them upon closing of the stream\r
+ */\r
+ private class ImageInputStream extends InputStream {\r
+\r
+ InputStream _in;\r
+ java.sql.Connection _con;\r
+ Statement _stmt;\r
+\r
+ public ImageInputStream(BlobInputStream in, java.sql.Connection con,\r
+ Statement stmt )\r
+ {\r
+ _in = in;\r
+ _con = con;\r
+ _stmt = stmt;\r
+ }\r
+\r
+ public void close () throws IOException {\r
+ _in.close();\r
+\r
+ try {\r
+ _con.setAutoCommit(true);\r
+ theStorageObject.freeConnection(_con,_stmt);\r
+ }\r
+ catch (Exception e) {\r
+ throw new IOException("close(): "+e.toString());\r
+ }\r
+ }\r
+\r
+ public int read() throws IOException {\r
+ return _in.read();\r
+ }\r
+\r
+ }\r
+}\r
import java.util.HashMap;
+import freemarker.template.SimpleList;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.media.MediaHelper;
import mir.storage.StorageObject;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
+import mir.log.LoggerWrapper;
+
import mircoders.storage.DatabaseContentToMedia;
import mircoders.storage.DatabaseUploadedMedia;
-import freemarker.template.SimpleList;
-import freemarker.template.SimpleScalar;
-import freemarker.template.TemplateModel;
-import freemarker.template.TemplateModelException;
/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
*
* @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.18 2003/02/20 16:05:33 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.19 2003/02/23 05:00:13 zapata Exp $
*/
public EntityUploadedMedia() {
super();
+
+ logger = new LoggerWrapper("Entity.UploadedMedia");
}
public EntityUploadedMedia(StorageObject theStorage) {
return "other";
}
catch (Exception ex) {
- theLog.printWarning("-- getMediaTypeString: could not fetch data "
- + this.getClass().toString() + " " + ex.toString());
+ logger.warn("EntityUploadedMedia.getMediaTypeString: could not fetch data: " + ex.toString());
}
return null;
}
return mediaHandler.getBigIconName();
}
catch (Exception ex) {
- theLog.printWarning("-- getBigIconName: could not fetch data "
- + this.getClass().toString() + " " + ex.toString());
+ logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
}
return null;
}
return mediaHandler.getURL(this, mediaType);
}
catch (Exception ex) {
- theLog.printWarning("-- getUrl: could not fetch data "
- + this.getClass().toString() + " " + ex.toString());
+ logger.warn("EntityUploadedMedia.getUrl: could not fetch data: " + ex.toString());
}
return null;
}
return mediaHandler.getDescr(mediaType);
}
catch (Exception ex) {
- theLog.printWarning("-- getDescr: could not fetch data "
- + this.getClass().toString() + " " + ex.toString());
+ logger.warn("EntityUploadedMedia.getDescr: could not fetch data: " + ex.toString());
}
return null;
}
return mediaType.getValue("mime_type");
}
catch (Exception ex) {
- theLog.printWarning("-- getBigIconName: could not fetch data "
- + this.getClass().toString() + " " + ex.toString());
+ logger.warn("EntityUploadedMedia.getBigIconName: could not fetch data: " + ex.toString());
}
return null;
}
-/*
- * 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.entity;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-
-import mir.storage.StorageObject;
-import mir.storage.StorageObjectFailure;
-
-/**
- * Diese Klasse enth?lt die Daten eines MetaObjekts
- *
- * @author RK
- * @version 11.11.2000
- */
-
-
-public class EntityVideo extends EntityUploadedMedia
-{
-
- public EntityVideo()
- {
- super();
- }
-
- public EntityVideo(StorageObject theStorage) {
- this();
- setStorage(theStorage);
- }
-
- //
- // methods
-
- public void update() throws StorageObjectFailure {
- super.update();
- try {
- theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId());
- } catch (SQLException e) {
- theLog.printError("video :: update :: failed!! "+ e.toString());
- }
- }
-
- public void setValues(HashMap theStringValues)
- {
- if (theStringValues != null) {
- if (!theStringValues.containsKey("is_published"))
- theStringValues.put("is_published","0");
- }
- super.setValues(theStringValues);
- }
-
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.entity;\r
+\r
+import java.sql.SQLException;\r
+import java.util.HashMap;\r
+\r
+import mir.storage.StorageObject;\r
+import mir.storage.StorageObjectFailure;\r
+import mir.log.LoggerWrapper;\r
+\r
+/**\r
+ * Diese Klasse enth?lt die Daten eines MetaObjekts\r
+ *\r
+ * @author RK\r
+ * @version 11.11.2000\r
+ */\r
+\r
+\r
+public class EntityVideo extends EntityUploadedMedia\r
+{\r
+ public EntityVideo() {\r
+ super();\r
+\r
+ logger = new LoggerWrapper("Entity.UploadedMedia.Video");\r
+ }\r
+\r
+ public EntityVideo(StorageObject theStorage) {\r
+ this();\r
+ setStorage(theStorage);\r
+ }\r
+\r
+ //\r
+ // methods\r
+\r
+ public void update() throws StorageObjectFailure {\r
+ super.update();\r
+\r
+ try {\r
+ theStorageObject.executeUpdate("update content set is_produced='0' where to_media=" + getId());\r
+ }\r
+ catch (SQLException e) {\r
+ logger.error("EntityVideo.update: " + e.toString());\r
+ }\r
+ }\r
+\r
+ public void setValues(HashMap theStringValues) {\r
+ if (theStringValues != null) {\r
+ if (!theStringValues.containsKey("is_published"))\r
+ theStringValues.put("is_published", "0");\r
+ }\r
+ super.setValues(theStringValues);\r
+ }\r
+\r
+}
\ No newline at end of file
protected Object clone() {
synchronized(this) {
- System.out.println(" blabla");
return new Job(data, identifier, status, priority, lastChange);
}
}
+++ /dev/null
-/*
- * 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.input;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-
-/**
- * Title: Indy-Prodsystem
- * Description:
- * Copyright: Copyright (c) 2001
- * Company: indymedia.de
- * @author idfx
- * @version 1.0
- */
-public class XmlFilenameFilter
- implements FilenameFilter {
-
- /**
- * put your documentation comment here
- */
- public XmlFilenameFilter () {
- }
-
- /**
- * @param dir
- * @param name
- * @return
- */
- public boolean accept (File dir, String name) {
- if (name.endsWith(".xml")) {
- return true;
- }
- return false;
- }
-}
-
-
-
+++ /dev/null
-/*
- * 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.
- */
-/**
- * Title: Indy
- * Description:
- * Copyright: Copyright (c) 2001
- * Company: indymedia.de
- * @author idfx
- * @version 1.0
- *
- * formatted with JxBeauty (c) johann.langhofer@nextra.at
- */
-
-
-
-package mircoders.input;
-
-import java.util.HashMap;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-
-/**
- * put your documentation comment here
- */
-public class XmlHandler extends DefaultHandler {
- static HashMap valueHash = new HashMap();
-
- /**
- * parses every starting XML-Element
- * @param uri
- * @param name
- * @param qname
- * @param atts
- */
- public void startElement (String uri, String name, String qname, Attributes atts) {
- HashMap values = new HashMap();
- if (name.equals("content")) {
- //table content
- valueHash.put("table", "Content");
- valueHash.put("values", values);
- // content-articles should be published immediatly
- ((HashMap)valueHash.get("values")).put("is_published", "1");
- }
- else if (name.equals("breaking")) {
- //table content
- valueHash.put("table", "Breaking");
- valueHash.put("values", values);
- }
- else {
- //System.out.println(name + ": " + atts.getValue("value"));
- ((HashMap)valueHash.get("values")).put(name, atts.getValue("value"));
- }
- }
-
- /**
- * Returns the HashMap filled with the Values of the parsed XML-File
- * @return
- */
- public static HashMap returnHash () {
- return valueHash;
- }
-}
-
-
-
protected LoggerWrapper logger;\r
\r
public MirBasicDataModelLocalizer() {\r
+ model=null;\r
+ logger = new LoggerWrapper("Localizer.DataModel");\r
}\r
\r
public EntityAdapterModel adapterModel() throws MirLocalizerFailure {\r
- logger = new LoggerWrapper("Localizer.Basic");\r
-\r
if (model==null)\r
model = buildModel();\r
\r
}\r
}\r
catch (Throwable t) {\r
- System.out.println("ContentToIconField: exception: " +t.getMessage());\r
- t.printStackTrace(System.out);\r
+ logger.error("ContentToIconField: " +t.getMessage());\r
throw new RuntimeException(t.getMessage());\r
}\r
\r
Map configMap = new HashMap();
Map utilityMap = new HashMap();
- logger = new LoggerWrapper("Localizer.Basic.ProducerAssistant");
+ logger = new LoggerWrapper("Localizer.ProducerAssistant");
// obsolete:
configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
// "new":
try {
configMap.putAll( MirPropertiesConfiguration.instance().allSettings() );
- } catch (PropertiesConfigExc e) {
- e.printStackTrace(System.err);
+ }
+ catch (PropertiesConfigExc e) {
+ throw new RuntimeException("Can't get configuration: " + e.getMessage());
}
utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
import mircoders.localizer.MirLocalizerExc;
import mircoders.localizer.MirLocalizerFailure;
import mircoders.localizer.MirProducerLocalizer;
-import mircoders.producer.CompositeProducerFactory;
-import mircoders.producer.OldProducerAdapterFactory;
-import mircoders.producer.ProducerAudio;
-import mircoders.producer.ProducerImages;
-import mircoders.producer.ProducerOther;
-import mircoders.producer.ProducerVideo;
import mircoders.producer.reader.SupplementalProducerNodeBuilders;
public class MirBasicProducerLocalizer implements MirProducerLocalizer {
i = usedFiles.iterator();
while (i.hasNext())
aFileMonitor.addFile((File) i.next());
-
- setupFactories(aFactories);
}
- protected void setupFactories(List aFactories) throws MirLocalizerExc, MirLocalizerFailure {
- CompositeProducerNode node;
-
- try {
- aFactories.add(
- new CompositeProducerFactory("media", new ProducerFactory[] {
- new OldProducerAdapterFactory("images", new ProducerImages()),
- new OldProducerAdapterFactory("audio", new ProducerAudio()),
- new OldProducerAdapterFactory("video", new ProducerVideo()),
- new OldProducerAdapterFactory("other", new ProducerOther())
- } )
- );
- }
- catch (Exception e) {
- throw new MirLocalizerFailure(e);
- }
- };
-
public void produceAllNew() {
MirGlobal.producerEngine().addTasks(allNewProducerTasks);
};
-/*
- * 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.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-import mir.entity.Entity;
-import mir.media.MirMedia;
-import mir.media.MirMediaException;
-import mir.misc.FileUtil;
-import mir.misc.Logfile;
-import mir.misc.StringUtil;
-import freemarker.template.SimpleList;
-
-
-/**
- * This is the Generic MediaHandler. It stores the media data on
- * the filesystem and keeps basic metadata (size, type...) in the
- * DB. Usually only representation needs to be overridden.
- * See the MediaHandlerAudio class to see an example of how one
- * could override it.
- * <p>
- * Most media handlers should override this class.
- * <p>
- * In theory, it could be used to handle miscellaneous media that
- * we don't have entered in the media_type table, (like RTF documents,
- * PS, PDF, etc..)
- * <p>
- * Of course it implements the MirMedia interface.
- *
- * @see mir.media.MirMedia
- * @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerGeneric.java,v 1.13 2003/01/25 17:50:35 idfx Exp $
- */
-
-public class MediaHandlerGeneric implements MirMedia
-{
- protected static MirPropertiesConfiguration configuration;
- protected static String imageHost;
- protected static String imageRoot;
- protected static Logfile theLog;
- private final String sepChar = File.separator;
-
- static {
- try {
- configuration = MirPropertiesConfiguration.instance();
- } catch (PropertiesConfigExc e) {
- e.printStackTrace();
- }
- imageHost = configuration.getString("Producer.Image.Host");
- imageRoot = configuration.getString("Producer.ImageRoot");
- theLog = Logfile.getInstance(configuration.getStringWithHome("log/media.log"));
- }
-
- public void set (InputStream in, Entity ent, Entity mediaTypeEnt )
- throws MirMediaException {
-
- String ext = mediaTypeEnt.getValue("name");
- String mediaFname = ent.getId()+"."+ext;
- String date = ent.getValue("date");
- String datePath = StringUtil.webdbDate2path(date);
- try {
- long size = FileUtil.write(getStoragePath()+sepChar+datePath+
- sepChar+mediaFname, in);
- ent.setValueForProperty("publish_path",datePath+mediaFname);
- ent.setValueForProperty("size", new Long(size).toString());
- ent.update();
- } catch (Exception e) {
- theLog.printError(e.toString());
- throw new MirMediaException(e.toString());
- }
-
- }
-
- public void produce (Entity ent, Entity mediaTypeEnt )
- throws MirMediaException {
-
- //check first if the media file exist since produced
- //location is also the storage location
- String date = ent.getValue("date");
- String datePath = StringUtil.webdbDate2path(date);
- String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name");
- String fname = getStoragePath()+relPath;
- if(! new File(fname).exists())
- throw new MirMediaException("error in MirMedia.produce(): "+relPath+
- " does not exist!");
- }
-
- public InputStream getMedia (Entity ent, Entity mediaTypeEnt)
- throws MirMediaException {
- String publishPath = ent.getValue("publish_path");
- String fname = getStoragePath()+publishPath;
- File f = new File(fname);
- if(! f.exists())
- throw new MirMediaException("error in MirMedia.getMedia(): "+fname+
- " does not exist!");
- FileInputStream in;
- try {
- in = new FileInputStream(f);
- } catch (IOException e) {
- throw new MirMediaException("getMedia(): "+e.toString());
- }
- return in;
- }
-
- public InputStream getIcon (Entity ent) throws MirMediaException {
- return null;
- }
-
- public String getStoragePath()
- {
- return configuration.getString("Producer.Media.Path");
- }
-
- public String getIconStoragePath()
- {
- return configuration.getString("Producer.Image.IconPath");
- }
-
- public String getPublishHost()
- {
- return StringUtil.removeSlash(configuration.getString("Producer.Media.Host"));
- }
-
- public String getTinyIconName()
- {
- return configuration.getString("Producer.Icon.TinyText");
- }
-
- public String getBigIconName()
- {
- return configuration.getString("Producer.Icon.BigText");
- }
-
- public String getIconAltName()
- {
- return "Generic media";
- }
-
- public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
- {
- SimpleList theList = new SimpleList();
- theList.add(ent);
- return theList;
- }
-
- public boolean isVideo()
- {
- return false;
- }
-
- public boolean isAudio()
- {
- return false;
- }
-
- public boolean isImage()
- {
- return false;
- }
-
- public String getDescr( Entity mediaType)
- {
- return mediaType.getValue("mime_type");
- }
-
-}
-
-
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.media;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+import freemarker.template.SimpleList;\r
+\r
+import mir.log.LoggerWrapper;\r
+\r
+import mir.config.MirPropertiesConfiguration;\r
+import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;\r
+import mir.entity.Entity;\r
+import mir.media.MirMedia;\r
+import mir.media.MirMediaException;\r
+import mir.misc.FileUtil;\r
+import mir.misc.StringUtil;\r
+\r
+\r
+/**\r
+ * This is the Generic MediaHandler. It stores the media data on\r
+ * the filesystem and keeps basic metadata (size, type...) in the\r
+ * DB. Usually only representation needs to be overridden.\r
+ * See the MediaHandlerAudio class to see an example of how one\r
+ * could override it.\r
+ * <p>\r
+ * Most media handlers should override this class.\r
+ * <p>\r
+ * In theory, it could be used to handle miscellaneous media that\r
+ * we don't have entered in the media_type table, (like RTF documents,\r
+ * PS, PDF, etc..)\r
+ * <p>\r
+ * Of course it implements the MirMedia interface.\r
+ *\r
+ * @see mir.media.MirMedia\r
+ * @author mh <mh@nadir.org>\r
+ * @version $Id: MediaHandlerGeneric.java,v 1.14 2003/02/23 05:00:14 zapata Exp $\r
+ */\r
+\r
+public class MediaHandlerGeneric implements MirMedia\r
+{\r
+ protected static MirPropertiesConfiguration configuration;\r
+ protected static String imageHost;\r
+ protected static String imageRoot;\r
+\r
+ protected LoggerWrapper logger;\r
+\r
+ static {\r
+ try {\r
+ configuration = MirPropertiesConfiguration.instance();\r
+ } catch (PropertiesConfigExc e) {\r
+ e.printStackTrace();\r
+ }\r
+ imageHost = configuration.getString("Producer.Image.Host");\r
+ imageRoot = configuration.getString("Producer.ImageRoot");\r
+ }\r
+\r
+ public MediaHandlerGeneric() {\r
+ logger = new LoggerWrapper("Media.Generic");\r
+ }\r
+\r
+ public void set (InputStream in, Entity ent, Entity mediaTypeEnt ) throws MirMediaException {\r
+ String ext = mediaTypeEnt.getValue("name");\r
+ String mediaFname = ent.getId() + "." + ext;\r
+ String date = ent.getValue("date");\r
+ String datePath = StringUtil.webdbDate2path(date);\r
+ try {\r
+ long size = FileUtil.write(getStoragePath() + File.separator + datePath +\r
+ File.separator + mediaFname, in);\r
+ ent.setValueForProperty("publish_path", datePath + mediaFname);\r
+ ent.setValueForProperty("size", new Long(size).toString());\r
+ ent.update();\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("MediaHandlerGeneric.set: " + e.toString());\r
+ throw new MirMediaException(e.toString());\r
+ }\r
+ }\r
+\r
+ public void produce (Entity ent, Entity mediaTypeEnt )\r
+ throws MirMediaException {\r
+\r
+ //check first if the media file exist since produced\r
+ //location is also the storage location\r
+ String date = ent.getValue("date");\r
+ String datePath = StringUtil.webdbDate2path(date);\r
+ String relPath = datePath+ent.getId()+"."+mediaTypeEnt.getValue("name");\r
+ String fname = getStoragePath()+relPath;\r
+ if(! new File(fname).exists())\r
+ throw new MirMediaException("error in MirMedia.produce(): "+relPath+\r
+ " does not exist!");\r
+ }\r
+\r
+ public InputStream getMedia (Entity ent, Entity mediaTypeEnt)\r
+ throws MirMediaException {\r
+ String publishPath = ent.getValue("publish_path");\r
+ String fname = getStoragePath()+publishPath;\r
+ File f = new File(fname);\r
+ if(! f.exists())\r
+ throw new MirMediaException("error in MirMedia.getMedia(): "+fname+\r
+ " does not exist!");\r
+ FileInputStream in;\r
+ try {\r
+ in = new FileInputStream(f);\r
+ } catch (IOException e) {\r
+ throw new MirMediaException("getMedia(): "+e.toString());\r
+ }\r
+ return in;\r
+ }\r
+\r
+ public InputStream getIcon (Entity ent) throws MirMediaException {\r
+ return null;\r
+ }\r
+\r
+ public String getStoragePath()\r
+ {\r
+ return configuration.getString("Producer.Media.Path");\r
+ }\r
+\r
+ public String getIconStoragePath()\r
+ {\r
+ return configuration.getString("Producer.Image.IconPath");\r
+ }\r
+\r
+ public String getPublishHost()\r
+ {\r
+ return StringUtil.removeSlash(configuration.getString("Producer.Media.Host"));\r
+ }\r
+\r
+ public String getTinyIconName()\r
+ {\r
+ return configuration.getString("Producer.Icon.TinyText");\r
+ }\r
+\r
+ public String getBigIconName()\r
+ {\r
+ return configuration.getString("Producer.Icon.BigText");\r
+ }\r
+\r
+ public String getIconAltName()\r
+ {\r
+ return "Generic media";\r
+ }\r
+\r
+ public SimpleList getURL(Entity ent, Entity mediaTypeEnt)\r
+ {\r
+ SimpleList theList = new SimpleList();\r
+ theList.add(ent);\r
+ return theList;\r
+ }\r
+\r
+ public boolean isVideo()\r
+ {\r
+ return false;\r
+ }\r
+\r
+ public boolean isAudio()\r
+ {\r
+ return false;\r
+ }\r
+\r
+ public boolean isImage()\r
+ {\r
+ return false;\r
+ }\r
+\r
+ public String getDescr( Entity mediaType)\r
+ {\r
+ return mediaType.getValue("mime_type");\r
+ }\r
+\r
+}\r
+\r
+\r
+\r
import java.io.File;
import java.io.InputStream;
+import freemarker.template.SimpleList;
+
import mir.config.MirPropertiesConfiguration;
import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
import mir.entity.Entity;
import mir.media.MirMedia;
import mir.media.MirMediaException;
import mir.misc.FileUtil;
-import mir.misc.Logfile;
import mir.misc.StringUtil;
import mir.storage.StorageObjectFailure;
+import mir.log.LoggerWrapper;
+
import mircoders.entity.EntityImages;
-import freemarker.template.SimpleList;
/**
* This class handles saving, fetching creating representations
*
* @see mir.media.MirMedia
* @author mh
- * @version $Id: MediaHandlerImages.java,v 1.16 2003/01/25 17:50:35 idfx Exp $
+ * @version $Id: MediaHandlerImages.java,v 1.17 2003/02/23 05:00:14 zapata Exp $
*/
public abstract class MediaHandlerImages implements MirMedia
{
- static MirPropertiesConfiguration configuration;
- static Logfile theLog;
- static final String PNG = "PNG";
- static final String JPEG = "JPEG";
+ protected static MirPropertiesConfiguration configuration;
+ protected static final String PNG = "PNG";
+ protected static final String JPEG = "JPEG";
+
+ protected LoggerWrapper logger;
static {
try {
configuration = MirPropertiesConfiguration.instance();
- } catch (PropertiesConfigExc e) {
- e.printStackTrace();
}
- theLog = Logfile.getInstance(configuration.getString("Home")+"log/media.log");
+ catch (PropertiesConfigExc e) {
+ throw new RuntimeException("Can't get configuration: " + e.getMessage());
+ }
}
-
+
abstract String getType();
- public InputStream getMedia(Entity ent, Entity mediaTypeEnt)
+ public MediaHandlerImages() {
+ logger = new LoggerWrapper("Media.Images");
+ }
+
+ public InputStream getMedia(Entity ent, Entity mediaTypeEnt)
throws MirMediaException
{
InputStream in;
try {
in = ((EntityImages)ent).getImage();
- } catch ( StorageObjectFailure e) {
- theLog.printDebugInfo("MediaHandlerImages.getImage: "+e.toString());
+ }
+ catch ( StorageObjectFailure e) {
+ logger.error("MediaHandlerImages.getImage: "+e.toString());
throw new MirMediaException(e.toString());
}
((EntityImages)ent).setImage(in, getType());
}
catch ( StorageObjectFailure e) {
- e.printStackTrace(System.out);
- theLog.printError("MediaHandlerImages.set: "+e.getMessage());
+ logger.error("MediaHandlerImages.set: "+e.getMessage());
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));
throw new MirMediaException(e.getMessage());
}
}
ent.setValueForProperty("icon_path",getIconStoragePath()+filepath);
ent.setValueForProperty("publish_path",filepath);
ent.update();
- } catch ( Exception e) {
- String msg = "MediaHandlerImages.produce - Error: " + e.toString();
- theLog.printError(msg);
- throw new MirMediaException(msg);
}
- } else {
- String msg="MediaHandlerImages.produce - missing image or icon OID for: "+
- ent.getId();
- theLog.printError(msg);
- throw new MirMediaException(msg);
+ catch (Throwable e) {
+ logger.error("MediaHandlerImages.produce: " + e.toString());
+ throw new MirMediaException("MediaHandlerImages.produce: " + e.toString());
+ }
+ }
+ else {
+ logger.error("MediaHandlerImages.produce: missing image or icon OID for: " + ent.getId());
+ throw new MirMediaException("MediaHandlerImages.produce: missing image or icon OID for: " + ent.getId());
}
}
InputStream in;
try {
in = ((EntityImages)ent).getIcon();
- } catch ( StorageObjectFailure e) {
- theLog.printDebugInfo("MediaHandlerImages.getIcon: "+e.toString());
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerImages.getIcon: " + e.toString());
throw new MirMediaException(e.toString());
}
import java.io.FileInputStream;\r
import java.io.InputStream;\r
\r
+import mir.log.LoggerWrapper;\r
import mir.config.MirPropertiesConfiguration;\r
import mir.entity.Entity;\r
import mir.media.MirMediaException;\r
import mir.misc.StringUtil;\r
+\r
import mircoders.storage.DatabaseUploadedMedia;\r
\r
\r
\r
public class MediaHandlerImagesExtern extends MediaHandlerGeneric\r
{\r
+ public MediaHandlerImagesExtern() {\r
+ logger = new LoggerWrapper("Media.Images.Extern");\r
+ }\r
+\r
public void produce(Entity anImageEntity, Entity mediaTypeEnt) throws MirMediaException\r
{\r
try {\r
}\r
processor.writeScaledData(iconFile);\r
\r
+ logger.info(processor.getWidth()+"x"+processor.getHeight());\r
+\r
anImageEntity.setValueForProperty("img_height", new Integer(processor.getHeight()).toString());\r
anImageEntity.setValueForProperty("img_width", new Integer(processor.getWidth()).toString());\r
\r
}\r
}\r
catch(Throwable t) {\r
- t.printStackTrace(System.out);\r
+ logger.error("MediaHandlerImagesExtern.produce: " + t.getMessage());\r
+ t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
throw new MirMediaException(t.getMessage());\r
}\r
}\r
-/*
- * 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.io.StringReader;
-
-import mir.entity.Entity;
-import mir.media.MirMedia;
-import mir.media.MirMediaException;
-import mir.misc.FileUtil;
-import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
-
-
-/**
- * Please note: this media handler produces
- * 3 media files, the raw .mp3, a .m3u which is
- * contains the URL for the mp3 and a .pls which
- * contains the URL to the mp3 in shoutcast playlist
- * format. What's important is that the web server (of
- * the media host) must recognize the .m3u and .pls file
- * extensions and send the proper "audio/x-mpegurl"
- * and "audio/x-scpls" mime-types respectively.
- * If the web server is apache, it's easy, just
- * add:
- *
- * audio/x-mpegurl m3u
- * audio/x-scpl pls
- *
- * to the file pointed to by the "TypesConfig"
- * command in your apache config file. Or add
- * and equivalent AddType command to your httpd.conf.
- * Of course this assumes that the mod_mime is loaded.
- *
- * If the web server is not apache, then your on your own.
- *
- * @see mir.media.MirMedia
- * @author mh <mh@nadir.org>
- * @version $Id: MediaHandlerMp3.java,v 1.10 2003/01/25 17:50:35 idfx Exp $
- */
-
-public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia
-{
-
- public void produce (Entity ent, Entity mediaTypeEnt )
- throws MirMediaException {
-
- // first check if the file exists
- super.produce(ent, mediaTypeEnt);
-
- String baseName = ent.getId();
- String date = ent.getValue("date");
- String datePath = StringUtil.webdbDate2path(date);
- String mp3Pointer = getPublishHost()+ent.getValue("publish_path");
- String mpegURLFile = baseName+".m3u";
- String playlistFile = baseName+".pls";
-
- try {
- //write the "meta" files
- //first the .m3u since it only contains one line
- FileUtil.write(getStoragePath()+"/"+datePath+"/"+mpegURLFile,
- new StringReader(mp3Pointer), "US-ASCII");
- //now the .pls file
- FileUtil.write(getStoragePath()+"/"+datePath+"/"+playlistFile,
- new StringReader(mp3Pointer), "US-ASCII");
- } catch (Exception e) {
- theLog.printError(e.toString());
- throw new MirMediaException(e.toString());
- }
- }
-
- public SimpleList getURL(Entity ent, Entity mediaTypeEnt)
- {
- SimpleList theList = new SimpleList();
-
- //String stringSize = ent.getValue("size");
- //int size = Integer.parseInt(stringSize, 10)/1024;
- theList.add(ent);
-
- String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
- ".mp3$","");
-
- // @todo the texts ("title") below urgently need to be sanely localizaeble
- // somehow
- SimpleHash m3uHash = new SimpleHash();
- m3uHash.put("publish_path", basePath+".m3u");
- m3uHash.put("publish_server", ent.getValue("publish_server"));
- m3uHash.put("title", "stream URL");
- theList.add(m3uHash);
-
- SimpleHash plsHash = new SimpleHash();
- plsHash.put("publish_path", basePath+".pls");
- plsHash.put("publish_server", ent.getValue("publish_server"));
- plsHash.put("title", "playlist URL");
- theList.add(plsHash);
-
- return theList;
-
- }
-
- public String getDescr(Entity mediaType)
- {
- return "mp3";
- }
-
-}
-
-
-
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.media;\r
+\r
+import java.io.StringReader;\r
+\r
+import freemarker.template.SimpleHash;\r
+import freemarker.template.SimpleList;\r
+\r
+import mir.entity.Entity;\r
+import mir.media.MirMedia;\r
+import mir.media.MirMediaException;\r
+import mir.misc.FileUtil;\r
+import mir.misc.StringUtil;\r
+import mir.log.LoggerWrapper;\r
+\r
+/**\r
+ * Please note: this media handler produces\r
+ * 3 media files, the raw .mp3, a .m3u which is\r
+ * contains the URL for the mp3 and a .pls which\r
+ * contains the URL to the mp3 in shoutcast playlist\r
+ * format. What's important is that the web server (of\r
+ * the media host) must recognize the .m3u and .pls file\r
+ * extensions and send the proper "audio/x-mpegurl"\r
+ * and "audio/x-scpls" mime-types respectively.\r
+ * If the web server is apache, it's easy, just\r
+ * add:\r
+ *\r
+ * audio/x-mpegurl m3u\r
+ * audio/x-scpl pls\r
+ *\r
+ * to the file pointed to by the "TypesConfig"\r
+ * command in your apache config file. Or add\r
+ * and equivalent AddType command to your httpd.conf.\r
+ * Of course this assumes that the mod_mime is loaded.\r
+ *\r
+ * If the web server is not apache, then your on your own.\r
+ *\r
+ * @see mir.media.MirMedia\r
+ * @author mh <mh@nadir.org>\r
+ * @version $Id: MediaHandlerMp3.java,v 1.11 2003/02/23 05:00:14 zapata Exp $\r
+ */\r
+\r
+public class MediaHandlerMp3 extends MediaHandlerAudio implements MirMedia\r
+{\r
+ protected LoggerWrapper logger;\r
+\r
+ public MediaHandlerMp3() {\r
+ logger = new LoggerWrapper("Media.Audio.Mp3");\r
+ }\r
+\r
+ public void produce(Entity ent, Entity mediaTypeEnt) throws MirMediaException {\r
+\r
+ // first check if the file exists\r
+ super.produce(ent, mediaTypeEnt);\r
+\r
+ String baseName = ent.getId();\r
+ String date = ent.getValue("date");\r
+ String datePath = StringUtil.webdbDate2path(date);\r
+ String mp3Pointer = getPublishHost() + ent.getValue("publish_path");\r
+ String mpegURLFile = baseName + ".m3u";\r
+ String playlistFile = baseName + ".pls";\r
+\r
+ try {\r
+ //write the "meta" files\r
+ //first the .m3u since it only contains one line\r
+ FileUtil.write(getStoragePath() + "/" + datePath + "/" + mpegURLFile,\r
+ new StringReader(mp3Pointer), "US-ASCII");\r
+ //now the .pls file\r
+ FileUtil.write(getStoragePath() + "/" + datePath + "/" + playlistFile,\r
+ new StringReader(mp3Pointer), "US-ASCII");\r
+ }\r
+ catch (Throwable e) {\r
+ logger.error("MediaHandlerMp3.produce: " + e.toString());\r
+ throw new MirMediaException(e.toString());\r
+ }\r
+ }\r
+\r
+ public SimpleList getURL(Entity ent, Entity mediaTypeEnt) {\r
+ SimpleList theList = new SimpleList();\r
+\r
+ //String stringSize = ent.getValue("size");\r
+ //int size = Integer.parseInt(stringSize, 10)/1024;\r
+ theList.add(ent);\r
+\r
+ String basePath = StringUtil.regexpReplace(ent.getValue("publish_path"),\r
+ ".mp3$", "");\r
+\r
+ // @todo the texts ("title") below urgently need to be sanely localizaeble\r
+ // somehow\r
+ SimpleHash m3uHash = new SimpleHash();\r
+ m3uHash.put("publish_path", basePath + ".m3u");\r
+ m3uHash.put("publish_server", ent.getValue("publish_server"));\r
+ m3uHash.put("title", "stream URL");\r
+ theList.add(m3uHash);\r
+\r
+ SimpleHash plsHash = new SimpleHash();\r
+ plsHash.put("publish_path", basePath + ".pls");\r
+ plsHash.put("publish_server", ent.getValue("publish_server"));\r
+ plsHash.put("title", "playlist URL");\r
+ theList.add(plsHash);\r
+\r
+ return theList;\r
+\r
+ }\r
+\r
+ public String getDescr(Entity mediaType) {\r
+ return "mp3";\r
+ }\r
+}\r
+\r
+\r
+\r
import java.io.StringReader;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+
+import mir.log.LoggerWrapper;
import mir.entity.Entity;
import mir.media.MirMedia;
import mir.media.MirMediaException;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MirMedia
* @author john <john@manifestor.org>, mh <heckmann@hbe.ca>
- * @version $Id: MediaHandlerRealAudio.java,v 1.14 2003/01/25 17:50:35 idfx Exp $
+ * @version $Id: MediaHandlerRealAudio.java,v 1.15 2003/02/23 05:00:14 zapata Exp $
*/
-public class MediaHandlerRealAudio extends MediaHandlerAudio implements
- MirMedia
+public class MediaHandlerRealAudio extends MediaHandlerAudio implements MirMedia
{
+ public MediaHandlerRealAudio() {
+ logger = new LoggerWrapper("Media.Audio.Real");
+ }
+
public void produce (Entity ent, Entity mediaTypeEnt )
throws MirMediaException {
//write an rm (ram?. -mh) file
FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
new StringReader(RealMediaPointer), "US-ASCII");
- } catch (Exception e) {
- theLog.printError(e.toString());
+ }
+ catch (Throwable e) {
+ logger.error("MediaHandlerRealAudio.produce: " + e.toString());
throw new MirMediaException(e.toString());
}
}
//String stringSize = ent.getValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
-
+
String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
".ra$","");
theList.add(ramHash);
return theList;
-
}
public String getStoragePath()
}
}
-
-
+
+
package mircoders.media;
import java.io.StringReader;
+import java.io.File;
+import freemarker.template.SimpleHash;
+import freemarker.template.SimpleList;
+
+import mir.log.LoggerWrapper;
import mir.entity.Entity;
import mir.media.MirMedia;
import mir.media.MirMediaException;
import mir.misc.FileUtil;
import mir.misc.StringUtil;
-import freemarker.template.SimpleHash;
-import freemarker.template.SimpleList;
* @see mir.media.MediaHandlerGeneric
* @see mir.media.MirMedia
* @author john <john@manifestor.org>, mh <mh@nadir.org>
- * @version $Id: MediaHandlerRealVideo.java,v 1.14 2003/01/25 17:50:35 idfx Exp $
+ * @version $Id: MediaHandlerRealVideo.java,v 1.15 2003/02/23 05:00:14 zapata Exp $
*/
-public class MediaHandlerRealVideo extends MediaHandlerVideo implements
- MirMedia
+public class MediaHandlerRealVideo extends MediaHandlerVideo implements MirMedia
{
+ protected LoggerWrapper logger;
+
+ public MediaHandlerRealVideo() {
+ logger = new LoggerWrapper("Media.Video.Real");
+ }
+
public void produce (Entity ent, Entity mediaTypeEnt )
throws MirMediaException {
String RealMediaFile = datePath+ent.getId()+".ram";
try {
//write an rm (ram?. -mh) file
- FileUtil.write(super.getStoragePath()+"/"+RealMediaFile,
+ FileUtil.write(super.getStoragePath()+File.separator+RealMediaFile,
new StringReader(RealMediaPointer), "US-ASCII");
- } catch (Exception e) {
- theLog.printError(e.toString());
+ }
+ catch (Exception e) {
+ logger.error("MediaHandlerRealVideo.produce: " + e.toString());
+
throw new MirMediaException(e.toString());
}
}
//String stringSize = ent.getValue("size");
//int size = Integer.parseInt(stringSize, 10)/1024;
theList.add(ent);
-
+
String basePath=StringUtil.regexpReplace(ent.getValue("publish_path"),
".rm$","");
}
}
-
-
+
+
-/*
- * 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 mir.media.MirMedia;
-
-
-/**
- * Handles video media, like mpeg, av, and qt
- * It is like MediaHandlerAudio with different icons.
- * It is MediaHandlerGeneric with different icons.
- *
- * @see mir.media.MediaHandlerGeneric
- * @see mir.media.MirMedia
- * @author john <john@manifestor.org>
- * @version $Id: MediaHandlerVideo.java,v 1.6 2003/01/25 17:50:35 idfx Exp $
- */
-
-public class MediaHandlerVideo extends MediaHandlerGeneric implements MirMedia
-{
-
- private static String tinyIcon;
- private static String bigIcon;
-
- static {
- tinyIcon = configuration.getString("Producer.Icon.TinyVideo");
- bigIcon = configuration.getString("Producer.Icon.BigVideo");
-
- }
-
- public String getTinyIcon()
- {
- return tinyIcon;
- }
-
- public String getBigIconName()
- {
- return bigIcon;
- }
-
- public String getIconAlt()
- {
- return "Video";
- }
-
- public boolean isVideo()
- {
- return true;
- }
-}
+/*\r
+ * Copyright (C) 2001, 2002 The Mir-coders group\r
+ *\r
+ * This file is part of Mir.\r
+ *\r
+ * Mir is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Mir is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with Mir; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ *\r
+ * In addition, as a special exception, The Mir-coders gives permission to link\r
+ * the code of this program with the com.oreilly.servlet library, any library\r
+ * licensed under the Apache Software License, The Sun (tm) Java Advanced\r
+ * Imaging library (JAI), The Sun JIMI library (or with modified versions of\r
+ * the above that use the same license as the above), and distribute linked\r
+ * combinations including the two. You must obey the GNU General Public\r
+ * License in all respects for all of the code used other than the above\r
+ * mentioned libraries. If you modify this file, you may extend this exception\r
+ * to your version of the file, but you are not obligated to do so. If you do\r
+ * not wish to do so, delete this exception statement from your version.\r
+ */\r
+\r
+package mircoders.media;\r
+\r
+import mir.media.MirMedia;\r
+\r
+\r
+/**\r
+ * Handles video media, like mpeg, av, and qt\r
+ * It is like MediaHandlerAudio with different icons.\r
+ * It is MediaHandlerGeneric with different icons.\r
+ *\r
+ * @see mir.media.MediaHandlerGeneric\r
+ * @see mir.media.MirMedia\r
+ * @author john <john@manifestor.org>\r
+ * @version $Id: MediaHandlerVideo.java,v 1.7 2003/02/23 05:00:14 zapata Exp $\r
+ */\r
+\r
+public class MediaHandlerVideo extends MediaHandlerGeneric implements MirMedia\r
+{\r
+ private static String tinyIcon;\r
+ private static String bigIcon;\r
+\r
+ static {\r
+ tinyIcon = configuration.getString("Producer.Icon.TinyVideo");\r
+ bigIcon = configuration.getString("Producer.Icon.BigVideo");\r
+ }\r
+\r
+ public String getTinyIcon() {\r
+ return tinyIcon;\r
+ }\r
+\r
+ public String getBigIconName() {\r
+ return bigIcon;\r
+ }\r
+\r
+ public String getIconAlt() {\r
+ return "Video";\r
+ }\r
+\r
+ public boolean isVideo() {\r
+ return true;\r
+ }\r
+}\r
import javax.servlet.ServletContext;
+import com.oreilly.servlet.multipart.FilePart;
+
+import mir.log.LoggerWrapper;
import mir.config.MirPropertiesConfiguration;
import mir.entity.Entity;
import mir.entity.EntityList;
import mir.storage.Database;
import mir.storage.StorageObjectExc;
import mir.storage.StorageObjectFailure;
-import mircoders.producer.ProducerMedia;
+
import mircoders.storage.DatabaseMediaType;
-import com.oreilly.servlet.multipart.FilePart;
/*
* MediaRequest.java -
* appropriate media objects are set.
*
* @author mh
- * @version $Id: MediaRequest.java,v 1.12 2003/01/25 17:50:35 idfx Exp $
+ * @version $Id: MediaRequest.java,v 1.13 2003/02/23 05:00:14 zapata Exp $
*
*/
public class MediaRequest implements FileHandler
{
+ private String _user;
+ private EntityList _returnList = new EntityList();
+ private boolean _publish;
+ private LoggerWrapper logger;
- String _user;
- EntityList _returnList = new EntityList();
- boolean _produce, _publish;
-
- public MediaRequest(String user, boolean produce, boolean publish) {
+ public MediaRequest(String user, boolean publish) {
_user = user;
- _produce = produce;
_publish = publish;
+ logger = new LoggerWrapper("Media.Request");
}
public EntityList getEntityList() {
String mediaId=null;
MirMedia mediaHandler;
Database mediaStorage = null;
- ProducerMedia mediaProducer = null;
try {
String fileName = filePart.getFileName();
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));
//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);
Entity mediaEnt = null;
try {
mediaEnt = (Entity)mediaStorage.getEntityClass().newInstance();
- if (_produce == true) {
- Class prodCls = Class.forName("mircoders.producer.Producer"+
- mediaType.getValue("tablename"));
- mediaProducer = (ProducerMedia)prodCls.newInstance();
- }
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new FileHandlerException("Error in MediaRequest: "+e.toString());
}
mediaHandler.set(filePart.getInputStream(), mediaEnt, mediaType);
}
catch (MirMediaException e) {
- e.printStackTrace(System.out);
throw new FileHandlerException(e.getMessage());
}
- try {
- if (_produce == true )
- mediaProducer.handle(null, null, false, false, mediaId);
- } catch (ModuleException e) {
- // first try to delete it.. don't catch exception as we've already..
- try { mediaStorage.delete(mediaId); } catch (Exception e2) {}
- throw new FileHandlerException("error in MediaRequest: "+e.toString());
- }
_returnList.add(mediaEnt);
}
catch (StorageObjectFailure e) {
// first try to delete it.. don't catch exception as we've already..
- try { mediaStorage.delete(mediaId); } catch (Exception e2) {}
+ try {
+ mediaStorage.delete(mediaId);
+ }
+ catch (Exception e2) {
+ }
throw new FileHandlerException("error in MediaRequest: "+e.toString());
- } catch (StorageObjectExc e) {
+ }
+ catch (StorageObjectExc e) {
throw new FileHandlerException("error in MediaRequest: "+e.toString());
} //end try/catch block
return theEntity.getId();
}
catch (StorageObjectFailure e) {
- e.printStackTrace(System.err);
throw new ModuleException(e.toString());
- } catch (StorageObjectExc e) {
- e.printStackTrace(System.err);
+ }
+ catch (StorageObjectExc e) {
throw new ModuleException(e.toString());
}
}
+++ /dev/null
-/*
- * 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.producer;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import mir.log.LoggerWrapper;
-import mir.producer.ProducerExc;
-import mir.producer.ProducerFailure;
-
-public class CompositeProducer implements mir.producer.Producer {
- private List producers;
-
- public CompositeProducer() {
- producers = new Vector();
- }
-
- public void addProducer(mir.producer.Producer aProducer) {
- producers.add(aProducer);
- }
-
- public void produce( LoggerWrapper aLogger ) throws ProducerFailure, ProducerExc {
- Iterator i;
-
- i=producers.iterator();
-
- while (i.hasNext())
- ((mir.producer.Producer) i.next()).produce(aLogger);
- }
-
- public void abort() {
-
- }
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import mir.producer.ProducerExc;
-import mir.producer.ProducerFactory;
-import mir.producer.ProducerFailure;
-
-public class CompositeProducerFactory implements ProducerFactory {
- private Map factories; // verb -> Vector ( ProducerFactory )
- private List verbs;
- private String name;
-
- public CompositeProducerFactory(String aName) {
- factories = new HashMap();
- verbs = new Vector();
- name = aName;
- }
-
- public CompositeProducerFactory(String aName, ProducerFactory[] aSubProducerFactories) {
- this(aName);
-
- int i;
-
- for (i=0; i<aSubProducerFactories.length; i++) {
- addFactory(aSubProducerFactories[i]);
- }
- }
-
- private List findFactoriesForVerb(String aVerb) {
- List result = (List) factories.get(aVerb);
-
- if (result==null)
- result = new Vector();
-
- return result;
- }
-
- private List factoriesForVerb(ProducerVerb aVerb) {
- List result;
-
- result=(List) factories.get(aVerb.getName());
-
- if (result==null) {
- result=new Vector();
-
- verbs.add(aVerb);
- factories.put(aVerb.getName(), result);
- }
-
- return result;
- }
-
- public void addFactory(ProducerFactory aFactory) {
- Iterator i;
-
- i=aFactory.verbs();
-
- while (i.hasNext()) {
- factoriesForVerb((ProducerVerb) i.next()).add(aFactory);
- }
- }
-
- public mir.producer.Producer makeProducer(String aVerb, Map aBasicValueSet) throws ProducerExc, ProducerFailure {
- CompositeProducer result = new CompositeProducer();
-
- Iterator i=findFactoriesForVerb(aVerb).iterator();
-
- while (i.hasNext())
- result.addProducer(((ProducerFactory) i.next()).makeProducer(aVerb, aBasicValueSet));
-
- return result;
- }
-
- public Iterator verbs() {
- return verbs.iterator();
- }
-
- public String getName() {
- return name;
- }
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import java.io.PrintWriter;
-
-import mir.log.LoggerToWriterAdapter;
-import mir.log.LoggerWrapper;
-import mir.producer.ProducerFailure;
-
-public class OldProducerAdapter implements mir.producer.Producer {
-
- private mircoders.producer.Producer oldProducer;
- private Boolean forced;
-
- public OldProducerAdapter( mircoders.producer.Producer anOldProducer, Boolean aForced ) {
- oldProducer = anOldProducer;
- forced = aForced;
- }
-
- public void produce( LoggerWrapper aLogger ) throws ProducerFailure {
- try {
- oldProducer.handle( new PrintWriter(new LoggerToWriterAdapter( aLogger, LoggerWrapper.INFO_MESSAGE )), null, forced.booleanValue(), false );
- }
- catch (Throwable e) {
- throw new ProducerFailure("Failure at handling old Producers",e);
- }
- }
-
- public void abort() {
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.producer;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import mir.producer.ProducerFactory;
-import mir.producer.SimpleProducerVerb;
-
-public class OldProducerAdapterFactory implements ProducerFactory {
- private List verbs;
- private String name;
-
- private mircoders.producer.Producer oldProducer;
-
- public OldProducerAdapterFactory(String aName, mircoders.producer.Producer anOldProducer) {
- name = aName;
- verbs = new Vector();
-
- verbs.add(new SimpleProducerVerb("new", "generate only altered items"));
- verbs.add(new SimpleProducerVerb("all", "generate all items"));
-
- oldProducer = anOldProducer;
- }
-
- public Iterator verbs() {
- return verbs.iterator();
- }
-
- public mir.producer.Producer makeProducer(String aVerb, Map anInitialValues) {
- return new OldProducerAdapter(oldProducer, new Boolean(aVerb.equals("all")));
- }
-
- public String getName() {
- return name;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.producer;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-
-import mir.config.MirPropertiesConfiguration;
-import mir.misc.HTMLParseException;
-import mir.misc.HTMLTemplateProcessor;
-import mir.misc.LineFilterWriter;
-import mir.misc.Logfile;
-import mir.module.ModuleException;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityUsers;
-import mircoders.module.ModuleContent;
-import mircoders.module.ModuleFeature;
-import mircoders.module.ModuleImages;
-import mircoders.module.ModuleLinksImcs;
-import mircoders.module.ModuleSchwerpunkt;
-import mircoders.module.ModuleTopics;
-import mircoders.module.ModuleUploadedMedia;
-import mircoders.storage.DatabaseContent;
-import mircoders.storage.DatabaseFeature;
-import mircoders.storage.DatabaseImages;
-import mircoders.storage.DatabaseLinksImcs;
-import mircoders.storage.DatabaseTopics;
-import freemarker.template.TemplateModelRoot;
-
-abstract public class Producer {
-
- protected static MirPropertiesConfiguration configuration;
- protected static String producerDocRoot;
- protected static String producerStorageRoot;
- protected static String producerProductionHost;
- protected static String producerOpenAction;
- protected static String actionRoot;
- protected static Logfile theLog;
- protected static ModuleTopics topicsModule;
- protected static ModuleLinksImcs linksImcsModule;
- protected static ModuleSchwerpunkt schwerpunktModule;
- protected static ModuleFeature featureModule;
- protected static ModuleContent contentModule;
- protected static ModuleImages imageModule;
- protected static ModuleUploadedMedia uploadedMediaModule;
-
- static {
- // init
- try {
- configuration = MirPropertiesConfiguration.instance();
- producerDocRoot = configuration.getString("Producer.DocRoot");
- producerStorageRoot = configuration.getString("Producer.StorageRoot");
- producerProductionHost = configuration.getString("Producer.ProductionHost");
- producerOpenAction = configuration.getString("Producer.OpenAction");
- actionRoot = configuration.getString("RootUri") + "/Mir";
- theLog = Logfile.getInstance(configuration.getStringWithHome("Producer.Logfile"));
- contentModule = new ModuleContent(DatabaseContent.getInstance());
- topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
- linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
- schwerpunktModule = new ModuleSchwerpunkt(DatabaseFeature.getInstance());
- featureModule = new ModuleFeature(DatabaseFeature.getInstance());
- imageModule = new ModuleImages(DatabaseImages.getInstance());
- uploadedMediaModule = new ModuleUploadedMedia(DatabaseImages.getInstance());
-
- }
- catch(Exception e)
- {
- System.err.println("*** failed to initialize Producer " + e.toString());
- }
- }
-
- public void handle(PrintWriter htmlout, EntityUsers user)
- throws StorageObjectFailure, ModuleException {
- handle(htmlout,user,false,false);
- }
-
- abstract public void handle(PrintWriter htmlout, EntityUsers user, boolean forced, boolean sync)
- throws StorageObjectFailure, ModuleException;
-
-//
-// Methods for producing files
-
- public boolean produce(String template, String filename, TemplateModelRoot model, PrintWriter htmlout) {
- return _produce(template, filename, model, htmlout, false,
- configuration.getString("Mir.DefaultEncoding"));
- }
-
- public boolean produce(String template, String filename, TemplateModelRoot model, PrintWriter htmlout, String encoding) {
- return _produce(template, filename, model, htmlout, false, encoding);
- }
-
- public boolean produce_compressed(String template, String filename, TemplateModelRoot model, PrintWriter htmlout) {
- return _produce(template, filename, model, htmlout, true,
- configuration.getString("Mir.DefaultEncoding"));
- }
-
- private boolean _produce(String template, String filename, TemplateModelRoot model, PrintWriter htmlout, boolean compressed, String encoding) {
- try {
- File f = new File(producerStorageRoot + filename);
- File dir = new File(f.getParent());
- dir.mkdirs();
- // it's important that we set the desired encoding. It should be UTF8
- // not the platform default.
- OutputStreamWriter outputFileStream =
- new OutputStreamWriter(new FileOutputStream(f), encoding);
- PrintWriter outStream;
- if (compressed==true) {
- outStream = new LineFilterWriter(outputFileStream);
- } else {
- outStream = new PrintWriter(outputFileStream);
- }
-
- HTMLTemplateProcessor.process(null,template, model, outStream,null);
- outputFileStream.close();
- outStream.close();
-
- printHTML(htmlout, "Produced <a href=\"" + producerProductionHost+producerDocRoot +
- filename + "\">" + filename + "</a>");
- //theLog.printInfo("Produced: " + producerStorageRoot + filename);
- //theLog.printDebugInfo("free mem:" + java.lang.Runtime.getRuntime().freeMemory());
- //theLog.printDebugInfo("total mem:" + java.lang.Runtime.getRuntime().totalMemory());
- return true;
-
- } catch(IOException exception){
- logHTML(htmlout, "Producer: File could not be written " + filename);
- System.out.println(exception.toString());
- return false;
- } catch(HTMLParseException exception){
- logHTML(htmlout,"Producer: Error in HTML-parsing: " + filename);
- return false;
- }
- }
-
- //
- // filename methods
-
- public String indexFileNameForPageCount(int pc) {
- return fileNameForPageCount("/index", pc);
- }
-
- public String fileNameForPageCount(String stub, int pc) {
- String fileName = producerDocRoot + stub;
- if (pc>1) {
- fileName+=pc;
- }
- fileName += ".html";
- return fileName;
- }
-
- /**
- * logging
- */
-
- public void logHTMLFinish(PrintWriter htmlout,String moduleName, int pageCount, long startTime, long endTime) {
- // timing and message to browser
- long overall = endTime - startTime;
- int pagesPerMinute=0; float perMinute = (float)overall/(float)60000;
- if (perMinute >0) pagesPerMinute = (int) ((float)pageCount / perMinute);
-
- logHTML(htmlout, "Producer."+moduleName+" finished producing: " +
- overall + " ms for "+ pageCount+" Pages = " +pagesPerMinute + " pages/min");
- printHTML(htmlout, "Back to <a href=\""+actionRoot+"\">Admin-Startage</a>");
- }
-
- public void logHTML(PrintWriter out, String s) {
- _print(out, s, true);
- }
-
- public void printHTML(PrintWriter out, String s) {
- _print(out, s, false);
- }
-
- private void _print(PrintWriter out, String s, boolean log) {
- if (out != null) { out.println(s+"<br />");out.flush(); }
- if (log == true) {
- theLog.printInfo(s);
- }
- }
-
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseAudio;
-
-
-public class ProducerAudio extends ProducerMedia {
-
- protected Database getStorage() throws StorageObjectFailure {
- return DatabaseAudio.getInstance();
- }
-
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseImages;
-
-
-public class ProducerImages extends ProducerMedia {
-
- protected Database getStorage() throws StorageObjectFailure {
- return DatabaseImages.getInstance();
- }
-
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import java.io.PrintWriter;
-
-import mir.entity.Entity;
-import mir.entity.EntityList;
-import mir.media.MediaHelper;
-import mir.media.MirMedia;
-import mir.module.ModuleException;
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.entity.EntityUsers;
-import mircoders.storage.DatabaseUploadedMedia;
-
-abstract public class ProducerMedia extends Producer {
-
- abstract Database getStorage() throws StorageObjectFailure;
-
- public void handle(PrintWriter htmlout, EntityUsers user, boolean force,
- boolean sync) throws StorageObjectFailure, ModuleException {
- handle(htmlout,user,force,sync,null);
- }
-
- public void handle(PrintWriter htmlout,EntityUsers user,boolean force,
- boolean sync, String id) throws StorageObjectFailure, ModuleException
- {
- long sessionConnectTime = 0;
- long startTime = (new java.util.Date()).getTime();
- String whereClause;
- String orderBy;
- Entity currentMedia;
- MirMedia currentMediaHandler;
- EntityList batchEntityList;
-
- int contentBatchsize =
- Integer.parseInt(configuration.getString("Producer.Content.Batchsize"));
- orderBy = "webdb_lastchange desc";
-
- // get batch of non-produced medias, that are to be published
- whereClause="is_published='1'";
- if (id!= null) {
- whereClause += " and id="+id;
- // optimization to avoid select count(*)..
- contentBatchsize = -1;
- }
- if (force==false) whereClause += " and is_produced='0'";
-
- batchEntityList = getStorage().selectByWhereClause(whereClause,
- orderBy, 0, contentBatchsize);
-
- while (batchEntityList != null) {
- for(int i=0;i<batchEntityList.size();i++) {
- currentMedia = (Entity)batchEntityList.elementAt(i);
- try {
- Entity currentMediaType =
- DatabaseUploadedMedia.getInstance().getMediaType(currentMedia);
- currentMediaHandler = MediaHelper.getHandler( currentMediaType );
-
- // now produce
- currentMediaHandler.produce(currentMedia,currentMediaType);
- currentMedia.setValueForProperty("publish_server",
- currentMediaHandler.getPublishHost());
- currentMedia.setValueForProperty("icon_is_produced", "1");
- currentMedia.setValueForProperty("is_produced", "1");
- currentMedia.update();
- logHTML(htmlout,"produced media id "+currentMedia.getId()
- +": "+currentMediaType.getValue("mime_type")+" success");
- } catch (Exception e) {
- // don't throw and exception here, just log.
- // we don't want to make the admin interface unuseable
- theLog.printError("media exception: "+currentMedia.getId()+
- e.toString());
- logHTML(htmlout, "problem with media id: "+currentMedia.getId()+
- " <font color=\"Red\"> failed!</font>: "+e.toString());
- e.printStackTrace(System.out);
- }
- }
-
- // if next batch get it...
- if (batchEntityList.hasNextBatch()){
- batchEntityList = uploadedMediaModule.getByWhereClause(whereClause,
- orderBy, batchEntityList.getNextBatch(),contentBatchsize);
- } else {
- batchEntityList=null;
- }
- }
- // Finish
- sessionConnectTime = new java.util.Date().getTime() - startTime;
- logHTML(htmlout, "Producer.Media finished: " + sessionConnectTime + " ms.");
- }
-
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseOther;
-
-
-public class ProducerOther extends ProducerMedia {
-
- protected Database getStorage() throws StorageObjectFailure {
- return DatabaseOther.getInstance();
- }
-
-}
+++ /dev/null
-/*
- * 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.producer;
-
-import mir.storage.Database;
-import mir.storage.StorageObjectFailure;
-import mircoders.storage.DatabaseVideo;
-
-
-public class ProducerVideo extends ProducerMedia {
-
- protected Database getStorage() throws StorageObjectFailure {
- return DatabaseVideo.getInstance();
- }
-
-}
* Allows one to do a basic edit of a file in a directory specified
* in the config file.
*
- * @author $Author: idfx $
- * @version $Revision: 1.4 $ $Date: 2003/01/25 17:50:36 $
+ * @author $Author: zapata $
+ * @version $Revision: 1.5 $ $Date: 2003/02/23 05:00:15 $
*
*/
if (offset==null || offset.equals("")) offset="0";
mergeData.put("offset",offset);
File dir = new File(_dirName);
- System.out.println("DIRNAME: "+_dirName);
+
FileExtFilter extFilter = new FileExtFilter(_extName);
String[] dirEntries = dir.list(extFilter);
SimpleList theList = new SimpleList();
for ( int i = 0; i < dirEntries.length; ++i ) {
- System.out.println(" FILE: "+dirEntries[i]);
theList.add(dirEntries[i]);
}
mergeData.put("filelist",theList);
* open-postings to the newswire\r
*\r
* @author mir-coders group\r
- * @version $Id: ServletModuleOpenIndy.java,v 1.58 2003/01/25 17:50:36 idfx Exp $\r
+ * @version $Id: ServletModuleOpenIndy.java,v 1.59 2003/02/23 05:00:15 zapata Exp $\r
*\r
*/\r
\r
// onetimepasswd\r
if (passwdProtection.equals("yes")) {\r
String passwd = this.createOneTimePasswd();\r
- System.out.println(passwd);\r
HttpSession session = req.getSession(false);\r
session.setAttribute("passwd", passwd);\r
mergeData.put("passwd", passwd);\r
// onetimepasswd\r
if(passwdProtection.equals("yes")){\r
String passwd = this.createOneTimePasswd();\r
- System.out.println(passwd);\r
HttpSession session = req.getSession(false);\r
session.setAttribute("passwd",passwd);\r
mergeData.put("passwd", passwd);\r
EntityList mediaList = null;\r
try {\r
// new MediaRequest, "1" is the id for the openPosting user\r
- MediaRequest mediaReq = new MediaRequest("1", true, true);\r
+ MediaRequest mediaReq = new MediaRequest("1", true);\r
mp = new WebdbMultipartRequest(req, (FileHandler)mediaReq);\r
mediaList = mediaReq.getEntityList();\r
}\r
}\r
}\r
catch (FileHandlerException e) {\r
- e.printStackTrace(System.out);\r
+ e.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));\r
throw new ServletModuleException("MediaException: "+ e.getMessage());\r
}\r
catch (IOException e) { throw new ServletModuleException("IOException: "+ e.getMessage());}\r
String producerStorageRoot=configuration.getString("Producer.StorageRoot");\r
String producerDocRoot=configuration.getString("Producer.DocRoot");\r
String publishPath = contentEnt.getValue("publish_path");\r
- String txtFilePath = producerStorageRoot + producerDocRoot + "/" + mail_language + \r
- publishPath + "/" + aid + ".txt";\r
-
+ String txtFilePath = producerStorageRoot + producerDocRoot + "/" + mail_language +\r
+ publishPath + "/" + aid + ".txt";\r
+\r
\r
File inputFile = new File(txtFilePath);\r
String content;\r
}\r
\r
SMTPClient client=new SMTPClient();\r
- try {
- int reply;\r
- client.connect(configuration.getString("ServletModule.OpenIndy.SMTPServer"));\r
- System.out.print(client.getReplyString());\r
- \r
- reply = client.getReplyCode();\r
- \r
- if(!SMTPReply.isPositiveCompletion(reply)) {\r
- client.disconnect();\r
- throw new ServletModuleUserException("SMTP server refused connection.");\r
- }\r
- \r
- client.sendSimpleMessage(configuration.getString("ServletModule.OpenIndy.EmailIsFrom"),to,content);\r
- \r
- client.disconnect();\r
- //mission accomplished\r
- deliver(req,res,mergeData,sentMailTemplate); \r
- } catch(IOException e) {\r
+ try {\r
+ int reply;\r
+ client.connect(configuration.getString("ServletModule.OpenIndy.SMTPServer"));\r
+\r
+ reply = client.getReplyCode();\r
+\r
+ if (!SMTPReply.isPositiveCompletion(reply)) {\r
+ client.disconnect();\r
+ throw new ServletModuleUserException("SMTP server refused connection.");\r
+ }\r
+\r
+ client.sendSimpleMessage(configuration.getString("ServletModule.OpenIndy.EmailIsFrom"), to, content);\r
+\r
+ client.disconnect();\r
+ //mission accomplished\r
+ deliver(req, res, mergeData, sentMailTemplate);\r
+ }\r
+ catch(IOException e) {\r
if(client.isConnected()) {\r
try {\r
client.disconnect();\r
String language = req.getParameter("language");\r
String generateFO=configuration.getString("GenerateFO");\r
String generatePDF=configuration.getString("GeneratePDF");\r
-
+\r
\r
//don't do anything if we are not making FO files, or if we are\r
//pregenerating PDF's\r
generator.generate(aResponse.getWriter(), generationData, new PrintWriter(new NullWriter()));
}
catch (Throwable t) {
- t.printStackTrace(System.out);
+ t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE));
throw new ServletModuleException(t.getMessage());
}
}
* ServletModuleBilder -
* liefert HTML fuer Bilder
*
- * @version $Id: ServletModuleUploadedMedia.java,v 1.15 2003/01/25 17:50:36 idfx Exp $
+ * @version $Id: ServletModuleUploadedMedia.java,v 1.16 2003/02/23 05:00:15 zapata Exp $
* @author RK, the mir-coders group
*/
throws ServletModuleException, ServletModuleUserException {
try {
EntityUsers user = _getUser(req);
- MediaRequest mediaReq = new MediaRequest(user.getId(), false, false);
+ MediaRequest mediaReq = new MediaRequest(user.getId(), false);
WebdbMultipartRequest mp = new WebdbMultipartRequest(req, (FileHandler)mediaReq);
EntityList mediaList = mediaReq.getEntityList();
\r
public SimpleList getPopupData() throws StorageObjectFailure {\r
SimpleList pData = null;\r
- try {\r
- pData = getPopupData("name", false);\r
- }\r
- catch (StorageObjectFailure e) {\r
- System.err.println("FF");\r
- }\r
+ pData = getPopupData("name", false);\r
+\r
return pData;\r
}\r
}\r