001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/I_CmsProjectDriver.java,v $
003: * Date : $Date: 2008-02-27 12:05:42 $
004: * Version: $Revision: 1.80 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.db;
033:
034: import org.opencms.db.generic.CmsSqlManager;
035: import org.opencms.file.CmsDataAccessException;
036: import org.opencms.file.CmsFile;
037: import org.opencms.file.CmsFolder;
038: import org.opencms.file.CmsGroup;
039: import org.opencms.file.CmsProject;
040: import org.opencms.file.CmsResource;
041: import org.opencms.file.CmsUser;
042: import org.opencms.file.CmsProject.CmsProjectType;
043: import org.opencms.main.CmsException;
044: import org.opencms.publish.CmsPublishJobInfoBean;
045: import org.opencms.report.I_CmsReport;
046: import org.opencms.util.CmsUUID;
047:
048: import java.util.List;
049: import java.util.Set;
050:
051: /**
052: * Definitions of all required project driver methods. <p>
053: *
054: * @author Thomas Weckert
055: * @author Michael Emmerich
056: *
057: * @version $Revision: 1.80 $
058: *
059: * @since 6.0.0
060: */
061: public interface I_CmsProjectDriver {
062:
063: /** Name of the setup project. */
064: String SETUP_PROJECT_NAME = "_setupProject";
065:
066: /** The type ID to identify project driver implementations. */
067: int DRIVER_TYPE_ID = 1;
068:
069: /** The name of the temp file project. */
070: String TEMP_FILE_PROJECT_NAME = "tempFileProject";
071:
072: /**
073: * Creates a new project.<p>
074: *
075: * @param dbc the current database context
076: * @param id the project id
077: * @param owner the owner of the project
078: * @param group the group for the project
079: * @param managergroup the manager group for the project
080: * @param name the name of the project to create
081: * @param description the description for the project
082: * @param flags the flags for the project
083: * @param type the type for the project
084: *
085: * @return the created <code>{@link CmsProject}</code> instance
086: *
087: * @throws CmsDataAccessException if something goes wrong
088: */
089: CmsProject createProject(CmsDbContext dbc, CmsUUID id,
090: CmsUser owner, CmsGroup group, CmsGroup managergroup,
091: String name, String description, int flags,
092: CmsProjectType type) throws CmsDataAccessException;
093:
094: /**
095: * Creates a new projectResource from a given CmsResource object.<p>
096: *
097: * @param dbc the current database context
098: * @param projectId The project in which the resource will be used
099: * @param resourceName The resource to be written to the Cms
100: *
101: * @throws CmsDataAccessException if something goes wrong
102: */
103: void createProjectResource(CmsDbContext dbc, CmsUUID projectId,
104: String resourceName) throws CmsDataAccessException;
105:
106: /**
107: * Inserts an entry for a publish job .<p>
108: *
109: * @param dbc the current database context
110: * @param publishJob the publish job data
111: *
112: * @throws CmsDataAccessException if something goes wrong
113: */
114: void createPublishJob(CmsDbContext dbc,
115: CmsPublishJobInfoBean publishJob)
116: throws CmsDataAccessException;
117:
118: /**
119: * Deletes all entries in the published resource table.<p>
120: *
121: * @param dbc the current database context
122: * @param linkType the type of resource deleted (0= non-paramter, 1=parameter)
123: *
124: * @throws CmsDataAccessException if something goes wrong
125: */
126: void deleteAllStaticExportPublishedResources(CmsDbContext dbc,
127: int linkType) throws CmsDataAccessException;
128:
129: /**
130: * Deletes a project from the cms.<p>
131: *
132: * Therefore it deletes all files, resources and properties.
133: *
134: * @param dbc the current database context
135: * @param project the project to delete
136: * @throws CmsDataAccessException if something goes wrong
137: */
138: void deleteProject(CmsDbContext dbc, CmsProject project)
139: throws CmsDataAccessException;
140:
141: /**
142: * Delete a projectResource from an given CmsResource object.<p>
143: *
144: * @param dbc the current database context
145: * @param projectId id of the project in which the resource is used
146: * @param resourceName name of the resource to be deleted from the Cms
147: *
148: * @throws CmsDataAccessException if something goes wrong
149: */
150: void deleteProjectResource(CmsDbContext dbc, CmsUUID projectId,
151: String resourceName) throws CmsDataAccessException;
152:
153: /**
154: * Deletes a specified project.<p>
155: *
156: * @param dbc the current database context
157: * @param project the project to be deleted
158: *
159: * @throws CmsDataAccessException if operation was not succesful
160: */
161: void deleteProjectResources(CmsDbContext dbc, CmsProject project)
162: throws CmsDataAccessException;
163:
164: /**
165: * Deletes all publish history entries with publish tags >=0 and < the specified max. publish tag.<p>
166: *
167: * @param dbc the current database context
168: * @param projectId the ID of the current project
169: * @param maxPublishTag entries with publish tags >=0 and < this max. publish tag get deleted
170: *
171: * @throws CmsDataAccessException if something goes wrong
172: */
173: void deletePublishHistory(CmsDbContext dbc, CmsUUID projectId,
174: int maxPublishTag) throws CmsDataAccessException;
175:
176: /**
177: * Deletes a publish history entry with publish tags >=0 and < the specified max. publish tag.<p>
178: *
179: * @param dbc the current database context
180: * @param publishHistoryId the id of the history to delete the entry from
181: * @param publishResource the entry to delete
182: *
183: * @throws CmsDataAccessException if something goes wrong
184: */
185: void deletePublishHistoryEntry(CmsDbContext dbc,
186: CmsUUID publishHistoryId,
187: CmsPublishedResource publishResource)
188: throws CmsDataAccessException;
189:
190: /**
191: * Deletes a publish job identified by its history id.<p>
192: *
193: * @param dbc the current database context
194: * @param publishHistoryId the history id identifying the publish job
195: * @throws CmsDataAccessException if something goes wrong
196: */
197: void deletePublishJob(CmsDbContext dbc, CmsUUID publishHistoryId)
198: throws CmsDataAccessException;
199:
200: /**
201: * Deletes the publish list assigned to a publish job.<p>
202: *
203: * @param dbc the current database context
204: * @param publishHistoryId the history id identifying the publish job
205: * @throws CmsDataAccessException if something goes wrong
206: */
207: void deletePublishList(CmsDbContext dbc, CmsUUID publishHistoryId)
208: throws CmsDataAccessException;
209:
210: /**
211: * Deletes an entry in the published resource table.<p>
212: *
213: * @param dbc the current database context
214: * @param resourceName The name of the resource to be deleted in the static export
215: * @param linkType the type of resource deleted (0= non-paramter, 1=parameter)
216: * @param linkParameter the parameters of the resource
217: *
218: * @throws CmsDataAccessException if something goes wrong
219: */
220: void deleteStaticExportPublishedResource(CmsDbContext dbc,
221: String resourceName, int linkType, String linkParameter)
222: throws CmsDataAccessException;
223:
224: /**
225: * Destroys this driver.<p>
226: *
227: * @throws Throwable if something goes wrong
228: */
229: void destroy() throws Throwable;
230:
231: /**
232: * Fills the OpenCms database tables with default values.<p>
233: *
234: * @param dbc the current database context
235: *
236: * @throws CmsDataAccessException if something goes wrong
237: */
238: void fillDefaults(CmsDbContext dbc) throws CmsDataAccessException;
239:
240: /**
241: * Returns the SqlManager of this driver.<p>
242: *
243: * @return the SqlManager of this driver
244: */
245: CmsSqlManager getSqlManager();
246:
247: /**
248: * Initializes the SQL manager for this driver.<p>
249: *
250: * To obtain JDBC connections from different pools, further
251: * {online|offline|history} pool Urls have to be specified.<p>
252: *
253: * @param classname the classname of the SQL manager
254: *
255: * @return the SQL manager for this driver
256: */
257: org.opencms.db.generic.CmsSqlManager initSqlManager(String classname);
258:
259: /**
260: * Publishes a deleted folder.<p>
261: *
262: * @param dbc the current database context
263: * @param report the report to log the output to
264: * @param m the number of the folder to publish
265: * @param n the number of all folders to publish
266: * @param onlineProject the online project
267: * @param offlineFolder the offline folder to publish
268: * @param publishHistoryId the publish history id
269: * @param publishTag the publish tag
270: *
271: * @throws CmsDataAccessException if something goes wrong
272: */
273: void publishDeletedFolder(CmsDbContext dbc, I_CmsReport report,
274: int m, int n, CmsProject onlineProject,
275: CmsFolder offlineFolder, CmsUUID publishHistoryId,
276: int publishTag) throws CmsDataAccessException;
277:
278: /**
279: * Publishes a new, changed or deleted file.<p>
280: *
281: * @param dbc the current database context
282: * @param report the report to log the output to
283: * @param m the number of the file to publish
284: * @param n the number of all files to publish
285: * @param onlineProject the online project
286: * @param offlineResource the offline file to publish
287: * @param publishedContentIds contains the UUIDs of already published content records
288: * @param publishHistoryId the publish history id
289: * @param publishTag the publish tag
290: *
291: * @throws CmsDataAccessException if something goes wrong
292: */
293: void publishFile(CmsDbContext dbc, I_CmsReport report, int m,
294: int n, CmsProject onlineProject,
295: CmsResource offlineResource, Set publishedContentIds,
296: CmsUUID publishHistoryId, int publishTag)
297: throws CmsDataAccessException;
298:
299: /**
300: * Publishes the content record of a file.<p>
301: *
302: * The content record is only published unless it's UUID is not contained in publishedContentIds.
303: * The calling method has to take care about whether an existing content record has to be deleted
304: * before or not.<p>
305: *
306: * The intention of this method is to get overloaded in a project driver
307: * for a specific DB server to shift the binary content from the offline into the online table
308: * in a more sophisticated way than in the generic ANSI-SQL implementation of this interface.
309: *
310: * @param dbc the current database context
311: * @param offlineProject the offline project to read data
312: * @param onlineProject the online project to write data
313: * @param offlineFileHeader the offline header of the file of which the content gets published
314: * @param publishedResourceIds a Set with the UUIDs of the already published content records
315: * @param needToUpdateContent <code>true</code> if the content record has to be updated
316: * @param publishTag the publish tag
317: *
318: * @return the published file (online)
319: *
320: * @throws CmsDataAccessException if something goes wrong
321: */
322: CmsFile publishFileContent(CmsDbContext dbc,
323: CmsProject offlineProject, CmsProject onlineProject,
324: CmsResource offlineFileHeader, Set publishedResourceIds,
325: boolean needToUpdateContent, int publishTag)
326: throws CmsDataAccessException;
327:
328: /**
329: * Publishes a new or changed folder.<p>
330: *
331: * @param dbc the current database context
332: * @param report the report to log the output to
333: * @param m the number of the folder to publish
334: * @param n the number of all folders to publish
335: * @param onlineProject the online project
336: * @param currentFolder the offline folder to publish
337: * @param publishHistoryId the publish history id
338: * @param publishTag the publish tag
339: *
340: * @throws CmsDataAccessException if something goes wrong
341: */
342: void publishFolder(CmsDbContext dbc, I_CmsReport report, int m,
343: int n, CmsProject onlineProject, CmsFolder currentFolder,
344: CmsUUID publishHistoryId, int publishTag)
345: throws CmsDataAccessException;
346:
347: /**
348: * Publishes a specified project to the online project.<p>
349: *
350: * @param dbc the current database context
351: * @param report an I_CmsReport instance to print output messages
352: * @param onlineProject the online project
353: * @param publishList a Cms publish list
354: * @param publishTag the publish tag
355: *
356: * @throws CmsException if something goes wrong
357: */
358: void publishProject(CmsDbContext dbc, I_CmsReport report,
359: CmsProject onlineProject, CmsPublishList publishList,
360: int publishTag) throws CmsException;
361:
362: /**
363: * Reads the <code>{@link List}<{@link org.opencms.lock.CmsLock};> </code>
364: * that were saved to the database in the previous run of OpenCms.<p>
365: *
366: * @param dbc the current database context
367: *
368: * @return the <code>{@link List}<{@link org.opencms.lock.CmsLock};> </code>
369: * that were saved to the database in the previous run of OpenCms.
370: *
371: * @throws CmsDataAccessException if something goes wrong
372: */
373: List readLocks(CmsDbContext dbc) throws CmsDataAccessException;
374:
375: /**
376: * Reads a project given the projects id.<p>
377: *
378: * @param dbc the current database context
379: * @param id the id of the project
380: *
381: * @return the project read
382: *
383: * @throws CmsDataAccessException if something goes wrong
384: */
385: CmsProject readProject(CmsDbContext dbc, CmsUUID id)
386: throws CmsDataAccessException;
387:
388: /**
389: * Reads a project.<p>
390: *
391: * @param dbc the current database context
392: * @param name the name of the project
393: *
394: * @return the project with the given name
395: * @throws CmsDataAccessException if something goes wrong
396: */
397: CmsProject readProject(CmsDbContext dbc, String name)
398: throws CmsDataAccessException;
399:
400: /**
401: * Reads the project resource path for a given project and resource path,
402: * to validate if a resource path for a given project already exists.<p>
403: *
404: * @param dbc the current database context
405: * @param projectId the ID of the project for which the resource path is read
406: * @param resourcename the project's resource path
407: *
408: * @return String the project's resource path
409: * @throws CmsDataAccessException if something goes wrong
410: */
411: String readProjectResource(CmsDbContext dbc, CmsUUID projectId,
412: String resourcename) throws CmsDataAccessException;
413:
414: /**
415: * Reads the project resources for a specified project.<p>
416: *
417: * @param dbc the current database context
418: * @param project the project for which the resource path is read
419: *
420: * @return a list of all project resource paths
421: *
422: * @throws CmsDataAccessException if something goes wrong
423: */
424: List readProjectResources(CmsDbContext dbc, CmsProject project)
425: throws CmsDataAccessException;
426:
427: /**
428: * Returns all projects in the given organizational unit.<p>
429: *
430: * @param dbc the current database context
431: * @param ouFqn the fully qualified name of the organizational unit to get the projects for
432: *
433: * @return a list of objects of type <code>{@link CmsProject}</code>
434: *
435: * @throws CmsDataAccessException if something goes wrong
436: */
437: List readProjects(CmsDbContext dbc, String ouFqn)
438: throws CmsDataAccessException;
439:
440: /**
441: * Returns all projects, which are accessible by a group.<p>
442: *
443: * @param dbc the current database context
444: * @param group the requesting group
445: *
446: * @return a Vector of projects
447: * @throws CmsDataAccessException if something goes wrong
448: */
449: List readProjectsForGroup(CmsDbContext dbc, CmsGroup group)
450: throws CmsDataAccessException;
451:
452: /**
453: * Returns all projects, which are manageable by a group.<p>
454: *
455: * @param dbc the current database context
456: * @param group The requesting group
457: * @return a Vector of projects
458: *
459: * @throws CmsDataAccessException if something goes wrong
460: */
461: List readProjectsForManagerGroup(CmsDbContext dbc, CmsGroup group)
462: throws CmsDataAccessException;
463:
464: /**
465: * Reads all projects which are owned by a specified user.<p>
466: *
467: * @param dbc the current database context
468: * @param user the user
469: *
470: * @return a list of objects of type <code>{@link CmsProject}</code>
471: *
472: * @throws CmsDataAccessException if something goes wrong
473: */
474: List readProjectsForUser(CmsDbContext dbc, CmsUser user)
475: throws CmsDataAccessException;
476:
477: /**
478: * Reads a single publish job identified by its publish history id.<p>
479: *
480: * @param dbc the current database context
481: * @param publishHistoryId unique id to identify the publish job in the publish history
482: * @return an object of type <code>{@link CmsPublishJobInfoBean}</code>
483: *
484: * @throws CmsDataAccessException if something goes wrong
485: */
486: CmsPublishJobInfoBean readPublishJob(CmsDbContext dbc,
487: CmsUUID publishHistoryId) throws CmsDataAccessException;
488:
489: /**
490: * Reads all publish jobs finished in the given time range.<p>
491: * If <code>(0L, 0L)</code> is passed as time range, all pending jobs are returned.
492: *
493: * @param dbc the current database context
494: * @param startTime the start of the time range for finish time
495: * @param endTime the end of the time range for finish time
496: * @return a list of objects of type <code>{@link CmsPublishJobInfoBean}</code>
497: *
498: * @throws CmsDataAccessException if something goes wrong
499: */
500: List readPublishJobs(CmsDbContext dbc, long startTime, long endTime)
501: throws CmsDataAccessException;
502:
503: /**
504: * Reads the publish list assigned to a publish job.<p>
505: *
506: * @param dbc the current database context
507: * @param publishHistoryId the history id identifying the publish job
508: * @return the assigned publish list
509: * @throws CmsDataAccessException if something goes wrong
510: */
511: CmsPublishList readPublishList(CmsDbContext dbc,
512: CmsUUID publishHistoryId) throws CmsDataAccessException;
513:
514: /**
515: * Reads the publish report assigned to a publish job.<p>
516: *
517: * @param dbc the current database context
518: * @param publishHistoryId the history id identifying the publish job
519: * @return the content of the assigned publish report
520: * @throws CmsDataAccessException if something goes wrong
521: */
522: byte[] readPublishReportContents(CmsDbContext dbc,
523: CmsUUID publishHistoryId) throws CmsDataAccessException;
524:
525: /**
526: * Reads the resources that were published during a publish process for a given publish history ID.<p>
527: *
528: * @param dbc the current database context
529: * @param publishHistoryId unique int ID to identify the publish process in the publish history
530: *
531: * @return a list of <code>{@link org.opencms.db.CmsPublishedResource}</code> objects
532: *
533: * @throws CmsDataAccessException if something goes wrong
534: */
535: List readPublishedResources(CmsDbContext dbc,
536: CmsUUID publishHistoryId) throws CmsDataAccessException;
537:
538: /**
539: * Returns the parameters of a resource in the table of all published template resources.<p>
540: *
541: * @param dbc the current database context
542: * @param rfsName the rfs name of the resource
543: *
544: * @return the paramter string of the requested resource
545: *
546: * @throws CmsDataAccessException if something goes wrong
547: */
548: String readStaticExportPublishedResourceParameters(
549: CmsDbContext dbc, String rfsName)
550: throws CmsDataAccessException;
551:
552: /**
553: * Returns a list of all template resources which must be processed during a static export.<p>
554: *
555: * @param dbc the current database context
556: * @param parameterResources flag for reading resources with parameters (1) or without (0)
557: * @param timestamp the timestamp information
558: *
559: * @return a list of template resources as <code>{@link String}</code> objects
560: *
561: * @throws CmsDataAccessException if something goes wrong
562: */
563: List readStaticExportResources(CmsDbContext dbc,
564: int parameterResources, long timestamp)
565: throws CmsDataAccessException;
566:
567: /**
568: * Removes the project id from all resources within a project.<p>
569: *
570: * This must be done when a project will deleted
571: *
572: * @param dbc the current database context
573: * @param project the project to delete
574: * @throws CmsDataAccessException if something goes wrong
575: */
576: void unmarkProjectResources(CmsDbContext dbc, CmsProject project)
577: throws CmsDataAccessException;
578:
579: /**
580: * Writes the <code>{@link List}<{@link org.opencms.lock.CmsLock};> </code>
581: * to the database for reuse in the next run of OpenCms.<p>
582: *
583: * This method must only be called at startup or the in-memory locking will overwritten.<p>
584: *
585: * @param dbc the current database context
586: *
587: * @param locks the <code>{@link List}<{@link org.opencms.lock.CmsLock};></code> that
588: * currently exist in OpenCms ({@link org.opencms.lock.CmsLockManager})
589: *
590: * @throws CmsDataAccessException if something goes wrong
591: */
592: void writeLocks(CmsDbContext dbc, List locks)
593: throws CmsDataAccessException;
594:
595: /**
596: * Writes an already existing project.<p>
597: *
598: * The project id has to be a valid OpenCms project id.<br>
599: *
600: * The project with the given id will be completely overriden
601: * by the given data.<p>
602: *
603: * @param dbc the current database context
604: * @param project the project that should be written
605: *
606: * @throws CmsDataAccessException if operation was not successful
607: */
608: void writeProject(CmsDbContext dbc, CmsProject project)
609: throws CmsDataAccessException;
610:
611: /**
612: * Inserts an entry in the publish history for a published VFS resource.<p>
613: *
614: * @param dbc the current database context
615: * @param publishId the ID of the current publishing process
616: * @param resource the state of the resource *before* it was published
617: *
618: * @throws CmsDataAccessException if something goes wrong
619: */
620: void writePublishHistory(CmsDbContext dbc, CmsUUID publishId,
621: CmsPublishedResource resource)
622: throws CmsDataAccessException;
623:
624: /**
625: * Writes a publish job.<p>
626: *
627: * @param dbc the current database context
628: * @param publishJob the publish job to write
629: * @throws CmsDataAccessException if something goes wrong
630: */
631: void writePublishJob(CmsDbContext dbc,
632: CmsPublishJobInfoBean publishJob)
633: throws CmsDataAccessException;
634:
635: /**
636: * Writes a publish report for a publish job.<p>
637: *
638: * @param dbc the current database context
639: * @param publishId the ID of the current publishing process
640: * @param content the report output
641: * @throws CmsDataAccessException if something goes wrong
642: */
643: void writePublishReport(CmsDbContext dbc, CmsUUID publishId,
644: byte[] content) throws CmsDataAccessException;
645:
646: /**
647: * Inserts an entry in the published resource table.<p>
648: *
649: * This is done during static export.<p>
650: *
651: * @param dbc the current database context
652: * @param resourceName The name of the resource to be added to the static export
653: * @param linkType the type of resource exported (0= non-paramter, 1=parameter)
654: * @param linkParameter the parameters added to the resource
655: * @param timestamp a timestamp for writing the data into the db
656: *
657: * @throws CmsDataAccessException if something goes wrong
658: */
659: void writeStaticExportPublishedResource(CmsDbContext dbc,
660: String resourceName, int linkType, String linkParameter,
661: long timestamp) throws CmsDataAccessException;
662:
663: }
|