Skip to content

Commit

Permalink
Merge branch 'develop' into at-units-in-multiple-languages
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed Feb 29, 2024
2 parents 659a8fe + 6e84932 commit 192215d
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 54 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/wise/portal/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/
package org.wise.portal.domain.user;

import java.util.List;

import org.wise.portal.domain.Persistable;
import org.wise.portal.domain.authentication.MutableUserDetails;

Expand Down Expand Up @@ -49,4 +51,6 @@ public interface User extends Persistable, Comparable<User> {
boolean isTeacher();

boolean isTrustedAuthor();

List<String> getRoles();
}
30 changes: 26 additions & 4 deletions src/main/java/org/wise/portal/domain/user/impl/UserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
package org.wise.portal.domain.user.impl;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -91,13 +94,31 @@ public boolean isTrustedAuthor() {
return userDetails.hasGrantedAuthority(UserDetailsService.TRUSTED_AUTHOR_ROLE);
}

public List<String> getRoles() {
List<String> roles = new ArrayList<String>();
if (this.isAdmin()) {
roles.add("admin");
}
if (this.isResearcher()) {
roles.add("researcher");
}
if (this.isTrustedAuthor()) {
roles.add("trustedAuthor");
}
if (this.isTeacher()) {
roles.add("teacher");
}
if (this.isStudent()) {
roles.add("student");
}
return roles;
}

@Override
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = PRIME
* result
+ ((userDetails == null) ? 0 : userDetails.hashCode());
result = PRIME * result + ((userDetails == null) ? 0 : userDetails.hashCode());
return result;
}

Expand All @@ -108,7 +129,8 @@ public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj instanceof HibernateProxy) {
if (getClass() != (( HibernateProxy) obj).getHibernateLazyInitializer().getImplementation().getClass()) {
if (getClass() != ((HibernateProxy) obj).getHibernateLazyInitializer().getImplementation()
.getClass()) {
return false;
}
} else if (getClass() != obj.getClass())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@ private void addCommonConfigParameters(HttpServletRequest request, JSONObject co
config.put("renewSessionURL", contextPath + "/api/session/renew");
config.put("sessionTimeout", request.getSession().getMaxInactiveInterval());
config.put("sessionLogOutURL", contextPath + "/api/logout");
config.put("speechToTextAWSRegion", appProperties.getProperty("speech-to-text.aws.region", ""));
config.put("speechToTextAWSIdentityPoolId",
appProperties.getProperty("speech-to-text.aws.identity-pool-id", ""));

User signedInUser = ControllerUtil.getSignedInUser();
setUserLocale(request, signedInUser, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,8 @@ HashMap<String, Object> getUserInfo(Authentication auth,
info.put("isPreviousAdmin", isPreviousAdmin(auth));
info.put("language", ud.getLanguage());
info.put("isGoogleUser", ud.isGoogleUser());

if (user.isStudent()) {
info.put("role", "student");
} else {
if (user.isAdmin()) {
info.put("role", "admin");
} else if (user.isResearcher()) {
info.put("role", "researcher");
} else if (user.isTeacher()) {
info.put("role", "teacher");
}
info.put("roles", user.getRoles());
if (user.isTeacher()) {
TeacherUserDetails tud = (TeacherUserDetails) ud;
info.put("displayName", tud.getDisplayname());
info.put("email", tud.getEmailAddress());
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application-dockerdev-sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ system-wide-salt=secret

# IP Address of Clam AV server for virus scanning
# clamav.server.address=127.0.0.1

# Speech to Text using AWS
#speech-to-text.aws.region=
#speech-to-text.aws.identity-pool-id=
4 changes: 4 additions & 0 deletions src/main/resources/application_sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ system-wide-salt=secret

# IP Address of Clam AV server for virus scanning
# clamav.server.address=127.0.0.1

# Speech to Text using AWS
#speech-to-text.aws.region=
#speech-to-text.aws.identity-pool-id=
64 changes: 25 additions & 39 deletions src/main/resources/cc-by-sa.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ https://creativecommons.org/licenses/by-sa/4.0/

--------

Attribution-NonCommercial-ShareAlike 4.0 International
Attribution-ShareAlike 4.0 International

=======================================================================

Expand Down Expand Up @@ -37,7 +37,7 @@ exhaustive, and do not form part of our licenses.
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
wiki.creativecommons.org/Considerations_for_licensors

Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
Expand All @@ -53,23 +53,23 @@ exhaustive, and do not form part of our licenses.
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
for the public:
wiki.creativecommons.org/Considerations_for_licensees

=======================================================================

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
Public License
Creative Commons Attribution-ShareAlike 4.0 International Public
License

By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International Public License
("Public License"). To the extent this Public License may be
interpreted as a contract, You are granted the Licensed Rights in
consideration of Your acceptance of these terms and conditions, and the
Licensor grants You such rights in consideration of benefits the
Licensor receives from making the Licensed Material available under
these terms and conditions.
Attribution-ShareAlike 4.0 International Public License ("Public
License"). To the extent this Public License may be interpreted as a
contract, You are granted the Licensed Rights in consideration of Your
acceptance of these terms and conditions, and the Licensor grants You
such rights in consideration of benefits the Licensor receives from
making the Licensed Material available under these terms and
conditions.


Section 1 -- Definitions.
Expand All @@ -88,7 +88,7 @@ Section 1 -- Definitions.
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.

c. BY-NC-SA Compatible License means a license listed at
c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.

Expand All @@ -112,7 +112,7 @@ Section 1 -- Definitions.

g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
Public License are Attribution, NonCommercial, and ShareAlike.
Public License are Attribution and ShareAlike.

h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
Expand All @@ -126,29 +126,21 @@ Section 1 -- Definitions.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.

k. NonCommercial means not primarily intended for or directed towards
commercial advantage or monetary compensation. For purposes of
this Public License, the exchange of the Licensed Material for
other material subject to Copyright and Similar Rights by digital
file-sharing or similar means is NonCommercial provided there is
no payment of monetary compensation in connection with the
exchange.

l. Share means to provide material to the public by any means or
k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.

m. Sui Generis Database Rights means rights other than copyright
l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.

n. You means the individual or entity exercising the Licensed Rights
m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.


Expand All @@ -162,10 +154,9 @@ Section 2 -- Scope.
exercise the Licensed Rights in the Licensed Material to:

a. reproduce and Share the Licensed Material, in whole or
in part, for NonCommercial purposes only; and
in part; and

b. produce, reproduce, and Share Adapted Material for
NonCommercial purposes only.
b. produce, reproduce, and Share Adapted Material.

2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
Expand Down Expand Up @@ -233,9 +224,7 @@ Section 2 -- Scope.
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties, including when
the Licensed Material is used other than for NonCommercial
purposes.
reserves any right to collect such royalties.


Section 3 -- License Conditions.
Expand Down Expand Up @@ -280,6 +269,7 @@ following conditions.
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.

3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
Expand All @@ -291,7 +281,7 @@ following conditions.

1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
later, or a BY-NC-SA Compatible License.
later, or a BY-SA Compatible License.

2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
Expand All @@ -311,8 +301,7 @@ apply to Your use of the Licensed Material:

a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database for NonCommercial purposes
only;
portion of the contents of the database;

b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Expand Down Expand Up @@ -419,6 +408,7 @@ Section 8 -- Interpretation.
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.


=======================================================================

Creative Commons is not a party to its public
Expand All @@ -439,7 +429,3 @@ the avoidance of doubt, this paragraph does not form part of the
public licenses.

Creative Commons may be contacted at creativecommons.org.

Official translations of this license are available in other languages
at https://creativecommons.org/licenses/by-sa/4.0/legalcode.

0 comments on commit 192215d

Please sign in to comment.