Source Code Cross Referenced for IssueTemplateInfo.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » om » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.om 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.om;
002:
003:        /* ================================================================
004:         * Copyright (c) 2000-2005 CollabNet.  All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are
008:         * met:
009:         * 
010:         * 1. Redistributions of source code must retain the above copyright
011:         * notice, this list of conditions and the following disclaimer.
012:         * 
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         * notice, this list of conditions and the following disclaimer in the
015:         * documentation and/or other materials provided with the distribution.
016:         * 
017:         * 3. The end-user documentation included with the redistribution, if
018:         * any, must include the following acknowlegement: "This product includes
019:         * software developed by Collab.Net <http://www.Collab.Net/>."
020:         * Alternately, this acknowlegement may appear in the software itself, if
021:         * and wherever such third-party acknowlegements normally appear.
022:         * 
023:         * 4. The hosted project names must not be used to endorse or promote
024:         * products derived from this software without prior written
025:         * permission. For written permission, please contact info@collab.net.
026:         * 
027:         * 5. Products derived from this software may not use the "Tigris" or 
028:         * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
029:         * prior written permission of Collab.Net.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034:         * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037:         * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039:         * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042:         *
043:         * ====================================================================
044:         * 
045:         * This software consists of voluntary contributions made by many
046:         * individuals on behalf of Collab.Net.
047:         */
048:
049:        import java.util.Arrays;
050:        import org.apache.torque.TorqueException;
051:
052:        import org.apache.turbine.TemplateContext;
053:        import org.apache.turbine.Turbine;
054:
055:        import org.apache.torque.om.Persistent;
056:
057:        import org.tigris.scarab.om.Module;
058:        import org.tigris.scarab.services.security.ScarabSecurity;
059:        import org.tigris.scarab.tools.localization.L10NKeySet;
060:        import org.tigris.scarab.util.Email;
061:        import org.tigris.scarab.util.EmailContext;
062:        import org.tigris.scarab.util.ScarabException;
063:
064:        /** 
065:         * This class represents the IssueTemplateInfo object.
066:         *
067:         * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
068:         * @version $Id: IssueTemplateInfo.java 10214 2006-07-22 09:39:48Z dabbous $
069:         */
070:        public class IssueTemplateInfo extends BaseIssueTemplateInfo implements 
071:                Persistent {
072:
073:            /**
074:             * A new IssueTemplateInfo object
075:             */
076:            public static IssueTemplateInfo getInstance() {
077:                return new IssueTemplateInfo();
078:            }
079:
080:            public boolean canDelete(ScarabUser user) throws TorqueException {
081:                // can delete a template if they have delete permission
082:                // Or if is their personal template
083:                boolean hasPermission = user.hasPermission(
084:                        ScarabSecurity.ITEM__DELETE, getIssue().getModule());
085:                boolean isCreatedBySelf = user.getUserId().equals(
086:                        getIssue().getCreatedBy().getUserId());
087:                boolean hasScopePersonal = getScopeId().equals(
088:                        Scope.PERSONAL__PK);
089:                return (hasPermission || (isCreatedBySelf && hasScopePersonal));
090:            }
091:
092:            public boolean canEdit(ScarabUser user) throws TorqueException {
093:                return canDelete(user);
094:            }
095:
096:            public void saveAndSendEmail(final ScarabUser user,
097:                    final Module module, final TemplateContext context)
098:                    throws TorqueException, ScarabException {
099:                // If it's a module scoped template, user must have Item | Approve 
100:                //   permission, Or its Approved field gets set to false
101:                boolean success = true;
102:                final Issue issue = IssueManager.getInstance(getIssueId());
103:
104:                // If it's a module template, user must have Item | Approve 
105:                //   permission, or its Approved field gets set to false
106:                if (getScopeId().equals(Scope.PERSONAL__PK)
107:                        || user.hasPermission(ScarabSecurity.ITEM__APPROVE,
108:                                module)) {
109:                    setApproved(true);
110:                } else {
111:                    setApproved(false);
112:                    issue.save();
113:
114:                    // Send Email to the people with module edit ability so
115:                    // that they can approve the new template
116:                    if (context != null) {
117:                        final String template = Turbine
118:                                .getConfiguration()
119:                                .getString(
120:                                        "scarab.email.requireapproval.template",
121:                                        "RequireApproval.vm");
122:
123:                        ScarabUser[] toUsers = module
124:                                .getUsers(ScarabSecurity.MODULE__EDIT);
125:                        // if the module doesn't have any users, then we need to add at 
126:                        // least ourselves...
127:                        if (toUsers.length == 0) {
128:                            toUsers = new ScarabUser[1];
129:                            toUsers[0] = user;
130:                        }
131:
132:                        final EmailContext ectx = new EmailContext();
133:                        ectx.setUser(user);
134:                        ectx.setModule(module);
135:                        ectx.setDefaultTextKey("NewTemplateRequiresApproval");
136:
137:                        final String fromUser = "scarab.email.default";
138:                        try {
139:                            Email.sendEmail(ectx, module, fromUser, module
140:                                    .getSystemEmail(), Arrays.asList(toUsers),
141:                                    null, template);
142:                        } catch (Exception e) {
143:                            save(); // Not shure about this, but i think it's ok,
144:                            // because we already did an issue.save(), see above
145:                            throw new ScarabException(
146:                                    L10NKeySet.ExceptionGeneral, e);
147:                        }
148:                    }
149:                }
150:                save();
151:            }
152:
153:            /*
154:             * Checks permission and approves or rejects template. If template
155:             * is approved,template type set to "module", else set to "personal".
156:             */
157:            public void approve(final ScarabUser user, final boolean approved)
158:                    throws TorqueException, ScarabException {
159:                final Module module = getIssue().getModule();
160:
161:                if (user.hasPermission(ScarabSecurity.ITEM__APPROVE, module)) {
162:                    setApproved(true);
163:                    if (!approved) {
164:                        setScopeId(Scope.PERSONAL__PK);
165:                    }
166:                    save();
167:                } else {
168:                    throw new ScarabException(
169:                            L10NKeySet.YouDoNotHavePermissionToAction);
170:                }
171:            }
172:
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.