bufix media
[mir.git] / source / mircoders / servlet / ServletModuleAdmin.java
index eb35ba8..ac41a31 100755 (executable)
  * 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 mircoders.servlet;
@@ -35,10 +35,13 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import mir.entity.adapter.EntityIteratorAdapter;
 import mir.log.LoggerWrapper;
 import mir.servlet.ServletModule;
 import mir.servlet.ServletModuleFailure;
+import mir.util.CachingRewindableIterator;
 import mir.util.URLBuilder;
+import mircoders.global.MirGlobal;
 
 public class ServletModuleAdmin extends ServletModule
 {
@@ -47,7 +50,7 @@ public class ServletModuleAdmin extends ServletModule
 
   private ServletModuleAdmin() {
     logger = new LoggerWrapper("ServletModule.Admin");
-    defaultAction = "showSuperUserMenu";
+    defaultAction = "start";
   }
 
   public void superusermenu(HttpServletRequest aRequest, HttpServletResponse aResponse) {
@@ -55,7 +58,7 @@ public class ServletModuleAdmin extends ServletModule
     int count;
 
     try {
-      Map responseData = ServletHelper.makeGenerationData(new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
+      Map responseData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] { getLocale(aRequest), getFallbackLocale(aRequest)});
       urlBuilder.setValue("module", "Admin");
       urlBuilder.setValue("do", "superusermenu");
 
@@ -67,4 +70,35 @@ public class ServletModuleAdmin extends ServletModule
       throw new ServletModuleFailure(e);
     }
   }
+
+  public void start(HttpServletRequest aRequest, HttpServletResponse aResponse) {
+    String startTemplate = configuration.getString("Mir.StartTemplate");
+    String sessionUrl = aResponse.encodeURL("");
+
+    try {
+      Map mergeData = ServletHelper.makeGenerationData(aRequest, aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)}
+          , "bundles.admin", "bundles.adminlocal");
+      mergeData.put("messages",
+                    new CachingRewindableIterator(
+          new EntityIteratorAdapter("", "webdb_create desc", 10,
+                                    MirGlobal.localizer().dataModel().adapterModel(), "internalMessage", 10, 0)));
+
+      mergeData.put("fileeditentries", ( (ServletModuleFileEdit) ServletModuleFileEdit.getInstance()).getEntries());
+      mergeData.put("administeroperations", ( (ServletModuleLocalizer) ServletModuleLocalizer.getInstance()).getAdministerOperations());
+
+      mergeData.put("searchvalue", null);
+      mergeData.put("searchfield", null);
+      mergeData.put("searchispublished", null);
+      mergeData.put("searcharticletype", null);
+      mergeData.put("searchorder", null);
+      mergeData.put("selectarticleurl", null);
+      mergeData.put("recipes", MirGlobal.localizer().producers().getRecipeNames());
+
+      ServletHelper.generateResponse(aResponse.getWriter(), mergeData, startTemplate);
+    }
+    catch (Exception e) {
+      throw new ServletModuleFailure(e);
+    }
+  }
+
 }