?? editemailgateway.jsp
字號:
<% /** * $RCSfile: editEmailGateway.jsp,v $ * $Revision: 1.3.2.1 $ * $Date: 2003/07/24 19:03:18 $ */%><%@ page import="java.util.*, java.text.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.gateway.*, com.jivesoftware.forum.util.*, com.jivesoftware.base.UnauthorizedException" errorPage="error.jsp"%><%@ include file="global.jsp" %><%! // Global variables, methods, etc. String POP3_GATEWAY = "pop3Gateway"; String IMAP_GATEWAY = "imapGateway";%><% // get parameters long forumID = ParamUtils.getLongParameter(request, "forum", -1L); boolean add = ParamUtils.getBooleanParameter(request, "add"); boolean importOnce = ParamUtils.getBooleanParameter(request, "importOnce"); boolean exportOnce = ParamUtils.getBooleanParameter(request, "exportOnce"); boolean advanced = ParamUtils.getBooleanParameter(request, "advanced"); boolean save = ParamUtils.getBooleanParameter(request, "save"); boolean createNew = ParamUtils.getBooleanParameter(request, "createNew"); boolean reload = ParamUtils.getBooleanParameter(request, "reload"); boolean edit = ParamUtils.getBooleanParameter(request, "edit"); int index = ParamUtils.getIntParameter(request, "index", -1); // form values - inbound String gatewayType = ParamUtils.getParameter(request, "gatewayType", true); String inboundHost = ParamUtils.getParameter(request, "inboundHost", false); int inboundPort = ParamUtils.getIntParameter(request, "inboundPort", 110); boolean inboundSSLEnabled = ParamUtils.getBooleanParameter(request, "inboundSSLEnabled", false); String inboundUsername = ParamUtils.getParameter(request, "inboundUsername", false); String inboundPassword = ParamUtils.getParameter(request, "inboundPassword", false); String inboundFolder = ParamUtils.getParameter(request, "inboundFolder", false); String tempParentBody = ParamUtils.getParameter(request, "tempParentBody", false); boolean deleteEnabled = ParamUtils.getBooleanParameter(request, "deleteEnabled", false); boolean inboundAttach = ParamUtils.getBooleanParameter(request, "inboundAttach", false); boolean subjectCheckEnabled = ParamUtils.getBooleanParameter(request, "subjectCheckEnabled", true); String importAfter = ParamUtils.getParameter(request, "importAfter", false); // form values - outbound String outboundHost = ParamUtils.getParameter(request, "outboundHost", false); int outboundPort = ParamUtils.getIntParameter(request, "outboundPort", 25); boolean outboundSSLEnabled = ParamUtils.getBooleanParameter(request, "outboundSSLEnabled", false); String outboundUsername = ParamUtils.getParameter(request, "outboundUsername", false); String outboundPassword = ParamUtils.getParameter(request, "outboundPassword", false); String fromAddress = ParamUtils.getParameter(request, "fromAddress", false); String replyToAddress = ParamUtils.getParameter(request, "replyToAddress", true); String toAddress = ParamUtils.getParameter(request, "toAddress", false); String organization = ParamUtils.getParameter(request, "organization", false); boolean emailPref = ParamUtils.getBooleanParameter(request, "emailPref", true); boolean fromPref = ParamUtils.getBooleanParameter(request, "fromPref", true); boolean outboundAttach = ParamUtils.getBooleanParameter(request, "outboundAttach", false); String exportAfter = ParamUtils.getParameter(request, "exportAfter", false); boolean updateMessageID = ParamUtils.getBooleanParameter(request, "updateMessageID", true); boolean allowExportAgain = ParamUtils.getBooleanParameter(request, "allowExportAgain", false); // form values - common boolean debug = ParamUtils.getBooleanParameter(request, "debug", false); // Check for errors boolean errors = false; // Get the Forum Forum forum = forumFactory.getForum(forumID); // Make sure the user has admin priv on this forum. if (!isSystemAdmin && !forum.isAuthorized(ForumPermissions.FORUM_CATEGORY_ADMIN | ForumPermissions.FORUM_ADMIN)) { throw new UnauthorizedException("You don't have admin privileges to perform this operation."); } // Go back to the gateways page if "cancel" is clicked: String submitButton = ParamUtils.getParameter(request, "submitButton"); if ("Cancel".equals(submitButton)) { if (importOnce) { response.sendRedirect("importGateway.jsp?forum="+forumID); } if (exportOnce) { response.sendRedirect("exportGateway.jsp?forum="+forumID); } else { response.sendRedirect("gateways.jsp?forum="+forumID); } return; } // Get a GatewayManager from the forum GatewayManager gatewayManager = forum.getGatewayManager(); // validate the gateway type, default to pop3 if (!IMAP_GATEWAY.equals(gatewayType)) { gatewayType = POP3_GATEWAY; } // setup ports when switching providers, ssl // switching from pop3 to imap if (gatewayType.equals(IMAP_GATEWAY) && inboundPort == 110 && inboundSSLEnabled == false) { inboundPort = 143; } // switching from pop3 ssl to imap ssl else if (gatewayType.equals(IMAP_GATEWAY) && inboundPort == 995 && inboundSSLEnabled == true) { inboundPort = 993; } // switching from imap to imap ssl else if (gatewayType.equals(IMAP_GATEWAY) && inboundPort == 143 && inboundSSLEnabled == true) { inboundPort = 993; } // switching from imap ssl to imap else if (gatewayType.equals(IMAP_GATEWAY) && inboundPort == 993 && inboundSSLEnabled == false) { inboundPort = 143; } // switching from imap to pop3 else if (gatewayType.equals(POP3_GATEWAY) && inboundPort == 143 && inboundSSLEnabled == false) { inboundPort = 110; } // switching from imap ssl to pop3 ssl else if (gatewayType.equals(POP3_GATEWAY) && inboundPort == 993 && inboundSSLEnabled == true) { inboundPort = 995; } // switching from pop3 to pop3 ssl else if (gatewayType.equals(POP3_GATEWAY) && inboundPort == 110 && inboundSSLEnabled == true) { inboundPort = 995; } // switching from pop3 ssl to pop3 else if (gatewayType.equals(POP3_GATEWAY) && inboundPort == 995 && inboundSSLEnabled == false) { inboundPort = 110; } // verify required fields if (save) { // import settings if (!exportOnce && (gatewayManager.isImportEnabled() || importOnce || inboundHost != null || inboundUsername != null || inboundPassword != null)) { if (inboundHost == null || inboundUsername == null || inboundPassword == null) { errors = true; setOneTimeMessage(session, "importError", "Not all required incoming mail settings have been provided. <br>" + "Host, Username and Password fields are required for importing mail."); } } // export settings if (!importOnce && (gatewayManager.isExportEnabled() || exportOnce || outboundHost != null || fromAddress != null || toAddress != null)) { if (outboundHost == null || fromAddress == null || toAddress == null) { errors = true; setOneTimeMessage(session, "exportError", "Not all required outgoing mail settings have been provided. <br>" + "Host, Default \"From\" address and \"To\" address fields are required " + "for exporting forum content."); } } } // Save properties of the gateway (or create a new gateway, and set its // properties). If importOnce, don't save the gateway using the gatewayManager // but redirect to the import jsp page. If exportOnce, don't save the gateway // using the gatewayManager but redirect to the export jsp page. if (!errors && save) { Gateway gateway = null; // create a new gateway/get the existing gateway if (importOnce || exportOnce || createNew) { if (gatewayType.equals(IMAP_GATEWAY)) { gateway = new ImapGateway(forumFactory, forum); } else { gateway = new EmailGateway(forumFactory, forum); } // save gateway if we are creating a new gateway if (!importOnce && !exportOnce && createNew) { gatewayManager.addGateway(gateway); } } else { gateway = gatewayManager.getGateway(index); if (gateway instanceof EmailGateway && gatewayType.equals(IMAP_GATEWAY)) { gateway = new ImapGateway(forumFactory, forum); gatewayManager.removeGateway(index); gatewayManager.addGateway(gateway, index); } else if (gateway instanceof ImapGateway && gatewayType.equals(POP3_GATEWAY)) { gateway = new EmailGateway(forumFactory, forum); gatewayManager.removeGateway(index); gatewayManager.addGateway(gateway, index); } } // set inbound gateway properties if (gatewayType.equals(IMAP_GATEWAY)) { ImapImporter imapImporter = (ImapImporter) gateway.getGatewayImporter(); imapImporter.setHost(inboundHost); imapImporter.setPort(inboundPort); imapImporter.setSSLEnabled(inboundSSLEnabled); imapImporter.setUsername(inboundUsername); imapImporter.setPassword(inboundPassword); imapImporter.setFolder(inboundFolder); imapImporter.setTemporaryParentBody(tempParentBody); imapImporter.setDeleteEnabled(deleteEnabled); imapImporter.setAttachmentsEnabled(inboundAttach); imapImporter.setSubjectParentageCheckEnabled(subjectCheckEnabled); imapImporter.setDebugEnabled(debug); } else { Pop3Importer pop3Importer = (Pop3Importer) gateway.getGatewayImporter(); pop3Importer.setHost(inboundHost); pop3Importer.setPort(inboundPort); pop3Importer.setSSLEnabled(inboundSSLEnabled); pop3Importer.setUsername(inboundUsername); pop3Importer.setPassword(inboundPassword); pop3Importer.setTemporaryParentBody(tempParentBody); pop3Importer.setDeleteEnabled(deleteEnabled); pop3Importer.setAttachmentsEnabled(inboundAttach); pop3Importer.setSubjectParentageCheckEnabled(subjectCheckEnabled); pop3Importer.setDebugEnabled(debug);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -