Skip to content
Snippets Groups Projects
Commit 93837eb3 authored by srosse's avatar srosse
Browse files

Merge remote-tracking branch 'origin/OpenOLAT_14.2' into OpenOLAT_15.0

parents 2b930cda 26f07d95
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@
column="projectgroup_fk" outer-join="false" cascade="none"/>
<many-to-one name="projectBroker" class="org.olat.course.nodes.projectbroker.datamodel.ProjectBrokerImpl"
column="projectbroker_fk" cascade="none"/>
column="projectbroker_fk" cascade="none" fetch="join"/>
<map name="customfields" table="o_projectbroker_customfields" cascade="all,delete-orphan" fetch="join">
<key column="fk_project_id" not-null="true"/>
......
......@@ -102,12 +102,13 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
* @param projectbroker_id
* @return List of projects for certain project-broker
*/
@Override
public List<Project> getProjectListBy(final Long projectBrokerId) {
final boolean debug = log.isDebugEnabled();
long rstart = 0;
if(debug){
log.debug("getProjectListBy for projectBroker=" + projectBrokerId);
log.debug("getProjectListBy for projectBroker={}", projectBrokerId);
rstart = System.currentTimeMillis();
}
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(),projectBrokerId);
......@@ -118,7 +119,7 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
if(debug){
long rstop = System.currentTimeMillis();
log.debug("time to fetch project with projectbroker_id " + projectBrokerId + " :" + (rstop - rstart));
log.debug("time to fetch project with projectbroker_id {} :{}", projectBrokerId, (rstop - rstart));
}
return projectList;
}
......@@ -274,12 +275,12 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
// invalide with removing from cache
projectCache.remove(projectBrokerId.toString());
if (deleteGroup) {
log.debug("start deleteProjectGroupFor project group=" + projectGroup);
log.debug("start deleteProjectGroupFor project group={}", projectGroup);
businessGroupService.deleteBusinessGroup(projectGroup);
}
});
log.debug("DONE deleteProjectGroupFor project=" + project);
log.debug("DONE deleteProjectGroupFor project={}", project);
}
public int getNbrSelectedProjects(Identity identity, List<Project> projectList) {
......@@ -341,7 +342,8 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
return true;
}
public boolean canBeCancelEnrollmentBy(Identity identity,Project project,ProjectBrokerModuleConfiguration moduleConfig) {
@Override
public boolean canBeCancelEnrollmentBy(Identity identity, Project project, ProjectBrokerModuleConfiguration moduleConfig) {
// 6. date for enrollemnt ok
if (!isEnrollmentDateOk(project,moduleConfig) ){
return false;
......@@ -350,10 +352,10 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
if(!projectGroupManager.isDeselectionAllowed(project)){
return false;
} else {
if (moduleConfig.isAcceptSelectionManually()) {
// could only cancel enrollment, when projectleader did not accept yet
return projectGroupManager.isProjectCandidate(identity, project) && !project.getState().equals(Project.STATE_ASSIGNED);
}
if (moduleConfig.isAcceptSelectionManually()) {
// could only cancel enrollment, when projectleader did not accept yet
return projectGroupManager.isProjectCandidate(identity, project) && !project.getState().equals(Project.STATE_ASSIGNED);
}
// could always cancel enrollment
return projectGroupManager.isProjectParticipant(identity, project);
}
......@@ -506,7 +508,7 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
private void deleteAllReturnboxFilesOfProject(Project project, CourseEnvironment courseEnv, CourseNode cNode) {
VFSContainer returnboxDir = VFSManager.olatRootContainer(ProjectBrokerReturnboxController.getReturnboxBasePathForProject(project,courseEnv,cNode), null);
returnboxDir.delete();
log.debug("deleteAllReturnboxFilesOfProject path=" + returnboxDir);
log.debug("deleteAllReturnboxFilesOfProject path={}", returnboxDir);
}
......@@ -517,7 +519,7 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
// 1. check if alreday a projectBroker is in the cache
ProjectBroker projectBroker = projectCache.get(projectBrokerId.toString());
if (projectBroker == null) {
log.debug("find no projectBroker in the cache => create a new one projectBrokerId=" + projectBrokerId);
log.debug("find no projectBroker in the cache => create a new one projectBrokerId={}", projectBrokerId);
StringBuilder sb = new StringBuilder();
sb.append("select distinct project from ").append(ProjectImpl.class.getName()).append(" as project ")
.append(" left join fetch project.projectGroup pGroup")
......@@ -582,7 +584,11 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
public List<Project> getProjectsWith(BusinessGroup group) {
StringBuilder sb = new StringBuilder();
sb.append("select project from ").append(ProjectImpl.class.getName()).append(" as project")
.append(" where project.projectGroup.key=:groupKey");
.append(" left join fetch project.projectGroup pGroup")
.append(" left join fetch pGroup.baseGroup bGroup")
.append(" left join fetch project.candidateGroup cGroup")
.append(" left join fetch project.projectBroker pBroker")
.append(" where pGroup.key=:groupKey");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Project.class)
.setParameter("groupKey", group.getKey())
......@@ -629,7 +635,7 @@ public class ProjectBrokerManagerImpl implements ProjectBrokerManager {
Number count = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Number.class)
.setParameter("projectBrokerId", projectBrokerId).setParameter("title", newProjectTitle)
.getSingleResult();
return count == null ? false : count.intValue() > 0;
return count != null && count.intValue() > 0;
}
@Override
......
......@@ -30,6 +30,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.apache.logging.log4j.Logger;
import org.hibernate.LazyInitializationException;
import org.olat.basesecurity.GroupRoles;
import org.olat.basesecurity.SecurityGroup;
import org.olat.basesecurity.manager.SecurityGroupDAO;
......@@ -37,7 +39,6 @@ import org.olat.core.commons.persistence.DB;
import org.olat.core.gui.UserRequest;
import org.olat.core.id.Identity;
import org.olat.core.logging.AssertException;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing;
import org.olat.core.util.coordinate.CoordinatorManager;
import org.olat.core.util.coordinate.SyncerCallback;
......@@ -104,10 +105,10 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
groupKey = accountManagerGroupProperty.getLongValue();
log.debug("accountManagerGroupProperty=" + accountManagerGroupProperty + " groupKey=" + groupKey);
}
log.debug("groupKey=" + groupKey);
log.debug("groupKey={}", groupKey);
if (groupKey != null) {
accountManagerGroup = businessGroupService.loadBusinessGroup(groupKey);
log.debug("load businessgroup=" + accountManagerGroup);
log.debug("load businessgroup={}", accountManagerGroup);
if (accountManagerGroup != null) {
return accountManagerGroup;
} else {
......@@ -127,7 +128,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
accountManagerGroup = businessGroupService.createBusinessGroup(identity, groupName + " _" + i, groupDescription, -1, -1, false, false, re);
i++;
}
log.debug("createAndPersistBusinessGroup businessgroup=" + accountManagerGroup);
log.debug("createAndPersistBusinessGroup businessgroup={}", accountManagerGroup);
if (accountManagerGroupProperty != null) {
accountManagerGroupProperty.setLongValue(accountManagerGroup.getKey());
......@@ -135,7 +136,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
} else {
saveAccountManagerGroupKey(accountManagerGroup.getKey(), cpm, courseNode);
}
log.debug("created account-manager default businessgroup=" + accountManagerGroup);
log.debug("created account-manager default businessgroup={}", accountManagerGroup);
}
} catch (AssertException e) {
log.error("", e);
......@@ -150,7 +151,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
public void saveAccountManagerGroupKey(Long accountManagerGroupKey, CoursePropertyManager cpm, CourseNode courseNode) {
Property accountManagerGroupKeyProperty = cpm.createCourseNodePropertyInstance(courseNode, null, null, ProjectBrokerCourseNode.CONF_ACCOUNTMANAGER_GROUP_KEY, null, accountManagerGroupKey, null, null);
cpm.saveProperty(accountManagerGroupKeyProperty);
log.debug("saveAccountManagerGroupKey accountManagerGroupKey=" + accountManagerGroupKey);
log.debug("saveAccountManagerGroupKey accountManagerGroupKey={}", accountManagerGroupKey);
}
@Override
......@@ -196,13 +197,13 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
if (accountManagerGroup != null) {
BusinessGroupService bgs = businessGroupService;
bgs.deleteBusinessGroup(accountManagerGroup);
log.info(Tracing.M_AUDIT, "ProjectBroker: Deleted accountManagerGroup=" + accountManagerGroup);
log.info(Tracing.M_AUDIT, "ProjectBroker: Deleted accountManagerGroup={}", accountManagerGroup);
} else {
log.debug("deleteAccountManagerGroup: accountManagerGroup=" + accountManagerGroup + " has already been deleted");
}
}
cpm.deleteProperty(accountManagerGroupProperty);
log.debug("deleteAccountManagerGroup: deleted accountManagerGroupProperty=" + accountManagerGroupProperty );
log.debug("deleteAccountManagerGroup: deleted accountManagerGroupProperty={}", accountManagerGroupProperty );
} else {
log.debug("deleteAccountManagerGroup: found no accountManagerGroup-key");
}
......@@ -230,7 +231,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
CourseGroupManager cgm = CourseFactory.loadCourse(courseId).getCourseEnvironment().getCourseGroupManager();
RepositoryEntry re = cgm.getCourseEntry();
log.debug("createProjectGroupFor groupName=" + groupName);
log.debug("createProjectGroupFor groupName={}", groupName);
BusinessGroup projectGroup = businessGroupService.createBusinessGroup(identity, groupName, groupDescription, -1, -1, false, false, re);
// projectGroup could be null when a group with name already exists
int counter = 2;
......@@ -240,7 +241,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
projectGroup = businessGroupService.createBusinessGroup(identity, newGroupName, groupDescription, -1, -1, false, false, re);
counter++;
}
log.debug("Created a new projectGroup=" + projectGroup);
log.debug("Created a new projectGroup={}", projectGroup);
return projectGroup;
}
......@@ -271,7 +272,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
if (!securityGroupDao.isIdentityInSecurityGroup(identity, project.getCandidateGroup()) ) {
securityGroupDao.addIdentityToSecurityGroup(identity, project.getCandidateGroup());
addedIdentityList.add(identity);
log.info(Tracing.M_AUDIT, "ProjectBroker: Add user as candidate, identity=" + identity);
log.info(Tracing.M_AUDIT, "ProjectBroker: Add user as candidate, identity={}", identity);
}
// fireEvents ?
}
......@@ -288,7 +289,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
Project reloadedProject = (Project) dbInstance.loadObject(project, true);
for (Identity identity : addIdentities) {
securityGroupDao.removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup());
log.info(Tracing.M_AUDIT, "ProjectBroker: Remove user as candidate, identity=" + identity);
log.info(Tracing.M_AUDIT, "ProjectBroker: Remove user as candidate, identity={}", identity);
// fireEvents ?
}
return Boolean.TRUE;
......@@ -387,7 +388,7 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
Project project = iterator.next();
List<Identity> candidates = securityGroupDao.getIdentitiesOfSecurityGroup(project.getCandidateGroup());
if (!candidates.isEmpty()) {
log.info(Tracing.M_AUDIT, "ProjectBroker: Accept ALL candidates, project=" + project);
log.info(Tracing.M_AUDIT, "ProjectBroker: Accept ALL candidates, project={}", project);
acceptCandidates(candidates, project, actionIdentity, autoSignOut, isAcceptSelectionManually);
}
}
......@@ -415,7 +416,11 @@ public class ProjectGroupManagerImpl implements ProjectGroupManager {
@Override
public boolean isDeselectionAllowed(Project project){
return project.getProjectGroup().isAllowToLeave();
try {
return project.getProjectGroup().isAllowToLeave();
} catch (LazyInitializationException e) {
return projectDao.loadProject(project.getKey()).getProjectGroup().isAllowToLeave();
}
}
@Override
......
......@@ -150,7 +150,7 @@ public class BigBlueButtonUriBuilder {
private static String checksum(String s) {
String checksum = "";
try {
checksum = org.apache.commons.codec.digest.DigestUtils.sha256Hex(s);
checksum = org.apache.commons.codec.digest.DigestUtils.sha1Hex(s);
} catch (Exception e) {
log.error("Cannot calculate checksum", e);
}
......
......@@ -46,7 +46,7 @@ public class BigBlueButtonUriBuilderTest {
.parameter("moderatorPW", "333444");
String url = builder.build().toString();
Assert.assertEquals("https://bbb.openolat.org/bigbluebutton/api/create?name=Test+Meeting&meetingID=abc123&attendeePW=111222&moderatorPW=333444&checksum=da9185f7f333cfdfcd6eeac32dca3777510c4c436020d8b887ba5515bd1d189e" , url);
Assert.assertEquals("https://bbb.openolat.org/bigbluebutton/api/create?name=Test+Meeting&meetingID=abc123&attendeePW=111222&moderatorPW=333444&checksum=1fcbb0c4fc1f039f73aa6d697d2db9ba7f803f17" , url);
}
@Test
......@@ -62,7 +62,7 @@ public class BigBlueButtonUriBuilderTest {
.parameter("moderatorPW", "333444");
String url = builder.build().toString();
Assert.assertEquals("https://bbb.openolat.org/bigbluebutton/api/create?name=Test+%C3%A9v%C3%A9nement&meetingID=abc123&attendeePW=111222&moderatorPW=333444&checksum=bedc6c6bf6edf42c5ac0f2f3c34cbc8283435029edfa590f43c670e18c4324f9", url);
Assert.assertEquals("https://bbb.openolat.org/bigbluebutton/api/create?name=Test+%C3%A9v%C3%A9nement&meetingID=abc123&attendeePW=111222&moderatorPW=333444&checksum=736920ac314bd083e97708e10c778254805967b9", url);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment