001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.interfaces;
034:
035: import com.flexive.shared.content.FxContent;
036: import com.flexive.shared.content.FxContentSecurityInfo;
037: import com.flexive.shared.content.FxContentVersionInfo;
038: import com.flexive.shared.content.FxPK;
039: import com.flexive.shared.exceptions.*;
040: import com.flexive.shared.FxLanguage;
041: import com.flexive.shared.structure.FxType;
042:
043: import javax.ejb.Remote;
044: import java.util.List;
045:
046: /**
047: * ContentEngine
048: *
049: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
050: */
051: @Remote
052: public interface ContentEngine {
053:
054: /**
055: * Initialize a new FxContent instance with preferred acl, step and language
056: *
057: * @param typeId type to use
058: * @param mandatorId mandator to assign this content (has to be available for the type!)
059: * @param prefACL preferred acl, if not applicable the best fit will be used
060: * @param prefStep preferred step, if not applicable the best fit will be used
061: * @param prefLang preferred language, if not applicable the best fit will be used
062: * @return FxContent
063: * @throws FxApplicationException TODO
064: * @throws FxLoadException on initialization errors
065: */
066: FxContent initialize(long typeId, long mandatorId, long prefACL,
067: long prefStep, long prefLang) throws FxApplicationException;
068:
069: /**
070: * Initialize a new FxContent instance for a type with default values.
071: * mandator, ACL, Step and Lang will be taken on a "first-useable" basis
072: *
073: * @param typeId type to use
074: * @return content instance
075: * @throws FxApplicationException on errors
076: */
077: FxContent initialize(long typeId) throws FxApplicationException;
078:
079: /**
080: * Initialize a new FxContent instance for a type with default values.
081: * mandator, ACL, Step and Lang will be taken on a "first-useable" basis
082: *
083: * @param typeName type to use
084: * @return content instance
085: * @throws FxApplicationException on errors
086: */
087: FxContent initialize(String typeName) throws FxApplicationException;
088:
089: /**
090: * Load a content
091: *
092: * @param pk primary key to load
093: * @return FxContent
094: * @throws FxApplicationException TODO
095: * @throws FxLoadException
096: * @throws FxNoAccessException
097: * @throws FxNotFoundException if no instance for this primary key was found
098: */
099: FxContent load(FxPK pk) throws FxApplicationException;
100:
101: /**
102: * Store an existing content or create a new one
103: *
104: * @param content the content to persist
105: * @return the primary key of the content
106: * @throws FxApplicationException TODO
107: * @throws FxCreateException on errors
108: * @throws FxUpdateException on errors
109: * @throws FxNoAccessException
110: */
111: FxPK save(FxContent content) throws FxApplicationException;
112:
113: /**
114: * Prepare a content for a save or create operation (resolves binaries for script processing, etc.).
115: * This is <b>optional</b> and is not required to be called prior to saving, it exists to have
116: * metadata available in GUI's prior to saving.
117: *
118: * @param content the content to prepare
119: * @return the prepared content
120: * @throws FxInvalidParameterException on errors
121: * @throws FxDbException on errors
122: */
123: FxContent prepareSave(FxContent content)
124: throws FxApplicationException;
125:
126: /**
127: * Create a new version for an existing content instance
128: *
129: * @param content the content to persist
130: * @return the primary key of the contents new version
131: * @throws FxApplicationException TODO
132: * @throws FxCreateException on errors
133: * @throws FxUpdateException on errors
134: * @throws FxNoAccessException
135: */
136: FxPK createNewVersion(FxContent content)
137: throws FxApplicationException;
138:
139: /**
140: * Remove a content
141: *
142: * @param pk primary key of the content to remove
143: * @throws FxApplicationException TODO
144: * @throws com.flexive.shared.exceptions.FxRemoveException
145: * on errors
146: * @throws FxNoAccessException on errors
147: */
148: void remove(FxPK pk) throws FxApplicationException;
149:
150: /**
151: * Remove a content's version.
152: * If the content consists only of this specific version the whole content is removed
153: *
154: * @param pk primary key of a distinct version to remove
155: * @throws FxApplicationException TODO
156: * @throws com.flexive.shared.exceptions.FxRemoveException
157: * on errors
158: * @throws FxNoAccessException on errors
159: */
160: void removeVersion(FxPK pk) throws FxApplicationException;
161:
162: /**
163: * Remove all instances of the given type.
164: * Beans using this method should apply very strict security restrictions!
165: *
166: * @param typeId affected FxType
167: * @return number of instances removed
168: * @throws FxApplicationException TODO
169: * @throws com.flexive.shared.exceptions.FxRemoveException
170: * on errors
171: */
172: int removeForType(long typeId) throws FxApplicationException;
173:
174: /**
175: * Get all security relevant information about a content instance identified by its primary key
176: *
177: * @param pk primary key to query security information for
178: * @return FxContentSecurityInfo
179: * @throws FxApplicationException TODO
180: */
181: FxContentSecurityInfo getContentSecurityInfo(FxPK pk)
182: throws FxApplicationException;
183:
184: /**
185: * Get information about the versions used for a content id
186: *
187: * @param id the id to query version information for
188: * @return FxContentVersionInfo
189: * @throws FxApplicationException on errors
190: */
191: FxContentVersionInfo getContentVersionInfo(FxPK id)
192: throws FxApplicationException;
193:
194: /**
195: * Get the number of references that exist for the requested content
196: *
197: * @param pk primary key of the requested content
198: * @return number of references that exist for the requested content
199: * @throws FxApplicationException on errors
200: */
201: int getReferencedContentCount(FxPK pk)
202: throws FxApplicationException;
203:
204: /**
205: * <p>
206: * Returns all primary keys for the given type. Since this method does not implement security,
207: * it may only be called by the global supervisor. You can use the search engine to achieve
208: * the same, just with security enabled, with
209: * </p>
210: * <code>
211: * final List<FxPK> folderPks = new SqlQueryBuilder().select("@pk").type("FOLDER").getResult().collectColumn(1);
212: * </code>
213: *
214: * @param typeId the type to request the primary keys for
215: * @param onePkPerInstance return one primary key per instance (with max version) or one per actual version?
216: * @return list containing the primary keys
217: * @throws FxApplicationException on errors
218: */
219: List<FxPK> getPKsForType(long typeId, boolean onePkPerInstance)
220: throws FxApplicationException;
221:
222: /**
223: * Get the binary id for the given XPath.
224: * The root ("/") XPath will return the contents preview binary id.
225: * An invalid XPath or no associated binary id will throw an FxNotFoundException or
226: * FxInvalidParameterException.
227: * Security will be checked and FxNoAccessException thrown if restricted.
228: *
229: * @param pk primary key
230: * @param xpath XPath
231: * @param language the language (if null, the user ticket language will be used)
232: * @return binary id
233: * @throws FxApplicationException on errors
234: */
235: long getBinaryId(FxPK pk, String xpath, FxLanguage language)
236: throws FxApplicationException;
237: }
|