001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/db/tags/sakai_2-4-1/db-util/storage/src/java/org/sakaiproject/util/StorageUser.java $
003: * $Id: StorageUser.java 7076 2006-03-27 21:25:47Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.util;
021:
022: import org.sakaiproject.entity.api.Edit;
023: import org.sakaiproject.entity.api.Entity;
024: import org.sakaiproject.time.api.Time;
025: import org.w3c.dom.Element;
026:
027: /**
028: * <p>
029: * StorageUser is ...%%% callbacks from the BaseXmlFileStorage and other Storage classes...
030: * </p>
031: */
032: public interface StorageUser {
033: /**
034: * Construct a new continer given just ids.
035: *
036: * @param ref
037: * The container reference.
038: * @return The new containe Resource.
039: */
040: Entity newContainer(String ref);
041:
042: /**
043: * Construct a new container resource, from an XML element.
044: *
045: * @param element
046: * The XML.
047: * @return The new container resource.
048: */
049: Entity newContainer(Element element);
050:
051: /**
052: * Construct a new container resource, as a copy of another
053: *
054: * @param other
055: * The other contianer to copy.
056: * @return The new container resource.
057: */
058: Entity newContainer(Entity other);
059:
060: /**
061: * Construct a new resource given just an id.
062: *
063: * @param container
064: * The Resource that is the container for the new resource (may be null).
065: * @param id
066: * The id for the new object.
067: * @param others
068: * (options) array of objects to load into the Resource's fields.
069: * @return The new resource.
070: */
071: Entity newResource(Entity container, String id, Object[] others);
072:
073: /**
074: * Construct a new resource, from an XML element.
075: *
076: * @param container
077: * The Resource that is the container for the new resource (may be null).
078: * @param element
079: * The XML.
080: * @return The new resource from the XML.
081: */
082: Entity newResource(Entity container, Element element);
083:
084: /**
085: * Construct a new resource from another resource of the same type.
086: *
087: * @param container
088: * The Resource that is the container for the new resource (may be null).
089: * @param other
090: * The other resource.
091: * @return The new resource as a copy of the other.
092: */
093: Entity newResource(Entity container, Entity other);
094:
095: /**
096: * Construct a new continer given just ids.
097: *
098: * @param ref
099: * The container reference.
100: * @return The new containe Resource.
101: */
102: Edit newContainerEdit(String ref);
103:
104: /**
105: * Construct a new container resource, from an XML element.
106: *
107: * @param element
108: * The XML.
109: * @return The new container resource.
110: */
111: Edit newContainerEdit(Element element);
112:
113: /**
114: * Construct a new container resource, as a copy of another
115: *
116: * @param other
117: * The other contianer to copy.
118: * @return The new container resource.
119: */
120: Edit newContainerEdit(Entity other);
121:
122: /**
123: * Construct a new resource given just an id.
124: *
125: * @param container
126: * The Resource that is the container for the new resource (may be null).
127: * @param id
128: * The id for the new object.
129: * @param others
130: * (options) array of objects to load into the Resource's fields.
131: * @return The new resource.
132: */
133: Edit newResourceEdit(Entity container, String id, Object[] others);
134:
135: /**
136: * Construct a new resource, from an XML element.
137: *
138: * @param container
139: * The Resource that is the container for the new resource (may be null).
140: * @param element
141: * The XML.
142: * @return The new resource from the XML.
143: */
144: Edit newResourceEdit(Entity container, Element element);
145:
146: /**
147: * Construct a new resource from another resource of the same type.
148: *
149: * @param container
150: * The Resource that is the container for the new resource (may be null).
151: * @param other
152: * The other resource.
153: * @return The new resource as a copy of the other.
154: */
155: Edit newResourceEdit(Entity container, Entity other);
156:
157: /**
158: * Collect the fields that need to be stored outside the XML (for the resource).
159: *
160: * @return An array of field values to store in the record outside the XML (for the resource).
161: */
162: Object[] storageFields(Entity r);
163:
164: /**
165: * Check if this resource is in draft mode.
166: *
167: * @param r
168: * The resource.
169: * @return true if the resource is in draft mode, false if not.
170: */
171: boolean isDraft(Entity r);
172:
173: /**
174: * Access the resource owner user id.
175: *
176: * @param r
177: * The resource.
178: * @return The resource owner user id.
179: */
180: String getOwnerId(Entity r);
181:
182: /**
183: * Access the resource date.
184: *
185: * @param r
186: * The resource.
187: * @return The resource date.
188: */
189: Time getDate(Entity r);
190: }
|