001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/I_CmsVfsDriver.java,v $
003: * Date : $Date: 2008-02-27 12:05:43 $
004: * Version: $Revision: 1.120 $
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.CmsProject;
039: import org.opencms.file.CmsProperty;
040: import org.opencms.file.CmsPropertyDefinition;
041: import org.opencms.file.CmsResource;
042: import org.opencms.relations.CmsRelation;
043: import org.opencms.relations.CmsRelationFilter;
044: import org.opencms.util.CmsUUID;
045:
046: import java.sql.ResultSet;
047: import java.sql.SQLException;
048: import java.util.List;
049: import java.util.Map;
050:
051: /**
052: * Definitions of all required VFS driver methods.<p>
053: *
054: * @author Thomas Weckert
055: * @author Michael Emmerich
056: *
057: * @version $Revision: 1.120 $
058: *
059: * @since 6.0.0
060: */
061: public interface I_CmsVfsDriver {
062:
063: /** The type ID to identify user driver implementations. */
064: int DRIVER_TYPE_ID = 3;
065:
066: /** The internal request attribute to indicate that the permissions have to be checked. */
067: String REQ_ATTR_CHECK_PERMISSIONS = "CHECK_PERMISSIONS";
068:
069: /**
070: * Counts the number of siblings of a resource.<p>
071: *
072: * @param dbc the current database context
073: * @param projectId the current project id
074: * @param resourceId the resource id to count the number of siblings from
075: *
076: * @return number of siblings
077: * @throws CmsDataAccessException if something goes wrong
078: */
079: int countSiblings(CmsDbContext dbc, CmsUUID projectId,
080: CmsUUID resourceId) throws CmsDataAccessException;
081:
082: /**
083: * Creates a content entry for the resource identified by the specified resource id.<p>
084: *
085: * @param dbc the current database context
086: * @param projectId the id of the current project
087: * @param resourceId the resource id of the resource to create the content for
088: * @param content the content to write
089: *
090: * @throws CmsDataAccessException if something goes wrong
091: */
092: void createContent(CmsDbContext dbc, CmsUUID projectId,
093: CmsUUID resourceId, byte[] content)
094: throws CmsDataAccessException;
095:
096: /**
097: * Creates a {@link CmsFile} instance from a JDBC ResultSet.<p>
098: *
099: * @param res the JDBC ResultSet
100: * @param projectId the project id
101: *
102: * @return the created file
103: * @throws SQLException in case the result set does not include a requested table attribute
104: */
105: CmsFile createFile(ResultSet res, CmsUUID projectId)
106: throws SQLException;
107:
108: /**
109: * Creates a {@link CmsFile} instance from a JDBC ResultSet.<p>
110: *
111: * @param res the JDBC ResultSet
112: * @param projectId the project id
113: * @param hasFileContentInResultSet flag to include the file content
114: *
115: * @return the created file
116: * @throws SQLException in case the result set does not include a requested table attribute
117: */
118: CmsFile createFile(ResultSet res, CmsUUID projectId,
119: boolean hasFileContentInResultSet) throws SQLException;
120:
121: /**
122: * Creates a {@link CmsFolder} instance from a JDBC ResultSet.<p>
123: *
124: * @param res the JDBC ResultSet
125: * @param projectId the ID of the current project
126: * @param hasProjectIdInResultSet true if the SQL select query includes the PROJECT_ID table attribute
127: *
128: * @return the created folder
129: * @throws SQLException in case the result set does not include a requested table attribute
130: */
131: CmsFolder createFolder(ResultSet res, CmsUUID projectId,
132: boolean hasProjectIdInResultSet) throws SQLException;
133:
134: /**
135: * Creates a new content in the offline project.<p>
136: *
137: * @param dbc the current database context
138: * @param resourceId the resource id of the content to write
139: * @param contents the content to publish
140: * @param publishTag the publish tag
141: * @param keepOnline if the content is online or has to be put in the history
142: * @param needToUpdateContent if the content blob has to be updated
143: *
144: * @throws CmsDataAccessException if something goes wrong
145: */
146: void createOnlineContent(CmsDbContext dbc, CmsUUID resourceId,
147: byte[] contents, int publishTag, boolean keepOnline,
148: boolean needToUpdateContent) throws CmsDataAccessException;
149:
150: /**
151: * Creates a new property definition in the database.<p>
152: *
153: * @param dbc the current database context
154: * @param projectId the project in which the property definition is created
155: * @param name the name of the property definition
156: * @param type the type of the property definition
157: *
158: * @return the new property definition
159: *
160: * @throws CmsDataAccessException if something goes wrong
161: */
162: CmsPropertyDefinition createPropertyDefinition(CmsDbContext dbc,
163: CmsUUID projectId, String name,
164: CmsPropertyDefinition.CmsPropertyType type)
165: throws CmsDataAccessException;
166:
167: /**
168: * Creates a new {@link CmsRelation} object in the database.<p>
169: *
170: * @param dbc the current database context
171: * @param projectId the id of the project to execute the query in
172: * @param relation the relation to create
173: *
174: * @throws CmsDataAccessException if something goes wrong
175: */
176: void createRelation(CmsDbContext dbc, CmsUUID projectId,
177: CmsRelation relation) throws CmsDataAccessException;
178:
179: /**
180: * Creates a new resource from a given {@link CmsResource} object.<p>
181: *
182: * This method works for both files and folders. Existing resources get overwritten.<p>
183: *
184: * @param dbc the current database context
185: * @param projectId the id of the current project
186: * @param resource the resource to be created
187: * @param content the file content, or null in case of a folder
188: * @return the created Cms resource
189: *
190: * @throws CmsDataAccessException if something goes wrong
191: *
192: * @see org.opencms.file.types.I_CmsResourceType#createResource(org.opencms.file.CmsObject, CmsSecurityManager, String, byte[], List)
193: * @see org.opencms.file.types.I_CmsResourceType#importResource(org.opencms.file.CmsObject, CmsSecurityManager, String, CmsResource, byte[], List)
194: * @see org.opencms.file.CmsObject#createResource(String, int, byte[], List)
195: * @see org.opencms.file.CmsObject#importResource(String, CmsResource, byte[], List)
196: */
197: CmsResource createResource(CmsDbContext dbc, CmsUUID projectId,
198: CmsResource resource, byte[] content)
199: throws CmsDataAccessException;
200:
201: /**
202: * Creates a CmsResource instance from a JDBC ResultSet.<p>
203: *
204: * @param res the JDBC ResultSet
205: * @param projectId the ID of the current project to adjust the modification date in case the resource is a VFS link
206: *
207: * @return the created resource
208: * @throws SQLException in case the result set does not include a requested table attribute
209: */
210: CmsResource createResource(ResultSet res, CmsUUID projectId)
211: throws SQLException;
212:
213: /**
214: * Creates a new sibling for a specified resource.<p>
215: * @param dbc the current database context
216: * @param project the project where to create the link
217: * @param resource the link prototype
218: *
219: * @throws CmsDataAccessException if something goes wrong
220: */
221: void createSibling(CmsDbContext dbc, CmsProject project,
222: CmsResource resource) throws CmsDataAccessException;
223:
224: /**
225: * Deletes a property definition.<p>
226: *
227: * @param dbc the current database context
228: * @param name the property definitions to be deleted
229: *
230: * @throws CmsDataAccessException if something goes wrong
231: */
232: void deletePropertyDefinition(CmsDbContext dbc,
233: CmsPropertyDefinition name) throws CmsDataAccessException;
234:
235: /**
236: * Deletes all property values of a file or folder.<p>
237: *
238: * You may specify which whether just structure or resource property values should
239: * be deleted, or both of them.<p>
240: *
241: * @param dbc the current database context
242: * @param projectId the id of the project
243: * @param resource the resource
244: * @param deleteOption determines which property values should be deleted
245: *
246: * @throws CmsDataAccessException if something goes wrong
247: *
248: * @see org.opencms.file.CmsProperty#DELETE_OPTION_DELETE_STRUCTURE_AND_RESOURCE_VALUES
249: * @see org.opencms.file.CmsProperty#DELETE_OPTION_DELETE_STRUCTURE_VALUES
250: * @see org.opencms.file.CmsProperty#DELETE_OPTION_DELETE_RESOURCE_VALUES
251: */
252: void deletePropertyObjects(CmsDbContext dbc, CmsUUID projectId,
253: CmsResource resource, int deleteOption)
254: throws CmsDataAccessException;
255:
256: /**
257: * Deletes all relations with the given filter for the given resource.<p>
258: *
259: * @param dbc the current database context
260: * @param projectId the id of the project to execute the query in
261: * @param resource the base resource. May be <code>null</code> for all
262: * @param filter the filter to restrict the relations to remove
263: *
264: * @throws CmsDataAccessException if something goes wrong
265: */
266: void deleteRelations(CmsDbContext dbc, CmsUUID projectId,
267: CmsResource resource, CmsRelationFilter filter)
268: throws CmsDataAccessException;
269:
270: /**
271: * Destroys this driver.<p>
272: *
273: * @throws Throwable if something goes wrong
274: */
275: void destroy() throws Throwable;
276:
277: /**
278: * Returns the SqlManager of this driver.<p>
279: *
280: * @return the SqlManager of this driver
281: */
282: CmsSqlManager getSqlManager();
283:
284: /**
285: * Initializes the SQL manager for this driver.<p>
286: *
287: * To obtain JDBC connections from different pools, further
288: * {online|offline|history} pool Urls have to be specified.<p>
289: *
290: * @param classname the class name of the SQL manager
291: *
292: * @return the SQL manager for this driver
293: */
294: org.opencms.db.generic.CmsSqlManager initSqlManager(String classname);
295:
296: /**
297: * Moves the given resource to the specified destination path.<p>
298: *
299: * @param dbc the current database context
300: * @param projectId the Id of the project
301: * @param source the resource to move
302: * @param destinationPath the root path of the destination resource
303: *
304: * @throws CmsDataAccessException if something goes wrong
305: */
306: void moveResource(CmsDbContext dbc, CmsUUID projectId,
307: CmsResource source, String destinationPath)
308: throws CmsDataAccessException;
309:
310: /**
311: * Publishes the structure and resource records of an
312: * offline resource into it's online counterpart.<p>
313: *
314: * @param dbc the current database context
315: * @param onlineProject the online project
316: * @param onlineResource the online resource
317: * @param offlineResource the offline resource
318: *
319: * @throws CmsDataAccessException if something goes wrong
320: */
321: void publishResource(CmsDbContext dbc, CmsProject onlineProject,
322: CmsResource onlineResource, CmsResource offlineResource)
323: throws CmsDataAccessException;
324:
325: /**
326: * Copies the version number from the offline resource to the online resource,
327: * this has to be done during publishing, direct after copying the resource itself.<p>
328: *
329: * @param dbc the current database context
330: * @param resource the resource that has been publish
331: * @param firstSibling if this is the first sibling to be publish
332: *
333: * @throws CmsDataAccessException if something goes wrong
334: */
335: void publishVersions(CmsDbContext dbc, CmsResource resource,
336: boolean firstSibling) throws CmsDataAccessException;
337:
338: /**
339: * Reads all child-files and/or child-folders of a specified parent resource.<p>
340: *
341: * @param dbc the current database context
342: * @param currentProject the current project
343: * @param resource the parent folder
344: * @param getFolders if true the child folders of the parent folder are returned in the result set
345: * @param getFiles if true the child files of the parent folder are returned in the result set
346: *
347: * @return a list of all sub folders or sub files
348: * @throws CmsDataAccessException if something goes wrong
349: */
350: List readChildResources(CmsDbContext dbc,
351: CmsProject currentProject, CmsResource resource,
352: boolean getFolders, boolean getFiles)
353: throws CmsDataAccessException;
354:
355: /**
356: * Reads the content of a file specified by it's resource ID.<p>
357: *
358: * @param dbc the current database context
359: * @param projectId the ID of the current project
360: * @param resourceId the id of the resource
361: *
362: * @return the file content
363: *
364: * @throws CmsDataAccessException if something goes wrong
365: */
366: byte[] readContent(CmsDbContext dbc, CmsUUID projectId,
367: CmsUUID resourceId) throws CmsDataAccessException;
368:
369: /**
370: * Reads a folder specified by it's structure ID.<p>
371: *
372: * @param dbc the current database context
373: * @param projectId the project in which the resource will be used
374: * @param folderId the structure id of the folder to be read
375: *
376: * @return the read folder
377: *
378: * @throws CmsDataAccessException if something goes wrong
379: */
380: CmsFolder readFolder(CmsDbContext dbc, CmsUUID projectId,
381: CmsUUID folderId) throws CmsDataAccessException;
382:
383: /**
384: * Reads a folder specified by it's resource name.<p>
385: *
386: * @param dbc the current database context
387: * @param projectId the project in which the resource will be used
388: * @param foldername the name of the folder to be read
389: *
390: * @return the read folder
391: * @throws CmsDataAccessException if something goes wrong
392: */
393: CmsFolder readFolder(CmsDbContext dbc, CmsUUID projectId,
394: String foldername) throws CmsDataAccessException;
395:
396: /**
397: * Reads the parent folder of a resource specified by it's structure ID.<p>
398: *
399: * The parent folder for the root '/' is defined as <code>null</code>.<p>
400: *
401: * @param dbc the current database context
402: * @param projectId the project in which the resource will be used
403: * @param structureId the id of the resource to read the parent folder for
404: *
405: * @return the read folder, or <code>null</code>
406: *
407: * @throws CmsDataAccessException if something goes wrong
408: */
409: CmsFolder readParentFolder(CmsDbContext dbc, CmsUUID projectId,
410: CmsUUID structureId) throws CmsDataAccessException;
411:
412: /**
413: * Reads a property definition for the specified resource type.<p>
414: *
415: * If no property definition with the given name is found,
416: * <code>null</code> is returned.<p>
417: *
418: * @param dbc the current database context
419: * @param name the name of the property definition to read
420: * @param projectId the id of the project
421: *
422: * @return the property definition that was read,
423: * or <code>null</code> if there is no property definition with the given name.
424: *
425: * @throws CmsDataAccessException if something goes wrong
426: */
427: CmsPropertyDefinition readPropertyDefinition(CmsDbContext dbc,
428: String name, CmsUUID projectId)
429: throws CmsDataAccessException;
430:
431: /**
432: * Reads all property definitions for the specified mapping type.<p>
433: *
434: * @param dbc the current database context
435: * @param projectId the id of the project
436: *
437: * @return a list with the <code>{@link CmsPropertyDefinition}</code> objects (may be empty)
438: *
439: * @throws CmsDataAccessException if something goes wrong
440: */
441: List readPropertyDefinitions(CmsDbContext dbc, CmsUUID projectId)
442: throws CmsDataAccessException;
443:
444: /**
445: * Reads a property object from the database specified by it's key name mapped to a resource.<p>
446: *
447: * The implementation must return {@link CmsProperty#getNullProperty()} if the property is not found.<p>
448: *
449: * @param dbc the current database context
450: * @param key the key of the property
451: * @param project the current project
452: * @param resource the resource where the property is attached to
453: *
454: * @return a CmsProperty object containing both the structure and resource value of the property
455: * @throws CmsDataAccessException if something goes wrong
456: */
457: CmsProperty readPropertyObject(CmsDbContext dbc, String key,
458: CmsProject project, CmsResource resource)
459: throws CmsDataAccessException;
460:
461: /**
462: * Reads all property objects mapped to a specified resource from the database.<p>
463: *
464: * The implementation must return an empty list if no properties are found at all.<p>
465: *
466: * @param dbc the current database context
467: * @param project the current project
468: * @param resource the resource where the property is attached to
469: *
470: * @return a list with CmsProperty objects containing both the structure and resource value of the property
471: * @throws CmsDataAccessException if something goes wrong
472: */
473: List readPropertyObjects(CmsDbContext dbc, CmsProject project,
474: CmsResource resource) throws CmsDataAccessException;
475:
476: /**
477: * Reads all relations with the given filter for the given resource.<p>
478: *
479: * @param dbc the current database context
480: * @param projectId the id of the project to execute the query in
481: * @param resource the resource to read the relations for, may be <code>null</code> for all
482: * @param filter the filter to restrict the relations to retrieve
483: *
484: * @return the read relations
485: *
486: * @throws CmsDataAccessException if something goes wrong
487: */
488: List readRelations(CmsDbContext dbc, CmsUUID projectId,
489: CmsResource resource, CmsRelationFilter filter)
490: throws CmsDataAccessException;
491:
492: /**
493: * Reads a resource specified by it's structure ID.<p>
494: *
495: * @param dbc the current database context
496: * @param projectId the Id of the project
497: * @param structureId the Id of the resource
498: * @param includeDeleted true if already deleted files are included
499: *
500: * @return the resource that was read
501: * @throws CmsDataAccessException if something goes wrong
502: */
503: CmsResource readResource(CmsDbContext dbc, CmsUUID projectId,
504: CmsUUID structureId, boolean includeDeleted)
505: throws CmsDataAccessException;
506:
507: /**
508: * Reads a resource specified by it's resource name.<p>
509: *
510: * @param dbc the current database context
511: * @param projectId the Id of the project in which the resource will be used
512: * @param filename the name of the file
513: * @param includeDeleted true if already deleted files are included
514: *
515: * @return the resource that was read
516: * @throws CmsDataAccessException if something goes wrong
517: */
518: CmsResource readResource(CmsDbContext dbc, CmsUUID projectId,
519: String filename, boolean includeDeleted)
520: throws CmsDataAccessException;
521:
522: /**
523: * Reads all resources inside a given project and with a given state.<p>
524: *
525: * @param dbc the current database context
526: * @param currentProject the current project
527: * @param state the state to match
528: * @param mode flag signaling the read mode
529: *
530: * @return a list with all resources that where read
531: * @throws CmsDataAccessException if something goes wrong
532: */
533: List readResources(CmsDbContext dbc, CmsUUID currentProject,
534: CmsResourceState state, int mode)
535: throws CmsDataAccessException;
536:
537: /**
538: * Returns all resources associated to a given principal via an ACE.<p>
539: *
540: * @param dbc the current database context
541: * @param project the to read the entries from
542: * @param principalId the id of the principal
543:
544: * @return a list of <code>{@link org.opencms.file.CmsResource}</code> objects
545: *
546: * @throws CmsDataAccessException if something goes wrong
547: */
548: List readResourcesForPrincipalACE(CmsDbContext dbc,
549: CmsProject project, CmsUUID principalId)
550: throws CmsDataAccessException;
551:
552: /**
553: * Returns all resources associated to a given principal through some of following attributes.<p>
554: *
555: * <ul>
556: * <li>User Created</li>
557: * <li>User Last Modified</li>
558: * </ul><p>
559: *
560: * @param dbc the current database context
561: * @param project the to read the entries from
562: * @param principalId the id of the principal
563:
564: * @return a list of <code>{@link org.opencms.file.CmsResource}</code> objects
565: *
566: * @throws CmsDataAccessException if something goes wrong
567: */
568: List readResourcesForPrincipalAttr(CmsDbContext dbc,
569: CmsProject project, CmsUUID principalId)
570: throws CmsDataAccessException;
571:
572: /**
573: * Reads all resources that have a value (containing the specified value)
574: * set for the specified property (definition), in the given path.<p>
575: *
576: * Both individual and shared properties of a resource are checked.<p>
577: *
578: * If the <code>value</code> parameter is <code>null</code>, all resources having the
579: * given property set are returned.<p>
580: *
581: * @param dbc the current database context
582: * @param projectId the id of the project
583: * @param propertyDefinition the id of the property definition
584: * @param path the folder to get the resources with the property from
585: * @param value the string to search in the value of the property
586: *
587: * @return a list of all <code>{@link CmsResource}</code> objects
588: * that have a value set for the specified property.
589: *
590: * @throws CmsDataAccessException if something goes wrong
591: */
592: List readResourcesWithProperty(CmsDbContext dbc, CmsUUID projectId,
593: CmsUUID propertyDefinition, String path, String value)
594: throws CmsDataAccessException;
595:
596: /**
597: * Reads all resources inside a given project matching the criteria specified by parameter values.<p>
598: *
599: * Important: If {@link CmsDriverManager#READMODE_EXCLUDE_TREE} is true (or {@link CmsDriverManager#READMODE_INCLUDE_TREE} is false),
600: * the provided parent String must be the UUID of the parent folder, NOT the parent folder path.<p>
601: *
602: * @param dbc the current database context
603: * @param projectId the project id for matching resources
604: * @param parent the path to the resource used as root of the searched subtree or {@link CmsDriverManager#READ_IGNORE_PARENT},
605: * {@link CmsDriverManager#READMODE_EXCLUDE_TREE} means to read immediate children only
606: * @param type the resource type of matching resources or {@link CmsDriverManager#READ_IGNORE_TYPE} (meaning inverted by {@link CmsDriverManager#READMODE_EXCLUDE_TYPE}
607: * @param state the state of matching resources (meaning inverted by {@link CmsDriverManager#READMODE_EXCLUDE_STATE} or <code>null</code> to ignore
608: * @param startTime the start of the time range for the last modification date of matching resources or READ_IGNORE_TIME
609: * @param endTime the end of the time range for the last modification date of matching resources or READ_IGNORE_TIME
610: * @param releasedAfter the start of the time range for the release date of matching resources
611: * @param releasedBefore the end of the time range for the release date of matching resources
612: * @param expiredAfter the start of the time range for the expire date of matching resources
613: * @param expiredBefore the end of the time range for the expire date of matching resources
614: * @param mode additional mode flags:
615: * <ul>
616: * <li>{@link CmsDriverManager#READMODE_INCLUDE_TREE}
617: * <li>{@link CmsDriverManager#READMODE_EXCLUDE_TREE}
618: * <li>{@link CmsDriverManager#READMODE_INCLUDE_PROJECT}
619: * <li>{@link CmsDriverManager#READMODE_EXCLUDE_TYPE}
620: * <li>{@link CmsDriverManager#READMODE_EXCLUDE_STATE}
621: * </ul>
622: *
623: * @return a list of CmsResource objects matching the given criteria
624: *
625: * @throws CmsDataAccessException if something goes wrong
626: */
627: List readResourceTree(CmsDbContext dbc, CmsUUID projectId,
628: String parent, int type, CmsResourceState state,
629: long startTime, long endTime, long releasedAfter,
630: long releasedBefore, long expiredAfter, long expiredBefore,
631: int mode) throws CmsDataAccessException;
632:
633: /**
634: * Reads all siblings that point to the resource record of a specified resource.<p>
635: *
636: * @param dbc the current database context
637: * @param projectId the id of the current project
638: * @param resource the specified resource
639: * @param includeDeleted <code>true</code> if deleted siblings should be included in the result list
640: *
641: * @return a list of <code>{@link CmsResource}</code>s that
642: * are siblings to the specified resource,
643: * including the specified resource itself.
644: *
645: * @throws CmsDataAccessException if something goes wrong
646: */
647: List readSiblings(CmsDbContext dbc, CmsUUID projectId,
648: CmsResource resource, boolean includeDeleted)
649: throws CmsDataAccessException;
650:
651: /**
652: * Reads a resource version numbers.<p>
653: *
654: * @param dbc the current database context
655: * @param projectId the project to read the versions from
656: * @param resourceId the resource id of the resource to read the versions from
657: * @param structureId the structure id of the resource to read the versions from
658: *
659: * @return a map with two entries with keys "structure" and "resource" for the
660: * structure and resource version number respectively, the values are {@link Integer}
661: * objects and may be <code>-1</code> if an entry could be found
662: *
663: * @throws CmsDataAccessException if something goes wrong
664: */
665: Map readVersions(CmsDbContext dbc, CmsUUID projectId,
666: CmsUUID resourceId, CmsUUID structureId)
667: throws CmsDataAccessException;
668:
669: /**
670: * Removes a file physically in the database.<p>
671: *
672: * @param dbc the current database context
673: * @param projectId the id of the current project
674: * @param resource the resource
675: *
676: * @throws CmsDataAccessException if something goes wrong
677: */
678: void removeFile(CmsDbContext dbc, CmsUUID projectId,
679: CmsResource resource) throws CmsDataAccessException;
680:
681: /**
682: * Removes a folder physically in the database.<p>
683: *
684: * @param dbc the current database context
685: * @param currentProject the current project
686: * @param resource the folder
687: *
688: * @throws CmsDataAccessException if something goes wrong
689: */
690: void removeFolder(CmsDbContext dbc, CmsProject currentProject,
691: CmsResource resource) throws CmsDataAccessException;
692:
693: /**
694: * Replaces the content and properties of an existing resource.<p>
695: * @param dbc the current database context
696: * @param newResource the new resource
697: * @param newResourceContent the new content
698: * @param newResourceType the resource type
699: *
700: * @throws CmsDataAccessException if something goes wrong
701: */
702: void replaceResource(CmsDbContext dbc, CmsResource newResource,
703: byte[] newResourceContent, int newResourceType)
704: throws CmsDataAccessException;
705:
706: /**
707: * Transfers the attributes of a resource from to the given users.<p>
708: *
709: * @param dbc the current database context
710: * @param project the current project
711: * @param resource the resource to modify
712: * @param createdUser the id of the user to be set as the creator of the resource
713: * @param lastModifiedUser the id of the user to be set as the last modificator of the resource
714: *
715: * @throws CmsDataAccessException if something goes wrong
716: */
717: void transferResource(CmsDbContext dbc, CmsProject project,
718: CmsResource resource, CmsUUID createdUser,
719: CmsUUID lastModifiedUser) throws CmsDataAccessException;
720:
721: /**
722: * Updates the relations on the online project copying the relations from the offline project.<p>
723: *
724: * @param dbc the current database context
725: * @param onlineProject the online project
726: * @param offlineResource the resource to update the relations for
727: *
728: * @throws CmsDataAccessException is something goes wrong
729: */
730: void updateRelations(CmsDbContext dbc, CmsProject onlineProject,
731: CmsResource offlineResource) throws CmsDataAccessException;
732:
733: /**
734: * Validates if the specified resource ID in the tables of the specified project {offline|online} exists.<p>
735: *
736: * @param dbc the current database context
737: * @param projectId the project id
738: * @param resourceId the resource id to test for
739: *
740: * @return true if a resource with the given id was found, false otherwise
741: *
742: * @throws CmsDataAccessException if something goes wrong
743: */
744: boolean validateResourceIdExists(CmsDbContext dbc,
745: CmsUUID projectId, CmsUUID resourceId)
746: throws CmsDataAccessException;
747:
748: /**
749: * Validates if the specified structure ID in the tables of the specified project {offline|online} exists.<p>
750: *
751: * @param dbc the current database context
752: * @param projectId the ID of current project
753: * @param structureId the structure id
754: *
755: * @return true, if the specified structure ID in the tables of the specified project {offline|online} exists
756: * @throws CmsDataAccessException if something goes wrong
757: */
758: boolean validateStructureIdExists(CmsDbContext dbc,
759: CmsUUID projectId, CmsUUID structureId)
760: throws CmsDataAccessException;
761:
762: /**
763: * Writes the resource content with the specified resource id.<p>
764: *
765: * @param dbc the current database context
766: * @param resourceId the id of the resource used to identify the content to update
767: * @param content the new content of the file
768: *
769: * @throws CmsDataAccessException if something goes wrong
770: */
771: void writeContent(CmsDbContext dbc, CmsUUID resourceId,
772: byte[] content) throws CmsDataAccessException;
773:
774: /**
775: * Writes the "last-modified-in-project" ID of a resource.<p>
776: *
777: * @param dbc the current database context
778: * @param project the resource record is updated with the ID of this project
779: * @param projectId the project id to write into the resource
780: * @param resource the resource that gets updated
781: *
782: * @throws CmsDataAccessException if something goes wrong
783: */
784: void writeLastModifiedProjectId(CmsDbContext dbc,
785: CmsProject project, CmsUUID projectId, CmsResource resource)
786: throws CmsDataAccessException;
787:
788: /**
789: * Writes a property object to the database mapped to a specified resource.<p>
790: *
791: * @param dbc the current database context
792: * @param project the current project
793: * @param resource the resource where the property should be attached to
794: * @param property a CmsProperty object containing both the structure and resource value of the property
795: *
796: * @throws CmsDataAccessException if something goes wrong
797: */
798: void writePropertyObject(CmsDbContext dbc, CmsProject project,
799: CmsResource resource, CmsProperty property)
800: throws CmsDataAccessException;
801:
802: /**
803: * Writes a list of property objects to the database mapped to a specified resource.<p>
804: *
805: * @param dbc the current database context
806: * @param project the current project
807: * @param resource the resource where the property should be attached to
808: * @param properties a list of CmsProperty objects
809: *
810: * @throws CmsDataAccessException if something goes wrong
811: */
812: void writePropertyObjects(CmsDbContext dbc, CmsProject project,
813: CmsResource resource, List properties)
814: throws CmsDataAccessException;
815:
816: /**
817: * Writes the structure and/or resource record(s) of an existing file.<p>
818: *
819: * Common usages of this method are saving the resource information
820: * after creating, importing or restoring complete files
821: * where all file header attributes are changed. Both the structure and resource
822: * records get written. Thus, using this method affects all siblings of
823: * a resource! Use {@link #writeResourceState(CmsDbContext, CmsProject, CmsResource, int, boolean)}
824: * instead if you just want to update the file state, e.g. of a single sibling.<p>
825: *
826: * The file state is set to "changed", unless the current state is "new"
827: * or "deleted". The "changed" argument allows to choose whether the structure
828: * or resource state, or none of them, is set to "changed".<p>
829: *
830: * The rating of the file state values is as follows:<br>
831: * unchanged < changed < new < deleted<p>
832: *
833: * Second, the "state" of the resource is the structure state, if the structure state
834: * has a higher file state value than the resource state. Otherwise the file state is
835: * the resource state.<p>
836: *
837: * @param dbc the current database context
838: * @param projectId the id of the current project
839: * @param resource the resource to be updated
840: * @param changed determines whether the structure or resource state, or none of them, is set to "changed"
841: *
842: * @throws CmsDataAccessException if something goes wrong
843: *
844: * @see org.opencms.db.CmsDriverManager#UPDATE_RESOURCE_STATE
845: * @see org.opencms.db.CmsDriverManager#UPDATE_STRUCTURE_STATE
846: * @see org.opencms.db.CmsDriverManager#NOTHING_CHANGED
847: * @see #writeResourceState(CmsDbContext, CmsProject, CmsResource, int, boolean)
848: */
849: void writeResource(CmsDbContext dbc, CmsUUID projectId,
850: CmsResource resource, int changed)
851: throws CmsDataAccessException;
852:
853: /**
854: * Writes file state in either the structure or resource record, or both of them.<p>
855: *
856: * This method allows to change the resource state to any state by setting the
857: * desired state value in the specified CmsResource instance.<p>
858: *
859: * This method is frequently used while resources are published to set the file state
860: * back to "unchanged".<p>
861: *
862: * Only file state attributes. get updated here. Use {@link #writeResource(CmsDbContext, CmsUUID, CmsResource, int)}
863: * instead to write the complete file header.<p>
864: *
865: * Please refer to the javadoc of {@link #writeResource(CmsDbContext, CmsUUID, CmsResource, int)} to read
866: * how setting resource state values affects the file state.<p>
867: *
868: * @param dbc the current database context
869: * @param project the current project
870: * @param resource the resource to be updated
871: * @param changed determines whether the structure or resource state, or none of them, is set to "changed"
872: * @param isPublishing if this method is called during publishing to version numbers are updated
873: *
874: * @throws CmsDataAccessException if something goes wrong
875: *
876: * @see org.opencms.db.CmsDriverManager#UPDATE_RESOURCE_STATE
877: * @see org.opencms.db.CmsDriverManager#UPDATE_STRUCTURE_STATE
878: * @see org.opencms.db.CmsDriverManager#UPDATE_ALL
879: */
880: void writeResourceState(CmsDbContext dbc, CmsProject project,
881: CmsResource resource, int changed, boolean isPublishing)
882: throws CmsDataAccessException;
883: }
|