1 <?xml version="1.0" encoding="UTF-8"?>
3 ====================================================================
4 Licensed to the Apache Software Foundation (ASF) under one or more
5 contributor license agreements. See the NOTICE file distributed with
6 this work for additional information regarding copyright ownership.
7 The ASF licenses this file to You under the Apache License, Version 2.0
8 (the "License"); you may not use this file except in compliance with
9 the License. You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ====================================================================
20 <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN" "../dtd/document-v11.dtd">
23 <title>POIFS Use Cases</title>
25 <person email="mjohnson@apache.org" name="Marc Johnson" id="MJ"/>
29 <section><title>POIFS Use Cases</title>
30 <section><title>Use Case 1: Read existing file system</title>
33 <td><em>Primary Actor:</em></td>
37 <td><em>Scope:</em></td>
41 <td><em>Level:</em></td>
45 <td><em>Stakeholders and Interests:</em></td>
47 POIFS client- wants to read content of file
49 POIFS - understands POIFS file system
53 <td><em>Precondition:</em></td>
57 <td><em>Minimal Guarantee:</em></td>
61 <td><em>Main Success Guarantee:</em></td>
63 1. POIFS client requests POIFS to read a POIFS file
65 <code>InputStream</code>
66 containing POIFS file system in question.<br/>
67 2. POIFS reads from the
68 <code>InputStream</code> in
70 3. POIFS verifies that the first block begins with
71 the well known signature
73 <code>0xE11AB1A1E011CFD0</code>)<br/>
74 4. POIFS reads the Block Allocation Table from the
75 first block and, if necessary, from the XBAT
77 5. POIFS obtains the start block of the Property
78 Table and reads the Property Table (use case 9,
80 6. POIFS reads the individual entries in the Property
82 7. POIFS obtains the start block of the Small Block
83 Allocation Table and reads the Small Block
84 Allocation Table (use case 9, read file)<br/>
85 8. POIFS obtains the start block of the Small Block
86 store from the first entry in the Property Table
87 and reads the Small Block Array (use case 9, read
92 <td><em>Extensions:</em></td>
94 2a. If the last block read is not a 512 byte
96 <code>InputStream</code> is not that of
97 a POIFS file system, and POIFS throws an
98 appropriate exception.
100 3a. If the signature is incorrect, the
101 <code>InputStream</code> is not that of a POIFS
102 file system, and POIFS throws an appropriate
108 <section><title>Use Case 2: Write file system</title>
111 <th>Primary Actor:</th>
112 <th>POIFS client</th>
123 <th>Stakeholders and Interests:</th>
125 POIFS client- wants to write file system out.<br/>
126 POIFS - knows how to write file system out.
130 <th>Precondition:</th>
132 File system has been read (use case 1, read
133 existing file system) and subsequently modified
134 (use case 4, replace file in file system; use case
135 5, delete file from file system; or use case 6,
136 write new file to file system; in any
139 File system has been created (use case 3, create
144 <th>Minimal Guarantee:</th>
148 <th>Main Success Guarantee:</th>
150 1. POIFS client provides an
151 <code>OutputStream</code>
152 to write the file system to.
154 2. POIFS gets the sizes of the Property Table and
155 each file in the file system.<br/>
156 3. If any files in the file system requires storage
157 in a Small Block Array, POIFS creates a Small
158 Block Array of sufficient size to hold all of the
160 4. POIFS calculates the number of big blocks needed
161 to hold all of the large files, the Property
162 Table, and, if necessary, the Small Block Array
163 and the Small Block Allocation Table.<br/>
164 5. POIFS creates a set of big blocks sufficient to
165 store the Block Allocation Table<br/>
166 6. POIFS creates and writes the header block<br/>
167 7. POIFS writes out the XBAT blocks, if needed.<br/>
168 8. POIFS writes out the Small Block Array, if
170 9. POIFS writes out the Small Block Allocation Table,
172 10. POIFS writes out the Property Table<br/>
173 11. POIFS writes out the large files, if needed<br/>
174 12. POIFS closes the <code>OutputStream</code>.
180 6a. Exceptions writing to the
181 <code>OutputStream</code> will be propagated back
184 7a. Exceptions writing to the
185 <code>OutputStream</code> will be propagated back
188 8a. Exceptions writing to the
189 <code>OutputStream</code> will be propagated back
192 9a. Exceptions writing to the
193 <code>OutputStream</code> will be propagated back
196 10a. Exceptions writing to the
197 <code>OutputStream</code> will be propagated back
200 11a. Exceptions writing to the
201 <code>OutputStream</code> will be propagated back
204 12a. Exceptions closing the
205 <code>OutputStream</code> will be propagated back
212 <section><title>Use Case 3: Create new file system</title>
215 <th>Primary Actor:</th>
216 <td>POIFS client</td>
227 <th>Stakeholders and Interests:</th>
229 POIFS client- wants to create a new file
231 POIFS - knows how to create a new file system
235 <th>Precondition:</th>
239 <th>Minimal Guarantee:</th>
243 <th>Main Success Guarantee:</th>
245 POIFS creates an empty Property Table.
254 <section><title>Use Case 4: Replace file in file system</title>
257 <td><em>Primary Actor:</em></td>
258 <td>POIFS client</td>
261 <td><em>Scope:</em></td>
265 <td><em>Level:</em></td>
269 <td><em>Stakeholders and Interests:</em></td>
271 1. POIFS client- wants to replace an existing file in
273 2. POIFS - knows how to manage the file system
277 <td><em>Precondition:</em></td>
281 The file system has been read (use case 1, read
282 existing file system) and a file has been
283 extracted from the file system (use case 7, read
284 existing file from file system)
285 <br/><br/>or<br/><br/>
286 The file system has been created (use case 3,
287 create new file system) and a file has been
288 written to the file system (use case 6, write new
293 <td><em>Minimal Guarantee:</em></td>
297 <td><em>Main Success Guarantee:</em></td>
299 1. POIFS discards storage of the existing file.<br/>
300 2. POIFS updates the existing file's entry in the
302 3. POIFS stores the new file's data
306 <td><em>Extensions:</em></td>
308 1a. POIFS throws an exception if the file does not
314 <section><title>Use Case 5: Delete file from file system</title>
317 <td><em>Primary Actor:</em></td>
318 <td>POIFS client</td>
321 <td><em>Scope:</em></td>
325 <td><em>Level:</em></td>
329 <td><em>Stakeholders and Interests:</em></td>
331 * POIFS client- wants to remove a file from a file
333 * POIFS - knows how to manage the file system
337 <td><em>Precondition:</em></td>
340 The file system has been read (use case 1, read
341 existing file system) and a file has been
342 extracted from the file system (use case 7, read
343 existing file from file system)<br/>
347 The file system has been created (use case 3,
348 create new file system) and a file has been
349 written to the file system (use case 6, write new
354 <td><em>Minimal Guarantee:</em></td>
358 <td><em>Main Success Guarantee:</em></td>
360 1. POIFS discards the specified file's storage.<br/>
361 2. POIFS discards the file's Property Table
366 <td><em>Extensions:</em></td>
368 1a. POIFS throws an exception if the file does not
374 <section><title>Use Case 6: Write new file to file system</title>
377 <td><em>Primary Actor:</em></td>
378 <td>POIFS client</td>
381 <td><em>Scope:</em></td>
385 <td><em>Level:</em></td>
389 <td><em>Stakeholders and Interests:</em></td>
391 * POIFS client- wants to add a new file to the file
393 * POIFS - knows how to manage the file system
397 <td><em>Precondition:</em></td>
398 <td>The specified file does not yet exist in the file
402 <td><em>Minimal Guarantee:</em></td>
406 <td><em>Main Success Guarantee:</em></td>
408 1. The POIFS client provides a file name<br/>
409 2. POIFS creates a new Property Table entry for the
411 3. POIFS provides the POIFS client with an
412 <code>OutputStream</code> to write to.<br/>
413 4. The POIFS client writes data to the provided
414 <code>OutputStream</code>.<br/>
415 5. The POIFS client closes the provided
416 <code>OutputStream</code><br/>
417 6. POIFS updates the Property Table entry with the
422 <td><em>Extensions:</em></td>
424 1a. POIFS throws an exception if a file with the
425 specified name already exists in the file
427 1b. POIFS throws an exception if the file name is
428 too long. The limit on file name length is 31
434 <section><title>Use Case 7: Read existing file from file system</title>
437 <td><em>Primary Actor:</em></td>
438 <td>POIFS client</td>
441 <td><em>Scope:</em></td>
445 <td><em>Level:</em></td>
449 <td><em>Stakeholders and Interests:</em></td>
451 * POIFS client- wants to read a file from the file
453 * POIFS - knows how to manage the file system
457 <td><em>Precondition:</em></td>
459 * The file system has been read (use case 1, read
460 existing file system) or has been created and
461 written to (use case 3, create new file system;
462 use case 6, write new file to file system).<br/>
463 * The specified file exists in the file system.
467 <td><em>Minimal Guarantee:</em></td>
471 <td><em>Main Success Guarantee:</em></td>
473 * The POIFS client provides the name of a file to be read <br/>
474 * POIFS provides an <code>InputStream</code> to read from. <br/>
475 * The POIFS client reads from the <code>InputStream</code>.<br/>
476 * The POIFS client closes the <code>InputStream</code>.
480 <td><em>Extensions:</em></td>
481 <td>1a. POIFS throws an exception if no file with the
482 specified name exists.</td>
486 <section><title>Use Case 8: Read file system directory</title>
489 <td><em>Primary Actor:</em></td>
490 <td>POIFS client</td>
493 <td><em>Scope:</em></td>
497 <td><em>Level:</em></td>
501 <td><em>Stakeholders and Interests:</em></td>
503 * POIFS client- wants to know what files exist in
505 * POIFS - knows how to manage the file system
509 <td><em>Precondition:</em></td>
510 <td>The file system has been read (use case 1, read
511 existing file system) or created (use case 3, create
512 new file system)</td>
515 <td><em>Minimal Guarantee:</em></td>
519 <td><em>Main Success Guarantee:</em></td>
521 1. The POIFS client requests the file system
523 2. POIFS returns an <code>Iterator</code>. The
524 <code>Iterator</code> will not include the root
525 entry in the Property Table, and may be an
526 <code>Iterator</code> over an empty
527 <code>Collection</code>.
531 <td><em>Extensions:</em></td>
536 <section><title>Use Case 9: Read file</title>
539 <td><em>Primary Actor:</em></td>
543 <td><em>Scope:</em></td>
547 <td><em>Level:</em></td>
551 <td><em>Stakeholders and Interests:</em></td>
553 POIFS - POIFS needs to read a file, or something
554 resembling a file (i.e., the Property Table, the
555 Small Block Array, or the Small Block Allocation
560 <td><em>Precondition:</em></td>
564 <td><em>Minimal Guarantee:</em></td>
568 <td><em>Main Success Guarantee:</em></td>
570 1. POIFS begins with a start block, a file size, and
571 a flag indicating whether to use the Big Block
572 Allocation Table or the Small Block Allocation
574 2. POIFS returns an <code>InputStream</code>.<br/>
575 3. Reads from the <code>InputStream</code> are
576 performed by walking the specified Block
577 Allocation Table and reading the blocks
579 4. POIFS closes the <code>InputStream</code> when
580 finished reading the file, or its client wants to
581 close the <code>InputStream</code>.
585 <td><em>Extensions:</em></td>
586 <td>3a. An exception will be thrown if the specified Block
587 Allocation Table is corrupt, as evidenced by an index
588 pointing to a non-existent block, or by a chain
589 extending past the known size of the file.</td>
593 <section><title>Use Case 10: Rename existing file in the file system</title>
596 <td><em>Primary Actor:</em></td>
597 <td>POIFS client</td>
600 <td><em>Scope:</em></td>
604 <td><em>Level:</em></td>
608 <td><em>Stakeholders and Interests:</em></td>
610 * POIFS client- wants to rename an existing file in
611 the file system.<br/>
612 * POIFS - knows how to manage the file system.
616 <td><em>Precondition:</em></td>
618 * The file system is has been read (use case 1, read
619 existing file system) or has been created and
620 written to (use case 3, create new file system;
621 use case 6, write new file to file system.<br/>
622 * The specified file exists in the file system.<br/>
623 * The new name for the file does not duplicate
624 another file in the file system.
628 <td><em>Minimal Guarantee:</em></td>
632 <td><em>Main Success Guarantee:</em></td>
634 1. POIFS updates the Property Table entry for the
635 specified file with its new name.
639 <td><em>Extensions:</em></td>
641 * 1a. If the old file name is not in the file
642 system, POIFS throws an exception.<br/>
643 * 1b. If the new file name already exists in the
644 file system, POIFS throws an exception.<br/>
645 * 1c. If the new file name is too long (the limit is
646 31 characters), POIFS throws an exception.