private Properties removeInstancePrefix()

in src/main/java/org/apache/sling/testing/serversetup/instance/SlingInstanceManager.java [53:79]


    private Properties removeInstancePrefix(Properties properties, String instanceName) {
        Properties result = new Properties();
        for (Object propertyKey : properties.keySet()) {
            Object propertyValue = properties.get(propertyKey);

            if (propertyKey instanceof String) {
                String propertyName = (String) propertyKey;
                String instancePropertyName = null;
                if (propertyName.startsWith(instanceName + ".")) {
                    instancePropertyName = propertyName.substring(instanceName.length()+1);
                }

                if (instancePropertyName != null) {
                    result.put(instancePropertyName, propertyValue);
                }
                else if (!result.containsKey(propertyName)) {
                    result.put(propertyName, propertyValue);
                }
            }
            else {
                result.put(propertyKey, propertyValue);

            }
        }

        return result;
    }