diff --git a/olat3/webapp/WEB-INF/src/org/olat/NewControllerFactory.java b/olat3/webapp/WEB-INF/src/org/olat/NewControllerFactory.java index ab2bc4fb29b1eb2aa263c3defac6440174f77680..0118cd780f906e25257fdda32a52fa7abaa7429d 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/NewControllerFactory.java +++ b/olat3/webapp/WEB-INF/src/org/olat/NewControllerFactory.java @@ -100,6 +100,20 @@ public class NewControllerFactory extends LogDelegator { return contextEntryControllerCreators.containsKey(key); } + /** + * Check first context entry can be launched + * a further check is mostly not possible, as it gets validated through the BC-stack while building the controller-chain + * + * return true: if this will be launchable at least for the first step. + */ + public boolean validateCEWithContextControllerCreator(final UserRequest ureq, final WindowControl wControl, ContextEntry ce){ + String firstType = ce.getOLATResourceable().getResourceableTypeName(); + if (canLaunch(firstType)){ + return contextEntryControllerCreators.get(firstType).validateContextEntryAndShowError(ce, ureq, wControl); + } + return false; + } + /** * Launch a controller in a tab or site in the given window from a user * request url diff --git a/olat3/webapp/WEB-INF/src/org/olat/admin/securitygroup/gui/_i18n/LocalStrings_en.properties b/olat3/webapp/WEB-INF/src/org/olat/admin/securitygroup/gui/_i18n/LocalStrings_en.properties index 46e9e7254794291cfc9ad3be31b217f869fc1b5e..a2a16a2c90241e368228a1c327e07b306b3d456e 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/admin/securitygroup/gui/_i18n/LocalStrings_en.properties +++ b/olat3/webapp/WEB-INF/src/org/olat/admin/securitygroup/gui/_i18n/LocalStrings_en.properties @@ -4,7 +4,7 @@ action.remove=Remove action.waitinglist.move=Transfer as participant add.searchuser=Which user would you like to add to the group? help.hover.meta.info.owner=$org.olat.repository\:help.hover.meta.info.owner -msg.alreadyinwaiitinggroup=User<b>{0}</b> is already member of this group and can therefore not be transferred from the waiting list to the list of participants. +msg.alreadyinwaiitinggroup=User <b>{0}</b> is already member of this group and can therefore not be transferred from the waiting list to the list of participants. msg.atleastone=At least one user is required in a group. msg.isingroupanonymous=You cannot add this guest user. User name\: <b>{0}</b> msg.selectionempty=You have not selected a user yet. diff --git a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/ProjectGroupController.java b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/ProjectGroupController.java index 1dc66d03120b071214a1b8b607b68d867b66027a..ed3d8e662182945f57223a10325519812fb43e38 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/ProjectGroupController.java +++ b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/ProjectGroupController.java @@ -141,11 +141,13 @@ public class ProjectGroupController extends BasicController { ProjectBrokerManagerFactory.getProjectGroupManager().removeCandidates(((IdentitiesRemoveEvent)event).getRemovedIdentities(), project); fireEvent(urequest, Event.CHANGED_EVENT ); } else if (event instanceof IdentitiesMoveEvent) { - IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event; - ProjectBrokerManagerFactory.getProjectGroupManager().acceptCandidates(identitiesMoveEvent.getChosenIdentities(), project, urequest.getIdentity(), - projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually()); - identitiesMoveEvent.setMovedIdentities(identitiesMoveEvent.getChosenIdentities()); - identitiesMoveEvent.setNotMovedIdentities(new ArrayList()); + final IdentitiesMoveEvent identitiesMoveEvent = (IdentitiesMoveEvent) event; + //OLAT-6342: check identity not in group first! + List<Identity> moveIdents = identitiesMoveEvent.getChosenIdentities(); + BusinessGroupAddResponse response = ProjectBrokerManagerFactory.getProjectGroupManager().acceptCandidates(moveIdents, project, urequest.getIdentity(), + projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually()); + identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities()); + identitiesMoveEvent.setNotMovedIdentities(response.getIdentitiesAlreadyInGroup()); // send mail for all of them MailerWithTemplate mailer = MailerWithTemplate.getInstance(); MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate(); diff --git a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManager.java b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManager.java index 4b54bb38fc1d87c2f69d94842b4dd52a16f95adb..2bdbfac1f6231f05a3ec6208d43e97f8de5f0e51 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManager.java +++ b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManager.java @@ -11,6 +11,7 @@ import org.olat.course.nodes.projectbroker.datamodel.Project; import org.olat.course.properties.CoursePropertyManager; import org.olat.course.run.environment.CourseEnvironment; import org.olat.group.BusinessGroup; +import org.olat.group.BusinessGroupAddResponse; public interface ProjectGroupManager { @@ -95,7 +96,7 @@ public interface ProjectGroupManager { * @param isAcceptSelectionManually * @return */ - public boolean acceptCandidates(List<Identity> identities, Project project, Identity actionIdentity, boolean autoSignOut, boolean isAcceptSelectionManually); + public BusinessGroupAddResponse acceptCandidates(List<Identity> identities, Project project, Identity actionIdentity, boolean autoSignOut, boolean isAcceptSelectionManually); /** * Add identities as candidates. diff --git a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java index 8b412de88d4b322d3758e3d69d3822952b355df5..88ff54b775d7e432b9ef4da3fdf7cd309a0863f2 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java +++ b/olat3/webapp/WEB-INF/src/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java @@ -45,6 +45,7 @@ import org.olat.course.nodes.projectbroker.datamodel.Project; import org.olat.course.properties.CoursePropertyManager; import org.olat.course.run.environment.CourseEnvironment; import org.olat.group.BusinessGroup; +import org.olat.group.BusinessGroupAddResponse; import org.olat.group.BusinessGroupFactory; import org.olat.group.BusinessGroupImpl; import org.olat.group.BusinessGroupManagerImpl; @@ -245,23 +246,28 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); } - public boolean acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) { + public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) { Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); final Project reloadedProject = (Project) DBFactory.getInstance().loadObject(project, true); + final BusinessGroupAddResponse response = new BusinessGroupAddResponse(); Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>(){ public Boolean execute() { - for (Identity identity : identities ) { - BaseSecurityManager.getInstance().removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup()); - BGConfigFlags flags = BGConfigFlags.createRightGroupDefaultFlags(); - BusinessGroupManagerImpl.getInstance().addParticipantAndFireEvent(actionIdentity, identity, reloadedProject.getProjectGroup(), flags, false); - logAudit("ProjectBroker: Accept candidate, identity=" + identity + " project=" + reloadedProject); - // fireEvents ? + for (final Identity identity : identities) { + if (!BaseSecurityManager.getInstance().isIdentityInSecurityGroup(identity, reloadedProject.getProjectGroup().getPartipiciantGroup())) { + BaseSecurityManager.getInstance().removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup()); + final BGConfigFlags flags = BGConfigFlags.createRightGroupDefaultFlags(); + BusinessGroupManagerImpl.getInstance().addParticipantAndFireEvent(actionIdentity, identity, reloadedProject.getProjectGroup(), flags, false); + logAudit("ProjectBroker: Accept candidate, identity=" + identity + " project=" + reloadedProject); + response.getAddedIdentities().add(identity); + } else { + response.getIdentitiesAlreadyInGroup().add(identity); + } } return Boolean.TRUE; } });// end of doInSync if (autoSignOut && result.booleanValue()) { - ProjectBrokerManagerFactory.getProjectBrokerManager().signOutFormAllCandidateList(identities, reloadedProject.getProjectBroker().getKey()); + ProjectBrokerManagerFactory.getProjectBrokerManager().signOutFormAllCandidateList(response.getAddedIdentities(), reloadedProject.getProjectBroker().getKey()); } if (isAcceptSelectionManually && (reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers()) { @@ -270,7 +276,7 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou } Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); - return result.booleanValue(); + return response; } @Override diff --git a/olat3/webapp/WEB-INF/src/org/olat/group/BusinessGroupAddResponse.java b/olat3/webapp/WEB-INF/src/org/olat/group/BusinessGroupAddResponse.java index 491c2c9a6b0bcc0b958049684813da73e8c873fc..b838ad04c7d0ad52f872a423983d61c75b76b594 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/group/BusinessGroupAddResponse.java +++ b/olat3/webapp/WEB-INF/src/org/olat/group/BusinessGroupAddResponse.java @@ -43,7 +43,7 @@ public class BusinessGroupAddResponse { /* Output-list of Identity which are added */ private List<Identity> identitiesWithoutPermission; - BusinessGroupAddResponse() { + public BusinessGroupAddResponse() { addedIdentities = new ArrayList<Identity>(); identitiesAlreadyInGroup = new ArrayList<Identity>(); identitiesWithoutPermission = new ArrayList<Identity>(); diff --git a/olat3/webapp/WEB-INF/src/org/olat/modules/fo/ForumController.java b/olat3/webapp/WEB-INF/src/org/olat/modules/fo/ForumController.java index b10fa3189387521f605d7f90348cf840b680f800..e206c36eefdf52cecbea57664c8c80c87e44d91c 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/modules/fo/ForumController.java +++ b/olat3/webapp/WEB-INF/src/org/olat/modules/fo/ForumController.java @@ -303,7 +303,8 @@ public class ForumController extends BasicController implements GenericEventList scrollToCurrentMessage(); } else { // message not found, do nothing. Load normal start screen - logDebug("Invalid messageId=" , ores.getResourceableId().toString()); + showError("deleteok"); + logDebug("Invalid messageId=", ores.getResourceableId().toString()); } } else { //FIXME:chg: Should not happen, occurs when course-node are called diff --git a/olat3/webapp/WEB-INF/src/org/olat/modules/wiki/WikiMainController.java b/olat3/webapp/WEB-INF/src/org/olat/modules/wiki/WikiMainController.java index cb65863c51f16fbc28c25d2704eaf684dafd8b4b..423860cf4f42dd2d354e5a691ef90421005908f9 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/modules/wiki/WikiMainController.java +++ b/olat3/webapp/WEB-INF/src/org/olat/modules/wiki/WikiMainController.java @@ -172,7 +172,10 @@ public class WikiMainController extends BasicController implements CloneableCont ThreadLocalUserActivityLogger.log(LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass()); // init the first page either startpage or an other page identified by initial page name if (initialPageName != null && wiki.pageExists(WikiManager.generatePageId(initialPageName))) page = wiki.getPage(initialPageName, true); - else page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE); + else { + page = wiki.getPage(WikiPage.WIKI_INDEX_PAGE); + if (initialPageName != null) showError("wiki.error.page.not.found"); + } this.pageId = page.getPageId(); WikiPage menuPage = getWiki().getPage(WikiPage.WIKI_MENU_PAGE); diff --git a/olat3/webapp/WEB-INF/src/org/olat/portfolio/ui/artefacts/view/EPArtefactViewController.java b/olat3/webapp/WEB-INF/src/org/olat/portfolio/ui/artefacts/view/EPArtefactViewController.java index 2fa2a75c07e8d3c44be54c75f7cc55eaa58fa480..1c6e736ba30f44258cdc900f0f4aec7b090465b8 100644 --- a/olat3/webapp/WEB-INF/src/org/olat/portfolio/ui/artefacts/view/EPArtefactViewController.java +++ b/olat3/webapp/WEB-INF/src/org/olat/portfolio/ui/artefacts/view/EPArtefactViewController.java @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.olat.NewControllerFactory; import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; @@ -211,7 +212,7 @@ public class EPArtefactViewController extends FormBasicController { // build link to original source if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) { - String sourceLink = createLinkToArtefactSource(artefact.getBusinessPath()); + String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath()); flc.contextPut("artefactSourceLink", sourceLink); } @@ -267,11 +268,12 @@ public class EPArtefactViewController extends FormBasicController { return busLink; } - private String createLinkToArtefactSource(String businessPath){ + private String createLinkToArtefactSource(UserRequest ureq, String businessPath){ BusinessControlFactory bCF = BusinessControlFactory.getInstance(); List<ContextEntry> ceList = bCF.createCEListFromString(businessPath); + boolean valid = NewControllerFactory.getInstance().validateCEWithContextControllerCreator(ureq, getWindowControl(), ceList.get(0)); String busLink = bCF.getAsURIString(ceList, true); - if (StringHelper.containsNonWhitespace(busLink)){ + if (valid && StringHelper.containsNonWhitespace(busLink)){ return "<a href=\"" + busLink + "\">" + translate("artefact.open.source") + "</a>"; } else return translate("artefact.no.source"); }