Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2011 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* If you wish your version of this file to be governed by only the CDDL |
28 |
* or only the GPL Version 2, indicate your decision by adding |
29 |
* "[Contributor] elects to include this software in this distribution |
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
31 |
* single choice of license, a recipient has the option to distribute |
32 |
* your version of this file under either the CDDL, the GPL Version 2 or |
33 |
* to extend the choice of license to its licensees as provided above. |
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
35 |
* Version 2 license, then the option applies only if the new code is |
36 |
* made subject to such option by the copyright holder. |
37 |
* |
38 |
* Contributor(s): |
39 |
* |
40 |
* Portions Copyrighted 2011 Sun Microsystems, Inc. |
41 |
*/ |
42 |
package org.netbeans.modules.fsbridge.spi; |
43 |
|
44 |
import java.io.IOException; |
45 |
import java.util.List; |
46 |
import org.openide.filesystems.FileObject; |
47 |
|
48 |
/** |
49 |
* Extension of {@link org.netbeans.modules.masterfs.providers.ProvidedExtensions} to process remote file operations. |
50 |
* |
51 |
* @author Alexander Simon |
52 |
*/ |
53 |
public interface FileProxyOperationsInterceptor { |
54 |
|
55 |
public interface FileProxyIOHandler { |
56 |
/** |
57 |
* @throws java.io.IOException if handled operation isn't successful |
58 |
*/ |
59 |
void handle() throws IOException; |
60 |
} |
61 |
|
62 |
public interface FileProxyDeleteHandler { |
63 |
/** |
64 |
* Deletes the file or directory denoted by this abstract pathname. If |
65 |
* this pathname denotes a directory, then the directory must be empty in |
66 |
* order to be deleted. |
67 |
* |
68 |
* @return <code>true</code> if and only if the file or directory is |
69 |
* successfully deleted; <code>false</code> otherwise |
70 |
*/ |
71 |
boolean delete(FileProxy file); |
72 |
} |
73 |
|
74 |
|
75 |
/** |
76 |
* Return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
77 |
* that is responsible for copying the file or null. |
78 |
* |
79 |
* Just the first non null instance of <code>FileProxyIOHandler</code> is used by |
80 |
* <code>RemoteFileSystem</code> |
81 |
* |
82 |
* @param from file to be copied |
83 |
* @param to target to copy this file to |
84 |
* @return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
85 |
* that is responsible for copying the file or null |
86 |
*/ |
87 |
FileProxyOperationsInterceptor.FileProxyIOHandler getCopyHandler(FileProxy from, FileProxy to); |
88 |
|
89 |
/** |
90 |
* Return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
91 |
* that is responsible for moving the file or null. |
92 |
* |
93 |
* Just the first non null instance of <code>FileProxyIOHandler</code> is used by |
94 |
* <code>RemoteFileSystem</code> |
95 |
* |
96 |
* @param from file to be moved |
97 |
* @param to target to move this file to |
98 |
* @return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
99 |
* that is responsible for moving the file or null |
100 |
*/ |
101 |
FileProxyOperationsInterceptor.FileProxyIOHandler getMoveHandler(FileProxy from, FileProxy to); |
102 |
|
103 |
/* |
104 |
* Return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
105 |
* that is responsible for renaming the file or null. |
106 |
* |
107 |
* Just the first non null instance of <code>FileProxyIOHandler</code> is used by |
108 |
* <code>RemoteFileSystem</code> |
109 |
* |
110 |
* @param from file to be renamed |
111 |
* @param newName new name of file |
112 |
* @return instance of {@link FileProxyOperationsInterceptor.FileProxyIOHandler} |
113 |
* that is responsible for renaming the file or null |
114 |
*/ |
115 |
FileProxyOperationsInterceptor.FileProxyIOHandler getRenameHandler(FileProxy from, String newName); |
116 |
|
117 |
/* |
118 |
* Return instance of {@link FileProxyOperationsInterceptor.FileProxyDeleteHandler} |
119 |
* that is responsible for deleting the file or null. |
120 |
* |
121 |
* Just the first non null instance of <code>FileProxyDeleteHandler</code> is used by |
122 |
* <code>RemoteFileSystem</code> |
123 |
* |
124 |
* @param f file or folder to be deleted |
125 |
* @return instance of {@link FileProxyOperationsInterceptor.FileProxyDeleteHandler} |
126 |
* that is responsible for deleting the file or null |
127 |
*/ |
128 |
FileProxyOperationsInterceptor.FileProxyDeleteHandler getDeleteHandler(FileProxy f); |
129 |
|
130 |
/** |
131 |
* Called by <code>RemoteFileSystem</code> before <code>FileObject</code> |
132 |
* is copied |
133 |
* @param from FileObject to be moved |
134 |
* @param to FileProxy target to move this file to |
135 |
*/ |
136 |
void beforeCopy(FileObject from, FileProxy to); |
137 |
|
138 |
/** |
139 |
* Called by <code>RemoteFileSystem</code> after <code>FileObject</code> |
140 |
* was successfully copied |
141 |
* @param from FileObject to be moved |
142 |
* @param to FileProxy target to move this file to |
143 |
*/ |
144 |
void copySuccess(FileObject from, FileProxy to); |
145 |
|
146 |
/** |
147 |
* Called by <code>RemoteFileSystem</code> after a <code>FileObject</code> |
148 |
* copy failed |
149 |
* @param from FileObject to be moved |
150 |
* @param to FileProxy target to move this file to |
151 |
*/ |
152 |
void copyFailure(FileObject from, FileProxy to); |
153 |
|
154 |
/** |
155 |
* Called by <code>RemoteFileSystem</code> before <code>FileObject</code> |
156 |
* is moved |
157 |
* @param from FileObject to be moved |
158 |
* @param to FileProxy target to move this file to |
159 |
*/ |
160 |
void beforeMove(FileObject from, FileProxy to); |
161 |
|
162 |
/** |
163 |
* Called by <code>RemoteFileSystem</code> after <code>FileObject</code> |
164 |
* was successfully |
165 |
* @param from FileObject to be moved |
166 |
* @param to FileProxy target to move this file to |
167 |
*/ |
168 |
void moveSuccess(FileObject from, FileProxy to); |
169 |
|
170 |
/** |
171 |
* Called by <code>RemoteFileSystem</code> after a <code>FileObject</code> |
172 |
* move failed |
173 |
* @param from FileObject to be moved |
174 |
* @param to FileProxy target to move this file to |
175 |
*/ |
176 |
void moveFailure(FileObject from, FileProxy to); |
177 |
|
178 |
/** |
179 |
* Called by <code>RemoteFileSystem</code> when <code>FileObject</code> is queried for writability with the |
180 |
* canWrite() method. |
181 |
* |
182 |
* @param f a FileProxy to query |
183 |
* @return true if the file can be written to, deleted or moved, false otherwise |
184 |
*/ |
185 |
boolean canWrite(FileProxy f); |
186 |
|
187 |
/** |
188 |
* Called by {@code RemoteFileSystem} when {@code FileObject} is |
189 |
* queried for attribute and attribute's name starts with {@code ProvidedExtensions} |
190 |
* prefix. |
191 |
* @param attrName name of attribute |
192 |
* @return value of attribute |
193 |
*/ |
194 |
Object getAttribute(FileProxy file, String attrName); |
195 |
|
196 |
/** Allows versioning system to exclude some children from recursive |
197 |
* listening check. Also notifies the versioning whenever a refresh |
198 |
* is required and allows the versiniong to provide special timestamp |
199 |
* for a directory. |
200 |
* <p> |
201 |
* Default implementation of this method returns -1. |
202 |
* |
203 |
* @param dir the directory to check timestamp for |
204 |
* @param lastTimeStamp the previously known timestamp or -1 |
205 |
* @param children add subfiles that shall be iterated into this array |
206 |
* @return the timestamp that shall represent this directory, it will |
207 |
* be compared with timestamps of all children and the newest |
208 |
* one will be kept and next time passed as lastTimeStamp. Return |
209 |
* 0 if the directory does not have any special timestamp. Return |
210 |
* -1 if you are not providing any special implementation |
211 |
*/ |
212 |
long refreshRecursively(FileProxy dir, long lastTimeStamp, List<? super FileProxy> children); |
213 |
} |