diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractComponent.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractComponent.java index d63e2b16dc2..053bb35dacf 100755 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractComponent.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractComponent.java @@ -1,7 +1,5 @@ package com.sap.sse.gwt.client.shared.components; -import java.util.ArrayList; - import com.sap.sse.common.settings.Settings; import com.sap.sse.gwt.client.shared.settings.ComponentContext; @@ -19,11 +17,6 @@ public abstract class AbstractComponent implement return parentComponent; } - @Override - public ArrayList getPath() { - return ComponentPathDeterminer.determinePath(this); - } - @Override public final ComponentContext getComponentContext() { return componentContext; diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractCompositeComponent.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractCompositeComponent.java index 9ead8952660..73bc6b3f7cb 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractCompositeComponent.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractCompositeComponent.java @@ -1,7 +1,5 @@ package com.sap.sse.gwt.client.shared.components; -import java.util.ArrayList; - import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.Composite; import com.sap.sse.common.settings.Settings; @@ -26,11 +24,6 @@ public abstract class AbstractCompositeComponent return parentComponent; } - @Override - public ArrayList getPath() { - return ComponentPathDeterminer.determinePath(this); - } - @Override public ComponentContext getComponentContext() { return componentContext; diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractLazyComponent.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractLazyComponent.java index 075cde4235e..1fba8ec5e66 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractLazyComponent.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/AbstractLazyComponent.java @@ -1,7 +1,5 @@ package com.sap.sse.gwt.client.shared.components; -import java.util.ArrayList; - import com.google.gwt.user.client.ui.LazyPanel; import com.google.gwt.user.client.ui.Widget; import com.sap.sse.common.settings.Settings; @@ -32,11 +30,6 @@ public abstract class AbstractLazyComponent exten return parent; } - @Override - public ArrayList getPath() { - return ComponentPathDeterminer.determinePath(this); - } - @Override public ComponentContext getComponentContext() { return componentContext; diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/Component.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/Component.java index 1df8b94ce4c..356321f30c3 100755 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/Component.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/Component.java @@ -8,7 +8,15 @@ import com.sap.sse.gwt.client.shared.perspective.Perspective; import com.sap.sse.gwt.client.shared.settings.ComponentContext; public interface Component { - ArrayList getPath(); + default Iterable getPath() { + ArrayList path = new ArrayList<>(); + Component cur = this; + while (cur.getParentComponent() != null) { + path.add(0, cur.getId()); + cur = cur.getParentComponent(); + } + return path; + }; /** * Each component instance has an ID that has to be unique in the context in which the component is used diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/ComponentPathDeterminer.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/ComponentPathDeterminer.java deleted file mode 100644 index 6c57505707d..00000000000 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/components/ComponentPathDeterminer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.sap.sse.gwt.client.shared.components; - -import java.util.ArrayList; - -public class ComponentPathDeterminer { - private ComponentPathDeterminer() { - } - - /** - * Helper that generates a path array, based on the parent's in a component, can probably be removed one java8 can - * be used, with a default implementation in component - * - * @param abstractComponent - * @return - */ - static ArrayList determinePath(Component start) { - ArrayList path = new ArrayList<>(); - Component cur = start; - while (true) { - if (cur == null || cur.getParentComponent() == null) { - return path; - } - path.add(cur.getId()); - cur = cur.getParentComponent(); - } - } -} diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/ComponentUtils.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/ComponentUtils.java index 21e50001d90..a9a0681d44e 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/ComponentUtils.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/ComponentUtils.java @@ -2,6 +2,7 @@ package com.sap.sse.gwt.client.shared.settings; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -25,26 +26,28 @@ public class ComponentUtils { * When the path cannot be resolved from the provided root lifecycle */ @SuppressWarnings("unchecked") - public static ComponentLifecycle determineLifecycle(List path, + public static ComponentLifecycle determineLifecycle(Iterable path, ComponentLifecycle current) { - while (current instanceof PerspectiveLifecycle && !path.isEmpty()) { - String last = path.remove(path.size() - 1); + final Iterator pathIterator = path.iterator(); + while (current instanceof PerspectiveLifecycle && pathIterator.hasNext()) { + String last = pathIterator.next(); current = ((PerspectiveLifecycle) current).getLifecycleForId(last); } - if (!path.isEmpty() || current == null) { + if (pathIterator.hasNext() || current == null) { throw new IllegalStateException("Settings path is not finished, but no perspective at current level"); } return (ComponentLifecycle) current; } @SuppressWarnings("unchecked") - public static CS determineComponentSettingsFromPerspectiveSettings(List path, + public static CS determineComponentSettingsFromPerspectiveSettings(Iterable path, Settings current) { - while (current instanceof PerspectiveCompositeSettings && !path.isEmpty()) { - String last = path.remove(path.size() - 1); + final Iterator pathIterator = path.iterator(); + while (current instanceof PerspectiveCompositeSettings && pathIterator.hasNext()) { + String last = pathIterator.next(); current = ((PerspectiveCompositeSettings) current).findSettingsByComponentId(last); } - if (!path.isEmpty() || current == null) { + if (pathIterator.hasNext() || current == null) { throw new IllegalStateException("Settings path is not finished, but no settings at current level"); } return (CS) current; diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/SettingsBuildingPipeline.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/SettingsBuildingPipeline.java index 3c249e41572..8f101e68bea 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/SettingsBuildingPipeline.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/SettingsBuildingPipeline.java @@ -1,7 +1,5 @@ package com.sap.sse.gwt.client.shared.settings; -import java.util.List; - import com.sap.sse.common.settings.Settings; /** @@ -48,7 +46,7 @@ public interface SettingsBuildingPipeline { * @return The storable settings representation of provided settings as User Settings */ StorableSettingsRepresentation getStorableRepresentationOfUserSettings(CS newSettings, - CS newInstance, List path); + CS newInstance, Iterable path); /** * Converts the provided settings according to storable settings representation for Document Settings. This method @@ -68,6 +66,6 @@ public interface SettingsBuildingPipeline { */ StorableSettingsRepresentation getStorableRepresentationOfDocumentSettings(CS newSettings, CS newInstance, StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, - List path); + Iterable path); } diff --git a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/StorableSettingsRepresentation.java b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/StorableSettingsRepresentation.java index 49afa3c428b..57028c1bd78 100644 --- a/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/StorableSettingsRepresentation.java +++ b/java/com.sap.sse.gwt/src/com/sap/sse/gwt/client/shared/settings/StorableSettingsRepresentation.java @@ -1,7 +1,6 @@ package com.sap.sse.gwt.client.shared.settings; -import java.util.ArrayList; -import java.util.Collections; +import java.util.Iterator; import java.util.List; import com.google.gwt.core.client.GWT; @@ -76,9 +75,9 @@ public class StorableSettingsRepresentation { * @return The patched storable settings representation */ public static StorableSettingsRepresentation patchSettingsRepresentation(StorableSettingsRepresentation root, - List path, StorableSettingsRepresentation newSettings) { - JSONObject patchedSettingsJsonRepresentation = patchJsonObject(root == null ? null : root.asJson(), path, - Collections.unmodifiableList(new ArrayList<>(path)), newSettings==null?null:newSettings.asJson()); + Iterable path, StorableSettingsRepresentation newSettings) { + JSONObject patchedSettingsJsonRepresentation = patchJsonObject(root == null ? null : root.asJson(), + path.iterator(), newSettings == null ? null : newSettings.asJson()); return new StorableSettingsRepresentation(patchedSettingsJsonRepresentation); } @@ -93,17 +92,17 @@ public class StorableSettingsRepresentation { * @param pipelineLevel * @return */ - private static JSONObject patchJsonObject(JSONObject root, List path, List originalPath, + private static JSONObject patchJsonObject(JSONObject root, Iterator path, JSONObject newSettings) { - if (path.isEmpty()) { + if (!path.hasNext()) { return newSettings; } if (root == null) { root = new JSONObject(); } - String current = path.remove(path.size() - 1); + String current = path.next(); // we need to go further - if (!path.isEmpty()) { + if (path.hasNext()) { JSONValue child = root.get(current); boolean haskey = root.containsKey(current); if (child == null || child.isObject() == null) { @@ -117,22 +116,22 @@ public class StorableSettingsRepresentation { child = new JSONObject(); root.put(current, child); } - return patchJsonObject(child.isObject(), path, originalPath, newSettings); + return patchJsonObject(child.isObject(), path, newSettings); } else { root.put(current, newSettings); } return root; } - public StorableSettingsRepresentation getSubSettingsRepresentation(List subPath) { - return new StorableSettingsRepresentation(getSubSettingsRepresentation(internalSettingsRepresentation, new ArrayList<>(subPath))); + public StorableSettingsRepresentation getSubSettingsRepresentation(Iterable subPath) { + return new StorableSettingsRepresentation(getSubSettingsRepresentation(internalSettingsRepresentation, subPath.iterator())); } - public static JSONObject getSubSettingsRepresentation(JSONObject root, List subPath) { - if (subPath.isEmpty()) { + public static JSONObject getSubSettingsRepresentation(JSONObject root, Iterator subPath) { + if (!subPath.hasNext()) { return root; } else { - String current = subPath.remove(subPath.size() - 1); + String current = subPath.next(); // we need to go further JSONValue child = root.get(current); boolean haskey = root.containsKey(current); diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/ComponentContextWithSettingsStorage.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/ComponentContextWithSettingsStorage.java index 1e82eea6ebd..c09dc1bb917 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/ComponentContextWithSettingsStorage.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/ComponentContextWithSettingsStorage.java @@ -1,8 +1,5 @@ package com.sap.sse.security.ui.settings; -import java.util.ArrayList; -import java.util.List; - import com.sap.sse.common.settings.Settings; import com.sap.sse.common.settings.generic.GenericSerializableSettings; import com.sap.sse.common.settings.generic.SettingsMap; @@ -204,8 +201,8 @@ public class ComponentContextWithSettingsStorage extends Sim @Override public void makeSettingsDefault(Component component, CS newDefaultSettings, final OnSettingsStoredCallback onSettingsStoredCallback) { - List path = component.getPath(); - ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(new ArrayList<>(path), + Iterable path = component.getPath(); + ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(path, rootLifecycle); CS userSettings = targetLifecycle.extractUserSettings(newDefaultSettings); updateUserSettings(path, userSettings, targetLifecycle.createDefaultSettings(), onSettingsStoredCallback); @@ -226,8 +223,8 @@ public class ComponentContextWithSettingsStorage extends Sim @Override public void storeSettingsForContext(Component component, CS newSettings, OnSettingsStoredCallback onSettingsStoredCallback) { - List path = component.getPath(); - ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(new ArrayList<>(path), + Iterable path = component.getPath(); + ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(path, rootLifecycle); CS documentSettings = targetLifecycle.extractDocumentSettings(newSettings); updateDocumentSettings(component.getPath(), documentSettings, targetLifecycle.createDefaultSettings(), @@ -237,14 +234,14 @@ public class ComponentContextWithSettingsStorage extends Sim @Override public void resetSettingsToDefault(Component component, CS newSettings, OnSettingsLoadedCallback onSettingsStoredCallback) { - List path = component.getPath(); - ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(new ArrayList<>(path), + Iterable path = component.getPath(); + ComponentLifecycle targetLifecycle = ComponentUtils.determineLifecycle(path, rootLifecycle); removeGlobalAndContextSettings(path, targetLifecycle, new OnSettingsStoredCallback() { @Override public void onSuccess() { - getInitialSettingsForComponent(component, onSettingsStoredCallback); + getInitialSettingsForComponent(component, onSettingsStoredCallback); } @Override @@ -255,7 +252,7 @@ public class ComponentContextWithSettingsStorage extends Sim } - private void removeGlobalAndContextSettings(List path, ComponentLifecycle targetLifecycle, + private void removeGlobalAndContextSettings(Iterable path, ComponentLifecycle targetLifecycle, OnSettingsStoredCallback onSettingsStoredCallback) { settingsStorageManager.retrieveSettingsRepresentation( new OnSettingsLoadedCallback() { @@ -270,11 +267,11 @@ public class ComponentContextWithSettingsStorage extends Sim public void onSuccess(StorableRepresentationOfDocumentAndUserSettings settingsRepresentation) { StorableSettingsRepresentation documentSettingsRepresentationRoot = StorableSettingsRepresentation .patchSettingsRepresentation(settingsRepresentation.getDocumentSettingsRepresentation(), - new ArrayList<>(path), null); + path, null); StorableSettingsRepresentation userSettingsRepresentationRoot = StorableSettingsRepresentation .patchSettingsRepresentation(settingsRepresentation.getUserSettingsRepresentation(), - new ArrayList<>(path), null); + path, null); StorableRepresentationOfDocumentAndUserSettings settingsRepresentationToStore = new StorableRepresentationOfDocumentAndUserSettings( userSettingsRepresentationRoot, documentSettingsRepresentationRoot); @@ -300,7 +297,7 @@ public class ComponentContextWithSettingsStorage extends Sim * @param onSettingsStoredCallback * The callback which is called when the settings storage process finishes */ - private void updateUserSettings(final List path, final Settings newUserSettings, final CS newInstance, + private void updateUserSettings(final Iterable path, final Settings newUserSettings, final CS newInstance, final OnSettingsStoredCallback onSettingsStoredCallback) { settingsStorageManager.retrieveSettingsRepresentation( new OnSettingsLoadedCallback() { @@ -315,7 +312,7 @@ public class ComponentContextWithSettingsStorage extends Sim public void onSuccess(StorableRepresentationOfDocumentAndUserSettings settingsRepresentation) { StorableSettingsRepresentation newUserSettingsRepresentationOfComponent = settingsBuildingPipeline.getStorableRepresentationOfUserSettings(newUserSettings, newInstance, path); StorableSettingsRepresentation userSettingsRepresentationRoot = StorableSettingsRepresentation.patchSettingsRepresentation( - settingsRepresentation.getUserSettingsRepresentation(), new ArrayList<>(path), + settingsRepresentation.getUserSettingsRepresentation(), path, newUserSettingsRepresentationOfComponent); cachedSettingsRepresentation = new StorableRepresentationOfDocumentAndUserSettings( @@ -346,7 +343,7 @@ public class ComponentContextWithSettingsStorage extends Sim * @param onSettingsStoredCallback * The callback which is called when the settings storage process finishes */ - private void updateDocumentSettings(final ArrayList path, final CS newDocumentSettings, final CS newInstance, + private void updateDocumentSettings(final Iterable path, final CS newDocumentSettings, final CS newInstance, final OnSettingsStoredCallback onSettingsStoredCallback) { settingsStorageManager.retrieveSettingsRepresentation( new OnSettingsLoadedCallback() { @@ -361,7 +358,7 @@ public class ComponentContextWithSettingsStorage extends Sim public void onSuccess(StorableRepresentationOfDocumentAndUserSettings settingsRepresentation) { StorableSettingsRepresentation newDocumentSettingsRepresentationOfComponent = settingsBuildingPipeline.getStorableRepresentationOfDocumentSettings(newDocumentSettings, newInstance, cachedSettingsRepresentation, path); StorableSettingsRepresentation documentSettingsRepresentationRoot = StorableSettingsRepresentation.patchSettingsRepresentation( - settingsRepresentation.getDocumentSettingsRepresentation(), new ArrayList<>(path), + settingsRepresentation.getDocumentSettingsRepresentation(), path, newDocumentSettingsRepresentationOfComponent); cachedSettingsRepresentation = new StorableRepresentationOfDocumentAndUserSettings( diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/SimpleComponentContext.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/SimpleComponentContext.java index 4a005e9e8b4..0b7b7322e51 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/SimpleComponentContext.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/SimpleComponentContext.java @@ -1,7 +1,5 @@ package com.sap.sse.security.ui.settings; -import java.util.ArrayList; - import com.sap.sse.common.settings.Settings; import com.sap.sse.gwt.client.shared.components.Component; import com.sap.sse.gwt.client.shared.components.ComponentLifecycle; @@ -155,14 +153,14 @@ public class SimpleComponentContext implements ComponentCont @Override public void onError(Throwable caught, S fallbackDefaultSettings) { CS componentFallbackSettings = ComponentUtils.determineComponentSettingsFromPerspectiveSettings( - new ArrayList<>(component.getPath()), fallbackDefaultSettings); + component.getPath(), fallbackDefaultSettings); callback.onError(caught, componentFallbackSettings); } @Override public void onSuccess(S settings) { CS componentSettings = ComponentUtils.determineComponentSettingsFromPerspectiveSettings( - new ArrayList<>(component.getPath()), settings); + component.getPath(), settings); callback.onSuccess(componentSettings); } }; diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UrlSettingsBuildingPipeline.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UrlSettingsBuildingPipeline.java index a2e4d28ce4c..41dd5edee05 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UrlSettingsBuildingPipeline.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UrlSettingsBuildingPipeline.java @@ -1,7 +1,5 @@ package com.sap.sse.security.ui.settings; -import java.util.List; - import com.sap.sse.common.settings.Settings; import com.sap.sse.gwt.client.shared.settings.ComponentContext; import com.sap.sse.gwt.client.shared.settings.SettingsBuildingPipeline; @@ -56,7 +54,7 @@ public class UrlSettingsBuildingPipeline implements SettingsBuildingPipeline { * representation, because it is supposed to be used by read-only {@link ComponentContext} implementations. */ @Override - public StorableSettingsRepresentation getStorableRepresentationOfUserSettings(CS newSettings, CS newInstance, List path) { + public StorableSettingsRepresentation getStorableRepresentationOfUserSettings(CS newSettings, CS newInstance, Iterable path) { throw new UnsupportedOperationException("This pipeline does not support JSON conversion"); } @@ -65,7 +63,7 @@ public class UrlSettingsBuildingPipeline implements SettingsBuildingPipeline { * representation, because it is supposed to be used by read-only {@link ComponentContext} implementations. */ @Override - public StorableSettingsRepresentation getStorableRepresentationOfDocumentSettings(CS newSettings, CS newInstance, StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, List path) { + public StorableSettingsRepresentation getStorableRepresentationOfDocumentSettings(CS newSettings, CS newInstance, StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, Iterable path) { throw new UnsupportedOperationException("This pipeline does not support JSON conversion"); } diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipeline.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipeline.java index 6b72976da04..63b77fa8697 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipeline.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipeline.java @@ -1,7 +1,5 @@ package com.sap.sse.security.ui.settings; -import java.util.List; - import com.sap.sse.common.settings.Settings; import com.sap.sse.common.settings.generic.support.SettingsUtil; import com.sap.sse.gwt.client.shared.settings.SettingsRepresentationTransformer; @@ -86,7 +84,7 @@ public class UserSettingsBuildingPipeline extends UrlSettingsBuildingPipeline { */ @Override public StorableSettingsRepresentation getStorableRepresentationOfUserSettings(CS newSettings, - CS newInstance, List path) { + CS newInstance, Iterable path) { return settingsRepresentationTransformer.convertToSettingsRepresentation(newSettings); } @@ -112,7 +110,7 @@ public class UserSettingsBuildingPipeline extends UrlSettingsBuildingPipeline { @Override public StorableSettingsRepresentation getStorableRepresentationOfDocumentSettings( CS newSettings, CS newInstance, - StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, List path) { + StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, Iterable path) { CS documentSettingsWithUserSettingsDiff; if (previousSettingsRepresentation.hasStoredUserSettings()) { CS pipelinedSettings = SettingsUtil.copyDefaultsFromValues(newInstance, newInstance); diff --git a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipelineWithAdditionalSettingsLayers.java b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipelineWithAdditionalSettingsLayers.java index 5fff33c8262..c517b1095d6 100644 --- a/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipelineWithAdditionalSettingsLayers.java +++ b/java/com.sap.sse.security.ui/src/main/java/com/sap/sse/security/ui/settings/UserSettingsBuildingPipelineWithAdditionalSettingsLayers.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import com.sap.sse.common.Util; import com.sap.sse.common.settings.Settings; import com.sap.sse.common.settings.generic.GenericSerializableSettings; import com.sap.sse.common.settings.generic.support.SettingsUtil; @@ -84,16 +85,16 @@ public class UserSettingsBuildingPipelineWithAdditionalSettingsLayers extends Us } protected static CS applyPatchesForPipelineLevel(CS currentSettings, - PipelineLevel pipelineLevel, List absolutePathOfComponentWithSettings, + PipelineLevel pipelineLevel, Iterable absolutePathOfComponentWithSettings, SettingsPatches settingsPatchesToConsider) { CS effectiveSettings = currentSettings; for (Entry, List>> entry : settingsPatchesToConsider .getSettingsPatches(pipelineLevel).entrySet()) { List path = new ArrayList<>(entry.getKey()); - if (path.size() >= absolutePathOfComponentWithSettings.size() - && path.subList(path.size() - absolutePathOfComponentWithSettings.size(), path.size()) + if (path.size() >= Util.size(absolutePathOfComponentWithSettings) + && path.subList(path.size() - Util.size(absolutePathOfComponentWithSettings), path.size()) .equals(absolutePathOfComponentWithSettings)) { - path = path.subList(0, path.size() - absolutePathOfComponentWithSettings.size()); + path = path.subList(0, path.size() - Util.size(absolutePathOfComponentWithSettings)); List> settingsPatches = entry.getValue(); if (!settingsPatches.isEmpty()) { Settings patchedComponentSettings = ComponentUtils @@ -136,7 +137,7 @@ public class UserSettingsBuildingPipelineWithAdditionalSettingsLayers extends Us */ @Override public StorableSettingsRepresentation getStorableRepresentationOfUserSettings(CS newSettings, - CS newInstance, List path) { + CS newInstance, Iterable path) { CS pipelinedSettings = SettingsUtil.copyDefaultsFromValues(newInstance, newInstance); pipelinedSettings = SettingsUtil.copyDefaults(newSettings, newInstance); // overrides values which are set to // default values @@ -173,7 +174,7 @@ public class UserSettingsBuildingPipelineWithAdditionalSettingsLayers extends Us @Override public StorableSettingsRepresentation getStorableRepresentationOfDocumentSettings( CS newSettings, CS newInstance, - StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, List path) { + StorableRepresentationOfDocumentAndUserSettings previousSettingsRepresentation, Iterable path) { CS pipelinedSettings = SettingsUtil.copyDefaultsFromValues(newInstance, newInstance); pipelinedSettings = SettingsUtil.copyDefaults(newSettings, newInstance); // overrides values which are set to // default values @@ -241,7 +242,7 @@ public class UserSettingsBuildingPipelineWithAdditionalSettingsLayers extends Us private Map, List>>> patchesForSettings = new HashMap<>(); - public void addSettingsPatch(List path, SettingsPatch settingsPatch, + public void addSettingsPatch(Iterable path, SettingsPatch settingsPatch, PipelineLevel pipelineLevel) { Map, List>> pipelinePatches = patchesForSettings .get(pipelineLevel); @@ -252,7 +253,7 @@ public class UserSettingsBuildingPipelineWithAdditionalSettingsLayers extends Us List> componentPatches = pipelinePatches.get(path); if (componentPatches == null) { componentPatches = new ArrayList<>(); - pipelinePatches.put(path, componentPatches); + pipelinePatches.put(Util.asList(path), componentPatches); } componentPatches.add(settingsPatch); }