@Override
public String getSpreadsheetURL(Long userId, String fileName) {
// if it's an administrator
if ((userId == null || userId == 0) && (fileName == null || "".equals(fileName))) {
gdataProxy = new GDataDocumentsProxy(documentsFeedUrl, spreadsheetFeedUrl, gdataAdminLogin, gdataAdminPassword, gdataThreadSleep, gdataConnectTimeout);
return gdataProxy.getSpreadsheetURL(adminSpreadsheet);
}
UserAccount user = DatastoreProxy.getUserAccountById(userId);
if (user != null) {
if (user.getGdataLogin() == null)
user.setGdataLogin(gdataWebLogin);
if (user.getGdataPassword() == null)
user.setGdataPassword(gdataWebPassword);
gdataProxy = new GDataDocumentsProxy(documentsFeedUrl, spreadsheetFeedUrl, user.getGdataLogin(), user.getGdataPassword(), gdataThreadSleep, gdataConnectTimeout);
DatastoreProxy.updateUser(user);
return gdataProxy.getSpreadsheetURL(fileName);
}
return null;
}