modified updateDevice call · stacksync/commons@835acc5 · GitHub
Skip to content

Commit 835acc5

Browse files
author
Adrian Moreno
committed
modified updateDevice call
1 parent 6b42e5d commit 835acc5

10 files changed

Lines changed: 222 additions & 112 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.stacksync.commons.exceptions;
2+
3+
public class DeviceNotUpdatedException extends Exception {
4+
5+
private static final long serialVersionUID = -4863718030211921279L;
6+
7+
public DeviceNotUpdatedException() {
8+
super();
9+
}
10+
11+
public DeviceNotUpdatedException(String message) {
12+
super(message);
13+
}
14+
15+
public DeviceNotUpdatedException(String message, Throwable cause) {
16+
super(message, cause);
17+
}
18+
19+
public DeviceNotUpdatedException(Throwable cause) {
20+
super(cause);
21+
}
22+
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.stacksync.commons.exceptions;
2+
3+
public class DeviceNotValidException extends Exception {
4+
5+
private static final long serialVersionUID = -5029097263469786400L;
6+
7+
public DeviceNotValidException() {
8+
super();
9+
}
10+
11+
public DeviceNotValidException(String message) {
12+
super(message);
13+
}
14+
15+
public DeviceNotValidException(String message, Throwable cause) {
16+
super(message, cause);
17+
}
18+
19+
public DeviceNotValidException(Throwable cause) {
20+
super(cause);
21+
}
22+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.stacksync.commons.exceptions;
2+
3+
public class UserNotFoundException extends Exception {
4+
5+
private static final long serialVersionUID = 3524957553230371283L;
6+
7+
public UserNotFoundException() {
8+
super();
9+
}
10+
11+
public UserNotFoundException(String message) {
12+
super(message);
13+
}
14+
15+
public UserNotFoundException(String message, Throwable cause) {
16+
super(message, cause);
17+
}
18+
19+
public UserNotFoundException(Throwable cause) {
20+
super(cause);
21+
}
22+
23+
}

src/main/java/com/stacksync/commons/models/Device.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.stacksync.commons.models;
22

3-
import java.io.Serializable;
43
import java.lang.reflect.Field;
54
import java.util.Date;
65

7-
public class Device implements Serializable{
8-
9-
private static final long serialVersionUID = -2932481953197148130L;
6+
public class Device {
107

118
private Long id;
129
private String name;

src/main/java/com/stacksync/commons/models/DeviceInfo.java

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/main/java/com/stacksync/commons/omq/ISyncService.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import java.util.List;
44

55
import com.stacksync.commons.models.Device;
6-
import com.stacksync.commons.models.DeviceInfo;
76
import com.stacksync.commons.models.ItemMetadata;
87
import com.stacksync.commons.models.User;
98
import com.stacksync.commons.models.Workspace;
9+
import com.stacksync.commons.requests.UpdateDeviceRequest;
10+
import com.stacksync.commons.exceptions.DeviceNotUpdatedException;
11+
import com.stacksync.commons.exceptions.DeviceNotValidException;
12+
import com.stacksync.commons.exceptions.UserNotFoundException;
1013

1114
import omq.Remote;
1215
import omq.client.annotation.AsyncMethod;
@@ -65,19 +68,17 @@ public void commit(String requestId, User user, Workspace workspace,
6568
* Function used to update information about a device. If the device ID is
6669
* empty, it will register it as a new device and return the unique ID to
6770
* the caller. Otherwise, it will update the information related to the
68-
* device ID and return the same device ID. If an error occurs and the
69-
* device information cannot be updated, it will return -1.
71+
* device ID and return the same device ID.
7072
*
71-
* @param user
72-
* The ID of the user
73-
* @param requestId
74-
* Used for the client to identify the request
75-
* @param device
76-
* Information about the device
73+
* @param UpdateDeviceRequest
74+
* The device information to be updated
7775
* @return A unique ID to identify the device
76+
* @throws DeviceNotUpdatedException
77+
* @throws DeviceNotValidException
78+
* @throws UserNotFoundException
7879
*/
7980
@SyncMethod(retry = 3, timeout = 5000)
80-
public Long updateDevice(String requestId, User user, DeviceInfo deviceInfo);
81+
public Long updateDevice(UpdateDeviceRequest request) throws UserNotFoundException, DeviceNotValidException, DeviceNotUpdatedException;
8182

8283
/***
8384
* Function used to create a share proposal through the desktop client.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.stacksync.commons.requests;
2+
3+
import java.util.UUID;
4+
5+
public class Request {
6+
7+
private String requestId;
8+
private String userId;
9+
10+
public Request(String userId){
11+
this.requestId = UUID.randomUUID().toString();
12+
this.userId = userId;
13+
}
14+
15+
public Request(String requestId, String userId){
16+
this.requestId = requestId;
17+
this.userId = userId;
18+
}
19+
20+
public String getRequestId() {
21+
return requestId;
22+
}
23+
24+
public void setRequestId(String requestId) {
25+
this.requestId = requestId;
26+
}
27+
28+
public String getUserId() {
29+
return userId;
30+
}
31+
32+
public void setUserId(String userId) {
33+
this.userId = userId;
34+
}
35+
36+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.stacksync.commons.requests;
2+
3+
import java.io.Serializable;
4+
5+
import com.stacksync.commons.utils.ClassUtils;
6+
7+
public class UpdateDeviceRequest extends Request implements Serializable {
8+
9+
private static final long serialVersionUID = 3763327030154389990L;
10+
11+
private Long deviceId;
12+
private String deviceName;
13+
private String os;
14+
private String ip;
15+
private String appVersion;
16+
17+
public UpdateDeviceRequest(String userId, Long deviceId, String deviceName, String os, String ip, String appVersion) {
18+
super(userId);
19+
20+
this.deviceId = deviceId;
21+
this.deviceName = deviceName;
22+
this.os = os;
23+
this.ip = ip;
24+
this.appVersion = appVersion;
25+
}
26+
27+
public String getOs() {
28+
return os;
29+
}
30+
31+
public void setOs(String os) {
32+
this.os = os;
33+
}
34+
35+
public String getIp() {
36+
return ip;
37+
}
38+
39+
public void setIp(String ip) {
40+
this.ip = ip;
41+
}
42+
43+
public String getAppVersion() {
44+
return appVersion;
45+
}
46+
47+
public void setAppVersion(String appVersion) {
48+
this.appVersion = appVersion;
49+
}
50+
51+
public Long getDeviceId() {
52+
return deviceId;
53+
}
54+
55+
public void setDeviceId(Long deviceId) {
56+
this.deviceId = deviceId;
57+
}
58+
59+
public String getDeviceName() {
60+
return deviceName;
61+
}
62+
63+
public void setDeviceName(String deviceName) {
64+
this.deviceName = deviceName;
65+
}
66+
67+
@Override
68+
public String toString() {
69+
return ClassUtils.classToString(this);
70+
}
71+
72+
}
Lines changed: 33 additions & 0 deletions

0 commit comments

Comments
 (0)