Source Code Cross Referenced for SimpleSiteManager.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » cms » site » simple » 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.site.simple 
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:        package org.apache.lenya.cms.site.simple;
019:
020:        import org.apache.avalon.framework.service.ServiceException;
021:        import org.apache.avalon.framework.service.ServiceManager;
022:        import org.apache.avalon.framework.service.Serviceable;
023:        import org.apache.lenya.cms.cocoon.source.SourceUtil;
024:        import org.apache.lenya.cms.publication.Document;
025:        import org.apache.lenya.cms.publication.DocumentException;
026:        import org.apache.lenya.cms.publication.DocumentFactory;
027:        import org.apache.lenya.cms.publication.DocumentLocator;
028:        import org.apache.lenya.cms.publication.Publication;
029:        import org.apache.lenya.cms.repository.RepositoryItemFactory;
030:        import org.apache.lenya.cms.site.AbstractSiteManager;
031:        import org.apache.lenya.cms.site.SiteException;
032:        import org.apache.lenya.cms.site.SiteNode;
033:        import org.apache.lenya.cms.site.SiteStructure;
034:        import org.apache.lenya.transaction.TransactionException;
035:
036:        /**
037:         * Simple site manager which does not imply structural information. The documents are stored in
038:         * collections.
039:         * 
040:         * @version $Id: SimpleSiteManager.java 527520 2007-04-11 15:22:11Z andreas $
041:         */
042:        public class SimpleSiteManager extends AbstractSiteManager implements 
043:                Serviceable {
044:
045:            private ServiceManager manager;
046:
047:            /**
048:             * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
049:             */
050:            public void service(ServiceManager manager) throws ServiceException {
051:                this .manager = manager;
052:            }
053:
054:            /**
055:             * @see org.apache.lenya.cms.site.SiteManager#requires(org.apache.lenya.cms.publication.DocumentFactory,
056:             *      org.apache.lenya.cms.site.SiteNode, org.apache.lenya.cms.site.SiteNode)
057:             */
058:            public boolean requires(DocumentFactory map,
059:                    SiteNode dependingResource, SiteNode requiredResource)
060:                    throws SiteException {
061:                return false;
062:            }
063:
064:            /**
065:             * @see org.apache.lenya.cms.site.SiteManager#getRequiringResources(org.apache.lenya.cms.publication.DocumentFactory,
066:             *      org.apache.lenya.cms.site.SiteNode)
067:             */
068:            public SiteNode[] getRequiringResources(DocumentFactory map,
069:                    SiteNode resource) throws SiteException {
070:                return new SiteNode[0];
071:            }
072:
073:            public void add(String path, Document document)
074:                    throws SiteException {
075:                getStore(document).add(path, document);
076:            }
077:
078:            /**
079:             * @param document The document.
080:             * @return The store of the document.
081:             * @throws SiteException if an error occurs.
082:             */
083:            private DocumentStore getStore(Document document)
084:                    throws SiteException {
085:                Publication publication = document.getPublication();
086:                String area = document.getArea();
087:                DocumentFactory map = document.getFactory();
088:                return getStore(map, publication, area);
089:            }
090:
091:            /**
092:             * @param map The identity map.
093:             * @param publication The publication.
094:             * @param area The area.
095:             * @return A document store.
096:             * @throws SiteException if an error occurs.
097:             */
098:            protected DocumentStore getStore(DocumentFactory map,
099:                    Publication publication, String area) throws SiteException {
100:                String key = getKey(publication, area);
101:                DocumentStore store;
102:                RepositoryItemFactory factory = new DocumentStoreFactory(
103:                        this .manager, getLogger());
104:                try {
105:                    store = (DocumentStore) map.getSession().getRepositoryItem(
106:                            factory, key);
107:                } catch (Exception e) {
108:                    throw new SiteException(e);
109:                }
110:
111:                return store;
112:            }
113:
114:            protected String getCollectionUuid(Publication pub) {
115:                String sourceUri = pub
116:                        .getContentURI(Publication.AUTHORING_AREA)
117:                        + DOCUMENT_PATH;
118:                try {
119:
120:                    if (!SourceUtil.exists(sourceUri, manager)) {
121:                        throw new RuntimeException("The site configuration ["
122:                                + sourceUri + "] does not exist!");
123:                    }
124:
125:                    org.w3c.dom.Document xml = SourceUtil.readDOM(sourceUri,
126:                            manager);
127:                    if (!xml.getDocumentElement().hasAttribute("uuid")) {
128:                        throw new RuntimeException("The document element of ["
129:                                + sourceUri
130:                                + "] doesn't contain a uuid attribute!");
131:                    }
132:                    return xml.getDocumentElement().getAttribute("uuid");
133:                } catch (Exception e) {
134:                    throw new RuntimeException(e);
135:                }
136:            }
137:
138:            protected static final String DOCUMENT_PATH = "/site.xml";
139:
140:            /**
141:             * @param publication The publication.
142:             * @param area The area.
143:             * @return The key to store sitetree objects in the identity map.
144:             */
145:            protected String getKey(Publication publication, String area) {
146:                return publication.getId() + ":" + area + ":"
147:                        + getCollectionUuid(publication);
148:            }
149:
150:            /**
151:             * @see org.apache.lenya.cms.site.SiteManager#contains(org.apache.lenya.cms.publication.Document)
152:             */
153:            public boolean contains(Document resource) throws SiteException {
154:
155:                try {
156:                    DocumentStore store = getStore(resource);
157:                    if (resource.equals(store)) {
158:                        return true;
159:                    }
160:                    return store.contains(resource);
161:                } catch (DocumentException e) {
162:                    throw new SiteException(e);
163:                }
164:            }
165:
166:            /**
167:             * @see org.apache.lenya.cms.site.SiteManager#containsInAnyLanguage(org.apache.lenya.cms.publication.Document)
168:             */
169:            public boolean containsInAnyLanguage(Document resource)
170:                    throws SiteException {
171:                try {
172:                    boolean contains = false;
173:
174:                    String[] languages = resource.getLanguages();
175:                    for (int i = 0; i < languages.length; i++) {
176:                        Document doc = resource.getTranslation(languages[i]);
177:                        DocumentStore store = getStore(doc);
178:                        contains = contains || store.contains(doc);
179:                    }
180:
181:                    return contains;
182:                } catch (Exception e) {
183:                    throw new SiteException(e);
184:                }
185:            }
186:
187:            /**
188:             * @see org.apache.lenya.cms.site.SiteManager#copy(org.apache.lenya.cms.publication.Document,
189:             *      org.apache.lenya.cms.publication.Document)
190:             */
191:            public void copy(Document sourceDocument,
192:                    Document destinationDocument) throws SiteException {
193:                DocumentStore destinationStore = getStore(destinationDocument);
194:                try {
195:                    if (!destinationStore.contains(destinationDocument)) {
196:                        destinationStore.add(destinationDocument);
197:                    }
198:                } catch (Exception e) {
199:                    throw new SiteException(e);
200:                }
201:            }
202:
203:            /**
204:             * @see org.apache.lenya.cms.site.SiteManager#setVisibleInNav(org.apache.lenya.cms.publication.Document,
205:             *      boolean)
206:             */
207:            public void setVisibleInNav(Document document, boolean visibleInNav)
208:                    throws SiteException {
209:            }
210:
211:            /**
212:             * @see org.apache.lenya.cms.site.SiteManager#getDocuments(org.apache.lenya.cms.publication.DocumentFactory,
213:             *      org.apache.lenya.cms.publication.Publication, java.lang.String)
214:             */
215:            public Document[] getDocuments(DocumentFactory identityMap,
216:                    Publication publication, String area) throws SiteException {
217:                DocumentStore store = getStore(identityMap, publication, area);
218:                try {
219:                    return store.getDocuments();
220:                } catch (DocumentException e) {
221:                    throw new SiteException(e);
222:                }
223:            }
224:
225:            /**
226:             * @see org.apache.lenya.cms.site.SiteManager#getSiteStructure(org.apache.lenya.cms.publication.DocumentFactory,
227:             *      org.apache.lenya.cms.publication.Publication, java.lang.String)
228:             */
229:            public SiteStructure getSiteStructure(DocumentFactory map,
230:                    Publication publication, String area) throws SiteException {
231:                return getStore(map, publication, area);
232:            }
233:
234:            /**
235:             * @see org.apache.lenya.cms.site.SiteManager#getAvailableLocator(DocumentFactory,
236:             *      DocumentLocator)
237:             */
238:            public DocumentLocator getAvailableLocator(DocumentFactory factory,
239:                    DocumentLocator document) throws SiteException {
240:                return document;
241:            }
242:
243:            public boolean isVisibleInNav(Document document)
244:                    throws SiteException {
245:                return true;
246:            }
247:
248:            public void set(String path, Document document)
249:                    throws SiteException {
250:                try {
251:                    getStore(document).setPath(document, path);
252:                } catch (TransactionException e) {
253:                    throw new SiteException(e);
254:                }
255:            }
256:
257:            public DocumentLocator[] getRequiredResources(DocumentFactory map,
258:                    DocumentLocator locator) throws SiteException {
259:                return new DocumentLocator[0];
260:            }
261:
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.