Source Code Cross Referenced for RenameFolderTag.java in  » Portal » Open-Portal » com » sun » portal » wireless » taglibs » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.wireless.taglibs.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /** 
002:         * $Id: RenameFolderTag.java,v 1.6 2005/09/21 10:52:53 dg154973 Exp $ 
003:         * Copyright 2002 Sun Microsystems, Inc. All 
004:         * rights reserved. Use of this product is subject 
005:         * to license terms. Federal Acquisitions: 
006:         * Commercial Software -- Government Users 
007:         * Subject to Standard License Terms and 
008:         * Conditions. 
009:         * 
010:         * Sun, Sun Microsystems, the Sun logo, and iPlanet 
011:         * are trademarks or registered trademarks of Sun Microsystems, 
012:         * Inc. in the United States and other countries. 
013:         */package com.sun.portal.wireless.taglibs.mail;
014:
015:        import javax.servlet.jsp.*;
016:        import javax.servlet.jsp.tagext.*;
017:
018:        import javax.mail.*;
019:        import javax.mail.internet.*;
020:        import javax.mail.search.*;
021:
022:        import com.sun.portal.wireless.taglibs.base.*;
023:        import com.sun.portal.log.common.PortalLogger;
024:
025:        import java.util.logging.Logger;
026:        import java.util.logging.Level;
027:
028:        /**
029:         * 
030:         * RenameFolderTag - execute a rename folder on the Store
031:         *
032:         * @version 1.0
033:         * @see com.sun.portal.wireless.taglibs.base.CommandTag
034:         */
035:        public class RenameFolderTag extends CommandTag {
036:            private static Logger logger = PortalLogger
037:                    .getLogger(RenameFolderTag.class);
038:
039:            private String foldername = null;
040:            private String oldname = null;
041:            private String path = null;
042:
043:            public boolean execute() throws JspException {
044:
045:                MailContext mc;
046:                try {
047:                    mc = MailContext.getContext(pageContext);
048:                } catch (Exception e) {
049:                    throw new JspException(this .getClass().getName()
050:                            + ".execute():  Couldn't get mail context:  "
051:                            + e.getMessage());
052:                }
053:
054:                // Reset error code 
055:                mc.setErrorCode("");
056:
057:                // User can specify the fullname to create or a foldername and a path
058:                String newname = null;
059:                if (path != null && path.length() > 0)
060:                    newname = path + "/" + foldername;
061:                else
062:                    newname = foldername;
063:
064:                try {
065:                    Store store = mc.getMailStore();
066:                    Folder folder = store.getFolder(oldname);
067:                    Folder newfolder = store.getFolder(newname);
068:
069:                    if (!folder.exists()) {
070:                        release();
071:                        // Set error code 
072:                        mc.setErrorCode("MAIL_005"); // MAIL_005 = Rename folder not exists
073:                        return false;
074:                    } else if (newfolder.exists()) {
075:                        release();
076:                        // Set error code 
077:                        mc.setErrorCode("MAIL_003"); // MAIL_003 = Mailbox already exists
078:                        return false;
079:                    } else {
080:                        // Folder has to be closed before rename
081:                        if (folder.isOpen()) {
082:                            folder.close(true);
083:                        }
084:                        folder.renameTo(newfolder);
085:
086:                        release();
087:                        return true;
088:                    }
089:                } catch (MessagingException e) {
090:                    logger.log(Level.FINE, "PSMA_CSPWTM0034", e);
091:                    release();
092:                    return false;
093:                }
094:
095:            }
096:
097:            /**
098:             * Cleanup
099:             */
100:
101:            public void release() {
102:                super .release();
103:                foldername = null;
104:                oldname = null;
105:                path = null;
106:            }
107:
108:            /**
109:             *
110:             * Set the folder name attribute
111:             *
112:             * @param set the folder name attribute
113:             */
114:
115:            public void setFoldername(String name) {
116:                foldername = evalAttribute(name);
117:            }
118:
119:            /**
120:             *
121:             * Set the old folder name attribute
122:             *
123:             * @param set the folder name attribute
124:             */
125:
126:            public void setOldname(String name) {
127:                oldname = evalAttribute(name);
128:            }
129:
130:            /**
131:             *
132:             * Set the file path attribute
133:             *
134:             * @param set the file path attribute
135:             */
136:
137:            public void setPath(String path) {
138:                this.path = evalAttribute(path);
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.