Source Code Cross Referenced for PublishingEnvironment.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » publishing » 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.publishing 
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:        /* $Id$  */
020:
021:        package org.apache.lenya.cms.publishing;
022:
023:        import java.io.File;
024:
025:        import org.apache.avalon.framework.configuration.Configurable;
026:        import org.apache.avalon.framework.configuration.Configuration;
027:        import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
028:        import org.apache.log4j.Logger;
029:
030:        /**
031:         * A class that holds various publishing parameters
032:         * @deprecated Use the usecase framework instead.
033:         */
034:        public class PublishingEnvironment implements  Configurable {
035:            private static Logger log = Logger
036:                    .getLogger(PublishingEnvironment.class);
037:            /**
038:             * <code>CONFIGURATION_FILE</code> The path to the publisher configuration file
039:             */
040:            public static final String CONFIGURATION_FILE = "config"
041:                    + File.separator + "publishing" + File.separator
042:                    + "publisher.xconf";
043:            /**
044:             * <code>PUBLICATION_PREFIX</code> The path to the publications from the webapp root
045:             */
046:            public static final String PUBLICATION_PREFIX = "lenya"
047:                    + File.separator + "pubs" + File.separator;
048:            /**
049:             * <code>PUBLICATION_PATH</code> The publication path
050:             */
051:            public static final String PUBLICATION_PATH = "publication-path";
052:            /**
053:             * <code>PARAMETER_AUTHORING_PATH</code> The authoring path
054:             */
055:            public static final String PARAMETER_AUTHORING_PATH = "authoring-path";
056:            /**
057:             * <code>PARAMETER_TREE_AUTHORING_PATH</code> The path to the authoring tree
058:             */
059:            public static final String PARAMETER_TREE_AUTHORING_PATH = "tree-authoring-path";
060:            /**
061:             * <code>PARAMETER_LIVE_PATH</code> The live path
062:             */
063:            public static final String PARAMETER_LIVE_PATH = "live-path";
064:            /**
065:             * <code>PARAMETER_TREE_LIVE_PATH</code> The path to the live tree
066:             */
067:            public static final String PARAMETER_TREE_LIVE_PATH = "tree-live-path";
068:            /**
069:             * <code>PARAMETER_REPLICATION_PATH</code> The replication path
070:             */
071:            public static final String PARAMETER_REPLICATION_PATH = "replication-path";
072:            /**
073:             * <code>PARAMETER_EXPORT_PATH</code> The export path
074:             */
075:            public static final String PARAMETER_EXPORT_PATH = "export-path";
076:            /**
077:             * <code>PARAMETER_SUBSTITUTE_REGEXP</code> The regular expression to use during export
078:             */
079:            public static final String PARAMETER_SUBSTITUTE_REGEXP = "substitute-regexp";
080:            /**
081:             * <code>PARAMETER_SUBSTITUTE_REPLACEMENT</code> The replacement value for the regular
082:             * expression
083:             */
084:            public static final String PARAMETER_SUBSTITUTE_REPLACEMENT = "substitute-replacement";
085:            private String publicationPath;
086:            private String replicationDirectory;
087:            private String authoringPath;
088:            private String livePath;
089:            private String treeAuthoringPath;
090:            private String treeLivePath;
091:            private String exportDirectory;
092:            private String substituteExpression;
093:            private String substituteReplacement;
094:
095:            /**
096:             * Creates a new PublishingEnvironment object.
097:             * 
098:             * @param contextPath The context path
099:             * @param publicationId The publication id
100:             */
101:            public PublishingEnvironment(String contextPath,
102:                    String publicationId) {
103:                this (PublishingEnvironment.getPublicationPath(contextPath,
104:                        publicationId));
105:                log.debug("Context Path and Publication Id: " + contextPath
106:                        + "::" + publicationId);
107:            }
108:
109:            /**
110:             * Creates a new PublishingEnvironment object.
111:             * 
112:             * @param _publicationPath The publication path
113:             */
114:            public PublishingEnvironment(String _publicationPath) {
115:                setPublicationPath(_publicationPath);
116:
117:                String configurationFilePath = _publicationPath
118:                        + CONFIGURATION_FILE;
119:
120:                File configurationFile = new File(configurationFilePath);
121:
122:                try {
123:                    DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
124:                    Configuration configuration = builder
125:                            .buildFromFile(configurationFile);
126:                    configure(configuration);
127:                } catch (Exception e) {
128:                    log
129:                            .info("Did not load publishing configuration from publisher.xconf (No such file or directory: "
130:                                    + configurationFile
131:                                    + "). "
132:                                    + "That means you can't access all PublishingEnvironment parameters and you should only "
133:                                    + "use the AntTask. But don't panic, this file has been DEPRECATED.");
134:                }
135:            }
136:
137:            /**
138:             * Initializes the class from a configuration file
139:             * 
140:             * @param configuration The configuration file
141:             * 
142:             * @throws org.apache.avalon.framework.configuration.ConfigurationException if an error occurs
143:             */
144:            public void configure(
145:                    org.apache.avalon.framework.configuration.Configuration configuration)
146:                    throws org.apache.avalon.framework.configuration.ConfigurationException {
147:                // authoring
148:                setAuthoringPath(configuration.getChild("authoring").getChild(
149:                        "documents").getAttribute("href"));
150:                setTreeAuthoringPath(configuration.getChild("authoring")
151:                        .getChild("tree").getAttribute("href"));
152:
153:                // replication
154:                setReplicationDirectory(configuration.getChild("replication")
155:                        .getChild("pending-documents").getAttribute("href"));
156:
157:                // live
158:                setLivePath(configuration.getChild("live")
159:                        .getChild("documents").getAttribute("href"));
160:                setTreeLivePath(configuration.getChild("live").getChild("tree")
161:                        .getAttribute("href"));
162:
163:                // export
164:                setExportDirectory(configuration.getChild("export").getChild(
165:                        "destination").getAttribute("href"));
166:                setSubstituteExpression(configuration.getChild("export")
167:                        .getChild("substitution").getAttribute("regexp"));
168:                setSubstituteReplacementExpression(configuration.getChild(
169:                        "export").getChild("substitution").getAttribute(
170:                        "replacement"));
171:
172:                log.debug("CONFIGURATION:\nauthoring path="
173:                        + getAuthoringPath() + "\nlive path=" + getLivePath());
174:                log.debug("CONFIGURATION:\ntree authoring path="
175:                        + getTreeAuthoringPath() + "\ntree live path="
176:                        + getTreeLivePath());
177:
178:                log.debug("CONFIGURATION:\nDirectory Prefix: href="
179:                        + getExportDirectory());
180:                log.debug("CONFIGURATION:\nPrefix Substitute: href="
181:                        + getSubstituteExpression());
182:
183:                log.debug("CONFIGURATION:\nReplication Directory: href="
184:                        + getReplicationDirectory());
185:            }
186:
187:            /**
188:             * Returns the publication path.
189:             * 
190:             * @return The publication path
191:             */
192:            public String getPublicationPath() {
193:                return this .publicationPath;
194:            }
195:
196:            /**
197:             * Returns the publication directory.
198:             * @return The publication directory
199:             */
200:            public File getPublicationDirectory() {
201:                return new File(getPublicationPath());
202:            }
203:
204:            protected void setPublicationPath(String path) {
205:                this .publicationPath = path;
206:            }
207:
208:            /**
209:             * Returns the authoring path
210:             * 
211:             * @return The authoring path
212:             */
213:            public String getAuthoringPath() {
214:                return this .authoringPath;
215:            }
216:
217:            protected void setAuthoringPath(String path) {
218:                this .authoringPath = path;
219:            }
220:
221:            /**
222:             * Returns the live path
223:             * 
224:             * @return The live path
225:             */
226:            public String getLivePath() {
227:                return this .livePath;
228:            }
229:
230:            protected void setLivePath(String path) {
231:                this .livePath = path;
232:            }
233:
234:            /**
235:             * Returns the path to the authoring tree
236:             * 
237:             * @return The path to the authoring tree
238:             */
239:            public String getTreeAuthoringPath() {
240:                return this .treeAuthoringPath;
241:            }
242:
243:            protected void setTreeAuthoringPath(String path) {
244:                this .treeAuthoringPath = path;
245:            }
246:
247:            /**
248:             * Returns the path to the live tree
249:             * 
250:             * @return The path to the live tree
251:             */
252:            public String getTreeLivePath() {
253:                return this .treeLivePath;
254:            }
255:
256:            protected void setTreeLivePath(String path) {
257:                this .treeLivePath = path;
258:            }
259:
260:            /**
261:             * Returns the path to the replication directory
262:             * 
263:             * @return The path to the replication directory
264:             */
265:            public String getReplicationDirectory() {
266:                return this .replicationDirectory;
267:            }
268:
269:            protected void setReplicationDirectory(String directory) {
270:                this .replicationDirectory = directory;
271:            }
272:
273:            /**
274:             * Returns the path to the export directory
275:             * 
276:             * @return The path to the export directory
277:             */
278:            public String getExportDirectory() {
279:                return this .exportDirectory;
280:            }
281:
282:            protected void setExportDirectory(String directory) {
283:                this .exportDirectory = directory;
284:            }
285:
286:            /**
287:             * Returns the substitution regular expression used in the export
288:             * 
289:             * @return The substitution regular expression
290:             */
291:            public String getSubstituteExpression() {
292:                return this .substituteExpression;
293:            }
294:
295:            protected void setSubstituteExpression(String substitute) {
296:                this .substituteExpression = substitute;
297:            }
298:
299:            /**
300:             * Set replacement string, which was read from publisher.xconf
301:             * @param replacement The replacement string
302:             */
303:            protected void setSubstituteReplacementExpression(String replacement) {
304:                this .substituteReplacement = replacement;
305:            }
306:
307:            /**
308:             * Get the replacement string, which was read from publisher.xconf
309:             * 
310:             * @return The replacement string
311:             */
312:            public String getSubstituteReplacement() {
313:                return this .substituteReplacement;
314:            }
315:
316:            /**
317:             * Returns the path to the publication given the servlet context path and the publication id
318:             * 
319:             * @param servletContextPath The servlet context path
320:             * @param publicationId The publication id
321:             * 
322:             * @return The path to the publication
323:             */
324:            public static String getPublicationPath(String servletContextPath,
325:                    String publicationId) {
326:                if (!servletContextPath.endsWith(File.separator)) {
327:                    servletContextPath += File.separator;
328:                }
329:
330:                return servletContextPath + PUBLICATION_PREFIX + publicationId
331:                        + File.separator;
332:            }
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.