KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > db > I_CmsBackupDriver


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/I_CmsBackupDriver.java,v $
3  * Date : $Date: 2005/07/28 10:53:54 $
4  * Version: $Revision: 1.52 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.db;
33
34 import org.opencms.db.generic.CmsSqlManager;
35 import org.opencms.file.CmsBackupProject;
36 import org.opencms.file.CmsBackupResource;
37 import org.opencms.file.CmsDataAccessException;
38 import org.opencms.file.CmsPropertyDefinition;
39 import org.opencms.file.CmsResource;
40 import org.opencms.util.CmsUUID;
41
42 import java.sql.ResultSet JavaDoc;
43 import java.sql.SQLException JavaDoc;
44 import java.util.List JavaDoc;
45
46 /**
47  * Definitions of all required backup driver methods.<p>
48  *
49  * A backup driver is a driver to write projects, resources and properties of
50  * resources optionally to a second set of backup database tables while resources
51  * get published. A unique backup tag ID is used to identify a set of resource that
52  * were saved during one backup process.<p>
53  *
54  * @author Michael Emmerich
55  * @author Thomas Weckert
56  *
57  * @version $Revision: 1.52 $
58  *
59  * @since 6.0.0
60  */

61 public interface I_CmsBackupDriver {
62
63     /** The type ID to identify backup driver implementations. */
64     int DRIVER_TYPE_ID = 0;
65
66     /**
67      * Creates a new property defintion in the database.<p>
68      *
69      * @param dbc the current database context
70      * @param name the name of the propertydefinitions to overwrite
71      *
72      * @return the new propertydefinition
73      * @throws CmsDataAccessException if something goes wrong
74      */

75     CmsPropertyDefinition createBackupPropertyDefinition(CmsDbContext dbc, String JavaDoc name) throws CmsDataAccessException;
76
77     /**
78      * Creates a valid CmsBackupResource instance from a JDBC ResultSet.<p>
79      *
80      * @param res the JDBC result set
81      * @param hasContent true if the file content is part of the result set
82      * @return CmsBackupResource the new resource/file instance
83      *
84      * @throws SQLException if a requested attribute was not found in the result set
85      */

86     CmsBackupResource createBackupResource(ResultSet JavaDoc res, boolean hasContent) throws SQLException JavaDoc;
87
88     /**
89      * Deletes all backup versions of a backup resource that are older than a given project tag and
90      * where the version id is lower than a given value.<p>
91      *
92      * @param dbc the current database context
93      * @param res the backup resource
94      * @param tag the project tag date
95      * @param versions the deletion version
96      *
97      * @throws CmsDataAccessException if something goes wrong
98      */

99     void deleteBackup(CmsDbContext dbc, CmsBackupResource res, int tag, int versions) throws CmsDataAccessException;
100
101     /**
102      * Deletes a property defintion.<p>
103      *
104      * @param dbc the current database context
105      * @param metadef the propertydefinitions to be deleted
106      *
107      * @throws CmsDataAccessException if something goes wrong
108      */

109     void deleteBackupPropertyDefinition(CmsDbContext dbc, CmsPropertyDefinition metadef) throws CmsDataAccessException;
110
111     /**
112      * Deletes backup versions of a resource.<p>
113      *
114      * Deletes the m-n oldest backup versions, if m is the number of backup versions, and n
115      * the number of max. allowed backup versions.<p>
116      *
117      * @param context the current database context
118      * @param existingBackups a list of backup resources ordered by their ascending creation date
119      * @param maxVersions maximum number of versions per resource
120      *
121      * @throws CmsDataAccessException if something goes wrong
122      */

123     void deleteBackups(CmsDbContext context, List JavaDoc existingBackups, int maxVersions) throws CmsDataAccessException;
124
125     /**
126      * Destroys this driver.<p>
127      *
128      * @throws Throwable if something goes wrong
129      */

130     void destroy() throws Throwable JavaDoc;
131
132     /**
133      * Returns the SqlManager of this driver.<p>
134      *
135      * @return the SqlManager of this driver
136      */

137     CmsSqlManager getSqlManager();
138
139     /**
140      * Initializes the SQL manager for this driver.<p>
141      *
142      * @param classname the classname of the SQL manager
143      *
144      * @return the SQL manager for this driver
145      */

146     org.opencms.db.generic.CmsSqlManager initSqlManager(String JavaDoc classname);
147
148     /**
149      * Reads a backup file including the file content.<p>
150      *
151      * @param dbc the current database context
152      * @param tagId the desired tag ID of the file
153      * @param resourcePath the path of the file to read
154      * @return the backup file
155      * @throws CmsDataAccessException if something goes wrong
156      */

157     CmsBackupResource readBackupFile(CmsDbContext dbc, int tagId, String JavaDoc resourcePath) throws CmsDataAccessException;
158
159     /**
160      * Reads all backup file headers excluding the file content.<p>.
161      *
162      * @param dbc the current database context
163      *
164      * @return List with all backup file headers
165      * @throws CmsDataAccessException if something goes wrong
166      */

167     List JavaDoc readBackupFileHeaders(CmsDbContext dbc) throws CmsDataAccessException;
168
169     /**
170      * Reads all file headers of a file.<br>
171      *
172      * This method returns a list with the history of all file headers, i.e.
173      * the file headers of a file, independent of the project they were attached to.<br>
174      *
175      * The reading excludes the file content.<p>
176      *
177      * The filter is (path OR id).<p>
178      *
179      * @param dbc the current database context
180      * @param resourcePath the path of the file to read
181      * @param id the resource id (usefull for siblings)
182      *
183      * @return a list of file headers, as <code>{@link CmsBackupResource}</code> objects, read from the Cms
184      *
185      * @throws CmsDataAccessException if something goes wrong
186      */

187     List JavaDoc readBackupFileHeaders(CmsDbContext dbc, String JavaDoc resourcePath, CmsUUID id) throws CmsDataAccessException;
188
189     /**
190      * Returns the max. current backup version of a resource.<p>
191      *
192      * @param dbc the current database context
193      * @param resourceId the resource ID of the resource
194      *
195      * @return Returns the max. current backup version of a resource
196      * @throws CmsDataAccessException if something goes wrong
197      */

198     int readBackupMaxVersion(CmsDbContext dbc, CmsUUID resourceId) throws CmsDataAccessException;
199
200     /**
201      * Reads a backup project.<p>
202      *
203      * @param dbc the current database context
204      * @param tagId the versionId of the project
205      *
206      * @return the requested backup project
207      *
208      * @throws CmsDataAccessException is something goes wrong
209      */

210     CmsBackupProject readBackupProject(CmsDbContext dbc, int tagId) throws CmsDataAccessException;
211
212     /**
213      * Reads all resources that belong to a given backup version ID.<p>
214      *
215      * @param dbc the current database context
216      * @param tagId the version ID of the backup
217      *
218      * @return all resources that belong to the given backup version ID
219      * @throws CmsDataAccessException if something goes wrong
220      */

221     List JavaDoc readBackupProjectResources(CmsDbContext dbc, int tagId) throws CmsDataAccessException;
222
223     /**
224      * Returns all projects from the history.<p>
225      *
226      * @param dbc the current database context
227      *
228      * @return list of <code>{@link CmsBackupProject}</code> objects
229      * with all projects from history.
230      *
231      * @throws CmsDataAccessException if an error occurs
232      */

233     List JavaDoc readBackupProjects(CmsDbContext dbc) throws CmsDataAccessException;
234
235     /**
236      * Gets the TagId of the first backup project after a given date.<p>
237      *
238      * This method is used during the deletion process of older backup data.<p>
239      *
240      * @param dbc the current database context
241      * @param maxdate the date to compare the backup projects with
242      *
243      * @return tag id of the first backup project after maxdate
244      * @throws CmsDataAccessException if something goes wrong
245      */

246     int readBackupProjectTag(CmsDbContext dbc, long maxdate) throws CmsDataAccessException;
247
248     /**
249      * Returns a list of all properties of a backup file or folder.<p>
250      *
251      * @param dbc the current database context
252      * @param resource the resource to read the properties from
253      *
254      * @return a Map of Strings representing the properties of the resource
255      * @throws CmsDataAccessException if something goes wrong
256      */

257     List JavaDoc readBackupProperties(CmsDbContext dbc, CmsBackupResource resource) throws CmsDataAccessException;
258
259     /**
260      * Reads a property definition for the specified mapping type.<p>
261      *
262      * @param dbc the current database context
263      * @param name the name of the propertydefinition to read
264      *
265      * @return the propertydefinition that corresponds to the overgiven arguments - or null if there is no valid propertydefinition
266      * @throws CmsDataAccessException if something goes wrong
267      */

268     CmsPropertyDefinition readBackupPropertyDefinition(CmsDbContext dbc, String JavaDoc name) throws CmsDataAccessException;
269
270     /**
271      * Reads the max. backup tag ID for a specified resource.<p>
272      *
273      * @param dbc the current database context
274      * @param resource the Cms resource
275      * @return the max. backup tag ID
276      *
277      * @throws CmsDataAccessException if something goes wrong
278      */

279     int readMaxTagId(CmsDbContext dbc, CmsResource resource) throws CmsDataAccessException;
280
281     /**
282      * Returns the next available backup version ID for a resource.<p>
283      *
284      * @param dbc the current database context
285      *
286      * @return the next available backup version ID
287      */

288     int readNextBackupTagId(CmsDbContext dbc);
289
290     /**
291      * Creates a backup of the current project.<p>
292      *
293      * @param dbc the current database context
294      * @param tagId the version ID of the backup
295      * @param publishDate long timestamp when the current project was published.
296      *
297      * @throws CmsDataAccessException if something goes wrong
298      */

299     void writeBackupProject(
300         CmsDbContext dbc,
301         int tagId,
302         long publishDate) throws CmsDataAccessException;
303
304     /**
305      * Writes the properties of a resource to the backup.<p>
306      * @param dbc the current database context
307      * @param resource the resource of the properties
308      * @param properties the properties to write
309      * @param backupId the id backup
310      * @param tagId the tag ID of the backup
311      * @param versionId the version ID of the backup
312      *
313      * @throws CmsDataAccessException if something goes wrong
314      */

315     void writeBackupProperties(
316         CmsDbContext dbc,
317         CmsResource resource,
318         List JavaDoc properties,
319         CmsUUID backupId,
320         int tagId,
321         int versionId) throws CmsDataAccessException;
322
323     /**
324      * Writes a resource to the backup.<p>
325      * @param dbc the current database context
326      * @param resource the resource that is written to the backup
327      * @param properties the properties of the resource
328      * @param tagId the version ID of the backup
329      * @param publishDate long timestamp when the resource was published
330      * @param maxVersions maximum number of backup versions
331      *
332      * @throws CmsDataAccessException if something goes wrong
333      */

334     void writeBackupResource(
335         CmsDbContext dbc,
336         CmsResource resource,
337         List JavaDoc properties,
338         int tagId,
339         long publishDate,
340         int maxVersions) throws CmsDataAccessException;
341
342 }
Popular Tags