Skip to content

Commit 2e229a1

Browse files
committed
Added the client API interfaces, and JSON implementation
1 parent 42fab27 commit 2e229a1

28 files changed

Lines changed: 2454 additions & 0 deletions
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2023 GK Spencer
3+
*
4+
* JFileServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* JFileServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with JFileServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.filesys.server.filesys.clientapi;
19+
20+
/**
21+
* Client API Request Id Enum
22+
*
23+
* <p>List of basic requests that a client API may implement. The client application will probe the filesystem
24+
* to see what requests the implementation supports</p>
25+
*
26+
* @author gkspencer
27+
*/
28+
public enum ApiRequest {
29+
GetApiInfo, // get API version and supported requests
30+
CheckOutFile, // check file(s) out
31+
CheckInFile, // check file(s) in
32+
CancelCheckOut, // cancel check out of file(s)
33+
GetUrlForPath, // return a URL for the specified path
34+
GetPathStatus, // return status for each path for a particular check type
35+
36+
Error // error type for response only
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2023 GK Spencer
3+
*
4+
* JFileServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* JFileServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with JFileServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.filesys.server.filesys.clientapi;
19+
20+
/**
21+
* Client API Response Id Enum
22+
*
23+
* <p>List of responses that a client API may return.</p>
24+
*
25+
* @author gkspencer
26+
*/
27+
public enum ApiResponse {
28+
GetApiInfo, // return server API version and supported requests
29+
CheckOutFile, // checked a file out
30+
CheckInFile, // checked a file in
31+
GetUrlForPath, // return a URL for the specified path
32+
GetPathStatus, // return path status info
33+
PathList, // success response with a list of relative paths
34+
35+
Error, // error message
36+
Success // when no values need to be returned
37+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2023 GK Spencer
3+
*
4+
* JFileServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* JFileServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with JFileServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.filesys.server.filesys.clientapi;
19+
20+
import org.filesys.server.SrvSession;
21+
import org.filesys.server.filesys.TreeConnection;
22+
23+
/**
24+
* Client API Interface
25+
*
26+
* <p>Optional interface that a DiskInterface driver can implement to provide a client callable API where the
27+
* requests/responses are tunnelled over an existing protocol connection.
28+
*
29+
* @author gkspencer
30+
*/
31+
public interface ClientAPI {
32+
33+
/**
34+
* Return the client API implementation associated with this virtual filesystem
35+
*
36+
* @param sess SrvSession
37+
* @param tree TreeConnection
38+
* @return ClientAPIInterface
39+
*/
40+
public ClientAPIInterface getClientAPI(SrvSession<?> sess, TreeConnection tree);
41+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (C) 2023 GK Spencer
3+
*
4+
* JFileServer is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* JFileServer is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with JFileServer. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package org.filesys.server.filesys.clientapi;
19+
20+
import org.filesys.server.SrvSession;
21+
import org.filesys.server.filesys.FileOpenParams;
22+
import org.filesys.server.filesys.NetworkFile;
23+
import org.filesys.server.filesys.TreeConnection;
24+
25+
/**
26+
* Client API Interface
27+
*
28+
* <p>Provides an optional interface that a filesystem can implement in order to handle requests from
29+
* a client side application</p>
30+
*
31+
* @author gkspencer
32+
*/
33+
public interface ClientAPIInterface {
34+
35+
/**
36+
* Return the path of the special file that is used to send the request to the API and receives the
37+
* response data
38+
*
39+
* @return String
40+
*/
41+
public String getClientAPIPath();
42+
43+
/**
44+
* Open a network file that is used to send requests to the API from a client session, and receives the response
45+
* via the file.
46+
*
47+
* @param sess Server session
48+
* @param tree Tree connection
49+
* @param params File open parameters
50+
* @return ClientAPINetworkFile
51+
* @throws java.io.IOException If an error occurs.
52+
*/
53+
public ClientAPINetworkFile openClientAPIFile(SrvSession<?> sess, TreeConnection tree, FileOpenParams params)
54+
throws java.io.IOException;
55+
56+
/**
57+
* Process a client API request
58+
*
59+
* @param netFile ClientAPINetworkFile
60+
* @throws java.io.IOException If an error occurs
61+
*/
62+
public void processRequest( ClientAPINetworkFile netFile)
63+
throws java.io.IOException;
64+
}

0 commit comments

Comments
 (0)