if (jsonObject == null) {
Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
logger.info("SimpleMetaStore.readUser: could not read user " + userId); //$NON-NLS-1$
return null;
}
UserInfo userInfo = new UserInfo();
try {
SimpleMetaStoreMigration migration = new SimpleMetaStoreMigration();
if (migration.isMigrationRequired(jsonObject)) {
// Migration to the latest version is required for this user
lock.readLock().unlock();
lock.writeLock().lock();
try {
migration.doMigration(getRootLocation(), userMetaFolder);
lock.readLock().lock();
} finally {
lock.writeLock().unlock();
}
jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, SimpleMetaStore.USER);
}
userInfo.setUniqueId(jsonObject.getString(MetadataInfo.UNIQUE_ID));
userInfo.setUserName(jsonObject.getString(UserConstants2.USER_NAME));
if (jsonObject.isNull(UserConstants2.FULL_NAME)) {
userInfo.setFullName("Unnamed User");
} else {
userInfo.setFullName(jsonObject.getString(UserConstants2.FULL_NAME));
}
List<String> userWorkspaceIds = new ArrayList<String>();
JSONArray workspaceIds = jsonObject.getJSONArray("WorkspaceIds");
if (workspaceIds.length() > 0) {
for (int i = 0; i < workspaceIds.length(); i++) {
userWorkspaceIds.add(workspaceIds.getString(i));
}
}
userInfo.setWorkspaceIds(userWorkspaceIds);
if (userInfo.getWorkspaceIds().size() > 1) {
// It is currently unexpected that a user has more than one workspace. See Bug 439735
Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
logger.warn("SimpleMetaStore.readUser: user id " + userInfo.getUniqueId() + " has a multiple workspace conflict: workspace: " + userInfo.getWorkspaceIds().get(0) + " and workspace: " + userInfo.getWorkspaceIds().get(1));
}
setProperties(userInfo, jsonObject.getJSONObject("Properties"));
userInfo.flush();
} catch (JSONException e) {
throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readUser: could not read user " + userId, e));
}
return userInfo;
}
} finally {
lock.readLock().unlock();
}
// user does not exist for this userId, create it ( see Bug 415505 )
UserInfo userInfo = new UserInfo();
userInfo.setUniqueId(userId);
userInfo.setUserName(userId);
userInfo.setFullName("Unnamed User");
createUser(userInfo);
return userInfo;
}