* Base class the entities are derived from. Provides base functionality of
* an entity.
*
- * @version $Id: AbstractEntity.java,v 1.8.2.1 2004/01/18 17:30:56 zapata Exp $
+ * @version $Id: AbstractEntity.java,v 1.8.2.2 2004/02/08 21:05:00 zapata Exp $
*/
public class AbstractEntity implements Entity {
}
/** {@inheritDoc} */
- public void setValues(Map aMap) {
+ public void setFieldValues(Map aMap) {
if (aMap!=null) {
Iterator i = aMap.entrySet().iterator();
synchronized(this) {
* An <code>Entity</code> represents a persistent data object, typically
* stored in a database.<p>
*
- * @version $Id: Entity.java,v 1.21.2.7 2004/01/18 17:30:56 zapata Exp $
+ * @version $Id: Entity.java,v 1.21.2.8 2004/02/08 21:05:01 zapata Exp $
*/
public interface Entity
* @param aMap Map containing the new values of the Entity
*/
- public void setValues(Map aMap);
+ public void setFieldValues(Map aMap);
/**
* Returns the primary key of the Entity.
public String evaluateStringExpression(Object aContext, Object aPreparsedExpression) {
try {
- return ParameterExpander.evaluateStringExpression(aContext, (String) aPreparsedExpression);
+ return ParameterExpander.expandExpression(aContext, (String) aPreparsedExpression);
}
catch (Throwable t) {
throw new TALFailure(t);
try {
Entity theEntity = (Entity)storage.getEntityClass().newInstance();
theEntity.setStorage(storage);
- theEntity.setValues(theValues);
+ theEntity.setFieldValues(theValues);
return theEntity.insert();
}
catch (Throwable e) {
Entity theEntity = storage.selectById((String)theValues.get("id"));
if (theEntity == null)
throw new ModuleExc("No object found with id " + theValues.get("id"));
- theEntity.setValues(theValues);
+ theEntity.setFieldValues(theValues);
theEntity.update();
return theEntity.getId();
}
* Treiber, Host, User und Passwort, ueber den der Zugriff auf die
* Datenbank erfolgt.
*
- * @version $Id: Database.java,v 1.44.2.21 2004/01/18 17:30:57 zapata Exp $
+ * @version $Id: Database.java,v 1.44.2.22 2004/02/08 21:05:01 zapata Exp $
* @author rk
*
*/
if (theEntityClass != null) {
returnEntity = (Entity) theEntityClass.newInstance();
returnEntity.setStorage(this);
- returnEntity.setValues(theResultHash);
+ returnEntity.setFieldValues(theResultHash);
if (returnEntity instanceof StorableObject) {
logger.debug("CACHE: ( in) " + returnEntity.getId() + " :" + mainTable);
* 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 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.
+ * the code of this program with 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.util;
}
};
}
+
+ public static class listSizeFunction implements Generator.GeneratorFunction {
+ public Object perform(List aParameters) throws GeneratorExc, GeneratorFailure {
+ try {
+ if (aParameters.size()!=1)
+ throw new GeneratorExc("listSizeFunction: 1 parameter expected");
+ if (aParameters.get(0)==null)
+ return "";
+
+ if (!(aParameters.get(0) instanceof RewindableIterator) && !(aParameters.get(0) instanceof List))
+ throw new GeneratorExc("listSizeFunction: first parameter must be a RewindableIterator (not a "+aParameters.get(0).getClass().getName()+")");
+
+ if ((aParameters.get(0) instanceof RewindableIterator)) {
+ RewindableIterator iterator = (RewindableIterator) aParameters.get(0);
+ iterator.rewind();
+ int result=0;
+ while (iterator.hasNext()) {
+ result++;
+ iterator.next();
+ }
+
+ iterator.rewind();
+ return new Integer(result);
+ }
+ else {
+ List list = (List) aParameters.get(0);
+ return new Integer(list.size());
+ }
+ }
+ catch (GeneratorExc e) {
+ throw e;
+ }
+ catch (GeneratorFailure e) {
+ throw e;
+ }
+ catch (Throwable e) {
+ throw new GeneratorFailure(e);
+ }
+ };
+ }
}
throw new ParameterExpanderExc( "Can't set key {1}: not inside a Map", new Object[]{aKey} );
}
- public static String expandExpression(Map aMap, String anExpression) throws Exception {
+ public static String expandExpression(Object aContext, String anExpression) throws Exception {
int previousPosition = 0;
int position;
int endOfExpressionPosition;
endOfExpressionPosition++;
}
if (endOfExpressionPosition<anExpression.length()) {
- result.append(evaluateStringExpression(aMap, anExpression.substring(position+2, endOfExpressionPosition)));
+ result.append(evaluateStringExpression(aContext, anExpression.substring(position+2, endOfExpressionPosition)));
previousPosition=endOfExpressionPosition+1;
}
else {
if (aValue instanceof String)
return (String) aValue;
if (aValue instanceof Integer)
- return ((Integer) aValue).toString();
+ return aValue.toString();
throw new RuntimeException("Not a string");
}
private final static String ESCAPE= "\\\\[ tn]";
private final static String UNICODE= "\\\\u[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]";
-
private static String decode(String aValue) {
try {
SimpleParser parser = new SimpleParser(aValue);
* 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 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.
+ * the code of this program with 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.
*/
* This class handles storage of audio data and meta data
*
* @author mh
- * @version $Id: EntityAudio.java,v 1.11 2003/04/21 12:42:53 idfx Exp $
+ * @version $Id: EntityAudio.java,v 1.11.2.1 2004/02/08 21:05:02 zapata Exp $
*/
setStorage(theStorage);
}
- public void setValues(Map theStringValues) {
+ public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
theStringValues.put("is_published", "0");
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
}
* This class maps one line of the comment-table to a java-object.
*
* @author $Author: zapata $
- * @version $Revision: 1.16.2.2 $ $Date: 2004/01/18 17:30:58 $
+ * @version $Revision: 1.16.2.3 $ $Date: 2004/02/08 21:05:02 $
*/
/**
- * overridden method setValues to patch creator_main_url
+ * overridden method setFieldValues to patch creator_main_url
*/
- public void setValues(Map theStringValues)
+ public void setFieldValues(Map theStringValues)
{
if (theStringValues != null) {
if (theStringValues.containsKey("main_url")){
}
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
/**
* this class implements mapping of one line of the database table content
* to a java object
*
- * @version $Id: EntityContent.java,v 1.19.2.5 2004/01/18 17:30:58 zapata Exp $
+ * @version $Id: EntityContent.java,v 1.19.2.6 2004/02/08 21:05:02 zapata Exp $
* @author mir-coders group
*
*/
}
/**
- * overridden method setValues to patch creator_main_url
+ * overridden method setFieldValues to patch creator_main_url
*/
- public void setValues(Map theStringValues) {
+ public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (theStringValues.containsKey("creator_main_url")){
if (((String)theStringValues.get("creator_main_url")).equalsIgnoreCase("http://")){
}
}
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
}
* 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 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.
+ * the code of this program with 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.
*/
setStorage(theStorage);
}
- public void setValues(Map theStringValues) {
+ public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
theStringValues.put("is_published", "0");
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
}
/**
*
* @author mh, mir-coders group
- * @version $Id: EntityUploadedMedia.java,v 1.26.2.6 2004/01/18 17:30:58 zapata Exp $
+ * @version $Id: EntityUploadedMedia.java,v 1.26.2.7 2004/02/08 21:05:02 zapata Exp $
*/
public class EntityUploadedMedia extends AbstractEntity {
}
}
- public void setValues(Map theStringValues) {
+ public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
theStringValues.put("is_published", "0");
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
setStorage(theStorage);
}
- public void setValues(Map theStringValues) {
+ public void setFieldValues(Map theStringValues) {
if (theStringValues != null) {
if (!theStringValues.containsKey("is_published"))
theStringValues.put("is_published", "0");
}
- super.setValues(theStringValues);
+ super.setFieldValues(theStringValues);
}
}
\ No newline at end of file
Map values = getIntersectingValues(aRequest, DatabaseContent.getInstance());
EntityContent article = (EntityContent) contentModule.createNew();
- article.setValues(values);
+ article.setFieldValues(values);
finalizeArticle(aRequest, aSession, article);
id = article.insert();
Map values = getIntersectingValues(aRequest, DatabaseComment.getInstance());
EntityComment comment = (EntityComment) commentModule.createNew();
- comment.setValues(values);
+ comment.setFieldValues(values);
finalizeComment(aRequest, aSession, comment);
id = comment.insert();
if (id == null) {
throw new MediaFailure(e);
}
- mediaEntity.setValues(values);
+ mediaEntity.setFieldValues(values);
mediaId = mediaEntity.insert();
try {
if (theEntity == null)
throw new ModuleExc("No Object in the database with id " + theValues.get("id"));
DatabaseContent.getInstance().setUnproduced("id=" + theEntity.getFieldValue("to_media"));
- theEntity.setValues(theValues);
+ theEntity.setFieldValues(theValues);
theEntity.update();
return theEntity.getId();
}
if (theEntity == null) {
throw new ModuleExc("No topic with id " + theValues.get("id") + " found");
}
- theEntity.setValues(theValues);
+ theEntity.setFieldValues(theValues);
theEntity.update();
return theEntity.getId();
package mircoders.servlet;
-import gnu.regexp.RE;
-import gnu.regexp.REMatch;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import java.util.Set;
import java.util.Vector;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import gnu.regexp.RE;
+import gnu.regexp.REMatch;
import mir.entity.Entity;
import mir.generator.Generator;
import mir.log.LoggerWrapper;
import mircoders.media.MediaUploadProcessor;
import mircoders.module.ModuleComment;
import mircoders.module.ModuleContent;
-import mircoders.module.ModuleImages;
import mircoders.module.ModuleMediaType;
-import mircoders.module.ModuleTopics;
import mircoders.pdf.PDFGenerator;
import mircoders.search.AudioSearchTerm;
import mircoders.search.ContentSearchTerm;
import mircoders.storage.DatabaseContent;
import mircoders.storage.DatabaseContentToMedia;
import mircoders.storage.DatabaseContentToTopics;
-import mircoders.storage.DatabaseImages;
import mircoders.storage.DatabaseLanguage;
import mircoders.storage.DatabaseTopics;
-
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.smtp.SMTPReply;
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.10 2004/01/11 20:35:53 zapata Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.11 2004/02/08 21:05:03 zapata Exp $
*
*/
private String prepareMailTemplate,sentMailTemplate,emailAnArticleTemplate;
private ModuleContent contentModule;
private ModuleComment commentModule;
- private ModuleImages imageModule;
- private ModuleTopics topicsModule;
private String directOp ="yes";
// Singelton / Kontruktor
private static ServletModuleOpenIndy instance = new ServletModuleOpenIndy();
commentModule = new ModuleComment(DatabaseComment.getInstance());
mainModule = commentModule;
contentModule = new ModuleContent(DatabaseContent.getInstance());
- topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
- imageModule = new ModuleImages(DatabaseImages.getInstance());
- defaultAction="addposting";
+ defaultAction = "defaultAction";
}
catch (StorageObjectFailure e) {
logger.error("servletmoduleopenindy could not be initialized: " + e.getMessage());
}
/**
- * Method to return an "apology" when open postings are disabled
+ * Perform the default open posting action
+ */
+ public void defaultAction(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
+ opensession(aRequest, aResponse);
+ }
+
+ /**
+ * Method to return an out of service notice when open postings are disabled
*
* @param aRequest
* @param aResponse
* @throws ServletModuleFailure
*/
public void openPostingDisabled(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
- deliver(aRequest, aResponse, (Map) null, null,
- configuration.getString("ServletModule.OpenIndy.PostingDisabledTemplate"));
+ deliver(aRequest, aResponse, null, null, configuration.getString("ServletModule.OpenIndy.PostingDisabledTemplate"));
}
/**
* Method for making a comment
*/
-
public void addcomment(HttpServletRequest req, HttpServletResponse res) throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
if (MirGlobal.abuse().getOpenPostingDisabled()) {
openPostingDisabled(req, res);
// onetimepasswd
if (MirGlobal.abuse().getOpenPostingPassword()) {
- String passwd = this.createOneTimePasswd();
+ String passwd = generateOnetimePassword();
HttpSession session = req.getSession(false);
session.setAttribute("passwd", passwd);
mergeData.put("passwd", passwd);
}
else {
- mergeData.put("passwd", (String)null);
+ mergeData.put("passwd", null);
}
mergeData.put("aid", aid);
response.setResponseGenerator(commentFormDoneTemplate);
if (id == null) {
- deliver(req, res, (Map)null, null, commentFormDupeTemplate);
+ deliver(req, res, null, null, commentFormDupeTemplate);
}
else {
DatabaseContent.getInstance().setUnproduced("id=" + aid);
mergeData.put("passwd", passwd);
}
else {
- mergeData.put("passwd", (String)null);
+ mergeData.put("passwd", null);
}
String maxMedia = configuration.getString("ServletModule.OpenIndy.MaxMediaUploadItems");
HttpSession session = aRequest.getSession(false);
String sessionPasswd = (String) session.getAttribute("passwd");
if (sessionPasswd != null) {
- String passwd = (String) parsedRequest.getParameter("passwd");
+ String passwd = parsedRequest.getParameter("passwd");
if (passwd == null || passwd.length() == 0) {
throw new ServletModuleUserExc("posting.error.missingpassword", new String[] {});
session.invalidate();
}
- if ((((String) parsedRequest.getParameter("title")).length() == 0) ||
- (((String) parsedRequest.getParameter("description")).length() == 0) ||
- (((String) parsedRequest.getParameter("content_data")).length() == 0))
+ if (((parsedRequest.getParameter("title")).length() == 0) ||
+ ((parsedRequest.getParameter("description")).length() == 0) ||
+ ((parsedRequest.getParameter("content_data")).length() == 0))
throw new ServletModuleUserExc("posting.error.missingfield", new String[] {});
List mediaList = new Vector();
private static final String SESSION_REQUEST_KEY="sessionid";
/**
- * Selects the language for the response.
- *
- * @param session
- * @param aRequest
+ * Determines the Locale to be used for the current session
*/
-
protected Locale getResponseLocale(HttpSession aSession, HttpServletRequest aRequest) {
String requestLanguage = aRequest.getParameter("language");
String sessionLanguage = (String) aSession.getAttribute("language");
* @throws ServletModuleUserExc
* @throws ServletModuleFailure
*/
-
public void opensession(HttpServletRequest aRequest, HttpServletResponse aResponse)
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure {
/**
* Method for preparing and sending a content as an email message
*/
-
public void mail(HttpServletRequest req, HttpServletResponse res)
throws ServletModuleExc, ServletModuleUserExc, ServletModuleFailure
{
ArrayList theDocs = (ArrayList) session.getAttribute("theDocumentsSorted");
if (theDocs != null) {
- mergeData.put("numberOfHits", ( (Integer) session.getAttribute("numberOfHits")).toString());
+ mergeData.put("numberOfHits", (session.getAttribute("numberOfHits")).toString());
List theHits = new Vector();
int pIR = ( (Integer) session.getAttribute("positionInResults")).intValue();
int terminus;
throw new ServletModuleFailure(e);
}
}
-
- private String createOneTimePasswd() {
- return "";
- }
}