Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml =================================================================== diff -u -r472bcb813040efc160e074021be5c71c15455f00 -r46bcc7bfdb3c82d1f241c629b3173f53ae606dca --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml (.../User.hbm.xml) (revision 472bcb813040efc160e074021be5c71c15455f00) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/usermanagement/User.hbm.xml (.../User.hbm.xml) (revision 46bcc7bfdb3c82d1f241c629b3173f53ae606dca) @@ -500,6 +500,39 @@ + + true + + @hibernate.property + column="lams_community_token" + length="255" + not-null="false" + + + + + true + + @hibernate.property + column="lams_community_username" + length="255" + not-null="false" + + + Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java =================================================================== diff -u -r472bcb813040efc160e074021be5c71c15455f00 -r46bcc7bfdb3c82d1f241c629b3173f53ae606dca --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java (.../User.java) (revision 472bcb813040efc160e074021be5c71c15455f00) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java (.../User.java) (revision 46bcc7bfdb3c82d1f241c629b3173f53ae606dca) @@ -39,21 +39,20 @@ import org.lamsfoundation.lams.usermanagement.dto.UserFlashDTO; import org.lamsfoundation.lams.util.LanguageUtil; -/** - * @hibernate.class - * table="lams_user" - * -*/ -public class User implements Serializable,Comparable { +/** + * @hibernate.class table="lams_user" + * + */ +public class User implements Serializable, Comparable { /** identifier field */ private Integer userId; /** persistent field */ private String login; - /** persistent field ] - * TODO needs to be removed for security reason + /** + * persistent field ] TODO needs to be removed for security reason */ private String password; @@ -83,7 +82,7 @@ /** nullable persistent field */ private String postcode; - + /** nullable persistent field */ private String country; @@ -107,7 +106,7 @@ /** persistent field */ private SupportedLocale locale; - + /** persistent field */ private Date createDate; @@ -119,10 +118,10 @@ /** persistent field */ private Set userOrganisations; - + /** persistent field */ private CSSThemeVisualElement flashTheme; - + /** persistent field */ private CSSThemeVisualElement htmlTheme; @@ -131,736 +130,676 @@ /** persistent field */ private Set learnerProgresses; - + /** persistent field */ private Set userToolSessions; - + /** persistent field */ private Set userGroups; - + /** persistent field */ private Set learningDesigns; - + /** persistent field */ private Set lessons; - + /** persistent field */ private Long portraitUuid; - + /** persistent field */ private Boolean changePassword; - + /** persistent field */ private Boolean enableFlash; + /** persistent field */ + private String lamsCommunityToken; + + /** persistent field */ + private String lamsCommunityUsername; + /** full constructor */ - public User(String login, String password, String title, String firstName, String lastName, String addressLine1, String addressLine2, String addressLine3, String city, String state, String postcode, String country, String dayPhone, String eveningPhone, String mobilePhone, String fax, String email, Boolean disabledFlag, Date createDate, Workspace workspace, AuthenticationMethod authenticationMethod, CSSThemeVisualElement flashTheme, CSSThemeVisualElement htmlTheme, Set userOrganisations, String chatId, Set learnerProgresses, Set userToolSessions, Set userGroups, Set learningDesigns, Set lessons, Long portraitUuid, Boolean changePassword, Boolean enableFlash) { - this.login = login; - this.password = password; - this.title = title; - this.firstName = firstName; - this.lastName = lastName; - this.addressLine1 = addressLine1; - this.addressLine2 = addressLine2; - this.addressLine3 = addressLine3; - this.city = city; - this.state = state; - this.postcode = postcode; - this.country = country; - this.dayPhone = dayPhone; - this.eveningPhone = eveningPhone; - this.mobilePhone = mobilePhone; - this.fax = fax; - this.email = email; - this.disabledFlag = disabledFlag; - this.createDate = createDate; - this.workspace = workspace; - this.authenticationMethod = authenticationMethod; - this.flashTheme = flashTheme; - this.htmlTheme = htmlTheme; - this.chatId = chatId; - this.userOrganisations = userOrganisations; - this.learnerProgresses = learnerProgresses; - this.userToolSessions = userToolSessions; - this.userGroups = userGroups; - this.learningDesigns = learningDesigns; - this.lessons = lessons; - this.portraitUuid = portraitUuid; - this.changePassword = changePassword; - this.enableFlash = enableFlash; + public User(String login, String password, String title, String firstName, String lastName, String addressLine1, + String addressLine2, String addressLine3, String city, String state, String postcode, String country, + String dayPhone, String eveningPhone, String mobilePhone, String fax, String email, Boolean disabledFlag, + Date createDate, Workspace workspace, AuthenticationMethod authenticationMethod, + CSSThemeVisualElement flashTheme, CSSThemeVisualElement htmlTheme, Set userOrganisations, String chatId, + Set learnerProgresses, Set userToolSessions, Set userGroups, Set learningDesigns, Set lessons, + Long portraitUuid, Boolean changePassword, Boolean enableFlash, String lamsCommunityToken) { + this.login = login; + this.password = password; + this.title = title; + this.firstName = firstName; + this.lastName = lastName; + this.addressLine1 = addressLine1; + this.addressLine2 = addressLine2; + this.addressLine3 = addressLine3; + this.city = city; + this.state = state; + this.postcode = postcode; + this.country = country; + this.dayPhone = dayPhone; + this.eveningPhone = eveningPhone; + this.mobilePhone = mobilePhone; + this.fax = fax; + this.email = email; + this.disabledFlag = disabledFlag; + this.createDate = createDate; + this.workspace = workspace; + this.authenticationMethod = authenticationMethod; + this.flashTheme = flashTheme; + this.htmlTheme = htmlTheme; + this.chatId = chatId; + this.userOrganisations = userOrganisations; + this.learnerProgresses = learnerProgresses; + this.userToolSessions = userToolSessions; + this.userGroups = userGroups; + this.learningDesigns = learningDesigns; + this.lessons = lessons; + this.portraitUuid = portraitUuid; + this.changePassword = changePassword; + this.enableFlash = enableFlash; + this.lamsCommunityToken = lamsCommunityToken; } /** default constructor */ public User() { - this.changePassword = false; - this.enableFlash = true; + this.changePassword = false; + this.enableFlash = true; } /** minimal constructor */ - public User(String login, String password, Boolean disabledFlag, Date createDate, Workspace workspace, AuthenticationMethod authenticationMethod, Set userOrganisations, Set learnerProgresses, Set userToolSessions, Set userGroups, Set learningDesigns, Set lessons) { - this.login = login; - this.password = password; - this.disabledFlag = disabledFlag; - this.createDate = createDate; - this.workspace = workspace; - this.authenticationMethod = authenticationMethod; - this.userOrganisations = userOrganisations; - this.learnerProgresses = learnerProgresses; - this.userToolSessions = userToolSessions; - this.userGroups = userGroups; - this.learningDesigns = learningDesigns; - this.lessons = lessons; - this.changePassword = false; - this.enableFlash = true; + public User(String login, String password, Boolean disabledFlag, Date createDate, Workspace workspace, + AuthenticationMethod authenticationMethod, Set userOrganisations, Set learnerProgresses, + Set userToolSessions, Set userGroups, Set learningDesigns, Set lessons) { + this.login = login; + this.password = password; + this.disabledFlag = disabledFlag; + this.createDate = createDate; + this.workspace = workspace; + this.authenticationMethod = authenticationMethod; + this.userOrganisations = userOrganisations; + this.learnerProgresses = learnerProgresses; + this.userToolSessions = userToolSessions; + this.userGroups = userGroups; + this.learningDesigns = learningDesigns; + this.lessons = lessons; + this.changePassword = false; + this.enableFlash = true; } - /** - * @hibernate.id - * generator-class="native" - * type="java.lang.Integer" - * column="user_id" - * + /** + * @hibernate.id generator-class="native" type="java.lang.Integer" + * column="user_id" + * */ public Integer getUserId() { - return this.userId; + return this.userId; } public void setUserId(Integer userId) { - this.userId = userId; + this.userId = userId; } - /** - * @hibernate.property - * column="login" - * length="255" - * unique="true" - * not-null="true" - * + /** + * @hibernate.property column="login" length="255" unique="true" + * not-null="true" + * */ public String getLogin() { - return this.login; + return this.login; } public void setLogin(String login) { - this.login = login; + this.login = login; } - /** - * @hibernate.property - * column="password" - * length="50" - * not-null="true" - * + /** + * @hibernate.property column="password" length="50" not-null="true" + * */ public String getPassword() { - return this.password; + return this.password; } public void setPassword(String password) { - this.password = password; + this.password = password; } - /** - * @hibernate.property - * column="title" - * length="32" - * + /** + * @hibernate.property column="title" length="32" + * */ public String getTitle() { - return this.title; + return this.title; } public void setTitle(String title) { - this.title = title; + this.title = title; } - /** - * @hibernate.property - * column="first_name" - * length="128" - * + /** + * @hibernate.property column="first_name" length="128" + * */ public String getFirstName() { - return this.firstName; + return this.firstName; } public void setFirstName(String firstName) { - this.firstName = firstName; + this.firstName = firstName; } - /** - * @hibernate.property - * column="last_name" - * length="128" - * + /** + * @hibernate.property column="last_name" length="128" + * */ public String getLastName() { - return this.lastName; + return this.lastName; } public void setLastName(String lastName) { - this.lastName = lastName; + this.lastName = lastName; } - public String getFullName() - { - return this.getFirstName()+" "+this.getLastName(); + public String getFullName() { + return this.getFirstName() + " " + this.getLastName(); } - /** - * @hibernate.property - * column="address_line_1" - * length="64" - * + + /** + * @hibernate.property column="address_line_1" length="64" + * */ public String getAddressLine1() { - return this.addressLine1; + return this.addressLine1; } public void setAddressLine1(String addressLine1) { - this.addressLine1 = addressLine1; + this.addressLine1 = addressLine1; } - /** - * @hibernate.property - * column="address_line_2" - * length="64" - * + /** + * @hibernate.property column="address_line_2" length="64" + * */ public String getAddressLine2() { - return this.addressLine2; + return this.addressLine2; } public void setAddressLine2(String addressLine2) { - this.addressLine2 = addressLine2; + this.addressLine2 = addressLine2; } - /** - * @hibernate.property - * column="address_line_3" - * length="64" - * + /** + * @hibernate.property column="address_line_3" length="64" + * */ public String getAddressLine3() { - return this.addressLine3; + return this.addressLine3; } public void setAddressLine3(String addressLine3) { - this.addressLine3 = addressLine3; + this.addressLine3 = addressLine3; } - /** - * @hibernate.property - * column="city" - * length="64" - * + /** + * @hibernate.property column="city" length="64" + * */ public String getCity() { - return this.city; + return this.city; } public void setCity(String city) { - this.city = city; + this.city = city; } - /** - * @hibernate.property - * column="state" - * length="64" - * + /** + * @hibernate.property column="state" length="64" + * */ public String getState() { - return this.state; + return this.state; } public void setState(String state) { - this.state = state; + this.state = state; } - - /** - * @hibernate.property - * column="postcode" - * length="10" - * + + /** + * @hibernate.property column="postcode" length="10" + * */ public String getPostcode() { - return this.postcode; + return this.postcode; } public void setPostcode(String postcode) { - this.postcode = postcode; + this.postcode = postcode; } - /** - * @hibernate.property - * column="country" - * length="64" - * + /** + * @hibernate.property column="country" length="64" + * */ public String getCountry() { - return this.country; + return this.country; } public void setCountry(String country) { - this.country = country; + this.country = country; } - /** - * @hibernate.property - * column="day_phone" - * length="64" - * + /** + * @hibernate.property column="day_phone" length="64" + * */ public String getDayPhone() { - return this.dayPhone; + return this.dayPhone; } public void setDayPhone(String dayPhone) { - this.dayPhone = dayPhone; + this.dayPhone = dayPhone; } - /** - * @hibernate.property - * column="evening_phone" - * length="64" - * + /** + * @hibernate.property column="evening_phone" length="64" + * */ public String getEveningPhone() { - return this.eveningPhone; + return this.eveningPhone; } public void setEveningPhone(String eveningPhone) { - this.eveningPhone = eveningPhone; + this.eveningPhone = eveningPhone; } - /** - * @hibernate.property - * column="mobile_phone" - * length="64" - * + /** + * @hibernate.property column="mobile_phone" length="64" + * */ public String getMobilePhone() { - return this.mobilePhone; + return this.mobilePhone; } public void setMobilePhone(String mobilePhone) { - this.mobilePhone = mobilePhone; + this.mobilePhone = mobilePhone; } - /** - * @hibernate.property - * column="fax" - * length="64" - * + /** + * @hibernate.property column="fax" length="64" + * */ public String getFax() { - return this.fax; + return this.fax; } public void setFax(String fax) { - this.fax = fax; + this.fax = fax; } - /** - * @hibernate.property - * column="email" - * length="128" - * + /** + * @hibernate.property column="email" length="128" + * */ public String getEmail() { - return this.email; + return this.email; } public void setEmail(String email) { - this.email = email; + this.email = email; } - /** - * @hibernate.property - * column="disabled_flag" - * length="1" - * not-null="true" - * + /** + * @hibernate.property column="disabled_flag" length="1" not-null="true" + * */ public Boolean getDisabledFlag() { - return this.disabledFlag; + return this.disabledFlag; } public void setDisabledFlag(Boolean disabledFlag) { - this.disabledFlag = disabledFlag; + this.disabledFlag = disabledFlag; } - /** - * @hibernate.property - * column="create_date" - * length="19" - * not-null="true" - * + /** + * @hibernate.property column="create_date" length="19" not-null="true" + * */ public Date getCreateDate() { - return this.createDate; + return this.createDate; } public void setCreateDate(Date createDate) { - this.createDate = createDate; + this.createDate = createDate; } - /** - * @hibernate.many-to-one - * not-null="true" - * lazy="false" - * cascade="all" - * @hibernate.column name="workspace_id" - * + /** + * @hibernate.many-to-one not-null="true" lazy="false" cascade="all" + * @hibernate.column name="workspace_id" + * */ public Workspace getWorkspace() { - return this.workspace; + return this.workspace; } public void setWorkspace(Workspace workspace) { - this.workspace = workspace; + this.workspace = workspace; } - /** - * @hibernate.many-to-one - * not-null="true" - * lazy="false" - * @hibernate.column name="authentication_method_id" - * + /** + * @hibernate.many-to-one not-null="true" lazy="false" + * @hibernate.column name="authentication_method_id" + * */ public AuthenticationMethod getAuthenticationMethod() { - return this.authenticationMethod; + return this.authenticationMethod; } public void setAuthenticationMethod(AuthenticationMethod authenticationMethod) { - this.authenticationMethod = authenticationMethod; + this.authenticationMethod = authenticationMethod; } - /** - * @hibernate.many-to-one - * not-null="false" - * @hibernate.column name="flash_theme_id" - * + /** + * @hibernate.many-to-one not-null="false" + * @hibernate.column name="flash_theme_id" + * */ public CSSThemeVisualElement getFlashTheme() { - return this.flashTheme; + return this.flashTheme; } - + public void setFlashTheme(CSSThemeVisualElement flashTheme) { - this.flashTheme = flashTheme; + this.flashTheme = flashTheme; } - - - /** - * @hibernate.many-to-one - * not-null="false" - * @hibernate.column name="html_theme_id" - * + + /** + * @hibernate.many-to-one not-null="false" + * @hibernate.column name="html_theme_id" + * */ public CSSThemeVisualElement getHtmlTheme() { - return this.htmlTheme; + return this.htmlTheme; } - + public void setHtmlTheme(CSSThemeVisualElement htmlTheme) { - this.htmlTheme = htmlTheme; + this.htmlTheme = htmlTheme; } - - /** - * @hibernate.property - * column="chat_id" - * length="255" - * + + /** + * @hibernate.property column="chat_id" length="255" + * */ public String getChatId() { - return this.chatId; + return this.chatId; } public void setChatId(String chatId) { - this.chatId = chatId; + this.chatId = chatId; } - - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="user_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.usermanagement.UserOrganisation" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="user_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.usermanagement.UserOrganisation" + * */ public Set getUserOrganisations() { - return this.userOrganisations; + return this.userOrganisations; } public void setUserOrganisations(Set userOrganisations) { - this.userOrganisations = userOrganisations; + this.userOrganisations = userOrganisations; } - /** This methods adds a new membership for the given user*/ - public void addUserOrganisation(UserOrganisation userOrganisation){ - if(this.userOrganisations==null) - userOrganisations = new HashSet(); - userOrganisations.add(userOrganisation); + + /** This methods adds a new membership for the given user */ + public void addUserOrganisation(UserOrganisation userOrganisation) { + if (this.userOrganisations == null) + userOrganisations = new HashSet(); + userOrganisations.add(userOrganisation); } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="user_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.lesson.LearnerProgress" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="user_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.lesson.LearnerProgress" + * */ public Set getLearnerProgresses() { - return this.learnerProgresses; + return this.learnerProgresses; } public void setLearnerProgresses(Set learnerProgresses) { - this.learnerProgresses = learnerProgresses; + this.learnerProgresses = learnerProgresses; } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="user_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.lesson.UserToolSession" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="user_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.lesson.UserToolSession" + * */ public Set getUserToolSessions() { - return this.userToolSessions; + return this.userToolSessions; } public void setUserToolSessions(Set userToolSessions) { - this.userToolSessions = userToolSessions; + this.userToolSessions = userToolSessions; } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="user_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.learningdesign.LearningDesign" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="user_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.LearningDesign" + * */ public Set getLearningDesigns() { - return this.learningDesigns; + return this.learningDesigns; } public void setLearningDesigns(Set learningDesigns) { - this.learningDesigns = learningDesigns; + this.learningDesigns = learningDesigns; } - /** - * @hibernate.set - * lazy="true" - * inverse="true" - * cascade="none" - * @hibernate.collection-key - * column="user_id" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.learningdesign.Lesson" - * + /** + * @hibernate.set lazy="true" inverse="true" cascade="none" + * @hibernate.collection-key column="user_id" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.learningdesign.Lesson" + * */ public Set getLessons() { - return this.lessons; + return this.lessons; } public void setLessons(Set lessons) { - this.lessons = lessons; + this.lessons = lessons; } public String toString() { - return new ToStringBuilder(this) - .append("userId", getUserId()) - .toString(); + return new ToStringBuilder(this).append("userId", getUserId()).toString(); } public boolean equals(Object other) { - if ( !(other instanceof User) ) return false; - User castOther = (User) other; - return new EqualsBuilder() - .append(this.getUserId(), castOther.getUserId()) - .isEquals(); + if (!(other instanceof User)) + return false; + User castOther = (User) other; + return new EqualsBuilder().append(this.getUserId(), castOther.getUserId()).isEquals(); } - public int compareTo(Object user){ - User u = (User)user; - return login.compareTo(u.getLogin()); + public int compareTo(Object user) { + User u = (User) user; + return login.compareTo(u.getLogin()); } - + public int hashCode() { - return new HashCodeBuilder() - .append(getUserId()) - .toHashCode(); + return new HashCodeBuilder().append(getUserId()).toHashCode(); } - public UserDTO getUserDTO(){ - String languageIsoCode = null; - String countryIsoCode = null; - String direction = null; - String fckLanguageMapping = null; - if (locale != null) { - languageIsoCode = locale.getLanguageIsoCode(); - countryIsoCode = locale.getCountryIsoCode(); - direction = locale.getDirection(); - fckLanguageMapping = locale.getFckLanguageMapping(); - - } else { - String defaults[] = LanguageUtil.getDefaultLangCountry(); - languageIsoCode = defaults[0]; - countryIsoCode=defaults[1]; - direction=LanguageUtil.getDefaultDirection(); - fckLanguageMapping = LanguageUtil.getSupportedLocale(languageIsoCode, countryIsoCode).getFckLanguageMapping(); - } - - return new UserDTO(this.userId, - this.firstName, - this.lastName, - this.login, - languageIsoCode, - countryIsoCode, - direction, - this.email, - new CSSThemeBriefDTO(this.flashTheme), - new CSSThemeBriefDTO(this.htmlTheme), - //TimeZone.getTimeZone("Australia/Sydney"), - TimeZone.getDefault(), - this.authenticationMethod.getAuthenticationMethodId(), - fckLanguageMapping, - enableFlash); + + public UserDTO getUserDTO() { + String languageIsoCode = null; + String countryIsoCode = null; + String direction = null; + String fckLanguageMapping = null; + if (locale != null) { + languageIsoCode = locale.getLanguageIsoCode(); + countryIsoCode = locale.getCountryIsoCode(); + direction = locale.getDirection(); + fckLanguageMapping = locale.getFckLanguageMapping(); + + } else { + String defaults[] = LanguageUtil.getDefaultLangCountry(); + languageIsoCode = defaults[0]; + countryIsoCode = defaults[1]; + direction = LanguageUtil.getDefaultDirection(); + fckLanguageMapping = LanguageUtil.getSupportedLocale(languageIsoCode, countryIsoCode) + .getFckLanguageMapping(); + } + + return new UserDTO(this.userId, this.firstName, this.lastName, this.login, languageIsoCode, countryIsoCode, + direction, this.email, new CSSThemeBriefDTO(this.flashTheme), new CSSThemeBriefDTO(this.htmlTheme), + //TimeZone.getTimeZone("Australia/Sydney"), + TimeZone.getDefault(), this.authenticationMethod.getAuthenticationMethodId(), fckLanguageMapping, + enableFlash, lamsCommunityToken, lamsCommunityUsername); } - + public UserFlashDTO getUserFlashDTO() { - return new UserFlashDTO(this.userId, - this.firstName, - this.lastName, - this.login); + return new UserFlashDTO(this.userId, this.firstName, this.lastName, this.login); } - - /**This method checks whether user is a member of the - * given organisation*/ - public boolean isMember(Organisation organisation){ - Iterator iterator = this.userOrganisations.iterator(); - while(iterator.hasNext()){ - UserOrganisation userOrganisation = (UserOrganisation)iterator.next(); - Integer organisationID = userOrganisation.getOrganisation().getOrganisationId(); - if(organisationID==organisation.getOrganisationId()) - return true; - } - return false; + + /** + * This method checks whether user is a member of the given organisation + */ + public boolean isMember(Organisation organisation) { + Iterator iterator = this.userOrganisations.iterator(); + while (iterator.hasNext()) { + UserOrganisation userOrganisation = (UserOrganisation) iterator.next(); + Integer organisationID = userOrganisation.getOrganisation().getOrganisationId(); + if (organisationID == organisation.getOrganisationId()) + return true; } - /** This method checks whether the user has membership access to - * the given workspaceFolder. Membership access means I am a member of the - * organisation relating to this folder (either as the root folder or a folder under - * the root folder). - * - * Membership access means that the user - * has read and write access but cannot modify anybody else's content/stuff - **/ - public boolean hasMemberAccess(WorkspaceFolder workspaceFolder){ - boolean foundMemberFolder = false; - Integer workspaceFolderID = workspaceFolder != null ? workspaceFolder.getWorkspaceFolderId() : null; - if ( workspaceFolderID != null ) { - Iterator iterator = this.userOrganisations.iterator(); - while(iterator.hasNext() && ! foundMemberFolder){ - UserOrganisation userOrganisation = (UserOrganisation)iterator.next(); - // not all orgs have a folder - Workspace workspace = userOrganisation.getOrganisation().getWorkspace(); - if ( workspace != null ) { - foundMemberFolder = checkFolders(workspace.getFolders(),workspaceFolderID); - } - } + return false; + } + + /** + * This method checks whether the user has membership access to the given + * workspaceFolder. Membership access means I am a member of the + * organisation relating to this folder (either as the root folder or a + * folder under the root folder). + * + * Membership access means that the user has read and write access but + * cannot modify anybody else's content/stuff + */ + public boolean hasMemberAccess(WorkspaceFolder workspaceFolder) { + boolean foundMemberFolder = false; + Integer workspaceFolderID = workspaceFolder != null ? workspaceFolder.getWorkspaceFolderId() : null; + if (workspaceFolderID != null) { + Iterator iterator = this.userOrganisations.iterator(); + while (iterator.hasNext() && !foundMemberFolder) { + UserOrganisation userOrganisation = (UserOrganisation) iterator.next(); + // not all orgs have a folder + Workspace workspace = userOrganisation.getOrganisation().getWorkspace(); + if (workspace != null) { + foundMemberFolder = checkFolders(workspace.getFolders(), workspaceFolderID); } - return foundMemberFolder; + } } + return foundMemberFolder; + } - private boolean checkFolders(Set folders, Integer desiredWorkspaceFolderId) { - boolean foundMemberFolder = false; - Iterator folderIter = folders.iterator(); - while ( folderIter.hasNext() && !foundMemberFolder) { - WorkspaceFolder folder = (WorkspaceFolder) folderIter.next(); - Integer folderID = folder.getWorkspaceFolderId(); - if ( folderID.equals(desiredWorkspaceFolderId) ) { - foundMemberFolder = true; - } else { - Set childFolders = folder.getChildWorkspaceFolders(); - if ( childFolders != null ) { - foundMemberFolder = checkFolders(childFolders, desiredWorkspaceFolderId); - } - } + private boolean checkFolders(Set folders, Integer desiredWorkspaceFolderId) { + boolean foundMemberFolder = false; + Iterator folderIter = folders.iterator(); + while (folderIter.hasNext() && !foundMemberFolder) { + WorkspaceFolder folder = (WorkspaceFolder) folderIter.next(); + Integer folderID = folder.getWorkspaceFolderId(); + if (folderID.equals(desiredWorkspaceFolderId)) { + foundMemberFolder = true; + } else { + Set childFolders = folder.getChildWorkspaceFolders(); + if (childFolders != null) { + foundMemberFolder = checkFolders(childFolders, desiredWorkspaceFolderId); } - return foundMemberFolder; + } } - - /** - * @hibernate.many-to-one - * not-null="true" - * lazy="false" - * @hibernate.column name="locale_id" - * @param localeCountry - */ - public SupportedLocale getLocale() { - return locale; - } + return foundMemberFolder; + } - public void setLocale(SupportedLocale locale) { - this.locale = locale; - } - - /** - * @hibernate.property - * column="portrait_uuid" - * length="20" - * + /** + * @hibernate.many-to-one not-null="true" lazy="false" + * @hibernate.column name="locale_id" + * @param localeCountry */ + public SupportedLocale getLocale() { + return locale; + } + + public void setLocale(SupportedLocale locale) { + this.locale = locale; + } + + /** + * @hibernate.property column="portrait_uuid" length="20" + * + */ public Long getPortraitUuid() { - return this.portraitUuid; + return this.portraitUuid; } public void setPortraitUuid(Long portraitUuid) { - this.portraitUuid = portraitUuid; + this.portraitUuid = portraitUuid; } - - /** - * @hibernate.property - * column="change_password" - * length="1" - * not-null="true" - * + + /** + * @hibernate.property column="change_password" length="1" not-null="true" + * */ public Boolean getChangePassword() { - return this.changePassword; + return this.changePassword; } public void setChangePassword(Boolean changePassword) { - this.changePassword = changePassword; + this.changePassword = changePassword; } - - /** - * @hibernate.property - * column="enable_flash" - * length="1" - * not-null="true" - * + + /** + * @hibernate.property column="enable_flash" length="1" not-null="true" + * */ public Boolean getEnableFlash() { - return this.enableFlash; + return this.enableFlash; } public void setEnableFlash(Boolean enableFlash) { - this.enableFlash = enableFlash; + this.enableFlash = enableFlash; } + /** + * @hibernate.property column="lams_community_token" length="255" + * not-null="false" + * + */ + public String getLamsCommunityToken() { + return lamsCommunityToken; + } + public void setLamsCommunityToken(String lamsCommunityToken) { + this.lamsCommunityToken = lamsCommunityToken; + } + + /** + * @hibernate.property column="lams_community_username" length="255" + * not-null="false" + * + */ + public String getLamsCommunityUsername() { + return lamsCommunityUsername; + } + + public void setLamsCommunityUsername(String lamsCommunityUsername) { + this.lamsCommunityUsername = lamsCommunityUsername; + } + + + } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java =================================================================== diff -u -r472bcb813040efc160e074021be5c71c15455f00 -r46bcc7bfdb3c82d1f241c629b3173f53ae606dca --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java (.../UserDTO.java) (revision 472bcb813040efc160e074021be5c71c15455f00) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java (.../UserDTO.java) (revision 46bcc7bfdb3c82d1f241c629b3173f53ae606dca) @@ -27,189 +27,207 @@ import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.themes.dto.CSSThemeBriefDTO; + /** * @author Manpreet Minhas */ public class UserDTO { - - private Integer userID; - private String firstName; - private String lastName; - private String login; - private String localeLanguage; - private String localeCountry; - private String fckLanguageMapping; - private String direction; + + private Integer userID; + private String firstName; + private String lastName; + private String login; + private String localeLanguage; + private String localeCountry; + private String fckLanguageMapping; + private String direction; private String email; - // private CSSThemeVisualElement theme; + // private CSSThemeVisualElement theme; private CSSThemeBriefDTO flashTheme; private CSSThemeBriefDTO htmlTheme; private TimeZone timeZone; private Integer authenticationMethodId; private Boolean enableFlash; + private String lamsCommunityToken; + private String lamsCommunityUsername; + private Boolean loggedIntoLamsCommunity; -// public UserDTO(Integer userID, String firstName, String lastName, -// String login, String email, CSSThemeVisualElement theme) { -// this.userID = userID; -// this.firstName = firstName; -// this.lastName = lastName; -// this.login = login; -// this.email = email; -// this.theme = theme; -// } - - public UserDTO(Integer userID, String firstName, String lastName, - String login, String localeLanguage, String localeCountry, String direction, - String email, CSSThemeBriefDTO flashTheme, CSSThemeBriefDTO htmlTheme, - TimeZone timezone, Integer authenticationMethodId, String fckLanguageMapping, - Boolean enableFlash) { - this.userID = userID; - this.firstName = firstName; - this.lastName = lastName; - this.login = login; - this.localeCountry = localeCountry; - this.localeLanguage = localeLanguage; - this.direction = direction; - this.email = email; - this.flashTheme = flashTheme; - this.htmlTheme = htmlTheme; - this.timeZone = timezone; - this.authenticationMethodId = authenticationMethodId; - this.fckLanguageMapping = fckLanguageMapping; - this.enableFlash = enableFlash; - } - - /** - * Equality test of UserDTO objects - */ - public boolean equals(Object o) { - if ((o != null) && (o.getClass() == this.getClass())) { - return ((UserDTO)o).userID == this.userID; - } else { - return false; - } - } - - /** - * Returns the hash code value for this object. - */ - public int hashCode() { - // TODO this might be an ineffcient implementation since userIDs are likely to be sequential, - // hence we dont get a good spread of values - return userID.intValue(); - } - - /** - * @return Returns the firstName. - */ - public String getFirstName() { - return firstName; - } - /** - * @return Returns the lastName. - */ - public String getLastName() { - return lastName; - } - /** - * @return Returns the login. - */ - public String getLogin() { - return login; - } - /** - * @return Returns the userID. - */ - public Integer getUserID() { - return userID; - } + // public UserDTO(Integer userID, String firstName, String lastName, + // String login, String email, CSSThemeVisualElement theme) { + // this.userID = userID; + // this.firstName = firstName; + // this.lastName = lastName; + // this.login = login; + // this.email = email; + // this.theme = theme; + // } + public UserDTO(Integer userID, String firstName, String lastName, String login, String localeLanguage, + String localeCountry, String direction, String email, CSSThemeBriefDTO flashTheme, + CSSThemeBriefDTO htmlTheme, TimeZone timezone, Integer authenticationMethodId, String fckLanguageMapping, + Boolean enableFlash, String lamsCommunityToken, String lamsCommunityUsername) { + this.userID = userID; + this.firstName = firstName; + this.lastName = lastName; + this.login = login; + this.localeCountry = localeCountry; + this.localeLanguage = localeLanguage; + this.direction = direction; + this.email = email; + this.flashTheme = flashTheme; + this.htmlTheme = htmlTheme; + this.timeZone = timezone; + this.authenticationMethodId = authenticationMethodId; + this.fckLanguageMapping = fckLanguageMapping; + this.enableFlash = enableFlash; + this.lamsCommunityToken = lamsCommunityToken; + this.lamsCommunityUsername = lamsCommunityUsername; + } - public CSSThemeBriefDTO getFlashTheme() { - return flashTheme; + /** + * Equality test of UserDTO objects + */ + public boolean equals(Object o) { + if ((o != null) && (o.getClass() == this.getClass())) { + return ((UserDTO) o).userID == this.userID; + } else { + return false; } + } + /** + * Returns the hash code value for this object. + */ + public int hashCode() { + // TODO this might be an ineffcient implementation since userIDs are likely to be sequential, + // hence we dont get a good spread of values + return userID.intValue(); + } - public void setFlashTheme(CSSThemeBriefDTO flashTheme) { - this.flashTheme = flashTheme; - } + /** + * @return Returns the firstName. + */ + public String getFirstName() { + return firstName; + } - public CSSThemeBriefDTO getHtmlTheme() { - return htmlTheme; - } + /** + * @return Returns the lastName. + */ + public String getLastName() { + return lastName; + } + /** + * @return Returns the login. + */ + public String getLogin() { + return login; + } - public void setHtmlTheme(CSSThemeBriefDTO htmlTheme) { - this.htmlTheme = htmlTheme; - } - - public String getEmail() { - return email; - } + /** + * @return Returns the userID. + */ + public Integer getUserID() { + return userID; + } + public CSSThemeBriefDTO getFlashTheme() { + return flashTheme; + } - public String getLocaleCountry() { - return localeCountry; - } + public void setFlashTheme(CSSThemeBriefDTO flashTheme) { + this.flashTheme = flashTheme; + } + public CSSThemeBriefDTO getHtmlTheme() { + return htmlTheme; + } - public String getLocaleLanguage() { - return localeLanguage; - } - - /** Should the page be displayed left to right (LTR) or right to left (RTL) */ - public String getDirection() { - return direction; - } - - /** User's timezone. At the moment, this is always the server's timezone */ - public TimeZone getTimeZone() { - return timeZone; - } - - public Integer getAuthenticationMethodId() { - return authenticationMethodId; - } - - public String toString() { - return new ToStringBuilder(this) - .append("userID", getUserID()) - .append("firstName", getFirstName()) - .append("lastName", getLastName()) - .append("login", getLogin()) - .append("localeLanguage", getLocaleLanguage()) - .append("localeCountry", getLocaleCountry()) - .append("direction", getDirection()) - .append("email", getEmail()) - .append("flashTheme", getFlashTheme()) - .append("htmlTheme", getHtmlTheme()) - .append("timeZone", getTimeZone()) - .append("authenticationMethodId", getAuthenticationMethodId()) - .append("fckLanguageMapping", getFckLanguageMapping()) - .append("enableFlash", getEnableFlash()) - .toString(); - } + public void setHtmlTheme(CSSThemeBriefDTO htmlTheme) { + this.htmlTheme = htmlTheme; + } - public String getFckLanguageMapping() { - return fckLanguageMapping; - } + public String getEmail() { + return email; + } - public Boolean getEnableFlash() { - return enableFlash; - } + public String getLocaleCountry() { + return localeCountry; + } - public void setEnableFlash(Boolean enableFlash) { - this.enableFlash = enableFlash; - } + public String getLocaleLanguage() { + return localeLanguage; + } + /** Should the page be displayed left to right (LTR) or right to left (RTL) */ + public String getDirection() { + return direction; + } -// public CSSThemeVisualElement getTheme() { -// return theme; -// } -// -// public void setTheme(CSSThemeVisualElement theme) { -// this.theme = theme; -// } - - + /** User's timezone. At the moment, this is always the server's timezone */ + public TimeZone getTimeZone() { + return timeZone; + } + + public Integer getAuthenticationMethodId() { + return authenticationMethodId; + } + + public String toString() { + return new ToStringBuilder(this).append("userID", getUserID()).append("firstName", getFirstName()).append( + "lastName", getLastName()).append("login", getLogin()).append("localeLanguage", getLocaleLanguage()) + .append("localeCountry", getLocaleCountry()).append("direction", getDirection()).append("email", + getEmail()).append("flashTheme", getFlashTheme()).append("htmlTheme", getHtmlTheme()).append( + "timeZone", getTimeZone()).append("authenticationMethodId", getAuthenticationMethodId()) + .append("fckLanguageMapping", getFckLanguageMapping()).append("enableFlash", getEnableFlash()).append( + "lamsCommunityUser", this.getLamsCommunityUsername()).append("lamsCommunityToken", + this.getLamsCommunityToken()).append("loggedIntoLamsCommunity", + "" + this.getLoggedIntoLamsCommunity()).toString(); + } + + public String getFckLanguageMapping() { + return fckLanguageMapping; + } + + public Boolean getEnableFlash() { + return enableFlash; + } + + public void setEnableFlash(Boolean enableFlash) { + this.enableFlash = enableFlash; + } + + public String getLamsCommunityToken() { + return lamsCommunityToken; + } + + public void setLamsCommunityToken(String lamsCommunityToken) { + this.lamsCommunityToken = lamsCommunityToken; + } + + public String getLamsCommunityUsername() { + return lamsCommunityUsername; + } + + public void setLamsCommunityUsername(String lamsCommunityUsername) { + this.lamsCommunityUsername = lamsCommunityUsername; + } + + public Boolean getLoggedIntoLamsCommunity() { + return loggedIntoLamsCommunity; + } + + public void setLoggedIntoLamsCommunity(Boolean loggedIntoLamsCommunity) { + this.loggedIntoLamsCommunity = loggedIntoLamsCommunity; + } + + // public CSSThemeVisualElement getTheme() { + // return theme; + // } + // + // public void setTheme(CSSThemeVisualElement theme) { + // this.theme = theme; + // } + }