⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandfetch.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                                        System.out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + ")");                                    }                                } catch (AccessControlException ace) {                                    getLogger().error("Exception storing flags for message: " + ace);                                } catch (AuthorizationException aze) {                                    getLogger().error("Exception storing flags for message: " + aze);                                } catch (Exception e) {                                    getLogger().error("Unanticipated exception storing flags for message: " + e);                                }                            }                        }                        response = UNTAGGED + SP + msn + SP + "FETCH (";                        responseAdded = false;                    }                    // Calls to underlying MimeMessage                    else if (arg.equalsIgnoreCase("RFC822")                             || arg.equalsIgnoreCase("BODY[]")                             || arg.equalsIgnoreCase("BODY.PEEK[]")) {                        System.out.println("Starting BODY[]");                        if (responseAdded) { // unlikely                            if (useUIDs) {                                response += " UID " + uid + ")";                            } else {                                response += ")";                            }                            out.println(response);                            System.out.println(response);                        }                        if (msg == null) { // probably                            if (useUIDs) {                                msg = currentMailbox.retrieveUID(uid, user);                            } else {                                msg = currentMailbox.retrieve(msn, user);                            }                        }                        if (flags == null) {                            if (useUIDs) {                                flags = currentMailbox.getFlagsUID(uid, user);                            } else {                                flags = currentMailbox.getFlags(msn, user);                            }                        }                        if (msg == null) { // bad                            out.println(tag + SP + msn + SP + BAD + "Error retrieving message3.");                            System.out.println(tag + SP + msn + SP + BAD + "Error retrieving message3.");                            getLogger().error("Retrieved null message");                            return;                        }                        try {                            long size = msg.getMessageSize();                            if (arg.equalsIgnoreCase("RFC822")) {                                out.println(UNTAGGED + SP + msn + SP + "FETCH ( RFC822 {" + size + "}");                                System.out.println(UNTAGGED + SP + msn + SP + "FETCH ( RFC822 {" + size + "}");                            } else {                                out.println(UNTAGGED + SP + msn + SP + "FETCH ( BODY[] {" + size + "}");                                System.out.println(UNTAGGED + SP + msn + SP + "FETCH ( BODY[] {" + size + "}");                            }                            msg.writeTo(outs);                            if (useUIDs) {                                out.println(" UID " + uid + ")");                                System.out.println(" UID " + uid + ")");                            } else {                                out.println(")");                                System.out.println(")");                            }                            if (! arg.equalsIgnoreCase("BODY.PEEK[]")) {                                if (flags.indexOf("Seen") == -1 ) {                                    String newflags;                                    if (useUIDs) {                                        currentMailbox.setFlagsUID(uid, user, "+flags (\\Seen)");                                        newflags = currentMailbox.getFlagsUID(uid, user);                                        out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + " UID " + uid +")");                                        System.out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + " UID " + uid +")");                                    } else {                                        currentMailbox.setFlags(msn, user, "+flags (\\Seen)");                                        newflags = currentMailbox.getFlags(msn, user);                                        out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + ")");                                        System.out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + ")");                                    }                                }                            }                        } catch (MessagingException me) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message4");                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message4");                            getLogger().error("Exception retrieving message: " + me);                        } catch (IOException ioe) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message5");                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message5");                            getLogger().error("Exception sending message: " + ioe);                        } catch (Exception e) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message6");                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message6");                            getLogger().error("Unanticipated exception retrieving message: " + e);                        }                        response = UNTAGGED + SP + msn + SP + "FETCH (";                        responseAdded = false;                    } else if (arg.equalsIgnoreCase("RFC822.TEXT")                               || arg.equalsIgnoreCase("BODY[TEXT]")                               || arg.equalsIgnoreCase("BODY.PEEK[TEXT]")) {                        System.out.println("Starting BODY[TEXT]");                        if (responseAdded) { // unlikely                            if (useUIDs) {                                response += " UID " + uid + ")";                            } else {                                response += ")";                            }                            out.println(response);                            System.out.println(response);                        }                        if (msg == null) { // probably                            if (useUIDs) {                                msg = currentMailbox.retrieveUID(uid, user);                            } else {                                msg = currentMailbox.retrieve(msn, user);                            }                        }                        if (flags == null) {                            if (useUIDs) {                                flags = currentMailbox.getFlagsUID(uid, user);                            } else {                                flags = currentMailbox.getFlags(msn, user);                            }                        }                        if (msg == null) { // bad                            out.println(tag + SP + msn + SP + NO + "Error retrieving message7.");                            System.out.println(tag + SP + msn + SP + NO + "Error retrieving message7.");                            getLogger().error("Retrieved null message");                            return;                        }                        try {                            int size = msg.getSize();                            if (arg.equalsIgnoreCase("RFC822.TEXT")) {                                out.println(UNTAGGED + SP + msn + SP + "FETCH ( RFC822.TEXT {" + size + "}");                                System.out.println(UNTAGGED + SP + msn + SP + "FETCH ( RFC822.TEXT {" + size + "}");                            } else {                                out.println(UNTAGGED + SP + msn + SP + "FETCH ( BODY[TEXT] {" + size + "}");                                System.out.println(UNTAGGED + SP + msn + SP + "FETCH ( BODY[TEXT] {" + size + "}");                            }                            msg.writeContentTo(outs);                            if (useUIDs) {                                out.println(  " UID " + uid + ")");                                System.out.println(  " UID " + uid + ")");                            } else {                                out.println(")");                                System.out.println(")");                            }                            if (! arg.equalsIgnoreCase("BODY.PEEK[TEXT]")) {                                if (flags.indexOf("Seen") == -1 ) {                                    String newflags;                                    if (useUIDs) {                                        currentMailbox.setFlagsUID(uid, user, "+flags (\\Seen)");                                        newflags = currentMailbox.getFlagsUID(uid, user);                                        out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + " UID " + uid +")");                                        System.out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + " UID " + uid +")");                                    } else {                                        currentMailbox.setFlags(msn, user, "+flags (\\Seen)");                                        newflags = currentMailbox.getFlags(msn, user);                                        out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + ")");                                        System.out.println(UNTAGGED + SP + msn + SP + "FETCH (FLAGS "                                                    + newflags + ")");                                    }                                }                            }                        } catch (MessagingException me) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message8:"+me);                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message8:"+me);                            me.printStackTrace();                            getLogger().error("Exception retrieving message: " + me);                        } catch (IOException ioe) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message9");                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message9");                            getLogger().error("Exception sending message: " + ioe);                        } catch (Exception e) {                            out.println(UNTAGGED + SP + NO + SP + "Error retrieving message10");                            System.out.println(UNTAGGED + SP + NO + SP + "Error retrieving message10");                            getLogger().error("Unanticipated exception retrieving message: " + e);                        }                        response = UNTAGGED + SP + msn + SP + "FETCH (";                        responseAdded = false;                    }   else { //unrecognised or not yet implemented                        if (responseAdded) {                            if (useUIDs) {                                response += " UID " + uid + ")";                            } else {                                response += ")";                            }                            out.println(response);                            System.out.println(response);                        }                        out.println(tag + SP + NO + SP                                    + "FETCH attribute not recognized");                        System.out.println(tag + SP + NO + SP                                    + "FETCH attribute not recognized");                        getLogger().error("Received: " + arg + " as argument to fetch");                        return;                    }                } // end while loop                if (responseAdded) {                    if (useUIDs) {                        response += " UID " + uid + ")";                    } else {                        response += ")";                    }                    out.println(response);                    System.out.println(response);                }            } // end for loop            out.println(tag + SP + OK + SP + "FETCH completed");            System.out.println(tag + SP + OK + SP + "FETCH completed");            caller.checkSize();            return;        } catch (AccessControlException ace) {            out.println(tag + SP + NO + SP + "No such mailbox");            System.out.println(tag + SP + NO + SP + "No such mailbox");            caller.logACE(ace);            return;        } catch (AuthorizationException aze) {            out.println(tag + SP + NO + SP                        + "You do not have the rights to read from mailbox: " + currentFolder);            System.out.println(tag + SP + NO + SP                        + "You do not have the rights to read from mailbox: " + currentFolder);            caller.logAZE(aze);            return ;        } catch (Exception e) {            out.println(tag + SP + NO + SP                        + "Unknown server error.");            System.out.println(tag + SP + NO + SP                        + "Unknown server error.");            getLogger().error("Exception expunging mailbox " + currentFolder + " by user " + user + " was : " + e);            if (DEEP_DEBUG) {e.printStackTrace();}            return;        }    }    private List convertMacroCommands( List fetchAttributes )    {        List convertedAttributes = new ArrayList();        // convert macro fetch commands to basic commands        Iterator iter = fetchAttributes.iterator();        while ( iter.hasNext() ) {            String arg = (String)iter.next();            if (arg.equalsIgnoreCase("FAST")) {                convertedAttributes.add("FLAGS");                convertedAttributes.add("INTERNALDATE");                convertedAttributes.add("RFC822.SIZE");            } else if (arg.equalsIgnoreCase("ALL")) {                convertedAttributes.add("FLAGS");                convertedAttributes.add("INTERNALDATE");                convertedAttributes.add("RFC822.SIZE");                convertedAttributes.add("ENVELOPE");            } else if (arg.equalsIgnoreCase("FULL")) {                convertedAttributes.add("FLAGS");                convertedAttributes.add("INTERNALDATE");                convertedAttributes.add("RFC822.SIZE");                convertedAttributes.add("ENVELOPE");                convertedAttributes.add("BODY");            }            else {                convertedAttributes.add( arg );            }            getLogger().debug("Found convertedAttributes: " + arg);        }        return convertedAttributes;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -