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

OO-963: add alternative for compatibility with old business path

parent fa8a5fcc
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.olat.core.CoreSpringFactory;
import org.olat.core.extensions.action.GenericActionExtension;
......@@ -153,7 +154,7 @@ public class ExtManager extends LogDelegator {
int count_disabled = 0;
int count_duplid = 0;
int count_duplnavkey = 0;
AtomicInteger count_duplnavkey = new AtomicInteger(0);
// first build ordered list
for (Extension extension : extensionValues) {
......@@ -190,13 +191,13 @@ public class ExtManager extends LogDelegator {
List<String>extensionPoints = gAE.getExtensionPoints();
for(String extensionPoint:extensionPoints) {
ExtensionPointKeyPair key = new ExtensionPointKeyPair(extensionPoint, gAE.getNavigationKey());
if (navKeyGAExtensionlookup.containsKey(key)) {
count_duplnavkey++;
logInfo(
"Devel-Info :: duplicate navigation-key for extension :: " + gAE.getNavigationKey() + " [ [" + idExtensionlookup.get(uid)
+ "] and [" + extension + "] ]", null);
} else {
navKeyGAExtensionlookup.put(key, gAE);
append(key, gAE, count_duplnavkey);
List<String> alternativeNavigationKeys = gAE.getAlternativeNavigationKeys();
if(alternativeNavigationKeys != null && alternativeNavigationKeys.size() > 0) {
for(String alternativeNavigationKey:alternativeNavigationKeys) {
ExtensionPointKeyPair altKey = new ExtensionPointKeyPair(extensionPoint, alternativeNavigationKey);
append(altKey, gAE, count_duplnavkey);
}
}
}
}
......@@ -209,7 +210,16 @@ public class ExtManager extends LogDelegator {
return extensionsList;
}
private class ExtensionPointKeyPair {
private void append(ExtensionPointKeyPair key, GenericActionExtension gAE, AtomicInteger countDuplicate) {
if (navKeyGAExtensionlookup.containsKey(key)) {
logInfo("Devel-Info :: duplicate navigation-key for extension :: " + key.navigationKey, null);
countDuplicate.incrementAndGet();
} else {
navKeyGAExtensionlookup.put(key, gAE);
}
}
private static class ExtensionPointKeyPair {
private String extensionPoint;
private String navigationKey;
......
......@@ -19,6 +19,7 @@
*/
package org.olat.core.extensions.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
......@@ -36,6 +37,7 @@ import org.olat.core.gui.translator.PackageTranslator;
import org.olat.core.gui.translator.Translator;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
import org.olat.core.util.i18n.I18nManager;
/**
......@@ -55,10 +57,11 @@ public class GenericActionExtension extends AbstractExtension implements ActionE
private String i18nActionKey;
private String i18nDescriptionKey;
/*
* fxdiff : we use this navigationKey to find the correct actionExtension in a
* We use this navigationKey to find the correct actionExtension in a
* genericMainController. (to select the correct tree-entry...)
*/
private String navigationKey;
private List<String> alternativeNavigationKeys;
private List<String> extensionPoints;
private String translationPackageName;
private String translationPackageNameDerived;
......@@ -104,7 +107,9 @@ public class GenericActionExtension extends AbstractExtension implements ActionE
if(getActionController() instanceof AutoCreator){
sb.append(((AutoCreator) getActionController()).getClassName()).append(":");
}
sb.append(getActionText(I18nManager.getInstance().getLocaleOrDefault(null))).append(":").append(getOrder()).append(":").append(getNavigationKey());
sb.append(getActionText(I18nManager.getInstance().getLocaleOrDefault(null)))
.append(":").append(getOrder())
.append(":").append(getNavigationKey());
return sb.toString();
}
......@@ -140,17 +145,19 @@ public class GenericActionExtension extends AbstractExtension implements ActionE
return translator.translate(i18nDescriptionKey);
}
public String getNavigationKey(){
public String getNavigationKey() {
return navigationKey;
}
//fxdiff
public List<String> getAlternativeNavigationKeys() {
return alternativeNavigationKeys;
}
public String getClassNameOfCorrespondingController(){
if(contentControllerClassName == null) return "";
return contentControllerClassName.substring(contentControllerClassName.lastIndexOf(".")+1);
}
// fxdiff
private Translator createPackageTranslator(Locale loc){
if (translationPackageName==null){
translationPackageName = translationPackageNameDerived;
......@@ -203,6 +210,15 @@ public class GenericActionExtension extends AbstractExtension implements ActionE
this.navigationKey = navKey;
}
public void setAlternativeNavigationKeys(String keys) {
if(StringHelper.containsNonWhitespace(keys)) {
alternativeNavigationKeys = new ArrayList<>();
for(String key:keys.split(",")) {
alternativeNavigationKeys.add(key);
}
}
}
public List<String> getExtensionPoints() {
return extensionPoints;
}
......
......@@ -122,7 +122,7 @@ public class OpenOLATServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
log.info(req.getMethod() + " :: " + req.getPathInfo());
//log.info(req.getMethod() + " :: " + req.getPathInfo());
GUIInterna.begin(req);
Tracing.setUreq(req);
......
......@@ -75,6 +75,7 @@
<bean class="org.olat.core.extensions.action.GenericActionExtension" name="mailBox" init-method="initExtensionPoints" >
<property name="order" value="404" />
<property name="navigationKey" value="Mail" />
<property name="alternativeNavigationKeys" value="Inbox,Outbox" />
<property name="iconCssClass" value="o_icon o_icon-fw o_icon_mail" />
<property name="actionController">
<bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype">
......
......@@ -23,7 +23,6 @@ package org.olat.home;
import org.olat.NewControllerFactory;
import org.olat.core.configuration.AbstractOLATModule;
import org.olat.core.configuration.PersistedProperties;
import org.olat.core.id.context.SiteContextEntryControllerCreator;
import org.olat.home.controllerCreators.GuestHomeCEControllerCreator;
/**
......@@ -40,7 +39,7 @@ public class HomeModule extends AbstractOLATModule {
@Override
public void init() {
NewControllerFactory.getInstance().addContextEntryControllerCreator(HomeSite.class.getSimpleName(),
new SiteContextEntryControllerCreator(HomeSite.class));
new HomeSiteContextEntryControllerCreator());
NewControllerFactory.getInstance().addContextEntryControllerCreator("Guest",
new GuestHomeCEControllerCreator());
}
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.home;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.ContextEntryControllerCreator;
import org.olat.core.id.context.DefaultContextEntryControllerCreator;
/**
*
* Initial date: 16.07.2014<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class HomeSiteContextEntryControllerCreator extends DefaultContextEntryControllerCreator {
@Override
public ContextEntryControllerCreator clone() {
return this;
}
@Override
public String getSiteClassName(List<ContextEntry> ces, UserRequest ureq) {
return HomeSite.class.getName();
}
}
\ No newline at end of file
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