Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=MISSING ENTITLEMENT: CONNECTOR_READ

menu.Topology=Topology
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=DROIT MANQUANT : CONNECTOR_READ

menu.Topology=Topologie
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=ENTITLEMENT MANCANTE: CONNECTOR_READ

menu.Topology=Topologia
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=\u6a29\u5229\u4ed8\u4e0e\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: CONNECTOR_READ

menu.Topology=\u30c8\u30dd\u30ed\u30b8\u30fc
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# specific language governing permissions and limitations
# under the License.
missingEntitlement=MISSING ENTITLEMENT: CONNECTOR_READ

menu.Topology=Topologia
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# missingEntitlement=Нет прав доступа на просмотр коннектора (CONNECTOR_READ)
missingEntitlement=\u041d\u0435\u0442 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u043a\u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 (CONNECTOR_READ)

menu.Topology=\u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044f
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private final Map<String, Class<?>> keysForPages;

public DynamicMenuRegister() {
keysForPages = new HashMap<>();
}

public void register(final String key, final Class<?> pageClass) {
keysForPages.put(key, pageClass);
}

public Class<?> getPage(final String key) {
return keysForPages.get(key);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* 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);

private DynamicMenuRegister dynamicMenuRegister;

public DynamicMenuStringResourceLoader(final DynamicMenuRegister dynamicMenuRegister) {
super(DynamicMenuStringResourceLoader.class);
this.dynamicMenuRegister = dynamicMenuRegister;
}

@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()) {
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Up @@ -69,6 +69,7 @@
import org.apache.syncope.client.console.rest.TaskRestClient;
import org.apache.syncope.client.console.rest.UserRestClient;
import org.apache.syncope.client.console.rest.UserSelfRestClient;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.ui.commons.MIMETypesLoader;
import org.apache.syncope.client.ui.commons.PreviewUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -334,4 +335,10 @@ public UserRestClient userRestClient() {
public UserSelfRestClient userSelfRestClient() {
return new UserSelfRestClient();
}

@ConditionalOnMissingBean
@Bean
public DynamicMenuRegister dynamicMenuRegister() {
return new DynamicMenuRegister();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.syncope.client.console.commons.StatusProvider;
import org.apache.syncope.client.console.init.ClassPathScanImplementationLookup;
import org.apache.syncope.client.console.wizards.any.UserFormFinalizer;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.ui.commons.actuate.SyncopeCoreHealthIndicator;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
Expand Down Expand Up @@ -87,7 +88,9 @@ public SyncopeWebApplication syncopeWebApplication(
@Qualifier(SyncopeWebApplication.LOGGEDOUT_SESSIONID_CACHE)
final Cache<String, OffsetDateTime> loggedoutSessionIdCache,
@Qualifier(SyncopeWebApplication.DESTROYED_SESSIONID_CACHE)
final Cache<String, OffsetDateTime> destroyedSessionIdCache) {
final Cache<String, OffsetDateTime> destroyedSessionIdCache,
final DynamicMenuRegister dynamicMenuRegister
) {

return new SyncopeWebApplication(
props,
Expand All @@ -103,7 +106,8 @@ public SyncopeWebApplication syncopeWebApplication(
userFormFinalizers,
resources,
loggedoutSessionIdCache,
destroyedSessionIdCache);
destroyedSessionIdCache,
dynamicMenuRegister);
}

@ConditionalOnMissingBean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -125,6 +129,8 @@ public static SyncopeWebApplication get() {

protected final Cache<String, OffsetDateTime> destroyedSessionIdCache;

protected final DynamicMenuRegister dynamicMenuRegister;

public SyncopeWebApplication(
final ConsoleProperties props,
final ClassPathScanImplementationLookup lookup,
Expand All @@ -140,7 +146,8 @@ public SyncopeWebApplication(
final List<UserFormFinalizer> userFormFinalizers,
final List<IResource> resources,
final Cache<String, OffsetDateTime> loggedoutSessionIdCache,
final Cache<String, OffsetDateTime> destroyedSessionIdCache) {
final Cache<String, OffsetDateTime> destroyedSessionIdCache,
final DynamicMenuRegister dynamicMenuRegister) {

this.props = props;
this.lookup = lookup;
Expand All @@ -157,6 +164,7 @@ public SyncopeWebApplication(
this.resources = resources;
this.loggedoutSessionIdCache = loggedoutSessionIdCache;
this.destroyedSessionIdCache = destroyedSessionIdCache;
this.dynamicMenuRegister = dynamicMenuRegister;
}

protected SyncopeUIRequestCycleListener buildSyncopeUIRequestCycleListener() {
Expand Down Expand Up @@ -240,6 +248,23 @@ protected void init() {

mountPage("/login", getSignInPageClass());

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(dynamicMenuRegister));

for (IResource resource : resources) {
Class<?> resourceClass = AopUtils.getTargetClass(resource);
Resource annotation = resourceClass.getAnnotation(Resource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
IdMPage ann = item.getModelObject().getAnnotation(IdMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("idmPage", item.getModelObject());
link.add(new Label("idmPageLabel", ann.label()));
link.add(new Label("idmPageLabel", getString("menu." + ann.label(), null, ann.label())));
if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down Expand Up @@ -226,7 +226,8 @@ protected void populateItem(final ListItem<Class<? extends BasePage>> item) {
AMPage ann = item.getModelObject().getAnnotation(AMPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("amPage", item.getModelObject());
link.add(new Label("amPageLabel", ann.label()));
link.add(new Label("amPageLabel", getString("menu." + ann.label(), null, ann.label())));

if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down Expand Up @@ -521,7 +522,7 @@ protected void populateItem(final ListItem<Class<? extends BaseExtPage>> item) {
ExtPage ann = item.getModelObject().getAnnotation(ExtPage.class);

BookmarkablePageLink<Page> link = new BookmarkablePageLink<>("extPage", item.getModelObject());
link.add(new Label("extPageLabel", ann.label()));
link.add(new Label("extPageLabel", getString("menu." + ann.label(), null, ann.label())));
if (StringUtils.isNotBlank(ann.listEntitlement())) {
MetaDataRoleAuthorizationStrategy.authorize(link, WebPage.RENDER, ann.listEntitlement());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ nomatch=No matches found
tooLargeFile=File is too large, max upload file size is ${maxUploadSizeB} bytes (${maxUploadSizeMB} MB).
confirmDelegation=Do you really want to switch user?
topology=Topology
engagements=Engagements
engagements=\u5a5a\u7d04
confirmProvisionMembers=Do you really want to provision all group members?
confirmDeprovisionMembers=Do you really want to deprovision all group members?
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ nomatch=Nenhuma correspond\u00eancia encontrada
tooLargeFile=File is too large, max upload file size is ${maxUploadSizeB} bytes (${maxUploadSizeMB} MB).
confirmDelegation=Do you really want to switch user?
topology=Topology
engagements=Engagements
engagements=Compromissos
confirmProvisionMembers=Do you really want to provision all group's members?
confirmDeprovisionMembers=Do you really want to deprovision all group members?
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ nomatch=No matches found
tooLargeFile=File is too large, max upload file size is ${maxUploadSizeB} bytes (${maxUploadSizeMB} MB).
confirmDelegation=Do you really want to switch user?
topology=Topology
engagements=Engagements
engagements=\u043f\u043e\u043c\u043e\u043b\u0432\u043a\u0438
confirmProvisionMembers=Do you really want to provision all group members?
confirmDeprovisionMembers=Do you really want to deprovision all group members?
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.
home=Home
version=Version
domain=Domain
domain=Domain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this space-adding change


systemInfo=System Information
hostname=Host Name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.syncope.client.lib.SyncopeAnonymousClient;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.common.keymaster.client.api.DomainOps;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
import org.apache.syncope.common.keymaster.client.api.model.JPADomain;
Expand Down Expand Up @@ -169,7 +170,7 @@ public TestSyncopeWebApplication(
super(props, lookup, serviceOps, resourceProvider, anyDirectoryPanelAdditionalActionsProvider,
anyDirectoryPanelAdditionalActionLinksProvider, anyWizardBuilderAdditionalSteps, statusProvider,
implementationInfoProvider, accessPolicyConfProvider, policyTabProviders, userFormFinalizers,
resources, loggedoutSessionIdCache, destroyedSessionIdCache);
resources, loggedoutSessionIdCache, destroyedSessionIdCache, new DynamicMenuRegister());
}

public interface SyncopeServiceClient extends SyncopeService, Client {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.syncope.client.enduser.rest.SecurityQuestionRestClient;
import org.apache.syncope.client.enduser.rest.SyncopeRestClient;
import org.apache.syncope.client.enduser.rest.UserSelfRestClient;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.ui.commons.MIMETypesLoader;
import org.apache.syncope.client.ui.commons.PreviewUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -91,4 +92,10 @@ public SyncopeRestClient syncopeRestClient() {
public UserSelfRestClient userSelfRestClient() {
return new UserSelfRestClient();
}

@ConditionalOnMissingBean
@Bean
public DynamicMenuRegister dynamicMenuRegister() {
return new DynamicMenuRegister();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import org.apache.syncope.client.enduser.init.ClassPathScanImplementationLookup;
import org.apache.syncope.client.ui.commons.DynamicMenuRegister;
import org.apache.syncope.client.ui.commons.actuate.SyncopeCoreHealthIndicator;
import org.apache.syncope.common.keymaster.client.api.ServiceOps;
import org.apache.syncope.common.keymaster.client.api.model.NetworkService;
Expand Down Expand Up @@ -62,9 +63,10 @@ public SyncopeWebApplication syncopeWebApplication(
final EnduserProperties props,
final ClassPathScanImplementationLookup lookup,
final ServiceOps serviceOps,
final List<IResource> resources) {
final List<IResource> resources,
final DynamicMenuRegister dynamicMenuRegister) {

return new SyncopeWebApplication(resourceLoader, props, lookup, serviceOps, resources);
return new SyncopeWebApplication(resourceLoader, props, lookup, serviceOps, resources, dynamicMenuRegister);
}

@ConditionalOnMissingBean
Expand Down
Loading
Loading