📄 jwmacontroller.java
字号:
session.redirect(JwmaKernel.FOLDER_VIEW); }//doDeleteFolders /** * Creates a folder with a given name and a given type and redirects * to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * @param foldername the full path of a possible new folder of the * actual store. * @param type the type of the folder to be created as <tt>int</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doCreateFolder(JwmaSession session, String foldername, int type) throws JwmaException { //create the folder session.getJwmaStore().createFolder(foldername, type); //redirect to folder view session.redirect(JwmaKernel.FOLDER_VIEW); }//doCreateFolder /** * Moves the given folders to a given destination folder * and redirects to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * @param foldernames an array of strings; each <tt>String</tt> * representing the full path of a valid folder of the * actual store. * @param destination the full path of a valid folder of the * actual store. * * @throws JwmaException if it fails to execute properly. */ private void doMoveFolders(JwmaSession session, String[] foldernames, String destname) throws JwmaException { //move the folders session.getJwmaStore().moveFolders(foldernames, destname); //redirect to folder view session.redirect(JwmaKernel.FOLDER_VIEW); }//doMoveFolders private void doDisplaySubscribedFolders(JwmaSession session) { session.redirect(JwmaKernel.SUBSCRIBED_VIEW); }//doDisplaySubscribedFolders private void doDisplayUnsubscribedFolders(JwmaSession session) { session.redirect(JwmaKernel.UNSUBSCRIBED_VIEW); }//doDisplayUnsubscribedFolders private void doUnsubscribeFolders(JwmaSession session, String[] foldernames) throws JwmaException { //Unsubscribe the folders session.getJwmaStore().updateFolderSubscription(foldernames,false); //redirect to subscription view session.redirect(JwmaKernel.SUBSCRIBED_VIEW); }//doUnsubscribeFolders private void doSubscribeFolders(JwmaSession session, String[] foldernames) throws JwmaException { //Subscribe the folders session.getJwmaStore().updateFolderSubscription(foldernames,true); //redirect to subscription view session.redirect(JwmaKernel.UNSUBSCRIBED_VIEW); }//doUnsubscribeFolders /*** End Folder Actions ***********************************************************/ /*** Message Actions *****************************************************/ /** * Prepares a given message for display and redirects to the * message view. * * @param session a <tt>JwmaSession</tt> instance. * @param number of the message to be displayed as <tt>int</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doDisplayMessage(JwmaSession session, int number) throws JwmaException { JwmaFolderImpl folder = session.getJwmaStore().getActualFolder(); //1. check folder existence if (!folder.checkMessageExistence(number)) { throw new JwmaException("message.display.existence"); } //store newly created bean session.storeBean("jwma.message", folder.getJwmaMessage(number) ); //redirect to message view session.redirect(JwmaKernel.MESSAGE_VIEW); }//doDisplayMessage /** * Displays the next message in the actual folder. * If there is no message left, it redirects to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * * @throws JwmaException if it fails to execute properly. */ private void doDisplayNextMessage(JwmaSession session) throws JwmaException { int next = session.getJwmaStore().getActualFolder() .getNextMessageNumber(); //if (next != -1) { if (next >= 1) { doDisplayMessage(session, next); } else { //FIXME: folder view? session.redirect(JwmaKernel.FOLDER_VIEW); } }//doDisplayNextMessage /** * Displays the previous message in the actual folder. * If there is no previous message left, it redirects * to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * * @throws JwmaException if it fails to execute properly. */ private void doDisplayPreviousMessage(JwmaSession session) throws JwmaException { int previous = session.getJwmaStore().getActualFolder() .getPreviousMessageNumber(); //if (previous != -1) { if (previous >= 1) { doDisplayMessage(session, previous); } else { //FIXME: folder view? session.redirect(JwmaKernel.FOLDER_VIEW); } }//doDisplayPreviousMessage /** * Deletes the active message and redirects either * to the next mail (if exists) or to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * * @throws JwmaException if it fails to execute properly. */ private void doDeleteActualMessage(JwmaSession session) throws JwmaException { int next = session.getJwmaStore().getActualFolder() .deleteActualMessage(); //if (next != -1) { if (next >= 1) { doDisplayMessage(session, next); } else { //FIXME: folder view? session.redirect(JwmaKernel.FOLDER_VIEW); } }//doDeleteActiveMessage /** * Deletes the given messages and * redirects to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * @param numbers the messages to be deleted as <tt>int[]</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doDeleteMessages(JwmaSession session, int[] numbers) throws JwmaException { //do the job session.getJwmaStore().getActualFolder().deleteMessages(numbers); //redirect to //FIXME: really folder view? session.redirect(JwmaKernel.FOLDER_VIEW); }//doDeleteMessages /** * Moves the active message to a given destination and * redirects either to the next message or to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * @param destination the full path of a valid folder of the * actual store as <tt>String</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doMoveActualMessage(JwmaSession session, String destination) throws JwmaException { int next = session.getJwmaStore().getActualFolder() .moveActualMessage(destination); //if (next != -1) { if (next >= 1) { doDisplayMessage(session, next); } else { //FIXME: folder view? session.redirect(JwmaKernel.FOLDER_VIEW); } }//doMoveActiveMessage /** * Moves the given messages and * redirects to the folder view. * * @param session a <tt>JwmaSession</tt> instance. * @param numbers the messages to be moved as <tt>int[]</tt>. * @param destination the full path of a valid folder of the * actual store as <tt>String</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doMoveMessages(JwmaSession session, String destination, int[] numbers) throws JwmaException { //do the job session.getJwmaStore().getActualFolder().moveMessages(numbers, destination); //redirect to //FIXME: really folder view? session.redirect(JwmaKernel.FOLDER_VIEW); }//doMoveMessages /** * Prepares a message model instance for * a message to be composed and redirects to * the compose view. * * @param session a <tt>JwmaSession</tt> instance. * @param reply flags whether it is a reply or not. * @param toall flags whether it is a reply to all senders * or not. * @param togglequote flags whether auto-quoting will be toggled for this message. * @param attfwd toggles whether attachments will be forwarded. * * @throws JwmaException if it fails to execute properly. */ private void doComposeMessage(JwmaSession session, String to, boolean forward, boolean reply, boolean toall, boolean togglequote, boolean attfwd) throws JwmaException { JwmaFolderImpl folder = session.getJwmaStore().getActualFolder(); JwmaComposeMessage message = null; JwmaDisplayMessage actualmsg = null; if (reply || forward) { actualmsg = (JwmaDisplayMessage) folder.getActualMessage(); } if (reply) { message = JwmaComposeMessage.createReply(actualmsg, toall, session.getPreferences(), togglequote); } else if (forward) { message = JwmaComposeMessage.createForward( session.getMailSession(), actualmsg, to, session.getPreferences(), togglequote, attfwd ); } else { message = JwmaComposeMessage.createJwmaComposeMessage( session.getMailSession() ); if (to != null) { try { message.setTo(to); } catch (MessagingException mex) { //handle probably? } } } //store compose message bean session.storeBean("jwma.composemessage", message ); //redirect to compose view session.redirect(JwmaKernel.COMPOSE_VIEW); }//doComposeMessage /** * Prepares a draft for composing and redirects to the * compose view. * * @param session a <tt>JwmaSession</tt> instance. * @param number of the draft message to be continued as * <tt>int</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doComposeDraft(JwmaSession session, int number) throws JwmaException { JwmaFolderImpl folder = session.getJwmaStore().getActualFolder(); //1. check folder existence if (!folder.checkMessageExistence(number)) { throw new JwmaException("message.draft.existence"); } JwmaMessage message = folder.getDraftMessage(number); //store newly created bean //store compose message bean session.storeBean("jwma.composemessage", message ); //redirect to compose view session.redirect(JwmaKernel.COMPOSE_VIEW); }//doComposeDraft /** * Outputs a given message part of the actual message. * * @param session a <tt>JwmaSession</tt> instance. * @param number of the message part to be displayed * as <tt>int</tt>. * * @throws JwmaException if it fails to execute properly. */ private void doDisplayMessagePart(JwmaSession session, int number) throws JwmaException { try { //1.get Messagepart JwmaFolderImpl folder = session.getJwmaStore() .getActualFolder(); JwmaDisplayMessage actualmsg = (JwmaDisplayMessage) folder.getActualMessage(); JwmaMessagePartImpl part = (JwmaMessagePartImpl) actualmsg.getMessagePart(number); //2. set content type and file name String type = new ContentType(part.getContentType()).getBaseType(); String fname = part.getName(); //we do it all for fun or not? if (fname == null) { fname = "easter.egg"; } session.getResponse().setContentType(type); session.getResponse().setHeader("Content-Disposition", "filename=" + fname);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -