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.remotefs.bridge.spi; |
43 |
|
44 |
import java.net.URL; |
45 |
import java.util.List; |
46 |
import org.netbeans.modules.masterfs.providers.ProvidedExtensions; |
47 |
import org.openide.filesystems.FileObject; |
48 |
|
49 |
/** |
50 |
* Extension of {@link ProvidedExtensions} to process remote file operations. |
51 |
* |
52 |
* The interface is intended to be implemented in remote file system and VCS |
53 |
* when modules extend class ProvidedExtensions. |
54 |
* |
55 |
* @author Alexander Simon |
56 |
*/ |
57 |
public interface ProvidedExtensions2 { |
58 |
/** |
59 |
* Return instance of {@link ProvidedExtensions.IOHandler} |
60 |
* that is responsible for copying the file or null. |
61 |
* |
62 |
* Just the first non null instance of <code>IOHandler</code> is used by |
63 |
* <code>RemoteFileSystem</code> |
64 |
* |
65 |
* @param from file to be copied |
66 |
* @param to target to copy this file to |
67 |
* @return instance of {@link ProvidedExtensions.IOHandler} |
68 |
* that is responsible for copying the file or null |
69 |
*/ |
70 |
ProvidedExtensions.IOHandler getCopyHandler(URL from, URL to); |
71 |
|
72 |
/** |
73 |
* Return instance of {@link ProvidedExtensions.IOHandler} |
74 |
* that is responsible for moving the file or null. |
75 |
* |
76 |
* Just the first non null instance of <code>IOHandler</code> is used by |
77 |
* <code>RemoteFileSystem</code> |
78 |
* |
79 |
* @param from file to be moved |
80 |
* @param to target to move this file to |
81 |
* @return instance of {@link ProvidedExtensions.IOHandler} |
82 |
* that is responsible for moving the file or null |
83 |
*/ |
84 |
ProvidedExtensions.IOHandler getMoveHandler(URL from, URL to); |
85 |
|
86 |
/* |
87 |
* Return instance of {@link ProvidedExtensions.IOHandler} |
88 |
* that is responsible for renaming the file or null. |
89 |
* |
90 |
* Just the first non null instance of <code>IOHandler</code> is used by |
91 |
* <code>RemoteFileSystem</code> |
92 |
* |
93 |
* @param from file to be renamed |
94 |
* @param newName new name of file |
95 |
* @return instance of {@link ProvidedExtensions.IOHandler} |
96 |
* that is responsible for renaming the file or null |
97 |
*/ |
98 |
ProvidedExtensions.IOHandler getRenameHandler(URL from, String newName); |
99 |
|
100 |
/* |
101 |
* Return instance of {@link ProvidedExtensions.DeleteHandler} |
102 |
* that is responsible for deleting the file or null. |
103 |
* |
104 |
* Just the first non null instance of <code>DeleteHandler</code> is used by |
105 |
* <code>RemoteFileSystem</code> |
106 |
* |
107 |
* @param f file or folder to be deleted |
108 |
* @return instance of {@link ProvidedExtensions2.DeleteHandler2} |
109 |
* that is responsible for deleting the file or null |
110 |
*/ |
111 |
ProvidedExtensions2.DeleteHandler2 getDeleteHandler(URL f); |
112 |
|
113 |
public interface DeleteHandler2 { |
114 |
/** |
115 |
* Deletes the file or directory denoted by this abstract pathname. If |
116 |
* this pathname denotes a directory, then the directory must be empty in |
117 |
* order to be deleted. |
118 |
* |
119 |
* @return <code>true</code> if and only if the file or directory is |
120 |
* successfully deleted; <code>false</code> otherwise |
121 |
*/ |
122 |
boolean delete(URL file); |
123 |
} |
124 |
|
125 |
/** |
126 |
* Called by <code>RemoteFileSystem</code> before <code>FileObject</code> |
127 |
* is copied |
128 |
* @param from FileObject to be moved |
129 |
* @param to URL target to move this file to |
130 |
*/ |
131 |
void beforeCopy(FileObject from, URL to); |
132 |
|
133 |
/** |
134 |
* Called by <code>RemoteFileSystem</code> after <code>FileObject</code> |
135 |
* was successfully copied |
136 |
* @param from FileObject to be moved |
137 |
* @param to URL target to move this file to |
138 |
*/ |
139 |
void copySuccess(FileObject from, URL to); |
140 |
|
141 |
/** |
142 |
* Called by <code>RemoteFileSystem</code> after a <code>FileObject</code> |
143 |
* copy failed |
144 |
* @param from FileObject to be moved |
145 |
* @param to URL target to move this file to |
146 |
*/ |
147 |
void copyFailure(FileObject from, URL to); |
148 |
|
149 |
/** |
150 |
* Called by <code>RemoteFileSystem</code> before <code>FileObject</code> |
151 |
* is moved |
152 |
* @param from FileObject to be moved |
153 |
* @param to URL target to move this file to |
154 |
*/ |
155 |
void beforeMove(FileObject from, URL to); |
156 |
|
157 |
/** |
158 |
* Called by <code>RemoteFileSystem</code> after <code>FileObject</code> |
159 |
* was successfully |
160 |
* @param from FileObject to be moved |
161 |
* @param to URL target to move this file to |
162 |
*/ |
163 |
void moveSuccess(FileObject from, URL to); |
164 |
|
165 |
/** |
166 |
* Called by <code>RemoteFileSystem</code> after a <code>FileObject</code> |
167 |
* move failed |
168 |
* @param from FileObject to be moved |
169 |
* @param to URL target to move this file to |
170 |
*/ |
171 |
void moveFailure(FileObject from, URL to); |
172 |
|
173 |
/** |
174 |
* Called by <code>RemoteFileSystem</code> when <code>FileObject</code> is queried for writability with the |
175 |
* canWrite() method. |
176 |
* |
177 |
* @param f a URL to query |
178 |
* @return true if the file can be written to, deleted or moved, false otherwise |
179 |
*/ |
180 |
boolean canWrite(URL f); |
181 |
|
182 |
/** |
183 |
* Called by {@code RemoteFileSystem} when {@code FileObject} is |
184 |
* queried for attribute and attribute's name starts with {@code ProvidedExtensions} |
185 |
* prefix. |
186 |
* @param attrName name of attribute |
187 |
* @return value of attribute |
188 |
*/ |
189 |
Object getAttribute(URL file, String attrName); |
190 |
|
191 |
/** Allows versioning system to exclude some children from recursive |
192 |
* listening check. Also notifies the versioning whenever a refresh |
193 |
* is required and allows the versiniong to provide special timestamp |
194 |
* for a directory. |
195 |
* <p> |
196 |
* Default implementation of this method returns -1. |
197 |
* |
198 |
* @param dir the directory to check timestamp for |
199 |
* @param lastTimeStamp the previously known timestamp or -1 |
200 |
* @param children add subfiles that shall be interated into this array |
201 |
* @return the timestamp that shall represent this directory, it will |
202 |
* be compared with timestamps of all children and the newest |
203 |
* one will be kept and next time passed as lastTimeStamp. Return |
204 |
* 0 if the directory does not have any special timestamp. Return |
205 |
* -1 if you are not providing any special implementation |
206 |
*/ |
207 |
long refreshRecursively(URL dir, long lastTimeStamp, List<URL> children); |
208 |
} |