KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > filesys > DiskDeviceContext


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.server.filesys;
18
19 import org.alfresco.filesys.server.core.DeviceContext;
20 import org.alfresco.filesys.server.core.DeviceContextException;
21 import org.alfresco.filesys.smb.server.notify.NotifyChangeHandler;
22 import org.alfresco.filesys.smb.server.notify.NotifyRequest;
23
24 /**
25  * Disk Device Context Class
26  */

27 public class DiskDeviceContext extends DeviceContext
28 {
29
30     // Change notification handler
31

32     private NotifyChangeHandler m_changeHandler;
33
34     // Volume information
35

36     private VolumeInfo m_volumeInfo;
37
38     // Disk sizing information
39

40     private SrvDiskInfo m_diskInfo;
41
42     // Filesystem attributes, required to enable features such as compression and encryption
43

44     private int m_filesysAttribs;
45
46     // Disk device attributes, can be used to make the device appear as a removeable, read-only,
47
// or write-once device for example.
48

49     private int m_deviceAttribs;
50
51     /**
52      * Class constructor
53      */

54     public DiskDeviceContext()
55     {
56         super();
57     }
58
59     /**
60      * Class constructor
61      *
62      * @param devName String
63      */

64     public DiskDeviceContext(String JavaDoc devName)
65     {
66         super(devName);
67     }
68
69     /**
70      * Determine if the volume information is valid
71      *
72      * @return boolean
73      */

74     public final boolean hasVolumeInformation()
75     {
76         return m_volumeInfo != null ? true : false;
77     }
78
79     /**
80      * Return the volume information
81      *
82      * @return VolumeInfo
83      */

84     public final VolumeInfo getVolumeInformation()
85     {
86         return m_volumeInfo;
87     }
88
89     /**
90      * Determine if the disk sizing information is valid
91      *
92      * @return boolean
93      */

94     public final boolean hasDiskInformation()
95     {
96         return m_diskInfo != null ? true : false;
97     }
98
99     /**
100      * Return the disk sizing information
101      *
102      * @return SMBSrvDiskInfo
103      */

104     public final SrvDiskInfo getDiskInformation()
105     {
106         return m_diskInfo;
107     }
108
109     /**
110      * Return the filesystem attributes
111      *
112      * @return int
113      */

114     public final int getFilesystemAttributes()
115     {
116         return m_filesysAttribs;
117     }
118
119     /**
120      * Return the filesystem type, either FileSystem.TypeFAT or FileSystem.TypeNTFS.
121      *
122      * Defaults to FileSystem.FAT but will be overridden if the filesystem driver implements the
123      * NTFSStreamsInterface.
124      *
125      * @return String
126      */

127     public String JavaDoc getFilesystemType()
128     {
129         return FileSystem.TypeFAT;
130     }
131     
132     /**
133      * Return the device attributes
134      *
135      * @return int
136      */

137     public final int getDeviceAttributes()
138     {
139         return m_deviceAttribs;
140     }
141
142     /**
143      * Determine if the filesystem is case sensitive or not
144      *
145      * @return boolean
146      */

147     public final boolean isCaseless()
148     {
149         return (m_filesysAttribs & FileSystem.CasePreservedNames) == 0 ? true : false;
150     }
151
152     /**
153      * Enable/disable the change notification handler for this device
154      *
155      * @param ena boolean
156      */

157     public final void enableChangeHandler(boolean ena)
158     {
159         if (ena == true)
160             m_changeHandler = new NotifyChangeHandler(this);
161         else
162         {
163
164             // Shutdown the change handler, if valid
165

166             if (m_changeHandler != null)
167                 m_changeHandler.shutdownRequest();
168             m_changeHandler = null;
169         }
170     }
171
172     /**
173      * Close the disk device context. Release the file state cache resources.
174      */

175     public void CloseContext()
176     {
177
178         // Call the base class
179

180         super.CloseContext();
181     }
182
183     /**
184      * Determine if the disk context has a change notification handler
185      *
186      * @return boolean
187      */

188     public final boolean hasChangeHandler()
189     {
190         return m_changeHandler != null ? true : false;
191     }
192
193     /**
194      * Return the change notification handler
195      *
196      * @return NotifyChangeHandler
197      */

198     public final NotifyChangeHandler getChangeHandler()
199     {
200         return m_changeHandler;
201     }
202
203     /**
204      * Add a request to the change notification list
205      *
206      * @param req NotifyRequest
207      */

208     public final void addNotifyRequest(NotifyRequest req)
209     {
210         m_changeHandler.addNotifyRequest(req);
211     }
212
213     /**
214      * Remove a request from the notify change request list
215      *
216      * @param req NotifyRequest
217      */

218     public final void removeNotifyRequest(NotifyRequest req)
219     {
220         m_changeHandler.removeNotifyRequest(req);
221     }
222
223     /**
224      * Set the volume information
225      *
226      * @param vol VolumeInfo
227      */

228     public final void setVolumeInformation(VolumeInfo vol)
229     {
230         m_volumeInfo = vol;
231     }
232
233     /**
234      * Set the disk information
235      *
236      * @param disk SMBSrvDiskInfo
237      */

238     public final void setDiskInformation(SrvDiskInfo disk)
239     {
240         m_diskInfo = disk;
241     }
242
243     /**
244      * Set the filesystem attributes
245      *
246      * @param attrib int
247      */

248     public final void setFilesystemAttributes(int attrib)
249     {
250         m_filesysAttribs = attrib;
251     }
252
253     /**
254      * Set the device attributes
255      *
256      * @param attrib int
257      */

258     public final void setDeviceAttributes(int attrib)
259     {
260         m_deviceAttribs = attrib;
261     }
262
263     /**
264      * Context has been initialized and attached to a shared device, do any startup processing in
265      * this method.
266      *
267      * @param share DiskSharedDevice
268      * @exception DeviceContextException
269      */

270     public void startFilesystem(DiskSharedDevice share) throws DeviceContextException
271     {
272     }
273 }
274
Popular Tags