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.site;
020:
021: import org.apache.lenya.cms.publication.Document;
022: import org.apache.lenya.cms.publication.DocumentFactory;
023: import org.apache.lenya.cms.publication.DocumentLocator;
024: import org.apache.lenya.cms.publication.Publication;
025:
026: /**
027: * <p>
028: * A site structure management component.
029: * </p>
030: *
031: * <p>
032: * A site manager has a dependence relation, which is always applied to documents of a single
033: * language. This means a document may not require a document of another language. Dependence on a
034: * set of resources must be a strict partial order <strong>< </strong>:
035: * </p>
036: * <ul>
037: * <li><em>irreflexive:</em> d <strong>< </strong>d does not hold for any resource d</li>
038: * <li><em>antisymmetric:</em> d <strong>< </strong>e and e <strong>< </strong>d implies
039: * d=e</li>
040: * <li><em>transitive:</em> d <strong>< </strong>e and e <strong>< </strong>f implies d
041: * <strong>< </strong>f</li>
042: * </ul>
043: *
044: * @version $Id: SiteManager.java 475069 2006-11-15 00:01:13Z andreas $
045: */
046: public interface SiteManager {
047:
048: /**
049: * The Avalon role.
050: */
051: String ROLE = SiteManager.class.getName();
052:
053: /**
054: * Checks if a resource requires another one.
055: * @param map The identity map to operate on.
056: * @param dependingResource The depending resource.
057: * @param requiredResource The required resource.
058: * @return A boolean value.
059: * @throws SiteException if an error occurs.
060: */
061: boolean requires(DocumentFactory map, SiteNode dependingResource,
062: SiteNode requiredResource) throws SiteException;
063:
064: /**
065: * Returns the resources which are required by a certain resource.
066: *
067: * @param map The identity map to operate on.
068: * @param locator The depending locator.
069: * @return An array of resources.
070: * @throws SiteException if an error occurs.
071: */
072: DocumentLocator[] getRequiredResources(DocumentFactory map,
073: DocumentLocator locator) throws SiteException;
074:
075: /**
076: * Returns the resources which require a certain resource.
077: *
078: * @param map The identity map to operate on.
079: * @param resource The required resource.
080: * @return An array of resources.
081: * @throws SiteException if an error occurs.
082: */
083: SiteNode[] getRequiringResources(DocumentFactory map,
084: SiteNode resource) throws SiteException;
085:
086: /**
087: * Adds a document to the site structure.
088: * @param path The path.
089: * @param document The document to add.
090: * @throws SiteException if the document is already contained.
091: */
092: void add(String path, Document document) throws SiteException;
093:
094: /**
095: * Sets a document to the site structure.
096: * @param path The path.
097: * @param document The document to add.
098: * @throws SiteException if the document is already contained or if the path doesn't exist.
099: */
100: void set(String path, Document document) throws SiteException;
101:
102: /**
103: * Checks if the site structure contains a certain resource in a certain area.
104: *
105: * @param resource The resource.
106: * @return A boolean value.
107: * @throws SiteException if an error occurs.
108: */
109: boolean contains(Document resource) throws SiteException;
110:
111: /**
112: * Checks if the site structure contains any language version of a certain resource in a certain
113: * area.
114: *
115: * @param resource The resource.
116: * @return A boolean value.
117: * @throws SiteException if an error occurs.
118: */
119: boolean containsInAnyLanguage(Document resource)
120: throws SiteException;
121:
122: /**
123: * Copies a document in the site structure.
124: *
125: * @param sourceDocument The source document.
126: * @param destinationDocument The destination document.
127: * @throws SiteException when something went wrong.
128: */
129: void copy(Document sourceDocument, Document destinationDocument)
130: throws SiteException;
131:
132: /**
133: * Sets the visibility of a node in the navigation. It is meant to hide specific nodes within
134: * the "public" navigation whereas the node is visible within the info/site area.
135: *
136: * @param document The document.
137: * @param visibleInNav The visibility.
138: * @throws SiteException if an error occurs.
139: */
140: void setVisibleInNav(Document document, boolean visibleInNav)
141: throws SiteException;
142:
143: /**
144: * Returns the visibility of a node in the navigation.
145: *
146: * @param document The document.
147: * @return A boolean value.
148: * @throws SiteException if an error occurs.
149: */
150: boolean isVisibleInNav(Document document) throws SiteException;
151:
152: /**
153: * Returns all documents in a certain area.
154: *
155: * @param identityMap The identityMap to use.
156: * @param publication The publication.
157: * @param area The area.
158: * @return An array of documents.
159: * @throws SiteException if an error occurs.
160: */
161: Document[] getDocuments(DocumentFactory identityMap,
162: Publication publication, String area) throws SiteException;
163:
164: /**
165: * Sorts a set of nodes using the "requires" relation.
166: *
167: * @param nodes The set.
168: * @return A sorted array of nodes.
169: * @throws SiteException if an error occurs.
170: */
171: SiteNode[] sortAscending(SiteNode[] nodes) throws SiteException;
172:
173: /**
174: * @param map The identity map.
175: * @param publication The publication.
176: * @param area The area.
177: * @return The object that holds the site structure information.
178: * @throws SiteException if an error occurs.
179: */
180: SiteStructure getSiteStructure(DocumentFactory map,
181: Publication publication, String area) throws SiteException;
182:
183: /**
184: * Checks if the document does already exist. If it does, returns a non-existing document with a
185: * similar document ID. If it does not, the original document is returned.
186: * @param factory The document factory.
187: * @param locator The locator.
188: * @return A locator.
189: * @throws SiteException if the new document could not be built.
190: */
191: DocumentLocator getAvailableLocator(DocumentFactory factory,
192: DocumentLocator locator) throws SiteException;
193:
194: }
|