<exclude name="xerces.jar"/>
</fileset>
</copy>
+ <copy todir="${deploy.home}/WEB-INF/classes">
+ <fileset dir="bundles"/>
+ </copy>
<mkdir dir="${javadoc.home}"/>
<mkdir dir="${deploy.home}/log"/>
<exclude name="xerces.jar"/>
</fileset>
</copy>
+ <copy todir="${deploy.home}/WEB-INF/classes">
+ <fileset dir="bundles"/>
+ </copy>
<mkdir dir="${javadoc.home}"/>
<mkdir dir="${deploy.home}/log"/>
--- /dev/null
+hello=Hello
\ No newline at end of file
--- /dev/null
+hello=halloli
\ No newline at end of file
ServletModuleDispatch.dispatch(smod,req,res);
}
catch (ServletModuleException e) {
- handleError(res, res.getWriter(), "ServletException in Module " + moduleName + " -- " + e.toString());
+ handleError(req, res, res.getWriter(),
+ "ServletException in Module " + moduleName + " -- " + e.toString());
}
catch (ServletModuleUserException e) {
- handleUserError(res,res.getWriter(), "User error" + e.toString());
+ handleUserError(req,res,res.getWriter(), "User error" + e.toString());
}
// timing...
}
- private void handleError(HttpServletResponse res, PrintWriter out, String errorString) {
+ private void handleError(HttpServletRequest req, HttpServletResponse res,
+ PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),modelRoot,out);
+ HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),
+ modelRoot,out,req.getLocale());
out.close();
}
catch (Exception e) {
}
}
- private void handleUserError(HttpServletResponse res,PrintWriter out, String errorString) {
-
+ private void handleUserError(HttpServletRequest req, HttpServletResponse res,
+ PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.UserErrorTemplate"),modelRoot,out);
+ HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.UserErrorTemplate"),
+ modelRoot,out, req.getLocale());
out.close();
}
catch (Exception e) {
}
SimpleHash mergeData = new SimpleHash();
mergeData.put("session",sessionUrl);
- HTMLTemplateProcessor.process(res,lang+"/"+loginTemplate, mergeData, out);
+ HTMLTemplateProcessor.process(res, lang+"/"+loginTemplate, mergeData,
+ out, req.getLocale());
} catch(HTMLParseException e) {
- handleError(res, out, "Error in logintemplate.");
+ handleError(req, res, out, "Error in logintemplate.");
}
}
mergeData.put("login_user", userEntity);
if (messageModule == null) messageModule = new ModuleMessage(DatabaseMessages.getInstance());
mergeData.put("messages", messageModule.getByWhereClause(null, "webdb_create desc",0,10));
- HTMLTemplateProcessor.process(res,getLanguage(req,session)+"/"+startTemplate, mergeData,out);
+ HTMLTemplateProcessor.process(res, getLanguage(req,session)+"/"+startTemplate,
+ mergeData, out, req.getLocale());
}
catch(Exception e) {
- handleError( res,out, "error while trying to send startpage. " + e.toString());
+ handleError(req, res, out, "error while trying to send startpage. " + e.toString());
}
}
long startTime = (new java.util.Date()).getTime();
long sessionConnectTime=0;
-
-
// get the configration
if(getServletContext().getAttribute("mir.confed") == null) {
getConfig(req);
ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
}
catch (ServletModuleUserException e) {
- handleUserError(res,res.getWriter(), e.getMsg());
+ handleUserError(req,res,res.getWriter(), e.getMsg());
}
catch (ServletModuleException e){
e.printStackTrace();
- handleError(res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString());
+ handleError(req,res,res.getWriter(), "OpenIndy :: ServletException in Module ServletModule -- " + e.toString());
}
// timing...
sessionConnectTime = new java.util.Date().getTime() - startTime;
theLog.printInfo("EXECTIME (ServletModuleOpenIndy): " + sessionConnectTime + " ms");
}
- private void handleUserError(HttpServletResponse res,PrintWriter out, String errorString) {
-
+ private void handleUserError(HttpServletRequest req, HttpServletResponse res,
+ PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.UserErrorTemplate"),modelRoot,out);
+ HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.UserErrorTemplate"),
+ modelRoot, out, req.getLocale() );
out.close();
}
catch (Exception e) {
}
- private void handleError(HttpServletResponse res,PrintWriter out, String errorString) {
+ private void handleError(HttpServletRequest req, HttpServletResponse res,PrintWriter out, String errorString) {
try {
theLog.printError(errorString);
SimpleHash modelRoot = new SimpleHash();
modelRoot.put("errorstring", new SimpleScalar(errorString));
- modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(new GregorianCalendar())));
- HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),modelRoot,out);
+ modelRoot.put("date", new SimpleScalar(StringUtil.date2readableDateTime(
+ new GregorianCalendar())));
+ HTMLTemplateProcessor.process(res,MirConfig.getProp("Mir.ErrorTemplate"),
+ modelRoot,out, req.getLocale());
out.close();
}
catch (Exception e) {
import mir.entity.*;
import mir.storage.*;
import javax.servlet.http.*;
+import org.apache.struts.util.MessageResources;
/**
private static String videoHost;
private static String imageHost;
private static String openAction;
- protected static String producerDocRoot = MirConfig.getProp("Producer.DocRoot");
- protected static String producerStorageRoot = MirConfig.getProp("Producer.StorageRoot");
-
+ protected static String producerDocRoot =
+ MirConfig.getProp("Producer.DocRoot");
+ protected static String producerStorageRoot =
+ MirConfig.getProp("Producer.StorageRoot");
//
// init
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename, EntityList entList, PrintWriter out)
- throws HTMLParseException {
- process(res, templateFilename, entList, (String)null, (TemplateModelRoot)null, out);
+ public static void process(HttpServletResponse res,String templateFilename,
+ EntityList entList, PrintWriter out, Locale locale)
+ throws HTMLParseException {
+ process(res, templateFilename, entList, (String)null, (TemplateModelRoot)null, out, locale);
}
/**
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename, EntityList entList, String additionalModelName,
- TemplateModelRoot additionalModel, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename,
+ EntityList entList, String additionalModelName,
+ TemplateModelRoot additionalModel, PrintWriter out,
+ Locale locale)
throws HTMLParseException {
SimpleHash modelRoot = new SimpleHash();
if (entList == null) {
- process(null,templateFilename, modelRoot, out);
+ process(null,templateFilename, modelRoot, out, locale);
} else {
try {
modelRoot = makeSimpleHashWithEntitylistInfos(entList);
if (additionalModelName != null && additionalModel != null)
modelRoot.put(additionalModelName, additionalModel);
- process(res,templateFilename, modelRoot, out);
+ process(res,templateFilename, modelRoot, out, locale);
} catch (StorageObjectException e) {
throw new HTMLParseException(e.toString());
}
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename, HashMap mergeData, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename,
+ HashMap mergeData, PrintWriter out, Locale locale)
throws HTMLParseException {
- process(res,templateFilename, makeSimpleHash(mergeData), out);
+ process(res,templateFilename, makeSimpleHash(mergeData), out, locale);
}
/**
* @param out
* @exception HTMLParseException
*/
- public static void process(String templateFilename, PrintWriter out)
+ public static void process(String templateFilename, PrintWriter out,
+ Locale locale)
throws HTMLParseException {
- process(null,templateFilename, (TemplateModelRoot)null, out);
+ process(null,templateFilename, (TemplateModelRoot)null, out, locale);
}
* @param out
* @exception HTMLParseException
*/
- public static void process(HttpServletResponse res,String templateFilename, TemplateModelRoot tmr, PrintWriter out)
+ public static void process(HttpServletResponse res,String templateFilename,
+ TemplateModelRoot tmr, PrintWriter out, Locale locale)
throws HTMLParseException {
if (out==null) throw new HTMLParseException("no outputstream");
Template tmpl = getTemplateFor(templateFilename);
SimpleHash outPutHash = new SimpleHash();
outPutHash.put("data",tmr);
outPutHash.put("config", configHash);
-
+
+ MessageResources messages = MessageResources.getMessageResources("admin");
+ outPutHash.put("message", new MessageMethodModel(locale, messages) );
+
tmpl.process(outPutHash,out);
}
import org.apache.struts.util.*;
/**
- * A FreeMarker <code>TemplateMethodModel</code> that provides access to a
+ * A FreeMarker <code>TemplateMethodModel</code> that provides access to a
* Struts <code>MessageResources</code>, for use in Interantionalized templates.
*
- * TODO: we probably want to be doing some memoizing or something with this class*
+ * TODO: we probably want to be doing some memoizing or something with this class*
* @author Kellan <kellan@protest.net>
*
*/
/**
* The perferred locale for this instance of MessageMethod.
*/
- private Locale locale;
+ private Locale locale;
/**
* The MessageResources to query, a single instances shared for
* the lifetime of servlet.
*/
- private MessageResources messages;
+ private MessageResources messages;
- /**
- * Construct a MessageMethod that uses the JVM's default locale.
- *
- * @param message The MessageResources object to query
- */
- public MessageMethodModel(MessageResources messages) {
- this(null, messages);
- }
-
- /**
- * Construct a MessageMethod
- *
- * @param locale a Locale object, persumably initialized
- * from users Accept-Language header field
- *
- * @param message The MessageResources object to query
- */
- public MessageMethodModel(Locale locale, MessageResources messages) {
- this.locale = locale;
- this.messages = messages;
- }
+ /**
+ * Construct a MessageMethod that uses the JVM's default locale.
+ *
+ * @param message The MessageResources object to query
+ */
+ public MessageMethodModel(MessageResources messages) {
+ this(null, messages);
+ }
+ /**
+ * Construct a MessageMethod
+ *
+ * @param locale a Locale object, persumably initialized
+ * from users Accept-Language header field
+ *
+ * @param message The MessageResources object to query
+ */
+ public MessageMethodModel(Locale locale, MessageResources messages) {
+ this.locale = locale;
+ this.messages = messages;
+ }
+
/**
* Takes the first argument as a resource key, then looks up
* TODO: this is an alpha implementation. We should then check if we have
* any keys left over, and attempt to apply MessageFormat.format.
* TODO: error messages should be i18n :)
- *
- * @param arguments List passed in by FM, first arguement is a string used as the key
+ *
+ * @param arguments List passed in by FM, first arguement is a string used as the key
*/
- public TemplateModel exec(List arguments) {
- if ( arguments != null ) {
- String key = (String)arguments.get(0);
- String mesg = messages.getMessage(locale, key);
- if ( mesg == null ) {
- return unknownTagScalar;
- }
- return new SimpleScalar(mesg);
- } else {
- return missingKeyScalar;
- }
- }
-
- // i'm not real clear on how this is used - kellan :)
- public boolean isEmpty() {
- if (messages == null)
- return true;
- else
- return false;
- }
+ public TemplateModel exec(List arguments) {
+ if ( arguments != null ) {
+ String key = (String)arguments.get(0);
+ String mesg = messages.getMessage(locale, key);
+ if ( mesg == null ) {
+ return unknownTagScalar;
+ }
+ return new SimpleScalar(mesg);
+ } else {
+ return missingKeyScalar;
+ }
+ }
+
+ // i'm not real clear on how this is used - kellan :)
+ public boolean isEmpty() {
+ if (messages == null)
+ return true;
+ else
+ return false;
+ }
- private static String errUnknownTag = "TAG NOT FOUND";
- private static String missingKey = "MESSAGE CALL WITHOUT KEY";
- private static SimpleScalar unknownTagScalar =
- new SimpleScalar(errUnknownTag);
- private static SimpleScalar missingKeyScalar =
- new SimpleScalar(missingKey);
+ private static String errUnknownTag = "TAG NOT FOUND";
+ private static String missingKey = "MESSAGE CALL WITHOUT KEY";
+ private static SimpleScalar unknownTagScalar =
+ new SimpleScalar(errUnknownTag);
+ private static SimpleScalar missingKeyScalar =
+ new SimpleScalar(missingKey);
}
theList = mainModule.getByWhereClause(null, offset);
//theList = mainModule.getByWhereClause((String)null, offset);
if (theList == null || theList.getCount() == 0 || theList.getCount()>1){
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, theList, out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, theList, out,req.getLocale());
} else {
deliver(req, res, theList.elementAt(0), templateObjektString);
}
try {
//PrintWriter out = new LineFilterWriter(res.getWriter());
PrintWriter out = res.getWriter();
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out, req.getLocale());
out.close();
} catch (HTMLParseException e) {
throw new ServletModuleException(e.toString());
try {
PrintWriter out = new LineFilterWriter(res.getWriter());
//PrintWriter out = res.getWriter();
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out, req.getLocale());
out.close();
} catch (HTMLParseException e) {
throw new ServletModuleException(e.toString());
*/
private void deliver(HttpServletResponse res,HttpServletRequest req, PrintWriter out, TemplateModelRoot rtm, String templateFilename)
throws HTMLParseException {
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out);
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateFilename, rtm , out, req.getLocale());
}
/**
outStream = new PrintWriter(outputFile);
}
- HTMLTemplateProcessor.process(null,template, model, outStream);
+ HTMLTemplateProcessor.process(null,template, model, outStream,null);
outputFile.close();
outStream.close();
}
}
// raus damit
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString,
+ mergeData, res.getWriter(), req.getLocale());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
catch (IOException e) {throw new ServletModuleException(e.toString());}
}
}
// raus damit
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString,
+ mergeData, res.getWriter(),req.getLocale());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}
catch (IOException e) {throw new ServletModuleException(e.toString());}
modelRoot.put("languagelist",HTMLTemplateProcessor.makeSimpleList(theLanguageList));
if (theParentList == null || theParentList.getCount() == 0 || theParentList.getCount()>1){
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateObjektString, modelRoot, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateObjektString,
+ modelRoot, res.getWriter(), req.getLocale());
} else {
deliver(req, res, modelRoot, templateObjektString);
}
if (theImcsList.hasPrevBatch())
modelRoot.put("prev", (new Integer(theImcsList.getPrevBatch())).toString());
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, modelRoot, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString,
+ modelRoot, res.getWriter(), req.getLocale());
} catch (Exception e) {
throw new ServletModuleException(e.toString());
mergeData.put("prev", (new Integer(theList.getPrevBatch())).toString());
// raus damit
- HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString, mergeData, res.getWriter());
+ HTMLTemplateProcessor.process(res,getLanguage(req)+"/"+templateListString,
+ mergeData, res.getWriter(), req.getLocale());
}
catch (ModuleException e) {throw new ServletModuleException(e.toString());}