public Mapping()

in src/main/java/org/apache/sling/serviceusermapping/Mapping.java [64:96]


    public Mapping(final String spec) {

        final int colon = spec.indexOf(':');
        final int equals = spec.indexOf('=');

        if (colon == 0 || equals <= 0) {
            throw new IllegalArgumentException("serviceName is required");
        } else if (equals == spec.length() - 1) {
            throw new IllegalArgumentException("userName or principalNames is required");
        } else if (colon + 1 == equals) {
            throw new IllegalArgumentException("serviceInfo must not be empty");
        }

        if (colon < 0 || colon > equals) {
            this.serviceName = spec.substring(0, equals);
            this.subServiceName = null;
            this.identity = this.serviceName;
        } else {
            this.serviceName = spec.substring(0, colon);
            this.subServiceName = spec.substring(colon + 1, equals);
            this.identity = this.serviceName + "-" + this.subServiceName;
        }

        String s = spec.substring(equals + 1);
        if (s.charAt(0) == '[' && s.charAt(s.length()-1) == ']') {
            this.userName = null;
            this.principalNames = extractPrincipalNames(s);
        } else {
            this.userName = s;
            this.principalNames = null;
            log.warn("Deprecated service mapping by userId, refactor to mapping by principal names (e.g. '{}{}=[{}]').", serviceName, ((subServiceName == null) ? "" : ":"+subServiceName) , s);
        }
    }