-
Notifications
You must be signed in to change notification settings - Fork 200
[SYNCOPE-1942] added getString to retrieve the label from localization properties file #1278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
9d3dcd6
d08921b
0ed8940
6794833
81be4c2
6958a05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.syncope.client.ui.commons; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public final class DynamicMenuRegister { | ||
|
|
||
| private static final Map<String, Class<?>> KEYS_FOR_PAGES = new HashMap<>(); | ||
|
|
||
| private DynamicMenuRegister() { | ||
| } | ||
|
|
||
| public static void register(final String key, final Class<?> pageClass) { | ||
| KEYS_FOR_PAGES.put(key, pageClass); | ||
| } | ||
|
|
||
| public static Class<?> getPage(final String key) { | ||
| return KEYS_FOR_PAGES.get(key); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.syncope.client.ui.commons; | ||
|
|
||
| import java.util.Locale; | ||
| import org.apache.wicket.core.util.resource.locator.IResourceNameIterator; | ||
| import org.apache.wicket.resource.IPropertiesFactory; | ||
| import org.apache.wicket.resource.Properties; | ||
| import org.apache.wicket.resource.loader.ClassStringResourceLoader; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class DynamicMenuStringResourceLoader extends ClassStringResourceLoader { | ||
|
|
||
| protected static final Logger LOG = LoggerFactory.getLogger(DynamicMenuStringResourceLoader.class); | ||
|
|
||
| public DynamicMenuStringResourceLoader() { | ||
| super(DynamicMenuStringResourceLoader.class); | ||
| } | ||
|
|
||
| @Override | ||
| public String loadStringResource( | ||
| final Class<?> clazz, | ||
| final String key, | ||
| final Locale locale, | ||
| final String style, | ||
| final String variation) { | ||
|
|
||
| if (key != null && key.startsWith("menu.")) { | ||
| Class<?> pageClass = DynamicMenuRegister.getPage(key); | ||
|
|
||
| if (pageClass != null) { | ||
| final String path = pageClass.getName().replace('.', '/'); | ||
| final IResourceNameIterator iter = newResourceNameIterator(path, locale, style, variation); | ||
| final IPropertiesFactory propertiesFactory = getPropertiesFactory(); | ||
|
|
||
| while (iter.hasNext()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use streams, not iterators |
||
| final String newPath = iter.next(); | ||
| final Properties props = propertiesFactory.load(pageClass, newPath); | ||
|
|
||
| if (props != null) { | ||
| final String localeLabel = props.getString(key); | ||
| LOG.debug("Found label \"{}\" for key: {}", localeLabel, key); | ||
| return localeLabel; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ | |
| import org.apache.syncope.client.console.commons.RealmsUtils; | ||
| import org.apache.syncope.client.console.commons.StatusProvider; | ||
| import org.apache.syncope.client.console.init.ClassPathScanImplementationLookup; | ||
| import org.apache.syncope.client.console.pages.BaseExtPage; | ||
| import org.apache.syncope.client.console.pages.BasePage; | ||
| import org.apache.syncope.client.console.pages.Dashboard; | ||
| import org.apache.syncope.client.console.pages.Login; | ||
|
|
@@ -52,7 +53,10 @@ | |
| import org.apache.syncope.client.ui.commons.BaseSession; | ||
| import org.apache.syncope.client.ui.commons.BaseWebApplication; | ||
| import org.apache.syncope.client.ui.commons.Constants; | ||
| import org.apache.syncope.client.ui.commons.DynamicMenuRegister; | ||
| import org.apache.syncope.client.ui.commons.DynamicMenuStringResourceLoader; | ||
| import org.apache.syncope.client.ui.commons.SyncopeUIRequestCycleListener; | ||
| import org.apache.syncope.client.ui.commons.annotations.ExtPage; | ||
| import org.apache.syncope.client.ui.commons.annotations.Resource; | ||
| import org.apache.syncope.client.ui.commons.themes.AdminLTE; | ||
| import org.apache.syncope.client.ui.commons.wizards.AjaxWizard; | ||
|
|
@@ -240,6 +244,26 @@ protected void init() { | |
|
|
||
| mountPage("/login", getSignInPageClass()); | ||
|
|
||
| //[SYNCOPE-1942] | ||
|
||
| //-- | ||
| final List<Class<? extends BasePage>> amPageClasses = lookup.getAMPageClasses(); | ||
| amPageClasses.forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| final List<Class<? extends BasePage>> idmPageClasses = lookup.getIdMPageClasses(); | ||
| idmPageClasses.forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| final List<Class<? extends BaseExtPage>> extPageClasses = lookup.getClasses(BaseExtPage.class); | ||
| extPageClasses.stream().filter(claz -> (claz.isAnnotationPresent(ExtPage.class))).forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| getResourceSettings().getStringResourceLoaders().add(new DynamicMenuStringResourceLoader()); | ||
| //-- | ||
|
|
||
| for (IResource resource : resources) { | ||
| Class<?> resourceClass = AopUtils.getTargetClass(resource); | ||
| Resource annotation = resourceClass.getAnnotation(Resource.class); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
| # under the License. | ||
| home=Home | ||
| version=Version | ||
| domain=Domain | ||
| domain=Domain | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this space-adding change |
||
|
|
||
| systemInfo=System Information | ||
| hostname=Host Name | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,10 @@ | |
| import org.apache.syncope.client.lib.SyncopeClientFactoryBean; | ||
| import org.apache.syncope.client.ui.commons.BaseLogin; | ||
| import org.apache.syncope.client.ui.commons.BaseWebApplication; | ||
| import org.apache.syncope.client.ui.commons.DynamicMenuRegister; | ||
| import org.apache.syncope.client.ui.commons.DynamicMenuStringResourceLoader; | ||
| import org.apache.syncope.client.ui.commons.SyncopeUIRequestCycleListener; | ||
| import org.apache.syncope.client.ui.commons.annotations.ExtPage; | ||
| import org.apache.syncope.client.ui.commons.annotations.Resource; | ||
| import org.apache.syncope.client.ui.commons.themes.AdminLTE; | ||
| import org.apache.syncope.common.keymaster.client.api.ServiceOps; | ||
|
|
@@ -203,6 +206,26 @@ public IResource getResource() { | |
| } | ||
| } | ||
|
|
||
| //[SYNCOPE-1942] | ||
|
||
| //-- | ||
| final List<Class<? extends BasePage>> amPageClasses = lookup.getAMPageClasses(); | ||
| amPageClasses.forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| final List<Class<? extends BasePage>> idmPageClasses = lookup.getIdMPageClasses(); | ||
| idmPageClasses.forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| final List<Class<? extends BasePage>> extPageClasses = lookup.getExtPageClasses(); | ||
| extPageClasses.stream().filter(claz -> (claz.isAnnotationPresent(ExtPage.class))).forEach(claz -> { | ||
| DynamicMenuRegister.register("menu." + claz.getSimpleName(), claz); | ||
| }); | ||
|
|
||
| getResourceSettings().getStringResourceLoaders().add(new DynamicMenuStringResourceLoader()); | ||
| //-- | ||
|
|
||
| try (InputStream is = resourceLoader.getResource(props.getCustomFormLayout()).getInputStream()) { | ||
| customFormLayout = MAPPER.readValue(is, new TypeReference<>() { | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| xmlEditorTitle=XML \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u044f | ||
| userWorkflow=User workflow | ||
| external_editor.title=Flowable Modeler | ||
|
|
||
| menu.Flowable=Flowable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| user.requests.accordion=${bpmnProcess} (${activityId}) | ||
| bpmn.process.title=Richieste | ||
| submit=Salva | ||
| executionId=Id esecuzione | ||
| startTime=Eseguito il | ||
| delete=Cancella | ||
| start=Esegui | ||
| requests.to.be.approved=Richieste in lavorazione | ||
| activityId=Id attivit\u00e0 | ||
|
|
||
| menu.Flowable=Demandes des utilisateurs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turn this class into a bean.
You can take https://github.com/apache/syncope/blob/master/client/idrepo/common-ui/src/main/java/org/apache/syncope/client/ui/commons/MIMETypesLoader.java as reference