dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39702
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20119: more j8 streams in ModuleManager
------------------------------------------------------------
revno: 20119
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-14 14:26:55 +0700
message:
more j8 streams in ModuleManager
modified:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2015-09-14 07:22:16 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2015-09-14 07:26:55 +0000
@@ -48,6 +48,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author Torgeir Lorange Ostby
@@ -151,10 +152,7 @@
List<Module> modules = getAccessibleMenuModules();
List<App> apps = appManager.getAccessibleApps();
- for ( App app : apps )
- {
- modules.add( Module.getModule( app ) );
- }
+ modules.addAll( apps.stream().map( Module::getModule ).collect( Collectors.toList() ) );
return modules;
}
@@ -264,15 +262,9 @@
private List<Module> getAccessibleModules( List<Module> modules )
{
- List<Module> allowed = new ArrayList<>();
-
- for ( Module module : modules )
- {
- if ( module != null && actionAccessResolver.hasAccess( module.getName(), defaultActionName ) )
- {
- allowed.add( module );
- }
- }
+ List<Module> allowed = modules.stream()
+ .filter( module -> module != null && actionAccessResolver.hasAccess( module.getName(), defaultActionName ) )
+ .collect( Collectors.toList() );
if ( modules.size() > allowed.size() )
{