-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathUserInfoServiceImpl.java
More file actions
71 lines (61 loc) · 1.96 KB
/
Copy pathUserInfoServiceImpl.java
File metadata and controls
71 lines (61 loc) · 1.96 KB
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
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2009-2011 Google, All Rights reserved
// Copyright 2011-2012 MIT, All rights reserved
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt
package com.google.appinventor.server;
import com.google.appinventor.server.storage.StorageIo;
import com.google.appinventor.server.storage.StorageIoInstanceHolder;
import com.google.appinventor.shared.rpc.user.User;
import com.google.appinventor.shared.rpc.user.UserInfoService;
/**
* Implementation of the user information service.
*
* <p>Note that this service must be state-less so that it can be run on
* multiple servers.
*
*/
public class UserInfoServiceImpl extends OdeRemoteServiceServlet implements UserInfoService {
// Storage of user settings
private final transient StorageIo storageIo = StorageIoInstanceHolder.INSTANCE;
private static final long serialVersionUID = -7316312435338169166L;
/**
* Returns user information.
*
* @return user information record
*/
@Override
public User getUserInformation() {
return userInfoProvider.getUser();
}
/**
* Retrieves the user's settings.
*
* @return user's settings
*/
@Override
public String loadUserSettings() {
return storageIo.loadSettings(userInfoProvider.getUserId());
}
/**
* Stores the user's settings.
* @param settings user's settings
*/
@Override
public void storeUserSettings(String settings) {
storageIo.storeSettings(userInfoProvider.getUserId(), settings);
}
/**
* Returns true if the current user has a user file with the given file name
*/
@Override
public boolean hasUserFile(String fileName) {
return storageIo.getUserFiles(userInfoProvider.getUserId()).contains(fileName);
}
/**
* Deletes the user file with the given file name
*/
@Override
public void deleteUserFile(String fileName) {
storageIo.deleteUserFile(userInfoProvider.getUserId(), fileName);
}
}