/
SmbResourceLocator.java
194 lines (152 loc) · 5.56 KB
/
SmbResourceLocator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* © 2017 AgNO3 Gmbh & Co. KG
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package jcifs;
import java.net.URL;
/**
* Location information for a SMB resource
*
* @author mbechler
*
*/
public interface SmbResourceLocator {
/**
* Returns the last component of the target URL. This will
* effectively be the name of the file or directory represented by this
* <code>SmbFile</code> or in the case of URLs that only specify a server
* or workgroup, the server or workgroup will be returned. The name of
* the root URL <code>smb://</code> is also <code>smb://</code>. If this
* <tt>SmbFile</tt> refers to a workgroup, server, share, or directory,
* the name will include a trailing slash '/' so that composing new
* <tt>SmbFile</tt>s will maintain the trailing slash requirement.
*
* @return The last component of the URL associated with this SMB
* resource or <code>smb://</code> if the resource is <code>smb://</code>
* itself.
*/
String getName ();
/**
*
* @return dfs referral data
*/
DfsReferralData getDfsReferral ();
/**
* Everything but the last component of the URL representing this SMB
* resource is effectively it's parent. The root URL <code>smb://</code>
* does not have a parent. In this case <code>smb://</code> is returned.
*
* @return The parent directory of this SMB resource or
* <code>smb://</code> if the resource refers to the root of the URL
* hierarchy which incidentally is also <code>smb://</code>.
*/
String getParent ();
/**
* Returns the full uncanonicalized URL of this SMB resource. An
* <code>SmbFile</code> constructed with the result of this method will
* result in an <code>SmbFile</code> that is equal to the original.
*
* @return The uncanonicalized full URL of this SMB resource.
*/
String getPath ();
/**
* Returns the full URL of this SMB resource with '.' and '..' components
* factored out. An <code>SmbFile</code> constructed with the result of
* this method will result in an <code>SmbFile</code> that is equal to
* the original.
*
* @return The canonicalized URL of this SMB resource.
*/
String getCanonicalURL ();
/**
* @return The canonicalized UNC path of this SMB resource (relative to it's share)
*/
String getUNCPath ();
/**
* @return The canonicalized URL path (relative to the server/domain)
*/
String getURLPath ();
/**
* Retrieves the share associated with this SMB resource. In
* the case of <code>smb://</code>, <code>smb://workgroup/</code>,
* and <code>smb://server/</code> URLs which do not specify a share,
* <code>null</code> will be returned.
*
* @return The share component or <code>null</code> if there is no share
*/
String getShare ();
/**
* Retrieve the hostname of the server for this SMB resource. If the resources has been resolved by DFS this will
* return the target name.
*
* @return The server name
*/
String getServerWithDfs ();
/**
* Retrieve the hostname of the server for this SMB resource. If this
* <code>SmbFile</code> references a workgroup, the name of the workgroup
* is returned. If this <code>SmbFile</code> refers to the root of this
* SMB network hierarchy, <code>null</code> is returned.
*
* @return The server or workgroup name or <code>null</code> if this
* <code>SmbFile</code> refers to the root <code>smb://</code> resource.
*/
String getServer ();
/**
* If the path of this <code>SmbFile</code> falls within a DFS volume,
* this method will return the referral path to which it maps. Otherwise
* <code>null</code> is returned.
*
* @return URL to the DFS volume
*/
String getDfsPath ();
/**
* @return the transport port, if specified
*/
int getPort ();
/**
* @return the original URL
*/
URL getURL ();
/**
* @return resolved server address
* @throws CIFSException
*/
Address getAddress () throws CIFSException;
/**
* @return whether this is a IPC connection
*/
boolean isIPC ();
/**
* Returns type of of object this <tt>SmbFile</tt> represents.
*
* @return <tt>TYPE_FILESYSTEM, TYPE_WORKGROUP, TYPE_SERVER,
* TYPE_NAMED_PIPE</tt>, or <tt>TYPE_SHARE</tt> in which case it may be either <tt>TYPE_SHARE</tt>,
* <tt>TYPE_PRINTER</tt> or <tt>TYPE_COMM</tt>.
* @throws CIFSException
*/
int getType () throws CIFSException;
/**
* @return whether this is a workgroup reference
* @throws CIFSException
*/
boolean isWorkgroup () throws CIFSException;
/**
*
* @return whether this is a root resource
*/
boolean isRoot ();
}