* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.oam.util;
+package org.onap.appc.oam.util;
import com.att.eelf.configuration.EELFLogger;
import org.apache.commons.lang3.ArrayUtils;
-import org.openecomp.appc.Constants;
-import org.openecomp.appc.configuration.Configuration;
-import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.onap.appc.Constants;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+
+import java.util.concurrent.TimeUnit;
/**
* Utility class provides general configuration helps
public class ConfigurationHelper {
final static String PROP_KEY_APPC_NAME = Constants.PROPERTY_APPLICATION_NAME;
final static String PROP_KEY_METRIC_STATE = "metric.enabled";
+ private final String OAM_OPERATION_TIMEOUT_SECOND = "appc.OAM.api.timeout";
+ /** Default operation timeout set to 1 minute */
+ private final int DEFAULT_OAM_OPERATION_TIMEOUT = 60;
private final EELFLogger logger;
private Configuration configuration = ConfigurationFactory.getConfiguration();
}
/**
- * Read property value of a specified proeprty key
+ * Read property value of a specified property key
*
* @param propertyKey string of the property key
* @return String[] of the property values associated with the propertyKey
}
return new String[]{propertyValue};
}
+
+
+
+
+
+ /**
+ * This method returns timeout in milliseconds. The source is chosen in the following order:
+ * The overrideTimeoutSeconds argument
+ * or {@link #OAM_OPERATION_TIMEOUT_SECOND} found in the configuration file
+ * or the {@link #DEFAULT_OAM_OPERATION_TIMEOUT}
+ * @param overrideTimeoutSeconds or null to us the other sources
+ * @return timeout in milliseconds
+ */
+ public long getOAMOperationTimeoutValue(Integer overrideTimeoutSeconds) {
+ return TimeUnit.SECONDS.toMillis(
+ overrideTimeoutSeconds == null ?
+ getConfig().getIntegerProperty(OAM_OPERATION_TIMEOUT_SECOND, DEFAULT_OAM_OPERATION_TIMEOUT)
+ :
+ overrideTimeoutSeconds
+ );
+ }
}