KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > fckeditor > FCKEditorTmpFiles


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.fckeditor;
14
15 import info.magnolia.cms.beans.runtime.Document;
16 import info.magnolia.context.Context;
17 import info.magnolia.context.MgnlContext;
18
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22
23 /**
24  * This class handles the uploaded files for the fckeditor. The editor uses the FCKEditoSimpleUploadServlet to upload
25  * the files. The files are stored in the tmp directory until the dialog gets saved. For each file is the Document
26  * object saved in the session.
27  * @author Philipp Bracher
28  * @version $Revision: 6658 $ ($Author: gjoseph $)
29  */

30 public class FCKEditorTmpFiles {
31
32     /**
33      * Used to save the map in the session
34      */

35     private static final String JavaDoc ATTRIBUTE_FCK_TEMPFILES = "info.magnolia.cms.gui.fckeditor.tmpfiles";
36
37     /**
38      * Get a saved document
39      * @param uuid
40      * @return the document
41      */

42     public static Document getDocument(String JavaDoc uuid) {
43         return (Document) getTmpFiles().get(uuid);
44     }
45
46     /**
47      * Add a document to the session
48      * @param doc
49      * @param uuid
50      */

51     public static void addDocument(Document doc, String JavaDoc uuid) {
52         getTmpFiles().put(uuid, doc);
53     }
54
55     /**
56      * Remove a document.
57      * @param uuid
58      */

59     public static void removeDocument(String JavaDoc uuid) {
60
61     }
62
63     /**
64      * Get the map holding the document objects
65      * @return the map
66      */

67     private static Map JavaDoc getTmpFiles() {
68         Map JavaDoc fckTmpFiles = (Map JavaDoc) MgnlContext.getAttribute(ATTRIBUTE_FCK_TEMPFILES, Context.SESSION_SCOPE);
69         if (fckTmpFiles == null) {
70             fckTmpFiles = new HashMap JavaDoc();
71             MgnlContext.setAttribute(ATTRIBUTE_FCK_TEMPFILES, fckTmpFiles, Context.SESSION_SCOPE);
72         }
73         return fckTmpFiles;
74     }
75 }
76
Popular Tags