return loc;
}
- // ACHTUNG DEPRECATED::::
- public void process(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException {
- }
-
public void redirect(HttpServletResponse aResponse, String aQuery) throws ServletModuleException {
try {
aResponse.sendRedirect(MirConfig.getProp("RootUri") + "/Mir?"+aQuery);
* Dispatcher, calls the method passed to ServletModule Class, through the "do"
* Parameter (via POST or GET)
*
- * @version $Id: ServletModuleDispatch.java,v 1.9 2002/11/29 13:43:41 zapata Exp $
+ * @version $Id: ServletModuleDispatch.java,v 1.10 2002/11/30 19:45:56 zapata Exp $
*
* @Author rk
*
*/
public final class ServletModuleDispatch {
- private static LoggerWrapper logger = new LoggerWrapper("servlet.dispatch");
+ private static LoggerWrapper logger = new LoggerWrapper("ServletModule.Dispatch");
private static final Class[] SIGNATURE = { HttpServletRequest.class, HttpServletResponse.class };
/**
protected ProducerEngine() {
producerJobQueue = new JobQueue();
- logger = new LoggerWrapper("producer");
+ logger = new LoggerWrapper("Producer");
queueThread = new Thread(new ProducerJobQueueThread());
queueThread.start();
import mir.entity.adapter.*;
public interface MirAdminInterfaceLocalizer {
- public Map simpleCommentOperations();
- public Map simpleArticleOperations();
+ public List simpleCommentOperations();
+ public MirSimpleEntityOperation simpleCommentOperationForName(String aName);
+
+ public List simpleArticleOperations();
+ public MirSimpleEntityOperation simpleArticleOperationForName(String aName);
public interface MirSimpleEntityOperation {
+ public String getName();
public boolean isAvailable(EntityAdapter anEntity);
public void perform(EntityAdapter anEntity);
}
public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocalizer {
- private Map simpleCommentOperations;
- private Map simpleArticleOperations;
+ private Vector simpleCommentOperations;
+ private Vector simpleArticleOperations;
+ private Map simpleCommentOperationsMap;
+ private Map simpleArticleOperationsMap;
public MirBasicAdminInterfaceLocalizer() throws MirLocalizerFailure, MirLocalizerExc {
- simpleCommentOperations = new HashMap();
- simpleArticleOperations = new HashMap();
+ simpleCommentOperations = new Vector();
+ simpleArticleOperations = new Vector();
+ simpleCommentOperationsMap = new HashMap();
+ simpleArticleOperationsMap = new HashMap();
- buildSimpleCommentOperations(simpleCommentOperations);
- buildSimpleArticleOperations(simpleArticleOperations);
+ addSimpleArticleOperation(new ChangeArticleFieldOperation("newswire", "to_article_type", "0", "1"));
+ addSimpleArticleOperation(new SetArticleFieldOperation("unhide", "is_published", "1"));
+ addSimpleArticleOperation(new SetArticleFieldOperation("hide", "is_published", "0"));
+
+ addSimpleCommentOperation(new SetCommentFieldOperation("unhide", "is_published", "1"));
+ addSimpleCommentOperation(new SetCommentFieldOperation("hide", "is_published", "0"));
}
- public Map simpleCommentOperations() {
+ public List simpleCommentOperations() {
return simpleCommentOperations;
};
- public Map simpleArticleOperations() {
+ public List simpleArticleOperations() {
return simpleArticleOperations;
};
- public void buildSimpleCommentOperations(Map anOperations) throws MirLocalizerFailure, MirLocalizerExc {
- anOperations.put("hide", new HideCommentOperation());
- anOperations.put("unhide", new UnhideCommentOperation());
+ public MirSimpleEntityOperation simpleArticleOperationForName(String aName) {
+ return (MirSimpleEntityOperation) simpleArticleOperationsMap.get(aName);
};
- public void buildSimpleArticleOperations(Map anOperations) throws MirLocalizerFailure, MirLocalizerExc {
- anOperations.put("hide", new HideArticleOperation());
- anOperations.put("unhide", new UnhideArticleOperation());
+ public MirSimpleEntityOperation simpleCommentOperationForName(String aName) {
+ return (MirSimpleEntityOperation) simpleCommentOperationsMap.get(aName);
};
+ public void removeSimpleArticleOperation(String aName) {
+ simpleArticleOperations.remove(simpleArticleOperationsMap.get(aName));
+ simpleArticleOperationsMap.remove(aName);
+ }
+
+ public void addSimpleArticleOperation(MirSimpleEntityOperation anOperation) {
+ removeSimpleArticleOperation(anOperation.getName());
+ simpleArticleOperationsMap.put(anOperation.getName(), anOperation);
+ simpleArticleOperations.add(anOperation);
+ }
+
+ public void removeSimpleCommentOperation(String aName) {
+ simpleCommentOperations.remove(simpleCommentOperationsMap.get(aName));
+ simpleCommentOperationsMap.remove(aName);
+ }
+
+ public void addSimpleCommentOperation(MirSimpleEntityOperation anOperation) {
+ removeSimpleCommentOperation(anOperation.getName());
+ simpleCommentOperationsMap.put(anOperation.getName(), anOperation);
+ simpleCommentOperations.add(anOperation);
+ }
+
protected abstract static class EntityModifyingOperation implements MirSimpleEntityOperation {
+ private String name;
+
+ protected EntityModifyingOperation(String aName) {
+ name = aName;
+ }
+
+ public String getName() {
+ return name;
+ };
+
public boolean isAvailable(EntityAdapter anEntity) {
try {
-
Entity entity = anEntity.getEntity();
- return (entity instanceof EntityComment) && isAvailable((EntityComment) entity);
+ return isAvailable(entity);
}
catch (Throwable t) {
return false;
}
public static abstract class CommentModifyingOperation extends EntityModifyingOperation {
+ public CommentModifyingOperation(String aName) {
+ super(aName);
+ }
+
protected boolean isAvailable(Entity anEntity) throws StorageObjectException {
return anEntity instanceof EntityComment && isAvailable((EntityComment) anEntity);
}
}
public static abstract class ArticleModifyingOperation extends EntityModifyingOperation {
+ public ArticleModifyingOperation(String aName) {
+ super(aName);
+ }
+
protected boolean isAvailable(Entity anEntity) throws StorageObjectException {
- return anEntity instanceof EntityContent && isAvailable((EntityComment) anEntity);
+ return anEntity instanceof EntityContent && isAvailable((EntityContent) anEntity);
}
protected void performModification(Entity anEntity) throws StorageObjectException {
protected abstract void performModification(EntityContent anArticle) throws StorageObjectException ;
}
- private static class HideCommentOperation extends CommentModifyingOperation {
- protected boolean isAvailable(EntityComment aComment) {
- return aComment.getValue("is_published").equals("1");
- }
- protected void performModification(EntityComment aComment) throws StorageObjectException {
- aComment.setValueForProperty("is_published", "0");
+ protected static class SetCommentFieldOperation extends CommentModifyingOperation {
+ private String field;
+ private String value;
+
+ public SetCommentFieldOperation(String aName, String aField, String aValue) {
+ super(aName);
+
+ field = aField;
+ value = aValue;
}
- }
- private static class UnhideCommentOperation extends CommentModifyingOperation {
protected boolean isAvailable(EntityComment aComment) {
- return aComment.getValue("is_published").equals("0");
+ return aComment.getValue(field) == null || !aComment.getValue(field).equals(value);
}
+
protected void performModification(EntityComment aComment) throws StorageObjectException {
- aComment.setValueForProperty("is_published", "1");
+ aComment.setValueForProperty(field, value);
}
}
- private static class HideArticleOperation extends ArticleModifyingOperation {
+ protected static class SetArticleFieldOperation extends ArticleModifyingOperation {
+ private String field;
+ private String value;
+
+ public SetArticleFieldOperation(String aName, String aField, String aValue) {
+ super(aName);
+
+ field = aField;
+ value = aValue;
+ }
+
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue("is_published").equals("1");
+ return anArticle.getValue(field) == null || !anArticle.getValue(field).equals(value);
}
+
protected void performModification(EntityContent anArticle) throws StorageObjectException {
- anArticle.setValueForProperty("is_published", "0");
+ anArticle.setValueForProperty(field, value);
}
}
- private static class UnhideArticleOperation extends ArticleModifyingOperation {
+ protected static class ChangeArticleFieldOperation extends ArticleModifyingOperation {
+ private String field;
+ private String oldValue;
+ private String newValue;
+
+ public ChangeArticleFieldOperation(String aName, String aField, String anOldValue, String aNewValue) {
+ super(aName);
+
+ field = aField;
+ newValue = aNewValue;
+ oldValue = anOldValue;
+ }
+
protected boolean isAvailable(EntityContent anArticle) {
- return anArticle.getValue("is_published").equals("0");
+ return anArticle.getValue(field) != null && anArticle.getValue(field).equals(oldValue);
}
+
protected void performModification(EntityContent anArticle) throws StorageObjectException {
- anArticle.setValueForProperty("is_published", "1");
+ anArticle.setValueForProperty(field, newValue);
}
}
}
\ No newline at end of file
\r
anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
anEntityAdapterDefinition.addCalculatedField("content_data_parsed", new FilteredField("content_data"));\r
+\r
+ anEntityAdapterDefinition.addCalculatedField("operations",\r
+ new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleArticleOperations()));\r
}\r
catch (Throwable t) {\r
throw new MirLocalizerFailure(t.getMessage(), t);\r
anEntityAdapterDefinition.addCalculatedField("to_content", new CommentToContentField());\r
\r
anEntityAdapterDefinition.addCalculatedField("description_parsed", new FilteredField("description"));\r
- anEntityAdapterDefinition.addCalculatedField("operations", new CommentToOperationsField());\r
+ anEntityAdapterDefinition.addCalculatedField("operations",\r
+ new EntityToSimpleOperationsField(MirGlobal.localizer().adminInterface().simpleCommentOperations()));\r
}\r
catch (Throwable t) {\r
throw new MirLocalizerFailure(t.getMessage(), t);\r
}\r
}\r
\r
- protected class CommentToOperationsField implements EntityAdapterDefinition.CalculatedField {\r
+ protected class EntityToSimpleOperationsField implements EntityAdapterDefinition.CalculatedField {\r
+ private List operations;\r
+\r
+ public EntityToSimpleOperationsField(List anOperations) {\r
+ operations = anOperations;\r
+ }\r
+\r
public Object getValue(EntityAdapter anEntityAdapter) {\r
try {\r
- Map operations = MirGlobal.localizer().adminInterface().simpleCommentOperations();\r
- Iterator i = operations.entrySet().iterator();\r
+ Iterator i = operations.iterator();\r
List availableOperations = new Vector();\r
\r
while (i.hasNext()) {\r
- Map.Entry entry = (Map.Entry) i.next();\r
-\r
MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =\r
- (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) entry.getValue();\r
+ (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();\r
\r
if (operation.isAvailable(anEntityAdapter)) {\r
- availableOperations.add(entry.getKey());\r
+ availableOperations.add(operation.getName());\r
}\r
};\r
\r
import mircoders.localizer.*;
public class MirBasicLocalizer implements MirLocalizer {
- protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
+// protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
public MirProducerLocalizer producers() throws MirLocalizerFailure, MirLocalizerExc {
return new MirBasicProducerLocalizer();
protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
public MirBasicProducerLocalizer() {
-
-
-
try {
String allNewProducers = MirGlobal.getConfigProperty("Mir.Localizer.Producer.AllNewProducers");
allNewProducerTasks = ProducerEngine.ProducerTask.parseProducerTaskList(allNewProducers);
/*
* ContentObjekt -
*
- * @version $Id: ModuleContent.java,v 1.11 2002/11/29 13:43:42 zapata Exp $
+ * @version $Id: ModuleContent.java,v 1.12 2002/11/30 19:45:56 zapata Exp $
*
* @author RK, mir-coders
*
}
return theStorage.selectByWhereClause(whereClause, orderBy, offset);
}
- catch (StorageObjectException e){ throw new ModuleException(e.toString()); }
+ catch (StorageObjectException e) {
+ throw new ModuleException(e.toString());
+ }
}
}
import mircoders.storage.*;
import mircoders.module.*;
import mircoders.entity.*;
+import mircoders.localizer.*;
/*
* ServletModuleContent -
* deliver html for the article admin form.
*
- * @version $Id: ServletModuleContent.java,v 1.23 2002/11/29 13:43:42 zapata Exp $
+ * @version $Id: ServletModuleContent.java,v 1.24 2002/11/30 19:45:56 zapata Exp $
* @author rk, mir-coders
*
*/
if (req.getParameter("prev") != null)
offset = Integer.parseInt(req.getParameter("prevoffset"));
-
-
returnArticleList(req, res, whereParam, orderParam, offset);
}
try {
EntityUsers user = _getUser(req);
HashMap withValues = getIntersectingValues(req, DatabaseContent.getInstance());
-//theLog.printDebugInfo(":: content :: got intersecting values");
+
String now = StringUtil.date2webdbDate(new GregorianCalendar());
withValues.put("date", now);
withValues.put("publish_path", StringUtil.webdbDate2path(now));
if (!withValues.containsKey("is_html"))
withValues.put("is_html","0");
-// ML: this is not multi-language friendly and this can be done in a template
-// if (withValues.get("creator").toString().equals(""))
-// withValues.put("creator","Anonym");
-
-
String id = mainModule.add(withValues);
DatabaseContentToTopics.getInstance().setTopics(id,req.getParameterValues("to_topic"));
-//theLog.printDebugInfo(":: content :: inserted");
+
_showObject(id, req, res);
}
catch (StorageObjectException e) {
public void delete(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
{
EntityUsers user = _getUser(req);
-// hier pruefen ob dem akt. user loeschen erlaubt ist...
+
String idParam = req.getParameter("id");
if (idParam == null) throw new ServletModuleException("Invalid call: id missing");
logger.info("where = " + req.getParameter("where"));
if (confirmParam == null && cancelParam == null) {
-// HTML Ausgabe zum Confirmen!
+
SimpleHash mergeData = new SimpleHash();
mergeData.put("module", "Content");
mergeData.put("infoString", "Content: " + idParam);
try {
mainModule.deleteById(idParam);
- /** @todo the following two should be imlied in
+ /** @todo the following two should be implied in
* DatabaseContent */
//delete rows in the content_x_topic-table
entContent = withValues;
}
-
extraInfo.put("themenPopupData", themenModule.getTopicsAsSimpleList());
try {
extraInfo.put("articletypePopupData", DatabaseArticleType.getInstance().getPopupData());
}
extraInfo.put("schwerpunktPopupData", schwerpunktModule.getSchwerpunktAsSimpleList());
-// hier code um zur liste zurueckzukommen
+
+ // code to be able to return to the list:
String offsetParam, whereParam, orderParam;
if ((offsetParam = req.getParameter("offset"))!=null) extraInfo.put("offset", offsetParam);
if ((whereParam = req.getParameter("where"))!=null) extraInfo.put("where", whereParam);
if ((orderParam = req.getParameter("order"))!=null) extraInfo.put("order", orderParam);
+
extraInfo.put("login_user", _getUser(req));
deliver(req, res, entContent, extraInfo, templateObjektString);
- } catch (Exception e) {
+ }
+ catch (Exception e) {
throw new ServletModuleException(e.toString());
}
}
import mir.servlet.*;
import mir.entity.adapter.*;
+import mir.log.*;
+
import mircoders.global.*;
import mircoders.localizer.*;
import mircoders.storage.*;
import mircoders.entity.*;
+import mircoders.module.*;
public class ServletModuleLocalizer extends ServletModule {
private static ServletModuleLocalizer instance = new ServletModuleLocalizer();
-
public static ServletModule getInstance() { return instance; }
+ private ModuleContent contentModule;
+
+ private ServletModuleLocalizer() {
+ try {
+ contentModule = new ModuleContent(DatabaseContent.getInstance());
+
+ logger = new LoggerWrapper("ServletModule.Localizer");
+ }
+ catch (Exception e) {
+ logger.error("ServletModuleLocalizer could not be initialized: " + e.getMessage());
+ }
+ }
+
+
public void commentoperation(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
{
try {
EntityComment comment = (EntityComment) DatabaseComment.getInstance().selectById(commentId);
MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =
(MirAdminInterfaceLocalizer.MirSimpleEntityOperation)
- MirGlobal.localizer().adminInterface().simpleCommentOperations().get(operationKey);
+ MirGlobal.localizer().adminInterface().simpleArticleOperationForName(operationKey);
EntityAdapter adapter = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("comment", comment);
throw new ServletModuleException(t.getMessage());
}
}
+
+ public void articleoperation(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleException {
+ String articleIdString = aRequest.getParameter("articleid");
+ String operationString = aRequest.getParameter("operation");
+ String returnUrlString = aRequest.getParameter("returnurl");
+
+ MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation;
+ EntityAdapter article;
+ EntityContent entity;
+
+ try {
+ entity = (EntityContent) contentModule.getById(articleIdString);
+
+ if (entity!=null) {
+ article = MirGlobal.localizer().dataModel().adapterModel().makeEntityAdapter("content", entity);
+ operation = MirGlobal.localizer().adminInterface().simpleArticleOperationForName(operationString);
+ operation.perform(article);
+ }
+
+ redirect(aResponse, returnUrlString);
+ }
+ catch (Throwable e) {
+ e.printStackTrace(System.out);
+ throw new ServletModuleException(e.getMessage());
+ }
+ }
+
+
}
\ No newline at end of file
* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.47 2002/11/29 14:22:30 john Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.48 2002/11/30 19:45:57 zapata Exp $
*
*/
private ServletModuleOpenIndy() {
try {
- logger = new LoggerWrapper("ServletModule.OpenIndy.Logfile");
+ logger = new LoggerWrapper("ServletModule.OpenIndy");
+
commentFormTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentTemplate");
commentFormDoneTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentDoneTemplate");
commentFormDupeTemplate = MirConfig.getProp("ServletModule.OpenIndy.CommentDupeTemplate");
}
catch (StorageObjectException e) {
- logger.error("servletmoduleopenindy could not be initialized");
+ logger.error("servletmoduleopenindy could not be initialized: " + e.getMessage());
}
}