/**
 * AET
 *
 * Copyright (C) 2013 Cognifide Limited
 *
 * Licensed 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 com.cognifide.aet.rest.helpers;

import java.util.Map;
import java.util.Optional;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;

@Service(ReportConfigurationManager.class)
@Component(metatype = true, description = "AET Report Application Configuration",
    label = "AET Report Application Configuration")
public class ReportConfigurationManager {

  private static final String REPORT_DOMAIN_PROPERTY_NAME = "report-domain";

  private static final String DEFAULT_REPORT_DOMAIN = "http://aet-vagrant";

  private static final String REPORT_DOMAIN_ENV = "REPORT_DOMAIN";

  @Property(name = REPORT_DOMAIN_PROPERTY_NAME, label = "Report application domain",
      description = "Report application domain", value = DEFAULT_REPORT_DOMAIN)
  private String reportDomain;

  @Activate
  public void activate(Map<String, String> properties) {
    reportDomain = Optional.ofNullable(System.getenv(REPORT_DOMAIN_ENV))
        .orElse(PropertiesUtil
            .toString(properties.get(REPORT_DOMAIN_PROPERTY_NAME), DEFAULT_REPORT_DOMAIN));
  }

  public String getReportDomain() {
    return reportDomain;
  }
}

@@ -892,61 +892,8 @@
 ice;
-%0Aimport org.apache.sling.commons.osgi.PropertiesUtil;
 %0A%0A@S
@@ -1464,17 +1464,196 @@
 n domain
-%22
+ that is printed at the end of processing suite. %22%0A          + %22If not provided here, env variable REPORT_DOMAIN will be used instead or value will fallback to the default.%22%0A      
 , value 
@@ -1821,21 +1821,22 @@
 ble(
-System
+properties
 .get
-env
 (REP
@@ -1846,19 +1846,29 @@
 _DOMAIN_
-ENV
+PROPERTY_NAME
 ))%0A     
@@ -1881,60 +1881,51 @@
 Else
-(PropertiesUtil%0A            .toString(properties
+Get(() -%3E Optional.ofNullable(System
 .get
+env
 (REP
@@ -1939,24 +1939,34 @@
 AIN_
-PROPERTY_NAME), 
+ENV))%0A            .orElse(
 DEFA

change the property resolving priority