Source Code Cross Referenced for DocumentUsecase.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » usecase » 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 » Content Management System » apache lenya 2.0 » org.apache.lenya.cms.usecase 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.lenya.cms.usecase;
020:
021:        import org.apache.lenya.cms.publication.Document;
022:        import org.apache.lenya.cms.publication.DocumentBuildException;
023:        import org.apache.lenya.cms.publication.DocumentFactory;
024:
025:        /**
026:         * <p>
027:         * Extends AbstractUsecase with document helper methods.
028:         * </p>
029:         * <p>
030:         * Some parameters are initialized by default:
031:         * </p>
032:         * <ul>
033:         * <li><code>document</code>- the document</li>
034:         * </ul>
035:         */
036:        public class DocumentUsecase extends AbstractUsecase {
037:
038:            protected static final String DOCUMENT = "document";
039:            protected static final String TARGET_DOCUMENT = "private.targetDocument";
040:
041:            /**
042:             * Ctor.
043:             */
044:            public DocumentUsecase() {
045:                super ();
046:            }
047:
048:            /**
049:             * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckPreconditions()
050:             */
051:            protected void doCheckPreconditions() throws Exception {
052:                super .doCheckPreconditions();
053:                if (getSourceDocument() == null) {
054:                    addErrorMessage("This usecase can only be invoked on documents!");
055:                }
056:            }
057:
058:            /*
059:            public void setParameter(String name, Object value) {
060:                if (name.equals(SOURCE_URL)) {
061:                    setSourceURL((String) value);
062:                }
063:                else {
064:                    super.setParameter(name, value);
065:                }
066:            }
067:             */
068:
069:            /**
070:             * @see org.apache.lenya.cms.usecase.Usecase#setSourceURL(java.lang.String)
071:            public void setSourceURL(String url) {
072:                try {
073:                    DocumentFactory factory = getDocumentFactory();
074:                    if (factory.isDocument(url)) {
075:                        Document document = factory.getFromURL(url);
076:                        setParameter(DOCUMENT, document);
077:                    }
078:                } catch (Exception e) {
079:                    throw new RuntimeException(e);
080:                }
081:                super.setParameter(SOURCE_URL, url);
082:            }
083:             */
084:
085:            /**
086:             * Returns the source document.
087:             * @return A document.
088:             */
089:            protected Document getSourceDocument() {
090:                Document doc = (Document) getParameter(DOCUMENT);
091:                if (doc == null
092:                        || doc.getFactory().getSession() != getSession()) {
093:                    try {
094:                        DocumentFactory factory = getDocumentFactory();
095:                        String sourceUrl = getParameterAsString(SOURCE_URL);
096:                        if (factory.isDocument(sourceUrl)) {
097:                            doc = factory.getFromURL(sourceUrl);
098:                            setParameter(DOCUMENT, doc);
099:                        }
100:                    } catch (DocumentBuildException e) {
101:                        throw new RuntimeException(e);
102:                    }
103:                }
104:                return doc;
105:            }
106:
107:            /**
108:             * Sets the target document for the case that the usecase execution
109:             * succeeded (see {@link #getTargetDocument(boolean)}).
110:             * @param document A document.
111:             */
112:            protected void setTargetDocument(Document document) {
113:                setParameter(TARGET_DOCUMENT, document);
114:            }
115:
116:            /**
117:             * Returns the document to be redirected to after the usecase has been
118:             * completed. If the parameter <code>success</code> is false, the source
119:             * document is returned (override this method to change this behaviour).
120:             * @param success If the usecase was successfully completed.
121:             * @return A document.
122:             */
123:            protected Document getTargetDocument(boolean success) {
124:                if (success) {
125:                    return (Document) getParameter(TARGET_DOCUMENT,
126:                            getSourceDocument());
127:                } else {
128:                    return getSourceDocument();
129:                }
130:            }
131:
132:            /**
133:             * If {@link #setTargetDocument(Document)}was not called, the URL of the
134:             * source document ( {@link #getSourceDocument()}) is returned.
135:             * @see org.apache.lenya.cms.usecase.Usecase#getTargetURL(boolean)
136:             */
137:            public String getTargetURL(boolean success) {
138:                Document document = getTargetDocument(success);
139:                String documentUrl = document.getCanonicalDocumentURL();
140:                String url = "/" + document.getPublication().getId() + "/"
141:                        + document.getArea() + documentUrl;
142:                return url + getExitQueryString();
143:            }
144:
145:            /**
146:             * @see org.apache.lenya.cms.usecase.AbstractUsecase#getSourceURL()
147:             */
148:            public String getSourceURL() {
149:                Document doc = getSourceDocument();
150:                if (doc == null || !doc.hasLink()) {
151:                    return super .getSourceURL();
152:                }
153:                return doc.getCanonicalWebappURL();
154:            }
155:
156:            /**
157:             * @see org.apache.lenya.cms.usecase.AbstractUsecase#setDefaultTargetURL(java.lang.String)
158:             */
159:            protected void setDefaultTargetURL(String url) {
160:                try {
161:                    Document target = getDocumentFactory().getFromURL(url);
162:                    setParameter(TARGET_DOCUMENT, target);
163:                } catch (DocumentBuildException e) {
164:                    throw new RuntimeException(e);
165:                }
166:            }
167:
168:            /**
169:             * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
170:            protected void initParameters() {
171:                super.initParameters();
172:
173:                setParameter(DOCUMENT, getSourceDocument());
174:            }
175:             */
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.