18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
24 */ |
24 */ |
25 |
25 |
26 package com.oracle.solaris.vp.panel.common.api.file; |
26 package com.oracle.solaris.vp.panel.common.api.file; |
27 |
27 |
28 import java.io.*; |
28 import java.io.*; |
29 import java.util.List; |
29 import java.util.List; |
30 import com.oracle.solaris.rad.ObjectException; |
30 import com.oracle.solaris.rad.client.RadObjectException; |
31 |
31 |
32 @SuppressWarnings({"serial"}) |
32 @SuppressWarnings({"serial"}) |
33 public class RemoteFile extends File { |
33 public class RemoteFile extends File { |
34 // |
34 // |
35 // Instance data |
35 // Instance data |
36 // |
36 // |
37 |
37 |
38 private FileBrowserMXBean browser; |
38 private FileBrowser browser; |
39 private FileSnapshot snapshot; |
39 private FileSnapshot snapshot; |
40 |
40 |
41 // |
41 // |
42 // Constructors |
42 // Constructors |
43 // |
43 // |
44 |
44 |
45 public RemoteFile(FileBrowserMXBean browser, FileSnapshot snapshot) { |
45 public RemoteFile(FileBrowser browser, FileSnapshot snapshot) { |
46 super(snapshot.getPath()); |
46 super(snapshot.getPath()); |
47 this.browser = browser; |
47 this.browser = browser; |
48 this.snapshot = snapshot; |
48 this.snapshot = snapshot; |
49 } |
49 } |
50 |
50 |
134 public RemoteFile getParentFile() { |
134 public RemoteFile getParentFile() { |
135 String parent = getParent(); |
135 String parent = getParent(); |
136 try { |
136 try { |
137 return parent == null ? null : |
137 return parent == null ? null : |
138 new RemoteFile(browser, browser.getFile(parent)); |
138 new RemoteFile(browser, browser.getFile(parent)); |
139 } catch (ObjectException e) { |
139 } catch (RadObjectException e) { |
140 /* Not correct, but our choices are limited */ |
140 /* Not correct, but our choices are limited */ |
141 return null; |
141 return null; |
142 } |
142 } |
143 } |
143 } |
144 |
144 |
191 int i = 0; |
191 int i = 0; |
192 for (FileSnapshot ss : snapshots) |
192 for (FileSnapshot ss : snapshots) |
193 names[i++] = ss.getBaseName(); |
193 names[i++] = ss.getBaseName(); |
194 |
194 |
195 return names; |
195 return names; |
196 } catch (ObjectException e) { |
196 } catch (RadObjectException e) { |
197 return null; |
197 return null; |
198 } |
198 } |
199 } |
199 } |
200 |
200 |
201 @Override |
201 @Override |
202 public RemoteFile[] listFiles() { |
202 public RemoteFile[] listFiles() { |
203 try { |
203 try { |
204 List<FileSnapshot> snapshots = browser.getFiles(getAbsolutePath()); |
204 List<FileSnapshot> snapshots = browser.getFiles(getAbsolutePath()); |
205 return toFiles(snapshots); |
205 return toFiles(snapshots); |
206 } catch (ObjectException e) { |
206 } catch (RadObjectException e) { |
207 return null; |
207 return null; |
208 } |
208 } |
209 } |
209 } |
210 |
210 |
211 @Override |
211 @Override |