1 | // $Id: PnfsGetStorageInfoMessage.java,v 1.7 2006-04-11 09:47:53 tigran Exp $ |
2 | package diskCacheV111.vehicles; |
3 | |
4 | import java.util.Set; |
5 | |
6 | import diskCacheV111.util.*; |
7 | import org.dcache.vehicles.FileAttributes; |
8 | import org.dcache.namespace.FileAttribute; |
9 | |
10 | import static org.dcache.namespace.FileAttribute.*; |
11 | |
12 | public class PnfsGetStorageInfoMessage extends PnfsGetFileMetaDataMessage { |
13 | |
14 | private StorageInfo _storageInfo = null ; |
15 | private boolean _followLinks = true; |
16 | |
17 | private static final long serialVersionUID = -2574949600859502380L; |
18 | |
19 | public PnfsGetStorageInfoMessage() |
20 | { |
21 | super(); |
22 | _attributes.add(STORAGEINFO); |
23 | } |
24 | |
25 | public PnfsGetStorageInfoMessage(Set<FileAttribute> attr) |
26 | { |
27 | super(attr); |
28 | _attributes.add(STORAGEINFO); |
29 | } |
30 | |
31 | public PnfsGetStorageInfoMessage(PnfsId pnfsId) |
32 | { |
33 | super(pnfsId); |
34 | _attributes.add(STORAGEINFO); |
35 | } |
36 | |
37 | /* To ensure backwards compatibility with pre 1.9.6 clients, we |
38 | * explicitly add attributes compatible with |
39 | * PnfsGetStorageInfoMessage to the set of requested attributes if |
40 | * the attribute set is null. |
41 | */ |
42 | @Override |
43 | public Set<FileAttribute> getRequestedAttributes() |
44 | { |
45 | Set<FileAttribute> attributes = _attributes; |
46 | if (attributes == null) { |
47 | attributes = super.getRequestedAttributes(); |
48 | attributes.add(STORAGEINFO); |
49 | } |
50 | return attributes; |
51 | } |
52 | |
53 | @Override |
54 | public void setFileAttributes(FileAttributes fileAttributes) |
55 | { |
56 | super.setFileAttributes(fileAttributes); |
57 | |
58 | /* For backwards compatibility with old versions we set this |
59 | * field. We do this even though we don't use the field. |
60 | */ |
61 | if (fileAttributes.isDefined(STORAGEINFO)) { |
62 | _storageInfo = fileAttributes.getStorageInfo(); |
63 | } |
64 | } |
65 | |
66 | public StorageInfo getStorageInfo() |
67 | { |
68 | return |
69 | (_fileAttributes == null || !_fileAttributes.isDefined(STORAGEINFO)) |
70 | ? null |
71 | : _fileAttributes.getStorageInfo(); |
72 | } |
73 | |
74 | public boolean resolve() { return this._followLinks; } |
75 | public void setResolve(boolean followLinks) |
76 | { |
77 | _followLinks = followLinks; |
78 | super.setResolve(followLinks); |
79 | } |
80 | } |