Skip to content

Commit fd1334f

Browse files
authored
Merge branch 'master' into 24-create-class-types-for-common-identifiers
2 parents 7dec7f8 + ecb64c1 commit fd1334f

12 files changed

Lines changed: 178 additions & 91 deletions

File tree

‎src/main/java/io/github/hikingc/matrixsdk/api/Event.java‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
/// All operations in this interface are blocking. Implementations must ensure thread safety and
2121
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
2222
///
23+
/// Unless otherwise noted, every method in this interface throws [MatrixIOException] if the request
24+
/// or response payload cannot be processed, and [MatrixNetworkException] if the server's response
25+
/// status is not successful.
26+
///
2327
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#events">Matrix Client-Server API
2428
/// Specification for Events</a>
2529
public interface Event {
@@ -36,6 +40,8 @@ public interface Event {
3640
///
3741
/// @param roomId the room ID to fetch data from.
3842
/// @return a list of room members.
43+
/// @throws MatrixIOException when the payload cannot be processed.
44+
/// @throws MatrixNetworkException when the response status is not successful.
3945
RoomMembers getJoinedMembers(RoomID roomId);
4046

4147
/// Returns a filterable list of members and their current membership state in a room.
@@ -48,13 +54,17 @@ public interface Event {
4854
/// @param notMembership the kind of membership to exclude from the results. Defaults to no
4955
/// filtering if unspecified.
5056
/// @return a list of [ClientEvent]s with the membership information of room members.
57+
/// @throws MatrixIOException when the payload cannot be processed.
58+
/// @throws MatrixNetworkException when the response status is not successful.
5159
List<RoomMemberEvent> getMembers(
5260
RoomID roomId, String at, Membership membership, Membership notMembership);
5361

5462
/// Get the state events for the current state of a room.
5563
///
5664
/// @param roomId the room ID to fetch data from.
57-
/// @return the current state of the room
65+
/// @return the current state of the room.
66+
/// @throws MatrixIOException when the payload cannot be processed.
67+
/// @throws MatrixNetworkException when the response status is not successful.
5868
List<StateEvent<?>> getStateEvents(RoomID roomId);
5969

6070
/// Looks up the contents of a state event in a room. If the user is joined to the room then the
@@ -65,6 +75,8 @@ List<RoomMemberEvent> getMembers(
6575
/// @param eventType the type of state to look up.
6676
/// @param stateKey the room to look up the state in.
6777
/// @return the content of the event, including all additional metadata fields.
78+
/// @throws MatrixIOException when the payload cannot be processed.
79+
/// @throws MatrixNetworkException when the response status is not successful.
6880
@SuppressWarnings("java:S1452")
6981
StateEvent<?> getStateEvent(RoomID roomId, String eventType, String stateKey);
7082

@@ -77,6 +89,7 @@ List<RoomMemberEvent> getMembers(
7789
/// @param dir the [ChronologicalDirection] in which to search
7890
/// @return [Messages] with available data.
7991
/// @throws MatrixIOException when the payload cannot be processed.
92+
/// @throws MatrixNetworkException when the response status is not successful.
8093
/// @throws NullPointerException when the roomId is null.
8194
Messages getMessages(RoomID roomId, ChronologicalDirection dir, QueryParametersMessages params);
8295

@@ -87,6 +100,8 @@ List<RoomMemberEvent> getMembers(
87100
/// @param dir the [ChronologicalDirection] in which to search
88101
/// @param timestamp the timestamp to search from, as given in milliseconds since the Unix epoch.
89102
/// @return [EventMetadata] if an event was found.
103+
/// @throws MatrixIOException when the payload cannot be processed.
104+
/// @throws MatrixNetworkException when the response status is not successful.
90105
EventMetadata getEventClosestToTimestamp(
91106
RoomID roomId, ChronologicalDirection dir, int timestamp);
92107

@@ -95,6 +110,8 @@ EventMetadata getEventClosestToTimestamp(
95110
///
96111
/// @param roomId the room ID to fetch data from.
97112
/// @return [RoomInfo] with current state of the room.
113+
/// @throws MatrixIOException when the payload cannot be processed.
114+
/// @throws MatrixNetworkException when the response status is not successful.
98115
RoomInfo getInitialSync(RoomID roomId);
99116

100117
/// Sends a state event.
@@ -105,6 +122,8 @@ EventMetadata getEventClosestToTimestamp(
105122
/// @return a [String] representing a unique identifier of the event.
106123
/// @throws MatrixIOException when the payload cannot be processed.
107124
/// @throws MatrixNetworkException when the response status is not successful.
125+
/// @throws MatrixIOException when the payload cannot be processed.
126+
/// @throws MatrixNetworkException when the response status is not successful.
108127
String sendStateEvent(RoomID roomId, String stateKey, StateEventContent content);
109128

110129
/// Sends a message event.
@@ -114,6 +133,8 @@ EventMetadata getEventClosestToTimestamp(
114133
/// same access token; it will be used by the server to ensure idempotency of requests.
115134
/// @param content of any type of message event.
116135
/// @return a [String] representing a unique identifier of the event.
136+
/// @throws MatrixIOException when the payload cannot be processed.
137+
/// @throws MatrixNetworkException when the response status is not successful.
117138
String sendMessageEvent(RoomID roomId, String txnId, MessageEventContent content);
118139

119140
/// Strips all information out of an event which isn’t critical to the integrity of the

‎src/main/java/io/github/hikingc/matrixsdk/api/Filter.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
import io.github.hikingc.matrixsdk.api.filters.FilterDefinition;
44
import io.github.hikingc.matrixsdk.api.identifiers.UserID;
5+
import io.github.hikingc.matrixsdk.exceptions.MatrixIOException;
6+
import io.github.hikingc.matrixsdk.exceptions.MatrixNetworkException;
57

68
/// Core interface for executing protocol operations for filtering.
79
///
810
/// All operations in this interface are blocking. Implementations must ensure thread safety and
911
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
1012
///
13+
/// Unless otherwise noted, every method in this interface throws [MatrixIOException] if the request
14+
/// or response payload cannot be processed, and [MatrixNetworkException] if the server's response
15+
/// status is not successful.
16+
///
1117
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#filtering>Matrix Client-Server
1218
/// API Specification for Filters</a>
1319
public interface Filter {
@@ -18,12 +24,16 @@ public interface Filter {
1824
/// @param userId the [UserID] of whoever is uploading the server.
1925
/// @param filter the definition of the filter.
2026
/// @return an ID of the filter definition, usable in supported endpoints.
27+
/// @throws MatrixIOException when the payload cannot be processed.
28+
/// @throws MatrixNetworkException when the response status is not successful.
2129
String publishFilter(UserID userId, FilterDefinition filter);
2230

2331
/// Retrieve a [FilterDefinition] from the homeserver.
2432
///
2533
/// @param userId the [UserID] to download a filter for.
2634
/// @param filterId the filter ID to download.
2735
/// @return a [FilterDefinition] with all uploaded data.
36+
/// @throws MatrixIOException when the payload cannot be processed.
37+
/// @throws MatrixNetworkException when the response status is not successful.
2838
FilterDefinition getFilter(UserID userId, String filterId);
2939
}

‎src/main/java/io/github/hikingc/matrixsdk/api/Room.java‎

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@
1717
/// All operations in this interface are blocking. Implementations must ensure thread safety and
1818
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
1919
///
20+
/// Unless otherwise noted, every method in this interface throws [MatrixIOException] if the request
21+
/// or response payload cannot be processed, and [MatrixNetworkException] if the server's response
22+
/// status is not successful.
23+
///
2024
/// @see <a href="https://spec.matrix.org/v1.19/client-server-api/#rooms">Matrix Client-Server API
2125
/// Specification for Rooms</a>
2226
public interface Room {
2327
/// Creates a room based on the received [InitialRoomConfiguration].
2428
///
2529
/// @param configuration of the room.
2630
/// @return the created room’s ID.
27-
/// @throws MatrixIOException when the payload cannot be processed
28-
/// @throws MatrixNetworkException when the response status is not successful
31+
/// @throws MatrixIOException when the payload cannot be processed.
32+
/// @throws MatrixNetworkException when the response status is not successful.
2933
String create(InitialRoomConfiguration configuration);
3034

3135
/// Requests the server to resolve a room alias if not possible, the server will use the
@@ -34,18 +38,24 @@ public interface Room {
3438
/// @param roomAlias the room alias.
3539
/// @return a [ResolvedAlias] containing the room ids for the requested alias and which servers
3640
/// are aware of it.
41+
/// @throws MatrixIOException when the payload cannot be processed.
42+
/// @throws MatrixNetworkException when the response status is not successful.
3743
ResolvedAlias resolveAlias(RoomAlias roomAlias);
3844

3945
/// Sets a room alias to a room.
4046
///
4147
/// @param roomAlias a [RoomAlias].
4248
/// @param roomId the [RoomID] to receive the alias.
49+
/// @throws MatrixIOException when the payload cannot be processed.
50+
/// @throws MatrixNetworkException when the response status is not successful.
4351
void setAlias(RoomAlias roomAlias, RoomID roomId);
4452

4553
/// Requests the server to remove a mapping of a room alias to a room id. On success, servers
4654
/// might modify `m.room.canonical_alias`
4755
///
4856
/// @param roomAlias the [RoomAlias] to remove.
57+
/// @throws MatrixIOException when the payload cannot be processed.
58+
/// @throws MatrixNetworkException when the response status is not successful.
4959
void deleteAlias(RoomAlias roomAlias);
5060

5161
/// Requests a list of aliases maintained by the local server for the given room, requires to be
@@ -56,12 +66,16 @@ public interface Room {
5666
///
5767
/// @param roomId the [RoomID] to find local aliases of.
5868
/// @return a [List] of Room aliases.
69+
/// @throws MatrixIOException when the payload cannot be processed.
70+
/// @throws MatrixNetworkException when the response status is not successful.
5971
List<String> getAliasesOfARoom(RoomID roomId);
6072

6173
/// Requests the server to retrieve a list of the user's current rooms (in simple terms whoever
6274
/// calls this method).
6375
///
6476
/// @return a [List] of the rooms.
77+
/// @throws MatrixIOException when the payload cannot be processed.
78+
/// @throws MatrixNetworkException when the response status is not successful.
6579
List<String> getJoinedRooms();
6680

6781
/// Send an invitation to a user to participate in a room, this endpoint requires the caller to be
@@ -80,7 +94,10 @@ public interface Room {
8094
/// @param request a [JoinRoomRequest] where additional information can be passed.
8195
/// @param via the servers to attempt to join the room through. One of the servers must be
8296
/// participating in the room.
83-
/// @return the room ID
97+
/// @return the room ID.
98+
/// @throws MatrixIOException when the payload cannot be processed.
99+
/// @throws MatrixNetworkException when the response status is not successful.
100+
/// @throws IllegalArgumentException when using an incorrect [Validator].
84101
String joinByRoomIdOrAliasIfAllowed(
85102
Validator roomIdOrAlias, JoinRoomRequest request, List<String> via);
86103

@@ -90,7 +107,9 @@ String joinByRoomIdOrAliasIfAllowed(
90107
/// @param request a [JoinRoomRequest] where additional information can be passed.
91108
/// @param via the servers to attempt to join the room through. One of the servers must be
92109
/// participating in the room.
93-
/// @return the room ID
110+
/// @return the room ID.
111+
/// @throws MatrixIOException when the payload cannot be processed.
112+
/// @throws MatrixNetworkException when the response status is not successful.
94113
String joinByRoomIdIfAllowed(RoomID roomId, JoinRoomRequest request, List<String> via);
95114

96115
/// Knock on a room to ask for permission to join. Acceptance of this request happens out of band.
@@ -100,6 +119,8 @@ String joinByRoomIdOrAliasIfAllowed(
100119
/// @param via the servers to attempt to join the room through. One of the servers must be
101120
/// participating in the room.
102121
/// @return the room ID of the knocked room.
122+
/// @throws MatrixIOException when the payload cannot be processed.
123+
/// @throws MatrixNetworkException when the response status is not successful.
103124
String knockOn(Validator roomIdOrAlias, String reason, List<String> via);
104125

105126
/// Sends a request to leave the room, upon success, you will forget all messages from this room.
@@ -171,8 +192,7 @@ String joinByRoomIdOrAliasIfAllowed(
171192
/// @param since a pagination token from a previous request, allowing you to get the next or
172193
/// previous batch of rooms. The direction of pagination is specified by which token is
173194
/// supplied.
174-
/// @return a [PublicRoomDirectory] containing [io.github.hikingc.matrixsdk.api.rooms.models.PublishedRoomsChunk] records of the published
175-
/// rooms on the server.
195+
/// @return a [PublicRoomDirectory] containing records of the published rooms on the server.
176196
/// @throws MatrixIOException when the payload cannot be processed.
177197
/// @throws NullPointerException when the roomId is null.
178198
/// @see #getPublishedRoomDirectory(PublicRoomRequest)
@@ -182,18 +202,21 @@ String joinByRoomIdOrAliasIfAllowed(
182202
/// Lists a server’s published room directory.
183203
///
184204
/// @param request a [PublicRoomRequest] with additional filters for the request.
185-
/// @return a [PublicRoomDirectory] containing [io.github.hikingc.matrixsdk.api.rooms.models.PublishedRoomsChunk] records of the published
186-
/// rooms on the server.
205+
/// @return a [PublicRoomDirectory] containing records of the published rooms on the server.
206+
/// @throws MatrixIOException when the payload cannot be processed.
207+
/// @throws MatrixNetworkException when the response status is not successful.
187208
PublicRoomDirectory getPublishedRoomDirectory(PublicRoomRequest request);
188209

189210
/// Retrieves a summary for a room. The response data might yield outdated, partial or even with
190211
/// no data.
191212
///
192-
/// @param roomIdOrAlias a [RoomID] or [RoomAlias] of the room to target
213+
/// @param roomIdOrAlias a [RoomID] or [RoomAlias] of the room to target.
193214
/// @param via the servers to attempt to request the summary from when the local server cannot
194-
/// generate it
215+
/// generate it.
195216
/// @return a [RoomSummary] containing all the information about the room.
196217
/// @throws MatrixIOException when the payload cannot be processed.
197218
/// @throws NullPointerException when the roomId is null.
219+
/// @throws MatrixIOException when the payload cannot be processed.
220+
/// @throws MatrixNetworkException when the response status is not successful.
198221
RoomSummary getRoomSummary(Validator roomIdOrAlias, List<String> via);
199222
}

‎src/main/java/io/github/hikingc/matrixsdk/api/UserData.java‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
import io.github.hikingc.matrixsdk.api.identifiers.UserID;
44
import io.github.hikingc.matrixsdk.api.userdata.UserProfile;
55
import io.github.hikingc.matrixsdk.api.userdata.UsersFound;
6+
import io.github.hikingc.matrixsdk.exceptions.MatrixIOException;
7+
import io.github.hikingc.matrixsdk.exceptions.MatrixNetworkException;
68

79
/// Core interface for executing protocol operations against User data.
810
///
911
/// All operations in this interface are blocking. Implementations must ensure thread safety and
1012
/// avoid synchronization blocks that cause carrier thread pinning during network I/O.
1113
///
14+
/// Unless otherwise noted, every method in this interface throws [MatrixIOException] if the request
15+
/// or response payload cannot be processed, and [MatrixNetworkException] if the server's response
16+
/// status is not successful.
17+
///
1218
/// @see <a href="https://spec.matrix.org/v1.18/client-server-api/#user-data">Matrix Client-Server
1319
/// API Specification for User Data</a>
1420
public interface UserData {
@@ -22,32 +28,42 @@ public interface UserData {
2228
/// @param limit the maximum number of results.
2329
/// @param searchTerm the term to search for.
2430
/// @return all the [UsersFound] by the server.
31+
/// @throws MatrixIOException when the payload cannot be processed.
32+
/// @throws MatrixNetworkException when the response status is not successful.
2533
UsersFound searchUsersByTerm(Integer limit, String searchTerm);
2634

2735
/// Get the profile of a user
2836
///
29-
/// @param userId the [UserID] to profile.
30-
/// @return the corresponding [UserProfile].
37+
/// @param userId the [UserID] to target.
38+
/// @return its [UserProfile].
39+
/// @throws MatrixIOException when the payload cannot be processed.
40+
/// @throws MatrixNetworkException when the response status is not successful.
3141
UserProfile getUserProfile(UserID userId);
3242

3343
/// Get the value of a profile field for a user
3444
///
35-
/// @param userId the [UserID] to profile.
36-
/// @param keyName a property field
37-
/// @return the value of the key property.
45+
/// @param userId the [UserID] to target.
46+
/// @param keyName the key name.
47+
/// @return the corresponding value of the pair.
48+
/// @throws MatrixIOException when the payload cannot be processed.
49+
/// @throws MatrixNetworkException when the response status is not successful.
3850
String getUserProfileByProperty(
3951
UserID userId, String keyName); // only 1 property allowed so no Map
4052

4153
/// Set or update a profile field for a user.
4254
///
43-
/// @param userId the [UserID] that'll receive the K-V.
44-
/// @param keyName the key to insert in the profile.
45-
/// @param valueName the value for the key.
55+
/// @param userId the [UserID] to target.
56+
/// @param keyName the key name.
57+
/// @param valueName the value name.
58+
/// @throws MatrixIOException when the payload cannot be processed.
59+
/// @throws MatrixNetworkException when the response status is not successful.
4660
void setUserProfileProperty(UserID userId, String keyName, String valueName);
4761

4862
/// Remove a specific field from a user’s profile.
4963
///
50-
/// @param userId the [UserID] that'll have his K-V deleted.
51-
/// @param keyName the key to be deleted.
64+
/// @param userId the [UserID] that'll have a key-value pair removed from its profile.
65+
/// @param keyName the key name.
66+
/// @throws MatrixIOException when the payload cannot be processed.
67+
/// @throws MatrixNetworkException when the response status is not successful.
5268
void deleteUserProfileProperty(UserID userId, String keyName);
5369
}

‎src/main/java/io/github/hikingc/matrixsdk/exceptions/MatrixIOException.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.hikingc.matrixsdk.exceptions;
22

33
/// Thrown to indicate that the code has attempted to process an I/O event to which it has failed.
4-
public class MatrixIOException extends RuntimeException {
4+
public class MatrixIOException extends MatrixException {
55
/// Constructs a [MatrixIOException] with a message.
66
///
77
/// @param message The detail message. The detail message is saved for later retrieval by the

‎src/main/java/io/github/hikingc/matrixsdk/exceptions/MatrixNetworkException.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.hikingc.matrixsdk.exceptions;
22

33
/// Thrown to indicate that the code has not received a successful HTTP status code.
4-
public class MatrixNetworkException extends RuntimeException {
4+
public class MatrixNetworkException extends MatrixException {
55
/// Constructs a [MatrixNetworkException] with a message.
66
///
77
/// @param message The detail message. The detail message is saved for later retrieval by the

0 commit comments

Comments
 (0)