diff options
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp')
86 files changed, 3515 insertions, 3117 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java index c4f221c875..b0c377c778 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java @@ -20,686 +20,725 @@ package org.openecomp.sdc.be.config; +import org.apache.commons.collections.map.CaseInsensitiveMap; import org.openecomp.sdc.common.api.BasicConfiguration; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; -import static java.lang.String.format; +import static java.lang.String.format; import static java.util.Collections.emptyMap; + public class Configuration extends BasicConfiguration { - private List<String> identificationHeaderFields; - /** - * Requests from these Urls will not be logged by - * org.openecomp.sdc.be.filters.BeServletFilter.<br> - **/ - private List<String> unLoggedUrls; - - /** - * backend host - */ - private String beFqdn; - /** - * backend http port - */ - private Integer beHttpPort; - /** - * backend http secured port - */ - private Integer beSslPort; - /** - * be http context - */ - private String beContext; - /** - * backend protocol. http | https - */ - private String beProtocol = "http"; - - private Date released; - private String version = "1111"; - private String toscaConformanceLevel = "3.0"; - private String minToscaConformanceLevel = "3.0"; - private List<String> protocols; - private Map<String, String> users; - private Map<String, Object> neo4j; - private ElasticSearchConfig elasticSearch; - private String titanCfgFile; - private String titanMigrationKeySpaceCfgFile; - private Boolean titanInMemoryGraph; - private int startMigrationFrom; - private Long titanLockTimeout; - private Long titanReconnectIntervalInSeconds; - private List<String> healthStatusExclude; - private Long titanHealthCheckReadTimeout; - private Long esReconnectIntervalInSeconds; - private Long uebHealthCheckReconnectIntervalInSeconds; - private Long uebHealthCheckReadTimeout; - private List<Map<String, Map<String, String>>> defaultImports; - - private List<String> resourceTypes; - private List<String> excludeResourceCategory; - private List<String> excludeResourceType; - private Map<String, Set<String>> excludedPolicyTypesMapping; - - private Map<String, Set<String>> excludedGroupTypesMapping; - private Map<String, Object> deploymentResourceArtifacts; - private Map<String, Object> deploymentResourceInstanceArtifacts; - private Map<String, Object> toscaArtifacts; - private Map<String, Object> informationalResourceArtifacts; - private Map<String, Object> informationalServiceArtifacts; - private Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts; - private Map<String, ArtifactTypeConfig> resourceInformationalArtifacts; - private Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts; - private Map<String, Object> serviceApiArtifacts; - private List<String> excludeServiceCategory; - private Map<String, Set<String>> requirementsToFulfillBeforeCert; - private Map<String, Set<String>> capabilitiesToConsumeBeforeCert; - - private List<String> artifactTypes; - private List<String> licenseTypes; - - private Integer additionalInformationMaxNumberOfKeys; - private Integer defaultHeatArtifactTimeoutMinutes; - - private BeMonitoringConfig systemMonitoring; - private CleanComponentsConfiguration cleanComponentsConfiguration; - - private String artifactsIndex; - - private String heatEnvArtifactHeader; - private String heatEnvArtifactFooter; - - private String toscaFilesDir; - private String heatTranslatorPath; - - private OnboardingConfig onboarding; - - private DcaeConfig dcae; - - private CassandrConfig cassandraConfig; - - private SwitchoverDetectorConfig switchoverDetector; - - private ApplicationL1CacheConfig applicationL1Cache; - - private ApplicationL2CacheConfig applicationL2Cache; - - private ToscaValidatorsConfig toscaValidators; - - private boolean disableAudit; - - private Map<String, VfModuleProperty> vfModuleProperties; - - private Map<String, String> genericAssetNodeTypes; - - private String appVersion; - private String artifactGeneratorConfig; - - public String getAutoHealingOwner() { - return autoHealingOwner; - } - - public void setAutoHealingOwner(String autoHealingOwner) { - this.autoHealingOwner = autoHealingOwner; - } - - private String autoHealingOwner; - - private Map<String, List<String>> resourcesForUpgrade; - private DmaapConsumerConfiguration dmaapConsumerConfiguration; - private boolean skipUpgradeFailedVfs; - private boolean skipUpgradeVSPs; - private DmeConfiguration dmeConfiguration; - - public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { - return dmaapConsumerConfiguration; - } - - public void setDmaapConsumerConfiguration(DmaapConsumerConfiguration dmaapConsumerConfiguration) { - this.dmaapConsumerConfiguration = dmaapConsumerConfiguration; - } - - public DmeConfiguration getDmeConfiguration() { - return dmeConfiguration; - } - - public void setDmeConfiguration(DmeConfiguration dmeConfiguration) { - this.dmeConfiguration = dmeConfiguration; - } - public void setSkipUpgradeVSPs(boolean skipUpgradeVSPs) { this.skipUpgradeVSPs = skipUpgradeVSPs; } + private List<String> identificationHeaderFields; + /** + * Requests from these Urls will not be logged by + * org.openecomp.sdc.be.filters.BeServletFilter.<br> + **/ + private List<String> unLoggedUrls; + + /** + * backend host + */ + private String beFqdn; + /** + * backend http port + */ + private Integer beHttpPort; + /** + * backend http secured port + */ + private Integer beSslPort; + /** + * be http context + */ + private String beContext; + /** + * backend protocol. http | https + */ + private String beProtocol = "http"; + + private Date released; + private String version = "1111"; + private String toscaConformanceLevel = "3.0"; + private String minToscaConformanceLevel = "3.0"; + private List<String> protocols; + private Map<String, String> users; + private Map<String, Object> neo4j; + private ElasticSearchConfig elasticSearch; + private String titanCfgFile; + private String titanMigrationKeySpaceCfgFile; + private Boolean titanInMemoryGraph; + private int startMigrationFrom; + private Long titanLockTimeout; + private Long titanReconnectIntervalInSeconds; + private List<String> healthStatusExclude; + private Long titanHealthCheckReadTimeout; + private Long esReconnectIntervalInSeconds; + private Long uebHealthCheckReconnectIntervalInSeconds; + private Long uebHealthCheckReadTimeout; + private List<Map<String, Map<String, String>>> defaultImports; + + private List<String> resourceTypes; + private List<String> excludeResourceCategory; + private List<String> excludeResourceType; + private Map<String, Set<String>> excludedPolicyTypesMapping; + + private Map<String, Set<String>> excludedGroupTypesMapping; + private Map<String, Object> deploymentResourceArtifacts; + private Map<String, Object> deploymentResourceInstanceArtifacts; + private Map<String, Object> toscaArtifacts; + private Map<String, Object> informationalResourceArtifacts; + private Map<String, Object> informationalServiceArtifacts; + private Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts; + private Map<String, ArtifactTypeConfig> resourceInformationalArtifacts; + private Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts; + private Map<String, Object> serviceApiArtifacts; + private List<String> excludeServiceCategory; + private Map<String, Set<String>> requirementsToFulfillBeforeCert; + private Map<String, Set<String>> capabilitiesToConsumeBeforeCert; + + private List<String> artifactTypes; + private List<String> licenseTypes; + + private Integer additionalInformationMaxNumberOfKeys; + private Integer defaultHeatArtifactTimeoutMinutes; + + private BeMonitoringConfig systemMonitoring; + private CleanComponentsConfiguration cleanComponentsConfiguration; + + private String artifactsIndex; + + private String heatEnvArtifactHeader; + private String heatEnvArtifactFooter; + + private String toscaFilesDir; + private String heatTranslatorPath; + + private OnboardingConfig onboarding; + + private DcaeConfig dcae; + + private CassandrConfig cassandraConfig; + + private SwitchoverDetectorConfig switchoverDetector; + + private ApplicationL1CacheConfig applicationL1Cache; + + private ApplicationL2CacheConfig applicationL2Cache; + + private ToscaValidatorsConfig toscaValidators; + + private boolean disableAudit; + + private Map<String, VfModuleProperty> vfModuleProperties; + + private Map<String, String> genericAssetNodeTypes; + + private String appVersion; + private String artifactGeneratorConfig; + + public String getAutoHealingOwner() { + return autoHealingOwner; + } + + public void setAutoHealingOwner(String autoHealingOwner) { + this.autoHealingOwner = autoHealingOwner; + } + + private String autoHealingOwner; + private boolean enableAutoHealing; + + private Map<String, List<String>> resourcesForUpgrade; + private DmaapConsumerConfiguration dmaapConsumerConfiguration; + private boolean skipUpgradeFailedVfs; + private boolean skipUpgradeVSPs; + private DmeConfiguration dmeConfiguration; + + private boolean supportAllottedResourcesAndProxy; + private Integer deleteLockTimeoutInSeconds; + private Integer maxDeleteComponents; + + public Integer getMaxDeleteComponents() { + return maxDeleteComponents; + } + + public void setMaxDeleteComponents(Integer maxDeleteComponents) { + this.maxDeleteComponents = maxDeleteComponents; + } + + public void setEnableAutoHealing(boolean enableAutoHealing) { + this.enableAutoHealing = enableAutoHealing; + } + + public boolean isEnableAutoHealing() { + return enableAutoHealing; + } + + public Integer getDeleteLockTimeoutInSeconds() { + return deleteLockTimeoutInSeconds; + } + + public void setDeleteLockTimeoutInSeconds(Integer deleteLockTimeoutInSeconds) { + this.deleteLockTimeoutInSeconds = deleteLockTimeoutInSeconds; + } + + public DmaapConsumerConfiguration getDmaapConsumerConfiguration() { + return dmaapConsumerConfiguration; + } + + public void setDmaapConsumerConfiguration(DmaapConsumerConfiguration dmaapConsumerConfiguration) { + this.dmaapConsumerConfiguration = dmaapConsumerConfiguration; + } + + public DmeConfiguration getDmeConfiguration() { + return dmeConfiguration; + } + + public void setDmeConfiguration(DmeConfiguration dmeConfiguration) { + this.dmeConfiguration = dmeConfiguration; + } + public void setSkipUpgradeVSPs(boolean skipUpgradeVSPs) { this.skipUpgradeVSPs = skipUpgradeVSPs; } + + public boolean getSkipUpgradeVSPsFlag() { return skipUpgradeVSPs; } + + public boolean getSkipUpgradeFailedVfs() { + return skipUpgradeFailedVfs; + } + + public boolean getSupportAllottedResourcesAndProxyFlag() { + return supportAllottedResourcesAndProxy; + } + + public void setSupportAllottedResourcesAndProxy(boolean supportAllottedResourcesAndProxy) { + this.supportAllottedResourcesAndProxy = supportAllottedResourcesAndProxy; + } + + public void setSkipUpgradeFailedVfs(boolean skipUpgradeFailedVfs) { + this.skipUpgradeFailedVfs = skipUpgradeFailedVfs; + } + + public String getAppVersion() { + return appVersion; + } - public boolean getSkipUpgradeVSPsFlag() { return skipUpgradeVSPs; } + public void setAppVersion(String appVersion) { + this.appVersion = appVersion; + } - public boolean getSkipUpgradeFailedVfs() { - return skipUpgradeFailedVfs; - } + public String getArtifactGeneratorConfig() { + return artifactGeneratorConfig; + } - public void setSkipUpgradeFailedVfs(boolean skipUpgradeFailedVfs) { - this.skipUpgradeFailedVfs = skipUpgradeFailedVfs; - } + public void setArtifactGeneratorConfig(String artifactGeneratorConfig) { + this.artifactGeneratorConfig = artifactGeneratorConfig; + } - public String getAppVersion() { - return appVersion; - } + private String workloadContext; - public void setAppVersion(String appVersion) { - this.appVersion = appVersion; - } + private EnvironmentContext environmentContext; - public String getArtifactGeneratorConfig() { - return artifactGeneratorConfig; - } + public Map<String, String> getGenericAssetNodeTypes() { + return genericAssetNodeTypes; + } - public void setArtifactGeneratorConfig(String artifactGeneratorConfig) { - this.artifactGeneratorConfig = artifactGeneratorConfig; - } + public void setGenericAssetNodeTypes(Map<String, String> genericAssetNodeTypes) { + this.genericAssetNodeTypes = genericAssetNodeTypes; + } - private String workloadContext; - - private EnvironmentContext environmentContext; + public SwitchoverDetectorConfig getSwitchoverDetector() { + return switchoverDetector; + } - public Map<String, String> getGenericAssetNodeTypes() { - return genericAssetNodeTypes; - } + public void setSwitchoverDetector(SwitchoverDetectorConfig switchoverDetector) { + this.switchoverDetector = switchoverDetector; + } - public void setGenericAssetNodeTypes(Map<String, String> genericAssetNodeTypes) { - this.genericAssetNodeTypes = genericAssetNodeTypes; - } + public ApplicationL1CacheConfig getApplicationL1Cache() { + return applicationL1Cache; + } - public SwitchoverDetectorConfig getSwitchoverDetector() { - return switchoverDetector; - } + public void setApplicationL1Cache(ApplicationL1CacheConfig applicationL1Cache) { + this.applicationL1Cache = applicationL1Cache; + } - public void setSwitchoverDetector(SwitchoverDetectorConfig switchoverDetector) { - this.switchoverDetector = switchoverDetector; - } + public ApplicationL2CacheConfig getApplicationL2Cache() { + return applicationL2Cache; + } - public ApplicationL1CacheConfig getApplicationL1Cache() { - return applicationL1Cache; - } + public void setApplicationL2Cache(ApplicationL2CacheConfig applicationL2Cache) { + this.applicationL2Cache = applicationL2Cache; + } - public void setApplicationL1Cache(ApplicationL1CacheConfig applicationL1Cache) { - this.applicationL1Cache = applicationL1Cache; - } + private EcompPortalConfig ecompPortal; - public ApplicationL2CacheConfig getApplicationL2Cache() { - return applicationL2Cache; - } + public CassandrConfig getCassandraConfig() { + return cassandraConfig; + } - public void setApplicationL2Cache(ApplicationL2CacheConfig applicationL2Cache) { - this.applicationL2Cache = applicationL2Cache; - } + public void setCassandraConfig(CassandrConfig cassandraKeySpace) { + this.cassandraConfig = cassandraKeySpace; + } - private EcompPortalConfig ecompPortal; + public List<String> getIdentificationHeaderFields() { + return identificationHeaderFields; + } - public CassandrConfig getCassandraConfig() { - return cassandraConfig; - } + public void setIdentificationHeaderFields(List<String> identificationHeaderFields) { + this.identificationHeaderFields = identificationHeaderFields; + } - public void setCassandraConfig(CassandrConfig cassandraKeySpace) { - this.cassandraConfig = cassandraKeySpace; - } + public Date getReleased() { + return released; + } - public List<String> getIdentificationHeaderFields() { - return identificationHeaderFields; - } + public String getVersion() { + return version; + } - public void setIdentificationHeaderFields(List<String> identificationHeaderFields) { - this.identificationHeaderFields = identificationHeaderFields; - } + public void setReleased(Date released) { + this.released = released; + } - public Date getReleased() { - return released; - } + public void setVersion(String version) { + this.version = version; + } - public String getVersion() { - return version; - } + public List<String> getProtocols() { + return protocols; + } - public void setReleased(Date released) { - this.released = released; - } + public void setProtocols(List<String> protocols) { + this.protocols = protocols; + } - public void setVersion(String version) { - this.version = version; - } + public Map<String, String> getUsers() { + return users; + } - public List<String> getProtocols() { - return protocols; - } + public void setUsers(Map<String, String> users) { + this.users = users; + } - public void setProtocols(List<String> protocols) { - this.protocols = protocols; - } + public String getBeFqdn() { + return beFqdn; + } - public Map<String, String> getUsers() { - return users; - } + public void setBeFqdn(String beHost) { + this.beFqdn = beHost; + } - public void setUsers(Map<String, String> users) { - this.users = users; - } + public Integer getBeHttpPort() { + return beHttpPort; + } - public String getBeFqdn() { - return beFqdn; - } + public void setBeHttpPort(Integer beHttpPort) { + this.beHttpPort = beHttpPort; + } - public void setBeFqdn(String beHost) { - this.beFqdn = beHost; - } + public Integer getBeSslPort() { + return beSslPort; + } - public Integer getBeHttpPort() { - return beHttpPort; - } + public void setBeSslPort(Integer beSslPort) { + this.beSslPort = beSslPort; + } - public void setBeHttpPort(Integer beHttpPort) { - this.beHttpPort = beHttpPort; - } + public String getBeContext() { + return beContext; + } - public Integer getBeSslPort() { - return beSslPort; - } + public void setBeContext(String beContext) { + this.beContext = beContext; + } - public void setBeSslPort(Integer beSslPort) { - this.beSslPort = beSslPort; - } + public String getBeProtocol() { + return beProtocol; + } - public String getBeContext() { - return beContext; - } + public void setBeProtocol(String beProtocol) { + this.beProtocol = beProtocol; + } - public void setBeContext(String beContext) { - this.beContext = beContext; - } + public Map<String, Object> getNeo4j() { + return neo4j; + } - public String getBeProtocol() { - return beProtocol; - } + public void setNeo4j(Map<String, Object> neo4j) { + this.neo4j = neo4j; + } - public void setBeProtocol(String beProtocol) { - this.beProtocol = beProtocol; - } + public ElasticSearchConfig getElasticSearch() { + return elasticSearch; + } - public Map<String, Object> getNeo4j() { - return neo4j; - } + public void setElasticSearch(ElasticSearchConfig elasticSearch) { + this.elasticSearch = elasticSearch; + } - public void setNeo4j(Map<String, Object> neo4j) { - this.neo4j = neo4j; - } + public String getTitanCfgFile() { + return titanCfgFile; + } - public ElasticSearchConfig getElasticSearch() { - return elasticSearch; - } + public void setTitanCfgFile(String titanCfgFile) { + this.titanCfgFile = titanCfgFile; + } - public void setElasticSearch(ElasticSearchConfig elasticSearch) { - this.elasticSearch = elasticSearch; - } + public String getTitanMigrationKeySpaceCfgFile() { + return titanMigrationKeySpaceCfgFile; + } - public String getTitanCfgFile() { - return titanCfgFile; - } + public void setTitanMigrationKeySpaceCfgFile(String titanMigrationKeySpaceCfgFile) { + this.titanMigrationKeySpaceCfgFile = titanMigrationKeySpaceCfgFile; + } - public void setTitanCfgFile(String titanCfgFile) { - this.titanCfgFile = titanCfgFile; - } + public Boolean getTitanInMemoryGraph() { + return titanInMemoryGraph; + } - public String getTitanMigrationKeySpaceCfgFile() { - return titanMigrationKeySpaceCfgFile; - } + public void setTitanInMemoryGraph(Boolean titanInMemoryGraph) { + this.titanInMemoryGraph = titanInMemoryGraph; + } - public void setTitanMigrationKeySpaceCfgFile(String titanMigrationKeySpaceCfgFile) { - this.titanMigrationKeySpaceCfgFile = titanMigrationKeySpaceCfgFile; - } + public int getStartMigrationFrom() { + return startMigrationFrom; + } - public Boolean getTitanInMemoryGraph() { - return titanInMemoryGraph; - } + public void setStartMigrationFrom(int startMigrationFrom) { + this.startMigrationFrom = startMigrationFrom; + } - public void setTitanInMemoryGraph(Boolean titanInMemoryGraph) { - this.titanInMemoryGraph = titanInMemoryGraph; - } + public Long getTitanLockTimeout() { + return titanLockTimeout; + } - public int getStartMigrationFrom() { - return startMigrationFrom; - } + public void setTitanLockTimeout(Long titanLockTimeout) { + this.titanLockTimeout = titanLockTimeout; + } - public void setStartMigrationFrom(int startMigrationFrom) { - this.startMigrationFrom = startMigrationFrom; - } + public Long getTitanHealthCheckReadTimeout() { + return titanHealthCheckReadTimeout; + } - public Long getTitanLockTimeout() { - return titanLockTimeout; - } + public Long getTitanHealthCheckReadTimeout(long defaultVal) { + return titanHealthCheckReadTimeout == null ? defaultVal : titanHealthCheckReadTimeout; + } - public void setTitanLockTimeout(Long titanLockTimeout) { - this.titanLockTimeout = titanLockTimeout; - } + public void setTitanHealthCheckReadTimeout(Long titanHealthCheckReadTimeout) { + this.titanHealthCheckReadTimeout = titanHealthCheckReadTimeout; + } - public Long getTitanHealthCheckReadTimeout() { - return titanHealthCheckReadTimeout; - } + public Long getTitanReconnectIntervalInSeconds() { + return titanReconnectIntervalInSeconds; + } - public Long getTitanHealthCheckReadTimeout(long defaultVal) { - return titanHealthCheckReadTimeout == null ? defaultVal : titanHealthCheckReadTimeout; - } + public Long getTitanReconnectIntervalInSeconds(long defaultVal) { + return titanReconnectIntervalInSeconds == null ? defaultVal : titanReconnectIntervalInSeconds; + } - public void setTitanHealthCheckReadTimeout(Long titanHealthCheckReadTimeout) { - this.titanHealthCheckReadTimeout = titanHealthCheckReadTimeout; - } + public void setTitanReconnectIntervalInSeconds(Long titanReconnectIntervalInSeconds) { + this.titanReconnectIntervalInSeconds = titanReconnectIntervalInSeconds; + } - public Long getTitanReconnectIntervalInSeconds() { - return titanReconnectIntervalInSeconds; - } + public Long getEsReconnectIntervalInSeconds() { + return esReconnectIntervalInSeconds; + } - public Long getTitanReconnectIntervalInSeconds(long defaultVal) { - return titanReconnectIntervalInSeconds == null ? defaultVal : titanReconnectIntervalInSeconds; - } + public Long getEsReconnectIntervalInSeconds(long defaultVal) { + return esReconnectIntervalInSeconds == null ? defaultVal : esReconnectIntervalInSeconds; + } - public void setTitanReconnectIntervalInSeconds(Long titanReconnectIntervalInSeconds) { - this.titanReconnectIntervalInSeconds = titanReconnectIntervalInSeconds; - } + public void setEsReconnectIntervalInSeconds(Long esReconnectIntervalInSeconds) { + this.esReconnectIntervalInSeconds = esReconnectIntervalInSeconds; + } - public Long getEsReconnectIntervalInSeconds() { - return esReconnectIntervalInSeconds; - } - - public Long getEsReconnectIntervalInSeconds(long defaultVal) { - return esReconnectIntervalInSeconds == null ? defaultVal : esReconnectIntervalInSeconds; - } - - public void setEsReconnectIntervalInSeconds(Long esReconnectIntervalInSeconds) { - this.esReconnectIntervalInSeconds = esReconnectIntervalInSeconds; - } - - public List<String> getArtifactTypes() { - return artifactTypes; - } - - public void setArtifactTypes(List<String> artifactTypes) { - this.artifactTypes = artifactTypes; - } - - public List<String> getExcludeResourceCategory() { - return excludeResourceCategory; - } - - public void setExcludeResourceCategory(List<String> excludeResourceCategory) { - this.excludeResourceCategory = excludeResourceCategory; - } - - public List<String> getExcludeResourceType() { - return excludeResourceType; - } - - public void setExcludeResourceType(List<String> excludeResourceType) { - this.excludeResourceType = excludeResourceType; - } - - public Map<String, Set<String>> getExcludedPolicyTypesMapping() { - return safeGetMap(excludedPolicyTypesMapping); - } - - public void setExcludedPolicyTypesMapping(Map<String, Set<String>> excludedPolicyTypesMapping) { - this.excludedPolicyTypesMapping = excludedPolicyTypesMapping; - } - - public Map<String, Set<String>> getExcludedGroupTypesMapping() { - return safeGetMap(excludedGroupTypesMapping); - } - - public void setExcludedGroupTypesMapping(Map<String, Set<String>> excludedGroupTypesMapping) { - this.excludedGroupTypesMapping = excludedGroupTypesMapping; - } - - public Map<String, Object> getToscaArtifacts() { - return toscaArtifacts; - } - - public void setToscaArtifacts(Map<String, Object> toscaArtifacts) { - this.toscaArtifacts = toscaArtifacts; - } - - public Map<String, Object> getInformationalResourceArtifacts() { - return informationalResourceArtifacts; - } - - public void setInformationalResourceArtifacts(Map<String, Object> informationalResourceArtifacts) { - this.informationalResourceArtifacts = informationalResourceArtifacts; - } - - public Map<String, Object> getInformationalServiceArtifacts() { - return informationalServiceArtifacts; - } - - public void setInformationalServiceArtifacts(Map<String, Object> informationalServiceArtifacts) { - this.informationalServiceArtifacts = informationalServiceArtifacts; - } - - public Map<String, Object> getServiceApiArtifacts() { - return serviceApiArtifacts; - } - - public void setServiceApiArtifacts(Map<String, Object> serviceApiArtifacts) { - this.serviceApiArtifacts = serviceApiArtifacts; - } + public List<String> getArtifactTypes() { + return artifactTypes; + } - public Map<String, ArtifactTypeConfig> getServiceDeploymentArtifacts() { - return serviceDeploymentArtifacts; - } + public void setArtifactTypes(List<String> artifactTypes) { + this.artifactTypes = artifactTypes; + } - public void setServiceDeploymentArtifacts(Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts) { - this.serviceDeploymentArtifacts = serviceDeploymentArtifacts; - } + public List<String> getExcludeResourceCategory() { + return excludeResourceCategory; + } - public Map<String, ArtifactTypeConfig> getResourceDeploymentArtifacts() { - return resourceDeploymentArtifacts; - } + public void setExcludeResourceCategory(List<String> excludeResourceCategory) { + this.excludeResourceCategory = excludeResourceCategory; + } - public void setResourceDeploymentArtifacts(Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts) { - this.resourceDeploymentArtifacts = resourceDeploymentArtifacts; - } + public List<String> getExcludeResourceType() { + return excludeResourceType; + } - public void setResourceInstanceDeploymentArtifacts( - Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts) { - this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts; - } + public void setExcludeResourceType(List<String> excludeResourceType) { + this.excludeResourceType = excludeResourceType; + } - public Map<String, ArtifactTypeConfig> getResourceInstanceDeploymentArtifacts() { - return resourceInstanceDeploymentArtifacts; - } + public Map<String, Set<String>> getExcludedPolicyTypesMapping() { + return safeGetCapsInsensitiveMap(excludedPolicyTypesMapping); + } - public List<String> getExcludeServiceCategory() { - return excludeServiceCategory; - } + public void setExcludedPolicyTypesMapping(Map<String, Set<String>> excludedPolicyTypesMapping) { + this.excludedPolicyTypesMapping = excludedPolicyTypesMapping; + } - public void setExcludeServiceCategory(List<String> excludeServiceCategory) { - this.excludeServiceCategory = excludeServiceCategory; - } + public Map<String, Set<String>> getExcludedGroupTypesMapping() { + return safeGetCapsInsensitiveMap(excludedGroupTypesMapping); + } - public List<String> getLicenseTypes() { - return licenseTypes; - } + public void setExcludedGroupTypesMapping(Map<String, Set<String>> excludedGroupTypesMapping) { + this.excludedGroupTypesMapping = excludedGroupTypesMapping; + } - public void setLicenseTypes(List<String> licenseTypes) { - this.licenseTypes = licenseTypes; - } - - public Integer getAdditionalInformationMaxNumberOfKeys() { - return additionalInformationMaxNumberOfKeys; - } - - public void setAdditionalInformationMaxNumberOfKeys(Integer additionalInformationMaxNumberOfKeys) { - this.additionalInformationMaxNumberOfKeys = additionalInformationMaxNumberOfKeys; - } - - public BeMonitoringConfig getSystemMonitoring() { - return systemMonitoring; - } - - public void setSystemMonitoring(BeMonitoringConfig systemMonitoring) { - this.systemMonitoring = systemMonitoring; - } - - public Integer getDefaultHeatArtifactTimeoutMinutes() { - return defaultHeatArtifactTimeoutMinutes; - } - - public void setDefaultHeatArtifactTimeoutMinutes(Integer defaultHeatArtifactTimeoutMinutes) { - this.defaultHeatArtifactTimeoutMinutes = defaultHeatArtifactTimeoutMinutes; - } - - public Long getUebHealthCheckReconnectIntervalInSeconds() { - return uebHealthCheckReconnectIntervalInSeconds; - } - - public void setUebHealthCheckReconnectIntervalInSeconds(Long uebHealthCheckReconnectIntervalInSeconds) { - this.uebHealthCheckReconnectIntervalInSeconds = uebHealthCheckReconnectIntervalInSeconds; - } - - public Long getUebHealthCheckReadTimeout() { - return uebHealthCheckReadTimeout; - } - - public void setUebHealthCheckReadTimeout(Long uebHealthCheckReadTimeout) { - this.uebHealthCheckReadTimeout = uebHealthCheckReadTimeout; - } - - public String getWorkloadContext() { - return workloadContext; - } - - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - public EnvironmentContext getEnvironmentContext() { - return environmentContext; - } - - public void setEnvironmentContext(EnvironmentContext environmentContext) { - this.environmentContext = environmentContext; - } - - public static class ElasticSearchConfig { + public Map<String, Object> getToscaArtifacts() { + return toscaArtifacts; + } - List<IndicesTimeFrequencyEntry> indicesTimeFrequency; - - public List<IndicesTimeFrequencyEntry> getIndicesTimeFrequency() { - return indicesTimeFrequency; - } - - public void setIndicesTimeFrequency(List<IndicesTimeFrequencyEntry> indicesTimeFrequency) { - this.indicesTimeFrequency = indicesTimeFrequency; - } - - public static class IndicesTimeFrequencyEntry { + public void setToscaArtifacts(Map<String, Object> toscaArtifacts) { + this.toscaArtifacts = toscaArtifacts; + } - String indexPrefix; - String creationPeriod; + public Map<String, Object> getInformationalResourceArtifacts() { + return informationalResourceArtifacts; + } - public String getIndexPrefix() { - return indexPrefix; - } + public void setInformationalResourceArtifacts(Map<String, Object> informationalResourceArtifacts) { + this.informationalResourceArtifacts = informationalResourceArtifacts; + } - public void setIndexPrefix(String indexPrefix) { - this.indexPrefix = indexPrefix; - } + public Map<String, Object> getInformationalServiceArtifacts() { + return informationalServiceArtifacts; + } - public String getCreationPeriod() { - return creationPeriod; - } + public void setInformationalServiceArtifacts(Map<String, Object> informationalServiceArtifacts) { + this.informationalServiceArtifacts = informationalServiceArtifacts; + } - public void setCreationPeriod(String creationPeriod) { - this.creationPeriod = creationPeriod; - } - } - } + public Map<String, Object> getServiceApiArtifacts() { + return serviceApiArtifacts; + } - public static class CassandrConfig { + public void setServiceApiArtifacts(Map<String, Object> serviceApiArtifacts) { + this.serviceApiArtifacts = serviceApiArtifacts; + } - List<String> cassandraHosts; - String localDataCenter; - Long reconnectTimeout; - Integer socketReadTimeout; - Integer socketConnectTimeout; - List<KeyspaceConfig> keySpaces; - boolean authenticate; - String username; - String password; - boolean ssl; - String truststorePath; - String truststorePassword; + public Map<String, ArtifactTypeConfig> getServiceDeploymentArtifacts() { + return serviceDeploymentArtifacts; + } - public String getLocalDataCenter() { - return localDataCenter; - } + public void setServiceDeploymentArtifacts(Map<String, ArtifactTypeConfig> serviceDeploymentArtifacts) { + this.serviceDeploymentArtifacts = serviceDeploymentArtifacts; + } - public void setLocalDataCenter(String localDataCenter) { - this.localDataCenter = localDataCenter; - } + public Map<String, ArtifactTypeConfig> getResourceDeploymentArtifacts() { + return resourceDeploymentArtifacts; + } - public boolean isAuthenticate() { - return authenticate; - } + public void setResourceDeploymentArtifacts(Map<String, ArtifactTypeConfig> resourceDeploymentArtifacts) { + this.resourceDeploymentArtifacts = resourceDeploymentArtifacts; + } - public void setAuthenticate(boolean authenticate) { - this.authenticate = authenticate; - } + public void setResourceInstanceDeploymentArtifacts( + Map<String, ArtifactTypeConfig> resourceInstanceDeploymentArtifacts) { + this.resourceInstanceDeploymentArtifacts = resourceInstanceDeploymentArtifacts; + } - public String getUsername() { - return username; - } + public Map<String, ArtifactTypeConfig> getResourceInstanceDeploymentArtifacts() { + return resourceInstanceDeploymentArtifacts; + } - public void setUsername(String username) { - this.username = username; - } + public List<String> getExcludeServiceCategory() { + return excludeServiceCategory; + } - public String getPassword() { - return password; - } + public void setExcludeServiceCategory(List<String> excludeServiceCategory) { + this.excludeServiceCategory = excludeServiceCategory; + } - public void setPassword(String password) { - this.password = password; - } + public List<String> getLicenseTypes() { + return licenseTypes; + } - public boolean isSsl() { - return ssl; - } + public void setLicenseTypes(List<String> licenseTypes) { + this.licenseTypes = licenseTypes; + } - public void setSsl(boolean ssl) { - this.ssl = ssl; - } + public Integer getAdditionalInformationMaxNumberOfKeys() { + return additionalInformationMaxNumberOfKeys; + } + + public void setAdditionalInformationMaxNumberOfKeys(Integer additionalInformationMaxNumberOfKeys) { + this.additionalInformationMaxNumberOfKeys = additionalInformationMaxNumberOfKeys; + } + + public BeMonitoringConfig getSystemMonitoring() { + return systemMonitoring; + } + + public void setSystemMonitoring(BeMonitoringConfig systemMonitoring) { + this.systemMonitoring = systemMonitoring; + } + + public Integer getDefaultHeatArtifactTimeoutMinutes() { + return defaultHeatArtifactTimeoutMinutes; + } + + public void setDefaultHeatArtifactTimeoutMinutes(Integer defaultHeatArtifactTimeoutMinutes) { + this.defaultHeatArtifactTimeoutMinutes = defaultHeatArtifactTimeoutMinutes; + } + + public Long getUebHealthCheckReconnectIntervalInSeconds() { + return uebHealthCheckReconnectIntervalInSeconds; + } + + public void setUebHealthCheckReconnectIntervalInSeconds(Long uebHealthCheckReconnectIntervalInSeconds) { + this.uebHealthCheckReconnectIntervalInSeconds = uebHealthCheckReconnectIntervalInSeconds; + } + + public Long getUebHealthCheckReadTimeout() { + return uebHealthCheckReadTimeout; + } + + public void setUebHealthCheckReadTimeout(Long uebHealthCheckReadTimeout) { + this.uebHealthCheckReadTimeout = uebHealthCheckReadTimeout; + } + + public String getWorkloadContext() { + return workloadContext; + } + + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public EnvironmentContext getEnvironmentContext() { + return environmentContext; + } + + public void setEnvironmentContext(EnvironmentContext environmentContext) { + this.environmentContext = environmentContext; + } + + public static class ElasticSearchConfig { - public String getTruststorePath() { - return truststorePath; - } + List<IndicesTimeFrequencyEntry> indicesTimeFrequency; + + public List<IndicesTimeFrequencyEntry> getIndicesTimeFrequency() { + return indicesTimeFrequency; + } + + public void setIndicesTimeFrequency(List<IndicesTimeFrequencyEntry> indicesTimeFrequency) { + this.indicesTimeFrequency = indicesTimeFrequency; + } + + public static class IndicesTimeFrequencyEntry { - public void setTruststorePath(String truststorePath) { - this.truststorePath = truststorePath; - } + String indexPrefix; + String creationPeriod; - public String getTruststorePassword() { - return truststorePassword; - } + public String getIndexPrefix() { + return indexPrefix; + } - public void setTruststorePassword(String truststorePassword) { - this.truststorePassword = truststorePassword; - } - - public Long getReconnectTimeout() { - return reconnectTimeout; - } - - public void setReconnectTimeout(Long reconnectTimeout) { - this.reconnectTimeout = reconnectTimeout; - } + public void setIndexPrefix(String indexPrefix) { + this.indexPrefix = indexPrefix; + } + + public String getCreationPeriod() { + return creationPeriod; + } + + public void setCreationPeriod(String creationPeriod) { + this.creationPeriod = creationPeriod; + } + } + } + + public static class CassandrConfig { + + List<String> cassandraHosts; + String localDataCenter; + Long reconnectTimeout; + Integer socketReadTimeout; + Integer socketConnectTimeout; + List<KeyspaceConfig> keySpaces; + boolean authenticate; + String username; + String password; + boolean ssl; + String truststorePath; + String truststorePassword; + + public String getLocalDataCenter() { + return localDataCenter; + } + + public void setLocalDataCenter(String localDataCenter) { + this.localDataCenter = localDataCenter; + } + + public boolean isAuthenticate() { + return authenticate; + } + + public void setAuthenticate(boolean authenticate) { + this.authenticate = authenticate; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean isSsl() { + return ssl; + } + + public void setSsl(boolean ssl) { + this.ssl = ssl; + } + + public String getTruststorePath() { + return truststorePath; + } + + public void setTruststorePath(String truststorePath) { + this.truststorePath = truststorePath; + } + + public String getTruststorePassword() { + return truststorePassword; + } + + public void setTruststorePassword(String truststorePassword) { + this.truststorePassword = truststorePassword; + } + + public Long getReconnectTimeout() { + return reconnectTimeout; + } + + public void setReconnectTimeout(Long reconnectTimeout) { + this.reconnectTimeout = reconnectTimeout; + } public Integer getSocketReadTimeout() { return socketReadTimeout; } @@ -709,843 +748,843 @@ public class Configuration extends BasicConfiguration { public void setSocketConnectTimeout(Integer socketConnectTimeout) { this.socketConnectTimeout = socketConnectTimeout; } - public List<String> getCassandraHosts() { - return cassandraHosts; - } - - public void setCassandraHosts(List<String> cassandraHosts) { - this.cassandraHosts = cassandraHosts; - } - - public List<KeyspaceConfig> getKeySpaces() { - return keySpaces; - } - - public void setKeySpaces(List<KeyspaceConfig> cassandraConfig) { - this.keySpaces = cassandraConfig; - } - - public static class KeyspaceConfig { - - String name; - String replicationStrategy; - List<String> replicationInfo; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getReplicationStrategy() { - return replicationStrategy; - } - - public void setReplicationStrategy(String replicationStrategy) { - this.replicationStrategy = replicationStrategy; - } - - public List<String> getReplicationInfo() { - return replicationInfo; - } - - public void setReplicationInfo(List<String> replicationInfo) { - this.replicationInfo = replicationInfo; - } - } - } - - public static class SwitchoverDetectorConfig { - - String gBeFqdn; - String gFeFqdn; - String beVip; - String feVip; - int beResolveAttempts; - int feResolveAttempts; - Boolean enabled; - long interval; - String changePriorityUser; - String changePriorityPassword; - String publishNetworkUrl; - String publishNetworkBody; - Map<String, GroupInfo> groups; - - public String getgBeFqdn() { - return gBeFqdn; - } - - public void setgBeFqdn(String gBeFqdn) { - this.gBeFqdn = gBeFqdn; - } - - public String getgFeFqdn() { - return gFeFqdn; - } - - public void setgFeFqdn(String gFeFqdn) { - this.gFeFqdn = gFeFqdn; - } - - public String getBeVip() { - return beVip; - } - - public void setBeVip(String beVip) { - this.beVip = beVip; - } - - public String getFeVip() { - return feVip; - } + public List<String> getCassandraHosts() { + return cassandraHosts; + } + + public void setCassandraHosts(List<String> cassandraHosts) { + this.cassandraHosts = cassandraHosts; + } + + public List<KeyspaceConfig> getKeySpaces() { + return keySpaces; + } + + public void setKeySpaces(List<KeyspaceConfig> cassandraConfig) { + this.keySpaces = cassandraConfig; + } + + public static class KeyspaceConfig { + + String name; + String replicationStrategy; + List<String> replicationInfo; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getReplicationStrategy() { + return replicationStrategy; + } + + public void setReplicationStrategy(String replicationStrategy) { + this.replicationStrategy = replicationStrategy; + } + + public List<String> getReplicationInfo() { + return replicationInfo; + } + + public void setReplicationInfo(List<String> replicationInfo) { + this.replicationInfo = replicationInfo; + } + } + } + + public static class SwitchoverDetectorConfig { + + String gBeFqdn; + String gFeFqdn; + String beVip; + String feVip; + int beResolveAttempts; + int feResolveAttempts; + Boolean enabled; + long interval; + String changePriorityUser; + String changePriorityPassword; + String publishNetworkUrl; + String publishNetworkBody; + Map<String, GroupInfo> groups; + + public String getgBeFqdn() { + return gBeFqdn; + } + + public void setgBeFqdn(String gBeFqdn) { + this.gBeFqdn = gBeFqdn; + } + + public String getgFeFqdn() { + return gFeFqdn; + } + + public void setgFeFqdn(String gFeFqdn) { + this.gFeFqdn = gFeFqdn; + } + + public String getBeVip() { + return beVip; + } + + public void setBeVip(String beVip) { + this.beVip = beVip; + } + + public String getFeVip() { + return feVip; + } - public void setFeVip(String feVip) { - this.feVip = feVip; - } + public void setFeVip(String feVip) { + this.feVip = feVip; + } - public int getBeResolveAttempts() { - return beResolveAttempts; - } + public int getBeResolveAttempts() { + return beResolveAttempts; + } - public void setBeResolveAttempts(int beResolveAttempts) { - this.beResolveAttempts = beResolveAttempts; - } + public void setBeResolveAttempts(int beResolveAttempts) { + this.beResolveAttempts = beResolveAttempts; + } - public int getFeResolveAttempts() { - return feResolveAttempts; - } + public int getFeResolveAttempts() { + return feResolveAttempts; + } - public void setFeResolveAttempts(int feResolveAttempts) { - this.feResolveAttempts = feResolveAttempts; - } + public void setFeResolveAttempts(int feResolveAttempts) { + this.feResolveAttempts = feResolveAttempts; + } - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public long getInterval() { - return interval; - } - - public void setInterval(long interval) { - this.interval = interval; - } - - public String getChangePriorityUser() { - return changePriorityUser; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public long getInterval() { + return interval; + } + + public void setInterval(long interval) { + this.interval = interval; + } + + public String getChangePriorityUser() { + return changePriorityUser; + } - public void setChangePriorityUser(String changePriorityUser) { - this.changePriorityUser = changePriorityUser; - } + public void setChangePriorityUser(String changePriorityUser) { + this.changePriorityUser = changePriorityUser; + } - public String getChangePriorityPassword() { - return changePriorityPassword; - } + public String getChangePriorityPassword() { + return changePriorityPassword; + } - public void setChangePriorityPassword(String changePriorityPassword) { - this.changePriorityPassword = changePriorityPassword; - } + public void setChangePriorityPassword(String changePriorityPassword) { + this.changePriorityPassword = changePriorityPassword; + } - public String getPublishNetworkUrl() { - return publishNetworkUrl; - } + public String getPublishNetworkUrl() { + return publishNetworkUrl; + } - public void setPublishNetworkUrl(String publishNetworkUrl) { - this.publishNetworkUrl = publishNetworkUrl; - } + public void setPublishNetworkUrl(String publishNetworkUrl) { + this.publishNetworkUrl = publishNetworkUrl; + } - public String getPublishNetworkBody() { - return publishNetworkBody; - } + public String getPublishNetworkBody() { + return publishNetworkBody; + } - public void setPublishNetworkBody(String publishNetworkBody) { - this.publishNetworkBody = publishNetworkBody; - } + public void setPublishNetworkBody(String publishNetworkBody) { + this.publishNetworkBody = publishNetworkBody; + } - public Map<String, GroupInfo> getGroups() { - return groups; - } + public Map<String, GroupInfo> getGroups() { + return groups; + } - public void setGroups(Map<String, GroupInfo> groups) { - this.groups = groups; - } + public void setGroups(Map<String, GroupInfo> groups) { + this.groups = groups; + } - public static class GroupInfo { + public static class GroupInfo { - String changePriorityUrl; - String changePriorityBody; + String changePriorityUrl; + String changePriorityBody; - public String getChangePriorityUrl() { - return changePriorityUrl; - } + public String getChangePriorityUrl() { + return changePriorityUrl; + } - public void setChangePriorityUrl(String changePriorityUrl) { - this.changePriorityUrl = changePriorityUrl; - } + public void setChangePriorityUrl(String changePriorityUrl) { + this.changePriorityUrl = changePriorityUrl; + } - public String getChangePriorityBody() { - return changePriorityBody; - } + public String getChangePriorityBody() { + return changePriorityBody; + } - public void setChangePriorityBody(String changePriorityBody) { - this.changePriorityBody = changePriorityBody; - } - } + public void setChangePriorityBody(String changePriorityBody) { + this.changePriorityBody = changePriorityBody; + } + } - } + } - public static class BeMonitoringConfig { + public static class BeMonitoringConfig { - Boolean enabled; - Boolean isProxy; - Integer probeIntervalInSeconds; + Boolean enabled; + Boolean isProxy; + Integer probeIntervalInSeconds; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Boolean getIsProxy() { - return isProxy; - } + public Boolean getIsProxy() { + return isProxy; + } - public void setIsProxy(Boolean isProxy) { - this.isProxy = isProxy; - } + public void setIsProxy(Boolean isProxy) { + this.isProxy = isProxy; + } - public Integer getProbeIntervalInSeconds() { - return probeIntervalInSeconds; - } + public Integer getProbeIntervalInSeconds() { + return probeIntervalInSeconds; + } - public Integer getProbeIntervalInSeconds(int defaultVal) { - return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds; - } + public Integer getProbeIntervalInSeconds(int defaultVal) { + return probeIntervalInSeconds == null ? defaultVal : probeIntervalInSeconds; + } - public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) { - this.probeIntervalInSeconds = probeIntervalInSeconds; - } - } + public void setProbeIntervalInSeconds(Integer probeIntervalInSeconds) { + this.probeIntervalInSeconds = probeIntervalInSeconds; + } + } - public static class ArtifactTypeConfig { + public static class ArtifactTypeConfig { - List<String> acceptedTypes; - List<String> validForResourceTypes; + List<String> acceptedTypes; + List<String> validForResourceTypes; - public List<String> getValidForResourceTypes() { - return validForResourceTypes; - } + public List<String> getValidForResourceTypes() { + return validForResourceTypes; + } - public void setValidForResourceTypes(List<String> validForResourceTypes) { - this.validForResourceTypes = validForResourceTypes; - } + public void setValidForResourceTypes(List<String> validForResourceTypes) { + this.validForResourceTypes = validForResourceTypes; + } - public List<String> getAcceptedTypes() { - return acceptedTypes; - } + public List<String> getAcceptedTypes() { + return acceptedTypes; + } - public void setAcceptedTypes(List<String> acceptedTypes) { - this.acceptedTypes = acceptedTypes; - } - } + public void setAcceptedTypes(List<String> acceptedTypes) { + this.acceptedTypes = acceptedTypes; + } + } - public static class OnboardingConfig { + public static class OnboardingConfig { - String protocol = "http"; - String host; - Integer port; - String downloadCsarUri; - String healthCheckUri; + String protocol = "http"; + String host; + Integer port; + String downloadCsarUri; + String healthCheckUri; - public String getProtocol() { - return protocol; - } + public String getProtocol() { + return protocol; + } - public void setProtocol(String protocol) { - this.protocol = protocol; - } + public void setProtocol(String protocol) { + this.protocol = protocol; + } - public String getHost() { - return host; - } + public String getHost() { + return host; + } - public void setHost(String host) { - this.host = host; - } + public void setHost(String host) { + this.host = host; + } - public Integer getPort() { - return port; - } + public Integer getPort() { + return port; + } - public void setPort(Integer port) { - this.port = port; - } + public void setPort(Integer port) { + this.port = port; + } - public String getDownloadCsarUri() { - return downloadCsarUri; - } + public String getDownloadCsarUri() { + return downloadCsarUri; + } - public void setDownloadCsarUri(String downloadCsarUri) { - this.downloadCsarUri = downloadCsarUri; - } + public void setDownloadCsarUri(String downloadCsarUri) { + this.downloadCsarUri = downloadCsarUri; + } - public String getHealthCheckUri() { - return healthCheckUri; - } + public String getHealthCheckUri() { + return healthCheckUri; + } - public void setHealthCheckUri(String healthCheckUri) { - this.healthCheckUri = healthCheckUri; - } + public void setHealthCheckUri(String healthCheckUri) { + this.healthCheckUri = healthCheckUri; + } - @Override - public String toString() { - return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri=" - + downloadCsarUri + "]"; - } + @Override + public String toString() { + return "OnboardingConfig [protocol=" + protocol + ", host=" + host + ", port=" + port + ", downloadCsarUri=" + + downloadCsarUri + "]"; + } - } + } - public DcaeConfig getDcae() { - return dcae; - } + public DcaeConfig getDcae() { + return dcae; + } - public void setDcae(DcaeConfig dcae) { - this.dcae = dcae; - } + public void setDcae(DcaeConfig dcae) { + this.dcae = dcae; + } - public static class DcaeConfig { + public static class DcaeConfig { - String protocol = "http"; - String host; - Integer port; - String healthCheckUri; + String protocol = "http"; + String host; + Integer port; + String healthCheckUri; - public String getProtocol() { - return protocol; - } + public String getProtocol() { + return protocol; + } - public void setProtocol(String protocol) { - this.protocol = protocol; - } + public void setProtocol(String protocol) { + this.protocol = protocol; + } - public String getHost() { - return host; - } + public String getHost() { + return host; + } - public void setHost(String host) { - this.host = host; - } + public void setHost(String host) { + this.host = host; + } - public Integer getPort() { - return port; - } + public Integer getPort() { + return port; + } - public void setPort(Integer port) { - this.port = port; - } + public void setPort(Integer port) { + this.port = port; + } - public String getHealthCheckUri() { - return healthCheckUri; - } + public String getHealthCheckUri() { + return healthCheckUri; + } - public void setHealthCheckUri(String healthCheckUri) { - this.healthCheckUri = healthCheckUri; - } - } + public void setHealthCheckUri(String healthCheckUri) { + this.healthCheckUri = healthCheckUri; + } + } - public static class EcompPortalConfig { + public static class EcompPortalConfig { - private String defaultFunctionalMenu; + private String defaultFunctionalMenu; - public String getDefaultFunctionalMenu() { - return defaultFunctionalMenu; - } + public String getDefaultFunctionalMenu() { + return defaultFunctionalMenu; + } - public void setDefaultFunctionalMenu(String defaultFunctionalMenu) { - this.defaultFunctionalMenu = defaultFunctionalMenu; - } + public void setDefaultFunctionalMenu(String defaultFunctionalMenu) { + this.defaultFunctionalMenu = defaultFunctionalMenu; + } - @Override - public String toString() { - return "EcompPortalConfig [defaultFunctionalMenu=" + defaultFunctionalMenu + "]"; - } + @Override + public String toString() { + return "EcompPortalConfig [defaultFunctionalMenu=" + defaultFunctionalMenu + "]"; + } - } + } - public static class ApplicationL1CacheConfig { + public static class ApplicationL1CacheConfig { - ApplicationL1CacheInfo datatypes; + ApplicationL1CacheInfo datatypes; - public ApplicationL1CacheInfo getDatatypes() { - return datatypes; - } + public ApplicationL1CacheInfo getDatatypes() { + return datatypes; + } - public void setDatatypes(ApplicationL1CacheInfo datatypes) { - this.datatypes = datatypes; - } + public void setDatatypes(ApplicationL1CacheInfo datatypes) { + this.datatypes = datatypes; + } - @Override - public String toString() { - return "ApplicationL1CacheConfig [datatypes=" + datatypes + "]"; - } + @Override + public String toString() { + return "ApplicationL1CacheConfig [datatypes=" + datatypes + "]"; + } - } + } - public static class ApplicationL2CacheConfig { + public static class ApplicationL2CacheConfig { - boolean enabled; - ApplicationL1CacheCatalogInfo catalogL1Cache; + boolean enabled; + ApplicationL1CacheCatalogInfo catalogL1Cache; - QueueInfo queue; + QueueInfo queue; - public boolean isEnabled() { - return enabled; - } + public boolean isEnabled() { + return enabled; + } - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } - public ApplicationL1CacheCatalogInfo getCatalogL1Cache() { - return catalogL1Cache; - } + public ApplicationL1CacheCatalogInfo getCatalogL1Cache() { + return catalogL1Cache; + } - public void setCatalogL1Cache(ApplicationL1CacheCatalogInfo catalogL1Cache) { - this.catalogL1Cache = catalogL1Cache; - } + public void setCatalogL1Cache(ApplicationL1CacheCatalogInfo catalogL1Cache) { + this.catalogL1Cache = catalogL1Cache; + } - public QueueInfo getQueue() { - return queue; - } + public QueueInfo getQueue() { + return queue; + } - public void setQueue(QueueInfo queue) { - this.queue = queue; - } + public void setQueue(QueueInfo queue) { + this.queue = queue; + } - @Override - public String toString() { - return "ApplicationL2CacheConfig [enabled=" + enabled + ", catalogL1Cache=" + catalogL1Cache + "]"; - } + @Override + public String toString() { + return "ApplicationL2CacheConfig [enabled=" + enabled + ", catalogL1Cache=" + catalogL1Cache + "]"; + } - } + } - public static class ToscaValidatorsConfig { + public static class ToscaValidatorsConfig { - private Integer stringMaxLength; + private Integer stringMaxLength; - public Integer getStringMaxLength() { - return stringMaxLength; - } + public Integer getStringMaxLength() { + return stringMaxLength; + } - public void setStringMaxLength(Integer stringMaxLength) { - this.stringMaxLength = stringMaxLength; - } + public void setStringMaxLength(Integer stringMaxLength) { + this.stringMaxLength = stringMaxLength; + } - @Override - public String toString() { - return "ToscaValidatorsConfig [stringMaxLength=" + stringMaxLength + "]"; - } + @Override + public String toString() { + return "ToscaValidatorsConfig [stringMaxLength=" + stringMaxLength + "]"; + } - } + } - public static class ApplicationL1CacheInfo { + public static class ApplicationL1CacheInfo { - Boolean enabled; - Integer firstRunDelay; - Integer pollIntervalInSec; + Boolean enabled; + Integer firstRunDelay; + Integer pollIntervalInSec; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Integer getFirstRunDelay() { - return firstRunDelay; - } + public Integer getFirstRunDelay() { + return firstRunDelay; + } - public void setFirstRunDelay(Integer firstRunDelay) { - this.firstRunDelay = firstRunDelay; - } + public void setFirstRunDelay(Integer firstRunDelay) { + this.firstRunDelay = firstRunDelay; + } - public Integer getPollIntervalInSec() { - return pollIntervalInSec; - } + public Integer getPollIntervalInSec() { + return pollIntervalInSec; + } - public void setPollIntervalInSec(Integer pollIntervalInSec) { - this.pollIntervalInSec = pollIntervalInSec; - } + public void setPollIntervalInSec(Integer pollIntervalInSec) { + this.pollIntervalInSec = pollIntervalInSec; + } - @Override - public String toString() { - return "ApplicationL1CacheInfo [enabled=" + enabled + ", firstRunDelay=" + firstRunDelay - + ", pollIntervalInSec=" + pollIntervalInSec + "]"; - } - } + @Override + public String toString() { + return "ApplicationL1CacheInfo [enabled=" + enabled + ", firstRunDelay=" + firstRunDelay + + ", pollIntervalInSec=" + pollIntervalInSec + "]"; + } + } - public static class ApplicationL1CacheCatalogInfo { + public static class ApplicationL1CacheCatalogInfo { - Boolean enabled; - Integer resourcesSizeInCache; - Integer servicesSizeInCache; - Integer productsSizeInCache; + Boolean enabled; + Integer resourcesSizeInCache; + Integer servicesSizeInCache; + Integer productsSizeInCache; - public Boolean getEnabled() { - return enabled; - } + public Boolean getEnabled() { + return enabled; + } - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } - public Integer getResourcesSizeInCache() { - return resourcesSizeInCache; - } + public Integer getResourcesSizeInCache() { + return resourcesSizeInCache; + } - public void setResourcesSizeInCache(Integer resourcesSizeInCache) { - this.resourcesSizeInCache = resourcesSizeInCache; - } + public void setResourcesSizeInCache(Integer resourcesSizeInCache) { + this.resourcesSizeInCache = resourcesSizeInCache; + } - public Integer getServicesSizeInCache() { - return servicesSizeInCache; - } - - public void setServicesSizeInCache(Integer servicesSizeInCache) { - this.servicesSizeInCache = servicesSizeInCache; - } - - public Integer getProductsSizeInCache() { - return productsSizeInCache; - } - - public void setProductsSizeInCache(Integer productsSizeInCache) { - this.productsSizeInCache = productsSizeInCache; - } - - @Override - public String toString() { - return "ApplicationL1CacheCatalogInfo [enabled=" + enabled + ", resourcesSizeInCache=" - + resourcesSizeInCache + ", servicesSizeInCache=" + servicesSizeInCache + ", productsSizeInCache=" - + productsSizeInCache + "]"; - } - - } - - public static class QueueInfo { - Integer numberOfCacheWorkers; - Integer waitOnShutDownInMinutes; - Integer syncIntervalInSecondes; - - public Integer getWaitOnShutDownInMinutes() { - return waitOnShutDownInMinutes; - } - - public void setWaitOnShutDownInMinutes(Integer waitOnShutDownInMinutes) { - this.waitOnShutDownInMinutes = waitOnShutDownInMinutes; - } - - public Integer getSyncIntervalInSecondes() { - return syncIntervalInSecondes; - } - - public void setSyncIntervalInSecondes(Integer syncIntervalInSecondes) { - this.syncIntervalInSecondes = syncIntervalInSecondes; - } - - public Integer getNumberOfCacheWorkers() { - return numberOfCacheWorkers; - } - - public void setNumberOfCacheWorkers(Integer numberOfCacheWorkers) { - this.numberOfCacheWorkers = numberOfCacheWorkers; - } - - @Override - public String toString() { - return "QueueInfo[" + "waitOnShutDownInMinutes=" + waitOnShutDownInMinutes + ", syncIntervalInSecondes=" - + syncIntervalInSecondes + ", numberOfCacheWorkers=" + this.numberOfCacheWorkers + ']'; - } - } - - public static class EnvironmentContext { - - String defaultValue; - List<String> validValues; - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public List<String> getValidValues() { - return validValues; - } - - public void setValidValues(List<String> validValues) { - this.validValues = validValues; - } - } - - - - public CleanComponentsConfiguration getCleanComponentsConfiguration() { - return cleanComponentsConfiguration; - } - - public void setCleanComponentsConfiguration(CleanComponentsConfiguration cleanComponentsConfiguration) { - this.cleanComponentsConfiguration = cleanComponentsConfiguration; - } - - @Override - public String toString() { - return new StringBuilder().append(format("backend host: %s%n", beFqdn)) - .append(format("backend http port: %s%n", beHttpPort)) - .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext)) - .append(format("backend protocol: %s%n", beProtocol)).append(format("Version: %s%n", version)) - .append(format("Released: %s%n", released)).append(format("Supported protocols: %s%n", protocols)) - .append(format("Users: %s%n", users)).append(format("Neo4j: %s%n", neo4j)) - .append(format("ElasticSearch: %s%n", elasticSearch)) - .append(format("Titan Cfg File: %s%n", titanCfgFile)) - .append(format("Titan In memory: %s%n", titanInMemoryGraph)) - .append(format("Titan lock timeout: %s%n", titanLockTimeout)) - .append(format("Titan reconnect interval seconds: %s%n", titanReconnectIntervalInSeconds)) - .append(format("excludeResourceCategory: %s%n", excludeResourceCategory)) - .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts)) - .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts)) - .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts)) - .append(format("Supported artifacts types: %s%n", artifactTypes)) - .append(format("Supported license types: %s%n", licenseTypes)) - .append(format("Additional information Maximum number of preoperties: %s%n", - additionalInformationMaxNumberOfKeys)) - .append(format("Default Heat Artifact Timeout in Minutes: %s%n", defaultHeatArtifactTimeoutMinutes)) - .append(format("URLs For HTTP Requests that will not be automatically logged : %s%n", unLoggedUrls)) - .append(format("Service Api Artifacts: %s%n", serviceApiArtifacts)) - .append(format("heat env artifact header: %s%n", heatEnvArtifactHeader)) - .append(format("heat env artifact footer: %s%n", heatEnvArtifactFooter)) + public Integer getServicesSizeInCache() { + return servicesSizeInCache; + } + + public void setServicesSizeInCache(Integer servicesSizeInCache) { + this.servicesSizeInCache = servicesSizeInCache; + } + + public Integer getProductsSizeInCache() { + return productsSizeInCache; + } + + public void setProductsSizeInCache(Integer productsSizeInCache) { + this.productsSizeInCache = productsSizeInCache; + } + + @Override + public String toString() { + return "ApplicationL1CacheCatalogInfo [enabled=" + enabled + ", resourcesSizeInCache=" + + resourcesSizeInCache + ", servicesSizeInCache=" + servicesSizeInCache + ", productsSizeInCache=" + + productsSizeInCache + "]"; + } + + } + + public static class QueueInfo { + Integer numberOfCacheWorkers; + Integer waitOnShutDownInMinutes; + Integer syncIntervalInSecondes; + + public Integer getWaitOnShutDownInMinutes() { + return waitOnShutDownInMinutes; + } + + public void setWaitOnShutDownInMinutes(Integer waitOnShutDownInMinutes) { + this.waitOnShutDownInMinutes = waitOnShutDownInMinutes; + } + + public Integer getSyncIntervalInSecondes() { + return syncIntervalInSecondes; + } + + public void setSyncIntervalInSecondes(Integer syncIntervalInSecondes) { + this.syncIntervalInSecondes = syncIntervalInSecondes; + } + + public Integer getNumberOfCacheWorkers() { + return numberOfCacheWorkers; + } + + public void setNumberOfCacheWorkers(Integer numberOfCacheWorkers) { + this.numberOfCacheWorkers = numberOfCacheWorkers; + } + + @Override + public String toString() { + return "QueueInfo[" + "waitOnShutDownInMinutes=" + waitOnShutDownInMinutes + ", syncIntervalInSecondes=" + + syncIntervalInSecondes + ", numberOfCacheWorkers=" + this.numberOfCacheWorkers + ']'; + } + } + + public static class EnvironmentContext { + + String defaultValue; + List<String> validValues; + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public List<String> getValidValues() { + return validValues; + } + + public void setValidValues(List<String> validValues) { + this.validValues = validValues; + } + } + + + + public CleanComponentsConfiguration getCleanComponentsConfiguration() { + return cleanComponentsConfiguration; + } + + public void setCleanComponentsConfiguration(CleanComponentsConfiguration cleanComponentsConfiguration) { + this.cleanComponentsConfiguration = cleanComponentsConfiguration; + } + + @Override + public String toString() { + return new StringBuilder().append(format("backend host: %s%n", beFqdn)) + .append(format("backend http port: %s%n", beHttpPort)) + .append(format("backend ssl port: %s%n", beSslPort)).append(format("backend context: %s%n", beContext)) + .append(format("backend protocol: %s%n", beProtocol)).append(format("Version: %s%n", version)) + .append(format("Released: %s%n", released)).append(format("Supported protocols: %s%n", protocols)) + .append(format("Users: %s%n", users)).append(format("Neo4j: %s%n", neo4j)) + .append(format("ElasticSearch: %s%n", elasticSearch)) + .append(format("Titan Cfg File: %s%n", titanCfgFile)) + .append(format("Titan In memory: %s%n", titanInMemoryGraph)) + .append(format("Titan lock timeout: %s%n", titanLockTimeout)) + .append(format("Titan reconnect interval seconds: %s%n", titanReconnectIntervalInSeconds)) + .append(format("excludeResourceCategory: %s%n", excludeResourceCategory)) + .append(format("informationalResourceArtifacts: %s%n", informationalResourceArtifacts)) + .append(format("deploymentResourceArtifacts: %s%n", deploymentResourceArtifacts)) + .append(format("informationalServiceArtifacts: %s%n", informationalServiceArtifacts)) + .append(format("Supported artifacts types: %s%n", artifactTypes)) + .append(format("Supported license types: %s%n", licenseTypes)) + .append(format("Additional information Maximum number of preoperties: %s%n", + additionalInformationMaxNumberOfKeys)) + .append(format("Default Heat Artifact Timeout in Minutes: %s%n", defaultHeatArtifactTimeoutMinutes)) + .append(format("URLs For HTTP Requests that will not be automatically logged : %s%n", unLoggedUrls)) + .append(format("Service Api Artifacts: %s%n", serviceApiArtifacts)) + .append(format("heat env artifact header: %s%n", heatEnvArtifactHeader)) + .append(format("heat env artifact footer: %s%n", heatEnvArtifactFooter)) .append(format("onboarding: %s%n", onboarding)) .append(format("tosca conformance level: %s%n", toscaConformanceLevel)) .toString(); - } + } + + public List<String> getUnLoggedUrls() { + return unLoggedUrls; + } - public List<String> getUnLoggedUrls() { - return unLoggedUrls; - } + public void setUnLoggedUrls(List<String> unLoggedUrls) { + this.unLoggedUrls = unLoggedUrls; + } - public void setUnLoggedUrls(List<String> unLoggedUrls) { - this.unLoggedUrls = unLoggedUrls; - } + public Map<String, Object> getDeploymentResourceArtifacts() { + return deploymentResourceArtifacts; + } - public Map<String, Object> getDeploymentResourceArtifacts() { - return deploymentResourceArtifacts; - } + public void setDeploymentResourceArtifacts(Map<String, Object> deploymentResourceArtifacts) { + this.deploymentResourceArtifacts = deploymentResourceArtifacts; + } - public void setDeploymentResourceArtifacts(Map<String, Object> deploymentResourceArtifacts) { - this.deploymentResourceArtifacts = deploymentResourceArtifacts; - } + public String getHeatEnvArtifactHeader() { + return heatEnvArtifactHeader; + } - public String getHeatEnvArtifactHeader() { - return heatEnvArtifactHeader; - } + public void setHeatEnvArtifactHeader(String heatEnvArtifactHeader) { + this.heatEnvArtifactHeader = heatEnvArtifactHeader; + } - public void setHeatEnvArtifactHeader(String heatEnvArtifactHeader) { - this.heatEnvArtifactHeader = heatEnvArtifactHeader; - } + public String getHeatEnvArtifactFooter() { + return heatEnvArtifactFooter; + } - public String getHeatEnvArtifactFooter() { - return heatEnvArtifactFooter; - } + public void setHeatEnvArtifactFooter(String heatEnvArtifactFooter) { + this.heatEnvArtifactFooter = heatEnvArtifactFooter; + } - public void setHeatEnvArtifactFooter(String heatEnvArtifactFooter) { - this.heatEnvArtifactFooter = heatEnvArtifactFooter; - } + public Map<String, Object> getDeploymentResourceInstanceArtifacts() { + return deploymentResourceInstanceArtifacts; + } - public Map<String, Object> getDeploymentResourceInstanceArtifacts() { - return deploymentResourceInstanceArtifacts; - } + public void setDeploymentResourceInstanceArtifacts(Map<String, Object> deploymentResourceInstanceArtifacts) { + this.deploymentResourceInstanceArtifacts = deploymentResourceInstanceArtifacts; + } - public void setDeploymentResourceInstanceArtifacts(Map<String, Object> deploymentResourceInstanceArtifacts) { - this.deploymentResourceInstanceArtifacts = deploymentResourceInstanceArtifacts; - } + public String getArtifactsIndex() { + return artifactsIndex; + } - public String getArtifactsIndex() { - return artifactsIndex; - } + public void setArtifactsIndex(String artifactsIndex) { + this.artifactsIndex = artifactsIndex; + } - public void setArtifactsIndex(String artifactsIndex) { - this.artifactsIndex = artifactsIndex; - } + public Map<String, ArtifactTypeConfig> getResourceInformationalDeployedArtifacts() { + return resourceInformationalDeployedArtifacts; + } - public Map<String, ArtifactTypeConfig> getResourceInformationalDeployedArtifacts() { - return resourceInformationalDeployedArtifacts; - } + public void setResourceInformationalDeployedArtifacts( + Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts) { + this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts; + } - public void setResourceInformationalDeployedArtifacts( - Map<String, ArtifactTypeConfig> resourceInformationalDeployedArtifacts) { - this.resourceInformationalDeployedArtifacts = resourceInformationalDeployedArtifacts; - } + public List<String> getResourceTypes() { + return resourceTypes; + } - public List<String> getResourceTypes() { - return resourceTypes; - } + public void setResourceTypes(List<String> resourceTypes) { + this.resourceTypes = resourceTypes; + } - public void setResourceTypes(List<String> resourceTypes) { - this.resourceTypes = resourceTypes; - } - - public String getToscaFilesDir() { - return toscaFilesDir; - } - - public void setToscaFilesDir(String toscaFilesDir) { - this.toscaFilesDir = toscaFilesDir; - } - - public String getHeatTranslatorPath() { - return heatTranslatorPath; - } - - public void setHeatTranslatorPath(String heatTranslatorPath) { - this.heatTranslatorPath = heatTranslatorPath; - } - - public Map<String, Set<String>> getRequirementsToFulfillBeforeCert() { - return requirementsToFulfillBeforeCert; - } - - public void setRequirementsToFulfillBeforeCert(Map<String, Set<String>> requirementsToFulfillBeforeCert) { - this.requirementsToFulfillBeforeCert = requirementsToFulfillBeforeCert; - } - - public Map<String, Set<String>> getCapabilitiesToConsumeBeforeCert() { - return capabilitiesToConsumeBeforeCert; - } - - public void setCapabilitiesToConsumeBeforeCert(Map<String, Set<String>> capabilitiesToConsumeBeforeCert) { - this.capabilitiesToConsumeBeforeCert = capabilitiesToConsumeBeforeCert; - } - - public OnboardingConfig getOnboarding() { - return onboarding; - } - - public void setOnboarding(OnboardingConfig onboarding) { - this.onboarding = onboarding; - } - - public EcompPortalConfig getEcompPortal() { - return ecompPortal; - } - - public void setEcompPortal(EcompPortalConfig ecompPortal) { - this.ecompPortal = ecompPortal; - } - - public ToscaValidatorsConfig getToscaValidators() { - return toscaValidators; - } - - public void setToscaValidators(ToscaValidatorsConfig toscaValidators) { - this.toscaValidators = toscaValidators; - } - - public boolean isDisableAudit() { - return disableAudit; - } - - public void setDisableAudit(boolean enableAudit) { - this.disableAudit = enableAudit; - } - - public Map<String, ArtifactTypeConfig> getResourceInformationalArtifacts() { - return resourceInformationalArtifacts; - } - - public void setResourceInformationalArtifacts(Map<String, ArtifactTypeConfig> resourceInformationalArtifacts) { - this.resourceInformationalArtifacts = resourceInformationalArtifacts; - } - - public Map<String, VfModuleProperty> getVfModuleProperties() { - return vfModuleProperties; - } - - public void setVfModuleProperties(Map<String, VfModuleProperty> vfModuleProperties) { - this.vfModuleProperties = vfModuleProperties; - } - - public String getToscaConformanceLevel() { - return toscaConformanceLevel; - } - - public void setToscaConformanceLevel(String toscaConformanceLevel) { - this.toscaConformanceLevel = toscaConformanceLevel; - } - - public String getMinToscaConformanceLevel() { - return minToscaConformanceLevel; - } - - public void setMinToscaConformanceLevel(String toscaConformanceLevel) { - this.minToscaConformanceLevel = toscaConformanceLevel; - } - - public static class VfModuleProperty { - private String forBaseModule; - private String forNonBaseModule; - public String getForBaseModule() { - return forBaseModule; - } - public void setForBaseModule(String forBaseModule) { - this.forBaseModule = forBaseModule; - } - public String getForNonBaseModule() { - return forNonBaseModule; - } - public void setForNonBaseModule(String forNonBaseModule) { - this.forNonBaseModule = forNonBaseModule; - } - } - - public List<Map<String, Map<String, String>>> getDefaultImports() { - return defaultImports; - } - - public void setDefaultImports(List<Map<String, Map<String, String>>> defaultImports) { - this.defaultImports = defaultImports; - } - - public Map<String, List<String>> getResourcesForUpgrade() { - return resourcesForUpgrade; - } - - public void setResourcesForUpgrade(Map<String, List<String>> resourcesForUpgrade) { - this.resourcesForUpgrade = resourcesForUpgrade; - } - - private <K,V> Map<K,V> safeGetMap(Map<K,V> map) { - return map == null ? emptyMap() : map; - } - - - public List<String> getHealthStatusExclude() { - return healthStatusExclude; - } - - public void setHealthStatusExclude(List<String> healthStatusExclude) { - this.healthStatusExclude = healthStatusExclude; - } + public String getToscaFilesDir() { + return toscaFilesDir; + } + + public void setToscaFilesDir(String toscaFilesDir) { + this.toscaFilesDir = toscaFilesDir; + } + + public String getHeatTranslatorPath() { + return heatTranslatorPath; + } + + public void setHeatTranslatorPath(String heatTranslatorPath) { + this.heatTranslatorPath = heatTranslatorPath; + } + + public Map<String, Set<String>> getRequirementsToFulfillBeforeCert() { + return requirementsToFulfillBeforeCert; + } + + public void setRequirementsToFulfillBeforeCert(Map<String, Set<String>> requirementsToFulfillBeforeCert) { + this.requirementsToFulfillBeforeCert = requirementsToFulfillBeforeCert; + } + + public Map<String, Set<String>> getCapabilitiesToConsumeBeforeCert() { + return capabilitiesToConsumeBeforeCert; + } + + public void setCapabilitiesToConsumeBeforeCert(Map<String, Set<String>> capabilitiesToConsumeBeforeCert) { + this.capabilitiesToConsumeBeforeCert = capabilitiesToConsumeBeforeCert; + } + + public OnboardingConfig getOnboarding() { + return onboarding; + } + + public void setOnboarding(OnboardingConfig onboarding) { + this.onboarding = onboarding; + } + + public EcompPortalConfig getEcompPortal() { + return ecompPortal; + } + + public void setEcompPortal(EcompPortalConfig ecompPortal) { + this.ecompPortal = ecompPortal; + } + + public ToscaValidatorsConfig getToscaValidators() { + return toscaValidators; + } + + public void setToscaValidators(ToscaValidatorsConfig toscaValidators) { + this.toscaValidators = toscaValidators; + } + + public boolean isDisableAudit() { + return disableAudit; + } + + public void setDisableAudit(boolean enableAudit) { + this.disableAudit = enableAudit; + } + + public Map<String, ArtifactTypeConfig> getResourceInformationalArtifacts() { + return resourceInformationalArtifacts; + } + + public void setResourceInformationalArtifacts(Map<String, ArtifactTypeConfig> resourceInformationalArtifacts) { + this.resourceInformationalArtifacts = resourceInformationalArtifacts; + } + + public Map<String, VfModuleProperty> getVfModuleProperties() { + return vfModuleProperties; + } + + public void setVfModuleProperties(Map<String, VfModuleProperty> vfModuleProperties) { + this.vfModuleProperties = vfModuleProperties; + } + + public String getToscaConformanceLevel() { + return toscaConformanceLevel; + } + + public void setToscaConformanceLevel(String toscaConformanceLevel) { + this.toscaConformanceLevel = toscaConformanceLevel; + } + + public String getMinToscaConformanceLevel() { + return minToscaConformanceLevel; + } + + public void setMinToscaConformanceLevel(String toscaConformanceLevel) { + this.minToscaConformanceLevel = toscaConformanceLevel; + } + + public static class VfModuleProperty { + private String forBaseModule; + private String forNonBaseModule; + public String getForBaseModule() { + return forBaseModule; + } + public void setForBaseModule(String forBaseModule) { + this.forBaseModule = forBaseModule; + } + public String getForNonBaseModule() { + return forNonBaseModule; + } + public void setForNonBaseModule(String forNonBaseModule) { + this.forNonBaseModule = forNonBaseModule; + } + } + + public List<Map<String, Map<String, String>>> getDefaultImports() { + return defaultImports; + } + + public void setDefaultImports(List<Map<String, Map<String, String>>> defaultImports) { + this.defaultImports = defaultImports; + } + + public Map<String, List<String>> getResourcesForUpgrade() { + return resourcesForUpgrade; + } + + public void setResourcesForUpgrade(Map<String, List<String>> resourcesForUpgrade) { + this.resourcesForUpgrade = resourcesForUpgrade; + } + + public static <K,V> Map<K,V> safeGetCapsInsensitiveMap(Map<K,V> map) { + return map == null ? emptyMap() : new CaseInsensitiveMap(map); + } + + + public List<String> getHealthStatusExclude() { + return healthStatusExclude; + } + + public void setHealthStatusExclude(List<String> healthStatusExclude) { + this.healthStatusExclude = healthStatusExclude; + } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java index 0015729be0..360d2e6cb3 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ConfigurationManager.java @@ -20,9 +20,6 @@ package org.openecomp.sdc.be.config; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -30,6 +27,9 @@ import org.openecomp.sdc.common.api.FileChangeCallback; import org.openecomp.sdc.common.config.EcompErrorConfiguration; import org.openecomp.sdc.common.config.IEcompConfigurationManager; +import java.util.HashMap; +import java.util.Map; + public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { ConfigurationSource configurationSource = null; @@ -42,7 +42,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura instance = this; } - Map<String, Object> configurations = new HashMap<String, Object>(); + Map<String, Object> configurations = new HashMap<>(); private void loadConfigurationFiles() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java index eeeca5b9bb..6ac399c729 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DistributionEngineConfiguration.java @@ -20,15 +20,11 @@ package org.openecomp.sdc.be.config; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.http.config.ExternalServiceConfig; +import java.util.*; + public class DistributionEngineConfiguration extends BasicConfiguration { private List<String> uebServers; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java index 8250df6c04..52ea02cfab 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorConfiguration.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.config; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; +import java.util.Map; + public class ErrorConfiguration extends BasicConfiguration { private Map<String, ErrorInfo> errors; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java index 85328caa22..ec9a61c81f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/ErrorInfo.java @@ -20,8 +20,7 @@ package org.openecomp.sdc.be.config; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class ErrorInfo { @@ -33,7 +32,7 @@ public class ErrorInfo { private static final String SVC_PREFIX = "SVC"; private static final String POL_PREFIX = "POL"; - private static Logger log = LoggerFactory.getLogger(ErrorInfo.class.getName()); + private static Logger log = Logger.getLogger(ErrorInfo.class.getName()); public ErrorInfo() { this.errorInfoType = ErrorInfoType.OK; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java index 24a85dc627..02965242cf 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/Neo4jErrorsConfiguration.java @@ -20,10 +20,10 @@ package org.openecomp.sdc.be.config; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; +import java.util.Map; + public class Neo4jErrorsConfiguration extends BasicConfiguration { private Map<String, String> errors; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java index f2438fcbfc..73358136b5 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/be/monitoring/BeMonitoringService.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.be.monitoring; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -import javax.servlet.ServletContext; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.entity.ContentType; @@ -38,19 +33,21 @@ import org.openecomp.sdc.common.http.client.api.HttpRequest; import org.openecomp.sdc.common.http.client.api.HttpResponse; import org.openecomp.sdc.common.http.config.HttpClientConfig; import org.openecomp.sdc.common.http.config.Timeouts; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.monitoring.MonitoringEvent; import org.openecomp.sdc.common.monitoring.MonitoringMetricsFetcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import javax.servlet.ServletContext; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; public class BeMonitoringService { private static final String URL = "%s://%s:%s/sdc2/rest/monitoring"; - private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.be.monitoring.service"); - private static Logger log = LoggerFactory.getLogger(BeMonitoringService.class.getName()); + private static Logger monitoringLogger = Logger.getLogger("asdc.be.monitoring.service"); + private static Logger log = Logger.getLogger(BeMonitoringService.class.getName()); private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); private class MonitoringScheduledTask implements Runnable { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java index 6beec9de54..408c36eeb6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/ArtifactTypeEnum.java @@ -37,10 +37,10 @@ public enum ArtifactTypeEnum { DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), // AAI Artifacts AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), - // MIB Artifacts + // MIB artifacts SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE"), - // PLAN Artifacts - PLAN("PLAN"); + PLAN("PLAN") + ; ArtifactTypeEnum(String type) { this.type = type; @@ -67,7 +67,7 @@ public enum ArtifactTypeEnum { } public static List<String> getAllTypes() { - List<String> types = new ArrayList<String>(); + List<String> types = new ArrayList<>(); for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { types.add(ate.getType()); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java index 5d33e9918f..0a7a105f19 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java @@ -136,7 +136,7 @@ public final class Constants { public static final String HC_COMPONENT_ES = "ES"; public static final String HC_COMPONENT_CASSANDRA = "CASSANDRA"; public static final String HC_COMPONENT_DISTRIBUTION_ENGINE = "DE"; - public static final String HC_COMPONENT_DMAAP_ENGINE = "DMAPP"; + public static final String HC_COMPONENT_DMAAP_ENGINE = "DMAAP"; //external HealthCheck components public static final String HC_COMPONENT_ON_BOARDING = "ON_BOARDING"; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java index 7a22495643..c887c09149 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.common.api; -import java.lang.reflect.Type; -import java.util.List; - import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.List; + public class HealthCheckInfo { private String healthCheckComponent; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java index 4ac6290940..1310ab170f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/YamlSuffixEnum.java @@ -49,7 +49,7 @@ public enum YamlSuffixEnum { public static List<String> getSuffixes() { - List<String> arrayList = new ArrayList<String>(); + List<String> arrayList = new ArrayList<>(); for (YamlSuffixEnum yamlSuffixEnum : YamlSuffixEnum.values()) { arrayList.add(yamlSuffixEnum.getSuffix()); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java index 368104dea1..196dd0aa71 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorConfiguration.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.common.config; +import org.openecomp.sdc.common.api.BasicConfiguration; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; -import org.openecomp.sdc.common.api.BasicConfiguration; - public class EcompErrorConfiguration extends BasicConfiguration { private Map<String, EcompErrorInfo> errors = new HashMap<>(); @@ -136,7 +136,7 @@ public class EcompErrorConfiguration extends BasicConfiguration { } /******************************* - * Enums + * enums */ public enum EcompErrorType { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java index 950af691da..af53611104 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java @@ -20,22 +20,21 @@ package org.openecomp.sdc.common.config; -import java.util.Formatter; -import java.util.IllegalFormatException; -import java.util.Locale; - +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorSeverity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.slf4j.MDC; -import fj.data.Either; +import java.util.Formatter; +import java.util.IllegalFormatException; +import java.util.Locale; public class EcompErrorLogUtil { private static String ECOMP_ERROR_TMPL = "ETYPE = \"%s\" ENAME = \"%s\" ECODE = \"%s\" ECONTEXT = \"%s\" EDESC = \"%s\""; - private static Logger log = LoggerFactory.getLogger(EcompErrorLogUtil.class.getName()); + private static Logger log = Logger.getLogger(EcompErrorLogUtil.class.getName()); private static final String FATAL_ERROR_PREFIX = "FATAL ERROR!! "; public static void logEcompError(EcompErrorName ecompErrorName, EcompErrorInfo ecompErrorInfo, @@ -62,24 +61,9 @@ public class EcompErrorLogUtil { // else it stays ERROR formatter.format(ECOMP_ERROR_TMPL, ecompErrorInfo.getType(), ecompErrorName.name(), ecompErrorInfo.getCode(), ecompErrorContext, description); - switch (severity) { - case INFO: - log.info(formatter.toString()); - break; - case WARN: - log.warn(formatter.toString()); - break; - case ERROR: - log.error(formatter.toString()); - break; - case FATAL: - // same as ERROR for now, might be additional logic later.. - log.error(formatter.toString()); - break; - default: - break; - } - } finally { + log.error(severity, EcompLoggerErrorCode.getByValue(ecompErrorInfo.getCode()), + ecompErrorContext, ecompErrorContext, description); + } finally { formatter.close(); MDC.remove("alarmSeverity"); } @@ -96,7 +80,7 @@ public class EcompErrorLogUtil { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); try { - String description = ecompErrorEnum.getEcompErrorCode().getDescription(); + String description; Either<String, Boolean> setDescriptionParamsResult = setDescriptionParams(ecompErrorEnum, ecompDescriptionParams); @@ -104,13 +88,12 @@ public class EcompErrorLogUtil { description = setDescriptionParamsResult.left().value(); } else { EcompErrorEnum mismatchErrorEnum = EcompErrorEnum.EcompMismatchParam; - if (logMissingParams == true) { - logEcompError("logEcompError", mismatchErrorEnum, false, ecompErrorEnum.name().toString()); - return; + if (logMissingParams) { + logEcompError("logEcompError", mismatchErrorEnum, false, ecompErrorEnum.name()); } else { log.info("Failed to log the error code {}", mismatchErrorEnum); - return; } + return; } EcompClassification classification = ecompErrorEnum.getClassification(); @@ -132,23 +115,9 @@ public class EcompErrorLogUtil { // else it stays ERROR formatter.format(ECOMP_ERROR_TMPL, ecompErrorEnum.geteType(), ecompErrorEnum.name(), eCode, ecompErrorContext, description); - switch (severity) { - case INFO: - log.info(formatter.toString()); - break; - case WARN: - log.warn(formatter.toString()); - break; - case ERROR: - log.error(formatter.toString()); - break; - case FATAL: - // same as ERROR for now, might be additional logic later.. - log.error(formatter.toString()); - break; - default: - break; - } + + log.error(severity, EcompLoggerErrorCode.getByValue(ecompErrorEnum.getEcompErrorCode().name()), + ecompErrorContext, ecompErrorContext, description); } finally { formatter.close(); MDC.remove("alarmSeverity"); @@ -161,9 +130,8 @@ public class EcompErrorLogUtil { String ecompErrorCode = ecompErrorEnum.getEcompErrorCode().name(); String ecodeNumber = ecompErrorCode.substring(ecompErrorCode.indexOf("_") + 1); - String eCode = "ASDC" + ecodeNumber + classification.getClassification(); - return eCode; + return "ASDC" + ecodeNumber + classification.getClassification(); } private static Either<String, Boolean> setDescriptionParams(EcompErrorEnum ecompErrorEnum, diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java index 6b7afc439f..8ee8c6035d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.common.config.generation; +import org.openecomp.sdc.common.config.EcompErrorEnum; +import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; +import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType; +import org.openecomp.sdc.common.config.EcompErrorLogUtil; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -31,11 +36,6 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.openecomp.sdc.common.config.EcompErrorEnum; -import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; -import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType; -import org.openecomp.sdc.common.config.EcompErrorLogUtil; - public class GenerateEcompErrorsCsv { private static Logger log = LoggerFactory.getLogger(GenerateEcompErrorsCsv.class); @@ -136,7 +136,7 @@ public class GenerateEcompErrorsCsv { boolean result = false; String dateFormatted = ""; - if (addTimeToFileName == true) { + if (addTimeToFileName) { DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); Date date = new Date(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java index 0dd15073da..06b2452d82 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java @@ -22,7 +22,7 @@ package org.openecomp.sdc.common.datastructure; import java.util.Date; -public enum AuditingFieldsKeysEnum { +public enum AuditingFieldsKey { // General AUDIT_TIMESTAMP(Date.class, "TIMESTAMP"), AUDIT_ACTION(String.class, "ACTION"), @@ -95,7 +95,7 @@ public enum AuditingFieldsKeysEnum { private Class<?> clazz; private String displayName; - AuditingFieldsKeysEnum(Class<?> clazz, String displayName) { + AuditingFieldsKey(Class<?> clazz, String displayName) { this.clazz = clazz; this.displayName = displayName; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java index 55b9f7f87f..d31f8227dc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java @@ -20,18 +20,12 @@ package org.openecomp.sdc.common.datastructure; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Formatter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import java.text.SimpleDateFormat; +import java.util.*; + /** * Extending this class enforces the objects of implementing classes to have a * timestamp, so that like in logstash, we can derive the index name for those @@ -42,15 +36,16 @@ import org.codehaus.jettison.json.JSONObject; */ public class ESTimeBasedEvent { + protected SimpleDateFormat simpleDateFormat; protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z"; protected String timestamp; - protected Map<String, Object> fields = new HashMap<String, Object>(); + protected Map<String, Object> fields = new HashMap<>(); public ESTimeBasedEvent() { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern); + simpleDateFormat = new SimpleDateFormat(dateFormatPattern); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); this.timestamp = simpleDateFormat.format(new Date()); - fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); + fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp); } @@ -64,7 +59,7 @@ public class ESTimeBasedEvent { while (keys.hasNext()) { String key = (String) keys.next(); event.fields.put(key, gsonObj.get(key)); - if (key.equals(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName())) { + if (key.equals(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName())) { event.timestamp = (String) gsonObj.get(key); } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java index 64266f5985..3f6fb4c298 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java @@ -20,28 +20,21 @@ package org.openecomp.sdc.common.datastructure; +import fj.F; +import fj.data.Either; +import org.apache.commons.lang3.math.NumberUtils; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.io.Serializable; import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import java.util.concurrent.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; -import org.apache.commons.lang3.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import fj.F; -import fj.data.Either; - /** * Class For Functional interfaces And Functional Methods * @@ -51,7 +44,7 @@ import fj.data.Either; public class FunctionalInterfaces { private static final int DEFAULT_REDO_INTERVAL_TIME_MS = 50; private static final int DEFAULT_MAX_WAIT_TIME_MS = 10000; - private static final Logger LOGGER = LoggerFactory.getLogger(FunctionalInterfaces.class); + private static final Logger LOGGER = Logger.getLogger(FunctionalInterfaces.class.getName()); /** * This is an interface of a List that implements Serializable @@ -183,8 +176,7 @@ public class FunctionalInterfaces { */ public static <R, E extends Exception> R swallowException(SupplierThrows<R, E> methodToRun) { try { - final R result = methodToRun.get(); - return result; + return methodToRun.get(); } catch (Exception e) { throw new FunctionalAttException(e); } @@ -510,15 +502,14 @@ public class FunctionalInterfaces { } public static <T> F<T, Boolean> convertToFunction(Consumer<T> consumer) { - F<T, Boolean> func = t -> { - try { - consumer.accept(t); - return true; - } catch (Exception e) { - return false; - } - }; - return func; + return t -> { + try { + consumer.accept(t); + return true; + } catch (Exception e) { + return false; + } + }; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java deleted file mode 100644 index e5f5fc99dd..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerAudit.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; - -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.Enums.StatusCode; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MDC; -import org.slf4j.MarkerFactory; - -public class EcompLoggerAudit extends EcompLoggerBase{ - private static EcompLoggerAudit instanceLoggerAudit = EcompLoggerFactory.getLogger(EcompLoggerAudit.class); - - EcompLoggerAudit(IEcompMdcWrapper ecompMdcWrapper) { - super (ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.AUDIT_MARKER.text())); - } - - public static EcompLoggerAudit getInstance() { - return instanceLoggerAudit; - } - - @Override - public EcompLoggerAudit startTimer() { - return (EcompLoggerAudit) super.startTimer(); - } - - public EcompLoggerAudit stopTimer() { - ecompMdcWrapper.stopTimer(); - return this; - } - - // automatic parameter this is optional - public EcompLoggerAudit setAutoServerFQDN(String serverFQDN) { - ecompMdcWrapper.setAutoServerFQDN(serverFQDN); - return this; - } - - // automatic parameter this is optional - public EcompLoggerAudit setAutoServerIPAddress(String serverIPAddress) { - ecompMdcWrapper.setAutoServerIPAddress(serverIPAddress); - return this; - } - - public EcompLoggerAudit setInstanceUUID(String instanceUUID) { - ecompMdcWrapper.setInstanceUUID(instanceUUID); - return this; - } - - public EcompLoggerAudit setOptClassName(String className) { - MDC.put("ClassName", className); - return this; - } - - public EcompLoggerAudit setOptProcessKey(String processKey) { - ecompMdcWrapper.setProcessKey(processKey); - return this; - } - - public EcompLoggerAudit setOptAlertSeverity(Severity alertSeverity) { - ecompMdcWrapper.setAlertSeverity(alertSeverity); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField1(String customField1) { - ecompMdcWrapper.setOptCustomField1(customField1); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField2(String customField2) { - ecompMdcWrapper.setOptCustomField2(customField2); - return this; - } - - // ecomplog optional parameter - public EcompLoggerAudit setOptCustomField3(String customField3) { - ecompMdcWrapper.setOptCustomField3(customField3); - return this; - } - - public EcompLoggerAudit setOptCustomField4(String customField4) { - ecompMdcWrapper.setOptCustomField4(customField4); - return this; - } - - @Override - public EcompLoggerAudit setKeyRequestId(String keyRequestId) { - return (EcompLoggerAudit) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerAudit setRemoteHost(String remoteHost) { - ecompMdcWrapper.setRemoteHost(remoteHost); - return this; - } - - public EcompLoggerAudit setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerAudit setStatusCode(String statusCode) { - // status code is either success (COMPLETE) or failure (ERROR) of the request. - String respStatus = Integer.parseInt(statusCode) / 100 == 2 ? StatusCode.COMPLETE.getStatusCodeEnum() : StatusCode.ERROR.getStatusCodeEnum(); - ecompMdcWrapper.setStatusCode(respStatus); - return this; - } - - public EcompLoggerAudit setPartnerName(String partnerName) { - ecompMdcWrapper.setPartnerName(partnerName); - return this; - } - - public EcompLoggerAudit setResponseCode(EcompLoggerErrorCode responseCode) { - ecompMdcWrapper.setResponseCode(responseCode.getErrorCode()); - return this; - } - - public EcompLoggerAudit setResponseDesc(String responseDesc) { - ecompMdcWrapper.setResponseDesc(responseDesc); - return this; - } - - public EcompLoggerAudit setOptServiceInstanceId(String serviceInstanceId) { - ecompMdcWrapper.setServiceInstanceId(serviceInstanceId); - return this; - } - - @Override - public EcompLoggerAudit clear() { - return (EcompLoggerAudit) super.clear(); - } - - @Override - public void initializeMandatoryFields() { - - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_END_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_STATUS_CODE); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_CODE); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_INSTANCE_ID); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_DESC); - ecompMdcWrapper.setMandatoryField(MDC_ELAPSED_TIME); - - //Theoretically Optional, but practically Mandatory - ecompMdcWrapper.setMandatoryField(MDC_SERVER_IP_ADDRESS); - ecompMdcWrapper.setMandatoryField(MDC_SERVER_FQDN); - - ecompMdcWrapper.setOptionalField(MDC_INSTANCE_UUID); - ecompMdcWrapper.setOptionalField(MDC_ALERT_SEVERITY); - ecompMdcWrapper.setOptionalField(MDC_REMOTE_HOST); - ecompMdcWrapper.setOptionalField(MDC_CLASS_NAME); - ecompMdcWrapper.setOptionalField(MDC_PROCESS_KEY); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD1); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD2); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD3); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD4); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java deleted file mode 100644 index 535e8a4204..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerBase.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.api.IEcompLogger; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.slf4j.Marker; - - -/** - * Created by mm288v on 12/27/2017. - * This class holds the common behavior of all Loger-Typed classes. - * The Concrete loggers shoudl derive from this one. - */ -public abstract class EcompLoggerBase implements IEcompLogger{ - private static Logger myLogger = LoggerFactory.getLogger(IEcompLogger.class.getName()); - private Marker myMarker; - IEcompMdcWrapper ecompMdcWrapper; - - EcompLoggerBase(IEcompMdcWrapper ecompMdcWrapper, Marker marker) { - this.ecompMdcWrapper = ecompMdcWrapper; - initializeMandatoryFields(); - this.myMarker = marker; - } - - @Override - public void log(LogLevel errorLevel, String message) { - - ecompMdcWrapper.validateMandatoryFields(); - - if (this instanceof EcompLoggerAudit || this instanceof EcompLoggerMetric) { - MDC.put(MDC_SERVER_IP_ADDRESS, EcompMDCWrapper.getInstance().getHostAddress()); - MDC.put(MDC_SERVER_FQDN, EcompMDCWrapper.getInstance().getFqdn()); - } - - if (errorLevel.equals(LogLevel.ERROR)) { - myLogger.error(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.WARN)) { - myLogger.warn(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.INFO)) { - myLogger.info(myMarker, message); - return; - } - - if (errorLevel.equals(LogLevel.DEBUG)) { - myLogger.info(myMarker, message); - } - } - - @Override - public IEcompLogger clear() { - ecompMdcWrapper.clear(); - return this; - } - - @Override - public IEcompLogger startTimer() { - ecompMdcWrapper.startTimer(); - return this; - } - - @Override - public IEcompLogger setKeyRequestId(String keyRequestId) { - ecompMdcWrapper.setKeyRequestId(keyRequestId); - return this; - } - -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java deleted file mode 100644 index aecb487e24..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerDebug.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - -public class EcompLoggerDebug extends EcompLoggerBase { - - private static EcompLoggerDebug instanceLoggerDebug = EcompLoggerFactory.getLogger(EcompLoggerDebug.class); - - protected final String endOfRecordDelimiter = "|^\\n"; - - EcompLoggerDebug(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text())); - } - - public static EcompLoggerDebug getInstance() { - return instanceLoggerDebug; - } - - @Override - public void log(LogLevel errorLevel, String message) { - String formattedMessage = String.format("%s%s", message, endOfRecordDelimiter); - super.log(errorLevel, formattedMessage); - } - - @Override - public void initializeMandatoryFields() { - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - } - - @Override - public EcompLoggerDebug clear() { - return (EcompLoggerDebug) super.clear(); - } - - @Override - public EcompLoggerDebug startTimer() { - return (EcompLoggerDebug) super.startTimer(); - } - - @Override - public EcompLoggerDebug setKeyRequestId(String keyRequestId) { - return (EcompLoggerDebug) super.setKeyRequestId(keyRequestId); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java deleted file mode 100644 index 92a495fda7..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerError.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CATEGORY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; - -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - -public class EcompLoggerError extends EcompLoggerBase{ - private static EcompLoggerError instanceLoggerError = EcompLoggerFactory.getLogger(EcompLoggerError.class); - - EcompLoggerError(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.ERROR_MARKER.text())); - } - - public static EcompLoggerError getInstance() { - return instanceLoggerError; - } - - @Override - public void initializeMandatoryFields() { - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_CATEGORY); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_CODE); - ecompMdcWrapper.setMandatoryField(MDC_ERROR_DESC); - - ecompMdcWrapper.setOptionalField(MDC_TARGET_ENTITY); - ecompMdcWrapper.setOptionalField(MDC_TARGET_SERVICE_NAME); - } - - @Override - public EcompLoggerError startTimer() { - return (EcompLoggerError) super.startTimer(); - } - - @Override - public EcompLoggerError setKeyRequestId(String keyRequestId) { - return (EcompLoggerError) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerError setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerError setTargetEntity(String targetEntity) { - ecompMdcWrapper.setTargetEntity(targetEntity); - return this; - } - - public EcompLoggerError setErrorCode(EcompLoggerErrorCode errorCode) { - ecompMdcWrapper.setErrorCode(errorCode.getErrorCode()); - return this; - } - - public EcompLoggerError setErrorDescription(String errorDescription) { - ecompMdcWrapper.setErrorDescription(errorDescription); - return this; - } - - public EcompLoggerError clear() { - return (EcompLoggerError) super.clear(); - } - -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java deleted file mode 100644 index 2ea1280f48..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -/** - * Created by dd4296 on 12/26/2017. - * this factory helps decouple the classes for Stopwatch and EcompMDCWrapper from - * the EcompLogger classes - */ -public class EcompLoggerFactory { - - private EcompLoggerFactory() { - } - - @SuppressWarnings("unchecked") - static public <T, V> V getLogger(Class<T> type) { - - if (type.getName().equals(EcompLoggerAudit.class.getName())) { - return (V) new EcompLoggerAudit(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerDebug.class.getName())) { - return (V) new EcompLoggerDebug(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerMetric.class.getName())) { - return (V) new EcompLoggerMetric(new EcompMDCWrapper(new Stopwatch())); - } - - if (type.getName().equals(EcompLoggerError.class.getName())) { - return (V) new EcompLoggerError(new EcompMDCWrapper(new Stopwatch())); - } - - return null; - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java deleted file mode 100644 index 2405a0eadf..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompLoggerMetric.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY; - -import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.slf4j.MarkerFactory; - - -public class EcompLoggerMetric extends EcompLoggerBase{ - private static EcompLoggerMetric instanceLoggerMetric = (EcompLoggerMetric) EcompLoggerFactory.getLogger(EcompLoggerMetric.class); - - EcompLoggerMetric(IEcompMdcWrapper ecompMdcWrapper) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text())); - } - - public static EcompLoggerMetric getInstance() { - return instanceLoggerMetric; - } - - @Override - public EcompLoggerMetric startTimer() { - return (EcompLoggerMetric) super.startTimer(); - } - - @Override - public EcompLoggerMetric setKeyRequestId(String keyRequestId) { - return (EcompLoggerMetric) super.setKeyRequestId(keyRequestId); - } - - public EcompLoggerMetric stopTimer() { - ecompMdcWrapper.stopTimer(); - return this; - } - - // automatic parameter this is optional - public EcompLoggerMetric setAutoServerFQDN(String serverFQDN) { - ecompMdcWrapper.setAutoServerFQDN(serverFQDN); - return this; - } - - // automatic parameter this is optional - public EcompLoggerMetric setAutoServerIPAddress(String serverIPAddress) { - ecompMdcWrapper.setAutoServerIPAddress(serverIPAddress); - return this; - } - - public EcompLoggerMetric setInstanceUUID(String instanceUUID) { - ecompMdcWrapper.setInstanceUUID(instanceUUID); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptProcessKey(String processKey) { - ecompMdcWrapper.setProcessKey(processKey); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptAlertSeverity(Severity alertSeverity) { - ecompMdcWrapper.setAlertSeverity(alertSeverity); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField1(String customField1) { - ecompMdcWrapper.setOptCustomField1(customField1); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField2(String customField2) { - ecompMdcWrapper.setOptCustomField2(customField2); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField3(String customField3) { - ecompMdcWrapper.setOptCustomField3(customField3); - return this; - } - - // ecomplog optional parameter - public EcompLoggerMetric setOptCustomField4(String customField4) { - ecompMdcWrapper.setOptCustomField4(customField4); - return this; - } - - public EcompLoggerMetric setRemoteHost(String remoteHost) { - ecompMdcWrapper.setRemoteHost(remoteHost); - return this; - } - - public EcompLoggerMetric setServiceName(String serviceName) { - ecompMdcWrapper.setServiceName(serviceName); - return this; - } - - public EcompLoggerMetric setStatusCode(String statusCode) { - ecompMdcWrapper.setStatusCode(statusCode); - return this; - } - - public EcompLoggerMetric setPartnerName(String partnerName) { - ecompMdcWrapper.setPartnerName(partnerName); - return this; - } - - public EcompLoggerMetric setResponseCode(int responseCode) { - ecompMdcWrapper.setResponseCode(responseCode); - return this; - } - - public EcompLoggerMetric setResponseDesc(String responseDesc) { - ecompMdcWrapper.setResponseDesc(responseDesc); - return this; - } - - public EcompLoggerMetric setOptServiceInstanceId(String serviceInstanceId) { - ecompMdcWrapper.setServiceInstanceId(serviceInstanceId); - return this; - } - - public EcompLoggerMetric setOptClassName(String className) { - ecompMdcWrapper.setClassName(className); - return this; - } - - public EcompLoggerMetric setTargetEntity(String targetEntity) { - ecompMdcWrapper.setTargetEntity(targetEntity); - return this; - } - - public EcompLoggerMetric setTargetServiceName(String targetServiceName) { - ecompMdcWrapper.setTargetServiceName(targetServiceName); - return this; - } - - public EcompLoggerMetric setTargetVirtualEntity(String targetVirtualEntity) { - ecompMdcWrapper.setTargetVirtualEntity(targetVirtualEntity); - return this; - } - - @Override - public EcompLoggerMetric clear () { - return (EcompLoggerMetric) super.clear(); - } - - - @Override - public void initializeMandatoryFields() { - - ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_END_TIMESTAMP); - ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME); - ecompMdcWrapper.setMandatoryField(MDC_STATUS_CODE); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_CODE); - ecompMdcWrapper.setMandatoryField(MDC_SERVICE_INSTANCE_ID); - ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_DESC); - ecompMdcWrapper.setMandatoryField(MDC_ELAPSED_TIME); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_ENTITY); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_SERVICE_NAME); - ecompMdcWrapper.setMandatoryField(MDC_TARGET_VIRTUAL_ENTITY); - - //Theoretically Optional, but practically Mandatory - ecompMdcWrapper.setMandatoryField(MDC_SERVER_IP_ADDRESS); - ecompMdcWrapper.setMandatoryField(MDC_SERVER_FQDN); - - ecompMdcWrapper.setOptionalField(MDC_INSTANCE_UUID); - ecompMdcWrapper.setOptionalField(MDC_ALERT_SEVERITY); - ecompMdcWrapper.setOptionalField(MDC_REMOTE_HOST); - ecompMdcWrapper.setOptionalField(MDC_CLASS_NAME); - ecompMdcWrapper.setOptionalField(MDC_PROCESS_KEY); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD1); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD2); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD3); - ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD4); - - - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java deleted file mode 100644 index 1d833ec6f9..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/EcompMDCWrapper.java +++ /dev/null @@ -1,290 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static java.lang.Integer.valueOf; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY; - -import java.net.InetAddress; -import java.util.ArrayList; - -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper; -import org.openecomp.sdc.common.ecomplog.api.IStopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -public class EcompMDCWrapper implements IEcompMdcWrapper { - - private static EcompMDCWrapper instanceMdcWrapper = new EcompMDCWrapper(new Stopwatch()); - - public static EcompMDCWrapper getInstance() { - return instanceMdcWrapper; - } - - private IStopWatch stopWatch; - protected static Logger log = LoggerFactory.getLogger(EcompMDCWrapper.class.getName()); - protected ArrayList<String> mandatoryFields = new ArrayList<>(); - protected ArrayList<String> optionalFields = new ArrayList<>(); - protected static String hostAddress; - protected static String fqdn; - - // in package classes can instantiate this class - // to use directly from outside the package usr the getInstance() Method - EcompMDCWrapper(IStopWatch stopwatch) { - this.stopWatch = stopwatch; - } - - static { - try { - hostAddress = InetAddress.getLocalHost().getHostAddress(); - fqdn = InetAddress.getByName(hostAddress).getCanonicalHostName(); - } catch (Exception ex) { - log.error("failed to get machine parameters", ex); - } - } - - @Override - public EcompMDCWrapper startTimer() { - stopWatch.start(); - return this; - } - - @Override - public EcompMDCWrapper stopTimer() { - try { - stopWatch.stop(); - } catch (Exception ex) { - log.error("StopWatch failed; probably start was not called before Stopwatch", ex); - } - return this; - } - - @Override - public EcompMDCWrapper setClassName(String className) { - MDC.put(MDC_CLASS_NAME, className); - return this; - } - - // automatic parameter this is optional - @Override - public EcompMDCWrapper setAutoServerFQDN(String serverFQDN) { - MDC.put(MDC_SERVER_FQDN, serverFQDN); - return this; - } - - // automatic parameter this is optional - @Override - public EcompMDCWrapper setAutoServerIPAddress(String serverIPAddress) { - MDC.put(MDC_SERVER_IP_ADDRESS, serverIPAddress); - return this; - } - - @Override - public EcompMDCWrapper setInstanceUUID(String instanceUUID) { - MDC.put(MDC_INSTANCE_UUID, instanceUUID); - return this; - } - - @Override - public EcompMDCWrapper setProcessKey(String processKey) { - MDC.put(MDC_PROCESS_KEY, processKey); - return this; - } - - @Override - public EcompMDCWrapper setAlertSeverity(Severity alertSeverity) { - MDC.put(MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType())); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField1(String customField1) { - MDC.put(MDC_OPT_FIELD1, customField1); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField2(String customField2) { - MDC.put(MDC_OPT_FIELD2, customField2); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField3(String customField3) { - MDC.put(MDC_OPT_FIELD3, customField3); - return this; - } - - @Override - public EcompMDCWrapper setOptCustomField4(String customField4) { - MDC.put(MDC_OPT_FIELD4, customField4); - return this; - } - - @Override - public EcompMDCWrapper setKeyRequestId(String keyRequestId) { - MDC.put(MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId() - return this; - } - - @Override - public EcompMDCWrapper setRemoteHost(String remoteHost) { - MDC.put(MDC_REMOTE_HOST, remoteHost); - return this; - } - - @Override - public EcompMDCWrapper setServiceName(String serviceName) { - MDC.put(MDC_SERVICE_NAME, serviceName); - return this; - } - - @Override - public EcompMDCWrapper setStatusCode(String statusCode) { - MDC.put(MDC_STATUS_CODE, statusCode); - return this; - } - - @Override - public EcompMDCWrapper setPartnerName(String partnerName) { - MDC.put(MDC_PARTNER_NAME, partnerName); - return this; - } - - @Override - public EcompMDCWrapper setResponseCode(int responseCode) { - MDC.put(MDC_RESPONSE_CODE, Integer.toString(responseCode)); - return this; - } - - @Override - public EcompMDCWrapper setResponseDesc(String responseDesc) { - MDC.put(MDC_RESPONSE_DESC, responseDesc); - return this; - } - - @Override - public EcompMDCWrapper setServiceInstanceId(String serviceInstanceId) { - MDC.put(MDC_SERVICE_INSTANCE_ID, serviceInstanceId); - return this; - } - - @Override - public EcompMDCWrapper setTargetEntity(String targetEntity) { - MDC.put(MDC_TARGET_ENTITY, targetEntity); - return this; - } - - @Override - public EcompMDCWrapper setTargetServiceName(String targetServiceName) { - MDC.put(MDC_TARGET_SERVICE_NAME, targetServiceName); - return this; - } - - @Override - public EcompMDCWrapper setTargetVirtualEntity(String targetVirtualEntity) { - MDC.put(MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); - return this; - } - - @Override - public EcompMDCWrapper setErrorCode(int errorCode) { - MDC.put(MDC_ERROR_CODE, valueOf(errorCode).toString()); - return this; - } - - @Override - public EcompMDCWrapper setErrorDescription(String errorDescription) { - MDC.put(MDC_ERROR_DESC, errorDescription); - return this; - } - - @Override - public void validateMandatoryFields() { - // this method only checks if the mandatory fields have been initialized - String filedNameThatHasNotBeenInitialized = checkMandatoryFieldsExistInMDC(); - - if (MDC.getCopyOfContextMap() == null || MDC.getCopyOfContextMap().isEmpty()) { - writeLogMDCEmptyError(); - return; - } - - if (!"".equalsIgnoreCase(filedNameThatHasNotBeenInitialized)) { - writeLogMissingFieldsError(filedNameThatHasNotBeenInitialized); - } - } - - protected void writeLogMissingFieldsError(String FiledNameThatHasNotBeenInitialized) { - log.error("mandatory parameters for EELF logging, missing fields: %s", FiledNameThatHasNotBeenInitialized); - } - - protected void writeLogMDCEmptyError() { - log.error("write to log when MDC is empty error"); - } - - @Override - public EcompMDCWrapper clear() { - mandatoryFields.forEach(MDC::remove); - optionalFields.forEach(MDC::remove); - return this; - } - - protected String checkMandatoryFieldsExistInMDC() { - // this method returns a String of uninitialised fields - StringBuilder missingFields = new StringBuilder(); - mandatoryFields.forEach(field -> { - if (isMDCParamEmpty(field)) { - missingFields.append(field).append(" "); - } - }); - return missingFields.toString(); - } - - @Override - public void setMandatoryField(String parameterName) { - mandatoryFields.add(parameterName); - } - - @Override - public void setOptionalField(String parameterName) { - optionalFields.add(parameterName); - } - - @Override - public boolean isMDCParamEmpty(String mdcKeyName) { - String val = MDC.get(mdcKeyName); - return (val == null || val.trim().length() == 0); - } - - @Override - public String getFqdn() { - return fqdn; - } - - @Override - public String getHostAddress() { - return hostAddress; - } -}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java deleted file mode 100644 index c6862656bb..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/EcompLoggerErrorCode.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.Enums; - -/** - * Created by dd4296 on 12/26/2017. - */ -public enum EcompLoggerErrorCode { - SUCCESS(0), - PERMISSION_ERROR(100), - AVAILABILITY_TIMEOUTS_ERROR(200), - DATA_ERROR(300), - SCHEMA_ERROR(400), - BUSINESS_PROCESS_ERROR(500), - UNKNOWN_ERROR(900); - - int errorCode; - - EcompLoggerErrorCode(int errorCode) { - this.errorCode = errorCode; - } - - public int getErrorCode() { - return errorCode; - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java deleted file mode 100644 index 76262e7815..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; - -import java.time.Clock; -import java.time.Duration; -import java.time.LocalDateTime; - -import org.openecomp.sdc.common.ecomplog.api.IStopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -/** - * Created by dd4296 on 12/13/2017. - * this is local implementation of the stopwatch class from EELF standard with the same interface - * can be replaced if needed with EELF lib - */ -public class Stopwatch implements IStopWatch { - - private static Logger log = LoggerFactory.getLogger(Stopwatch.class.getName()); - - public Stopwatch() { - } - - public void start() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null || MDC.get(MDC_BEGIN_TIMESTAMP).trim().length() == 0) - MDC.put(MDC_BEGIN_TIMESTAMP, generatedTimeNow()); - } - - public void stop() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null) { - log.error("call to stop without calling start first, this is not compliant with EELF format"); - } - MDC.put(MDC_END_TIMESTAMP, generatedTimeNow()); - setElapsedTime(); - } - - private void setElapsedTime() { - - try { - - final LocalDateTime startTime = LocalDateTime.parse(MDC.get(MDC_BEGIN_TIMESTAMP)); - final LocalDateTime endTime = LocalDateTime.parse(MDC.get(MDC_END_TIMESTAMP)); - - final Duration timeDifference = Duration.between(startTime, endTime); - - MDC.put(MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); - - } catch(Exception ex) { - log.error("failed to calculate elapsed time",ex); - } - } - - private String generatedTimeNow() { - return String.valueOf(LocalDateTime.now(Clock.systemUTC())); - } - -}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java deleted file mode 100644 index 569343eaf6..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogger.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -/** - * Created by dd4296 on 12/24/2017. - */ -public interface IEcompLogger { - void log(LogLevel errorLevel, String message); - void initializeMandatoryFields(); - IEcompLogger clear(); - IEcompLogger startTimer(); - IEcompLogger setKeyRequestId(String keyRequestId); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java deleted file mode 100644 index 37d77fd6c5..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompMdcWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -import org.openecomp.sdc.common.ecomplog.EcompMDCWrapper; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; - -/** - * Created by dd4296 on 12/25/2017. - */ -public interface IEcompMdcWrapper { - EcompMDCWrapper startTimer(); - - EcompMDCWrapper stopTimer(); - - EcompMDCWrapper setClassName(String className); - - // automatic parameter this is optional - EcompMDCWrapper setAutoServerFQDN(String serverFQDN); - - // automatic parameter this is optional - EcompMDCWrapper setAutoServerIPAddress(String serverIPAddress); - - EcompMDCWrapper setInstanceUUID(String instanceUUID); - - EcompMDCWrapper setProcessKey(String processKey); - - EcompMDCWrapper setAlertSeverity(Severity alertSeverity); - - EcompMDCWrapper setOptCustomField1(String customField1); - - EcompMDCWrapper setOptCustomField2(String customField2); - - EcompMDCWrapper setOptCustomField3(String customField3); - - EcompMDCWrapper setOptCustomField4(String customField4); - - EcompMDCWrapper setKeyRequestId(String keyRequestId); - - EcompMDCWrapper setRemoteHost(String remoteHost); - - EcompMDCWrapper setServiceName(String serviceName); - - EcompMDCWrapper setStatusCode(String statusCode); - - EcompMDCWrapper setPartnerName(String partnerName); - - EcompMDCWrapper setResponseCode(int responseCode); - - EcompMDCWrapper setResponseDesc(String responseDesc); - - EcompMDCWrapper setServiceInstanceId(String serviceInstanceId); - - EcompMDCWrapper setTargetEntity(String targetEntity); - - EcompMDCWrapper setTargetServiceName(String targetServiceName); - - EcompMDCWrapper setTargetVirtualEntity(String targetVirtualEntity); - - EcompMDCWrapper setErrorCode(int errorCode); - - EcompMDCWrapper setErrorDescription(String errorDescription); - - EcompMDCWrapper clear(); - - void validateMandatoryFields(); - - void setMandatoryField(String mdcKeyRequestId); - - void setOptionalField(String mdcKeyRequestId); - - boolean isMDCParamEmpty(String mdcKeyName); - - String getFqdn(); - - String getHostAddress(); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java deleted file mode 100644 index 4f1649cef1..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IStopWatch.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.openecomp.sdc.common.ecomplog.api; - -/** - * Created by dd4296 on 12/14/2017. - * - * stop watch interface compliant with ecomplog stop watch class - */ -public interface IStopWatch { - void start(); - void stop(); -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java deleted file mode 100644 index 57499b340d..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcAudit.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; - -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.ecomplog.EcompLoggerAudit; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.slf4j.MDC; - - -/** - * Created by dd4296 on 12/19/2017. - * - * audit log for asdc using the ecomplog library - * this is adapted for filter classes - */ -public class EcompLoggerSdcAudit extends EcompLoggerSdcUtilBase { - - private static String AUDIT_ON = "auditOn"; - private String className; - - public EcompLoggerSdcAudit(String className) { - this.className = className; - } - - public void startLog() { - EcompLoggerAudit - .getInstance() - .clear() - .startTimer(); - MDC.put(AUDIT_ON, "true"); - } - - public static boolean isFlowBeingTakenCare(){ - try - { - if (MDC.get(AUDIT_ON).equals("true")){ - return true; - } - return false; - } - catch (Exception E) - { - return false; - } - } - - public void log(HttpServletRequest sr, - ContainerRequestContext requestContext, - Response.StatusType statusInfo, - MultivaluedMap<String, Object> responseHeaders, - LogLevel errorLevel, - Severity securityLevel, - String message) { - - try { - EcompLoggerAudit.getInstance() - .stopTimer() - .setRemoteHost(sr.getRemoteAddr()) - .setServiceName(getServiceName(requestContext)) - .setResponseCode(convertHttpCodeToErrorCode(statusInfo.getStatusCode())) - .setStatusCode(Integer.toString(statusInfo.getStatusCode())) - .setResponseDesc(statusInfo.getReasonPhrase()) - .setKeyRequestId(getRequestIDfromHeaders(responseHeaders.get(Constants.X_ECOMP_REQUEST_ID_HEADER))) - - .setPartnerName(getPartnerName( - requestContext.getHeaderString("user-agent"), - requestContext.getHeaderString("USER_ID"), - getUrl(requestContext))) - - .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) - - .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) - .setOptClassName(className) - .setOptAlertSeverity(securityLevel) - .setOptCustomField1(requestContext.getMethod() + ": " + getUrl(requestContext)) - .setOptCustomField2(Integer.toString(statusInfo.getStatusCode())) - .log(errorLevel, message); - } - catch (Exception E) - { - log.warn("Faild to write to Audit Log. Original Message: {}", message); - } - finally { - MDC.put(AUDIT_ON,"false"); - } - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java deleted file mode 100644 index 57e9e8c5a0..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcDebug.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import java.util.Arrays; - -import org.openecomp.sdc.common.ecomplog.EcompLoggerDebug; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -public class EcompLoggerSdcDebug { - - public void log(LogLevel errorLevel, - String uuid, - String message, - Exception ex) { - - StringBuilder stackTrack = new StringBuilder(); - Arrays.asList(ex.getStackTrace()).forEach(item -> stackTrack.append(item.toString()).append("\n")); - - EcompLoggerDebug.getInstance() - .clear() - .startTimer() - .setKeyRequestId(uuid) - .log(errorLevel, String.format("%s %s", message, stackTrack.toString())); - } - - public void log(LogLevel errorLevel, - String uuid, - String message) { - - EcompLoggerDebug.getInstance() - .clear() - .startTimer() - .setKeyRequestId(uuid) - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java deleted file mode 100644 index a2478c40eb..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcError.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import org.openecomp.sdc.common.ecomplog.EcompLoggerError; -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; - -public class EcompLoggerSdcError { - - public void log(LogLevel errorLevel, - EcompLoggerErrorCode errorCodeEnum, - String uuid, - String errorDescription, - String partnerName, - String targetEntity, - String message) { - - EcompLoggerError.getInstance() - .clear() - .startTimer() - .setErrorDescription(errorDescription) - .setErrorCode(errorCodeEnum) - .setKeyRequestId(uuid) - .setServiceName(partnerName) - .setTargetEntity(targetEntity) - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java deleted file mode 100644 index 8603a77d08..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcMetric.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.container.ContainerRequestContext; -import javax.ws.rs.core.Response; - -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.ecomplog.EcompLoggerAudit; -import org.openecomp.sdc.common.ecomplog.EcompLoggerMetric; -import org.openecomp.sdc.common.ecomplog.Enums.LogLevel; -import org.openecomp.sdc.common.ecomplog.Enums.Severity; -import org.openecomp.sdc.common.util.ThreadLocalsHolder; - -/** - * Created by dd4296 on 12/20/2017. - * - * METRIC log for asdc using the ecomplog library - */ -public class EcompLoggerSdcMetric extends EcompLoggerSdcUtilBase { - - private String className; - - public EcompLoggerSdcMetric(String className) { - this.className = className; - } - - public void startLog() { - EcompLoggerAudit - .getInstance() - .clear() - .startTimer(); - } - - public void writeToLog(HttpServletRequest sr, - ContainerRequestContext requestContext, - Response.StatusType statusInfo, - LogLevel errorLevel, - Severity securityLevel, - String targetEntity, - String targetServiceName, - String targetVirtualEntity, - String message) { - - EcompLoggerMetric.getInstance() - .stopTimer() - .setRemoteHost(sr.getRemoteAddr()) - .setServiceName(getServiceName(requestContext)) - .setResponseCode(statusInfo.getStatusCode()) - .setStatusCode(Integer.toString(statusInfo.getStatusCode())) - .setResponseDesc(statusInfo.getReasonPhrase()) - .setKeyRequestId(ThreadLocalsHolder.getUuid()) - - .setPartnerName(getPartnerName( - requestContext.getHeaderString("user-agent"), - requestContext.getHeaderString("USER_ID"), - getUrl(requestContext))) - - .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) - - .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) - .setOptClassName(className) - .setOptAlertSeverity(securityLevel) - .setOptCustomField1(getUrl(requestContext) + "/" + requestContext.getMethod()) - - .setTargetEntity(targetEntity) - .setTargetServiceName(targetServiceName) - .setTargetVirtualEntity(targetVirtualEntity) - - .log(errorLevel, message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java index 26518a6456..1240f9a8f9 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClient.java @@ -1,9 +1,5 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.IOException; -import java.net.URI; -import java.util.Properties; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; @@ -13,13 +9,7 @@ import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.client.methods.*; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; @@ -29,11 +19,14 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.FunctionThrows; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import java.io.IOException; +import java.net.URI; +import java.util.Properties; public class HttpClient { - private static final Logger logger = LoggerFactory.getLogger(HttpClient.class); + private static final Logger logger = Logger.getLogger(HttpClient.class.getName()); private final CloseableHttpClient client; private final HttpClientConfigImmutable configImmutable; @@ -82,7 +75,7 @@ public class HttpClient { private <T> HttpResponse<T> execute(HttpRequestBase request, Properties headers, FunctionThrows<CloseableHttpResponse, HttpResponse<T>, Exception> responseBuilder) throws HttpExecuteException { if(configImmutable.getHeaders() != null) { - configImmutable.getHeaders().forEach((k, v) -> request.addHeader(k, v)); + configImmutable.getHeaders().forEach(request::addHeader); } if (headers != null) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java index bfd3b473b4..1745650c91 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientConfigImmutable.java @@ -1,14 +1,14 @@ package org.openecomp.sdc.common.http.client.api; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.http.config.BasicAuthorization; import org.openecomp.sdc.common.http.config.ClientCertificate; import org.openecomp.sdc.common.http.config.HttpClientConfig; import org.openecomp.sdc.common.http.config.Timeouts; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + final class HttpClientConfigImmutable { private final Map<String, String> headers; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java index c52880cb96..357eef3d0d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpClientFactory.java @@ -8,12 +8,11 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.http.config.ClientCertificate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class HttpClientFactory { - private static final Logger LOGGER = LoggerFactory.getLogger(HttpClientFactory.class); + private static final Logger logger = Logger.getLogger(HttpClientFactory.class.getName()); private static final UserTokenHandler userTokenHandler = context -> null; private final HttpConnectionMngFactory connectionMngFactory; @@ -22,7 +21,7 @@ public class HttpClientFactory { } HttpClient createClient(String protocol, HttpClientConfigImmutable config) { - LOGGER.debug("Create {} client based on {}", protocol, config); + logger.debug("Create {} client based on {}", protocol, config); ClientCertificate clientCertificate = Constants.HTTPS.equals(protocol) ? config.getClientCertificate() : null; HttpClientConnectionManager connectionManager = connectionMngFactory.getOrCreate(clientCertificate); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java index 6a408c92cd..de50e8a0a7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpConnectionMngFactory.java @@ -1,13 +1,5 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - import org.apache.commons.lang3.StringUtils; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; @@ -21,8 +13,15 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.http.config.ClientCertificate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class HttpConnectionMngFactory { @@ -33,7 +32,7 @@ public class HttpConnectionMngFactory { private static final String P12_KEYSTORE_TYPE = "pkcs12"; private static final String JKS_KEYSTORE_TYPE = "jks"; - private static final Logger logger = LoggerFactory.getLogger(HttpConnectionMngFactory.class); + private static final Logger logger = Logger.getLogger(HttpConnectionMngFactory.class.getName()); private static final int DEFAULT_CONNECTION_POOL_SIZE = 30; private static final int DEFAULT_MAX_CONNECTION_PER_ROUTE = 5; private static final int VALIDATE_CONNECTION_AFTER_INACTIVITY_MS = 10000; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java index 5722fc9c4e..9619e11a14 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequestHandler.java @@ -1,10 +1,6 @@ package org.openecomp.sdc.common.http.client.api; -import java.io.InputStream; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; - +import com.google.common.annotations.VisibleForTesting; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -13,8 +9,13 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.FunctionalInterfaces.FunctionThrows; import org.openecomp.sdc.common.http.config.HttpClientConfig; -public enum HttpRequestHandler { - HANDLER; +import java.io.InputStream; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +public class HttpRequestHandler { + private static HttpRequestHandler handlerInstance = new HttpRequestHandler(); private static final String HTTPS_PREFIX = "https://"; private static final String HTTP_PREFIX = "http://"; @@ -46,13 +47,13 @@ public enum HttpRequestHandler { httpResponse.getStatusLine().getReasonPhrase()); }; - HttpRequestHandler() { + private HttpRequestHandler() { HttpConnectionMngFactory connectionMngFactory = new HttpConnectionMngFactory(); clientFactory = new HttpClientFactory(connectionMngFactory); } - static HttpRequestHandler get() { - return HANDLER; + public static HttpRequestHandler get() { + return handlerInstance; } public HttpResponse<String> get(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException { @@ -100,7 +101,12 @@ public enum HttpRequestHandler { return clientFactory.createClient(protocol, config); } - private String getProtocol(String url) throws HttpExecuteException { + @VisibleForTesting + public static void setTestInstance(HttpRequestHandler handlerInstance) { + HttpRequestHandler.handlerInstance = handlerInstance; + } + + private String getProtocol(String url) throws HttpExecuteException { if (url.startsWith(HTTPS_PREFIX)) { return Constants.HTTPS; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java index 3e3b61f0f1..da5368d2a6 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RetryHandlers.java @@ -1,21 +1,20 @@ package org.openecomp.sdc.common.http.client.api; import org.apache.http.protocol.HttpContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; import java.io.IOException; public class RetryHandlers { - private static final Logger LOGGER = LoggerFactory.getLogger(RetryHandlers.class); + private static final Logger logger = Logger.getLogger(RetryHandlers.class.getName()); private RetryHandlers(){} public static ComparableHttpRequestRetryHandler getDefault(int numOfRetries) { return (IOException exception, int executionCount, HttpContext context) -> { - LOGGER.debug("failed sending request with exception", exception); - LOGGER.debug("try request number: {}", executionCount); + logger.debug("failed sending request with exception", exception); + logger.debug("try request number: {}", executionCount); return executionCount <= numOfRetries; }; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java index 4fb8fadce4..57750be0f1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java @@ -1,10 +1,9 @@ package org.openecomp.sdc.common.http.config; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.security.SecurityUtil; -import fj.data.Either; - public class BasicAuthorization { private String userName; private String password; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java index 972a4178e0..11e0fa7b1b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/ClientCertificate.java @@ -1,10 +1,9 @@ package org.openecomp.sdc.common.http.config; +import fj.data.Either; import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.security.SecurityUtil; -import fj.data.Either; - public class ClientCertificate { private String keyStore; private String keyStorePassword; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java index 69789957b4..c454ffcb0e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/HttpClientConfig.java @@ -1,9 +1,9 @@ package org.openecomp.sdc.common.http.config; -import java.util.Map; - import org.openecomp.sdc.common.http.client.api.ComparableHttpRequestRetryHandler; +import java.util.Map; + public class HttpClientConfig { private BasicAuthorization basicAuthorization; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java index 9364dad476..3a7ccd774a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java @@ -20,24 +20,23 @@ package org.openecomp.sdc.common.impl; +import org.apache.commons.jci.listeners.FileChangeListener; +import org.openecomp.sdc.common.api.BasicConfiguration; +import org.openecomp.sdc.common.api.ConfigurationListener; +import org.openecomp.sdc.common.log.wrappers.Logger; +import org.openecomp.sdc.common.util.YamlToObjectConverter; + import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.jci.listeners.FileChangeListener; -import org.openecomp.sdc.common.api.BasicConfiguration; -import org.openecomp.sdc.common.api.ConfigurationListener; -import org.openecomp.sdc.common.util.YamlToObjectConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ConfigFileChangeListener extends FileChangeListener { - private static Logger log = LoggerFactory.getLogger(ConfigFileChangeListener.class.getName()); + private static Logger log = Logger.getLogger(ConfigFileChangeListener.class.getName()); - private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<String, List<ConfigurationListener>>(); + private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<>(); private Object lock = new Object(); @@ -116,7 +115,7 @@ public class ConfigFileChangeListener extends FileChangeListener { List<ConfigurationListener> callbacks = fileChangeToCallBack.get(id); if (callbacks == null) { - callbacks = new ArrayList<ConfigurationListener>(); + callbacks = new ArrayList<>(); fileChangeToCallBack.put(id, callbacks); } callbacks.add(configurationListener); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java index b23dcb8812..79a78828e8 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java @@ -20,11 +20,11 @@ package org.openecomp.sdc.common.impl; -import java.io.File; - import org.apache.commons.jci.monitor.FilesystemAlterationMonitor; import org.openecomp.sdc.common.api.ConfigurationSource; +import java.io.File; + /** * * Save the diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java index c7ce7a8c32..3b88ff8978 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/MutableHttpServletRequest.java @@ -20,15 +20,9 @@ package org.openecomp.sdc.common.impl; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; +import java.util.*; public final class MutableHttpServletRequest extends HttpServletRequestWrapper { // holds custom header and value mapping @@ -36,7 +30,7 @@ public final class MutableHttpServletRequest extends HttpServletRequestWrapper { public MutableHttpServletRequest(HttpServletRequest request) { super(request); - this.customHeaders = new HashMap<String, String>(); + this.customHeaders = new HashMap<>(); } public void putHeader(String name, String value) { @@ -56,7 +50,7 @@ public final class MutableHttpServletRequest extends HttpServletRequestWrapper { public Enumeration<String> getHeaderNames() { // create a set of the custom header names - Set<String> set = new HashSet<String>(customHeaders.keySet()); + Set<String> set = new HashSet<>(customHeaders.keySet()); // now add the headers from the wrapped request object @SuppressWarnings("unchecked") diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java index dfcf5b58c0..a4fc1b520e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/jsongraph/util/CommonUtility.java @@ -20,7 +20,7 @@ package org.openecomp.sdc.common.jsongraph.util; -import org.slf4j.Logger; +import org.openecomp.sdc.common.log.wrappers.Logger; /** * Provides common utility: functionality, common fields and enumerations diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java index 5644ef5c41..65cf7161d4 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/kpi/api/ASDCKpiApi.java @@ -20,12 +20,11 @@ package org.openecomp.sdc.common.kpi.api; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; public class ASDCKpiApi { - private static Logger log = LoggerFactory.getLogger(ASDCKpiApi.class.getName()); + private static Logger log = Logger.getLogger(ASDCKpiApi.class.getName()); /* Number of activated resource imports. */ public static void countImportResourcesKPI() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java index 75449529d6..f5325a73e1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java @@ -20,6 +20,15 @@ package org.openecomp.sdc.common.listener; +import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; +import org.openecomp.sdc.common.log.wrappers.Logger; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -28,20 +37,9 @@ import java.util.Map; import java.util.jar.Attributes; import java.util.jar.Manifest; -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import org.openecomp.sdc.common.api.ConfigurationSource; -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.impl.ExternalConfiguration; -import org.openecomp.sdc.common.impl.FSConfigurationSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class AppContextListener implements ServletContextListener { - private static Logger log = LoggerFactory.getLogger(AppContextListener.class.getName()); + private static Logger log = Logger.getLogger(AppContextListener.class.getName()); public void contextInitialized(ServletContextEvent context) { @@ -91,7 +89,7 @@ public class AppContextListener implements ServletContextListener { public static Map<String, String> getManifestInfo(ServletContext application) { - Map<String, String> result = new HashMap<String, String>(); + Map<String, String> result = new HashMap<>(); InputStream inputStream = null; try { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java index 6521ea78e1..d5acb34319 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/api/IEcompLogConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java @@ -1,17 +1,6 @@ -package org.openecomp.sdc.common.ecomplog.api; +package org.openecomp.sdc.common.log.api; -public interface IEcompLogConfiguration { - String PROPERTY_LOGGING_FILE_NAME = "com.att.ecomplog.logging.file"; - String PROPERTY_LOGGING_FILE_PATH = "com.att.ecomplog.logging.path"; - String GENERAL_LOGGER_NAME = "com.att.ecomplog"; - String METRICS_LOGGER_NAME = "com.att.ecomplog.metrics"; - String PERF_LOGGER_NAME = "com.att.ecomplog.perf"; - String POLICY_LOGGER_NAME = "com.att.ecomplog.policy"; - String SECURITY_LOGGER_NAME = "com.att.ecomplog.security"; - String SERVER_LOGGER_NAME = "com.att.ecomplog.server"; - String AUDIT_LOGGER_NAME = "com.att.ecomplog.audit"; - String ERROR_LOGGER_NAME = "com.att.ecomplog.error"; - String DEBUG_LOGGER_NAME = "com.att.ecomplog.debug"; +public interface ILogConfiguration { String MDC_KEY_REQUEST_ID = "RequestId"; String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceId"; String MDC_SERVICE_NAME = "ServiceName"; @@ -19,8 +8,10 @@ public interface IEcompLogConfiguration { String MDC_SERVER_IP_ADDRESS = "ServerIPAddress"; String MDC_SERVER_FQDN = "ServerFQDN"; String MDC_REMOTE_HOST = "RemoteHost"; + String MDC_AUDIT_MESSAGE = "AuditMessage"; String MDC_ALERT_SEVERITY = "AlertSeverity"; - String MDC_BEGIN_TIMESTAMP = "BeginTimestamp"; + String MDC_AUDIT_BEGIN_TIMESTAMP = "AuditBeginTimestamp"; + String MDC_METRIC_BEGIN_TIMESTAMP = "MetricBeginTimestamp"; String MDC_END_TIMESTAMP = "EndTimestamp"; String MDC_PARTNER_NAME = "PartnerName"; String MDC_STATUS_CODE = "StatusCode"; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java new file mode 100644 index 0000000000..1c46a41af2 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java @@ -0,0 +1,111 @@ +package org.openecomp.sdc.common.log.api; + +import org.openecomp.sdc.common.log.enums.Severity; + +/** + * Created by dd4296 on 12/25/2017. + */ +public interface ILogFieldsHandler { + void startAuditTimer(); + + void startMetricTimer(); + + void stopAuditTimer(); + + void stopMetricTimer(); + + void setClassName(String className); + + void setServerFQDN(String serverFQDN); + + void setServerIPAddress(String serverIPAddress); + + // intended for setting this parameter in a given thread + void setServerFQDNInternally(); + + // intended for setting this parameter in a given thread + void setServerIPAddressInternally(); + + void setInstanceUUID(String instanceUUID); + + void setProcessKey(String processKey); + + void setAlertSeverity(Severity alertSeverity); + + void setOptCustomField1(String customField1); + + void setOptCustomField2(String customField2); + + void setOptCustomField3(String customField3); + + void setOptCustomField4(String customField4); + + void setKeyRequestId(String keyRequestId); + + void setRemoteHost(String remoteHost); + + void setServiceName(String serviceName); + + void setStatusCode(String statusCode); + + void setPartnerName(String partnerName); + + void setResponseCode(int responseCode); + + void setResponseDesc(String responseDesc); + + void setServiceInstanceId(String serviceInstanceId); + + void setTargetEntity(String targetEntity); + + void setTargetServiceName(String targetServiceName); + + void setTargetVirtualEntity(String targetVirtualEntity); + + void setErrorCode(int errorCode); + + void setErrorCategory(String errorCategory); + + String getErrorCode(); + + String getServiceName(); + + String getErrorCategory(); + + void clear(); + + boolean isMDCParamEmpty(String mdcKeyName); + + String getFqdn(); + + String getHostAddress(); + + String getKeyRequestId(); + + void removeStatusCode(); + + void removePartnerName(); + + void removeResponseCode(); + + void removeResponseDesc(); + + void removeServiceInstanceId(); + + void removeTargetEntity(); + + void removeTargetServiceName(); + + void removeTargetVirtualEntity(); + + void removeErrorCode(); + + void removeErrorCategory(); + + void removeErrorDescription(); + + void setAuditMessage(String message); + + String getAuditMessage(); + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java new file mode 100644 index 0000000000..887be9189e --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java @@ -0,0 +1,18 @@ +package org.openecomp.sdc.common.log.api; + +import org.openecomp.sdc.common.log.enums.LogLevel; + +import java.util.List; + +/** + * Created by dd4296 on 12/24/2017. + */ +public interface ILogger { + void log(LogLevel logLevel, String message); + void log(LogLevel logLevel, String message, Object...params); + void log(LogLevel logLevel, String message, Throwable throwable); + List<String> getMandatoryFields(); + ILogger clear(); + ILogger startTimer(); + ILogger setKeyRequestId(String keyRequestId); +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java new file mode 100644 index 0000000000..3e4d7d4c89 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java @@ -0,0 +1,322 @@ +package org.openecomp.sdc.common.log.elements; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.Severity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; + +import java.net.InetAddress; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; + +import static java.lang.Integer.valueOf; + +public class LogFieldsMdcHandler implements ILogFieldsHandler { + + private static LogFieldsMdcHandler instanceMdcWrapper = new LogFieldsMdcHandler(); + + public static LogFieldsMdcHandler getInstance() { + return instanceMdcWrapper; + } + + private final static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSSz"; + private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(dateFormatPattern); + protected static Logger log = LoggerFactory.getLogger(LogFieldsMdcHandler.class.getName()); + protected static String hostAddress; + protected static String fqdn; + + static { + try { + hostAddress = InetAddress.getLocalHost().getHostAddress(); + fqdn = InetAddress.getByName(hostAddress).getCanonicalHostName(); + } catch (Exception ex) { + log.error("failed to get machine parameters", ex); + } + } + + @Override + public void startAuditTimer() { + if (StringUtils.isEmpty(MDC.get(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP))) { + MDC.put(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP, generatedTimeNow()); + } + } + + @Override + public void startMetricTimer() { + if (StringUtils.isEmpty(MDC.get(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP))) { + MDC.put(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP, generatedTimeNow()); + } + } + + @Override + public void stopAuditTimer() { + //set start time if it is not set yet + startAuditTimer(); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); + setElapsedTime(MDC.get(ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP)); + } + + @Override + public void stopMetricTimer() { + //set start time if it is not set yet + startMetricTimer(); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); + setElapsedTime(MDC.get(ILogConfiguration.MDC_METRIC_BEGIN_TIMESTAMP)); + } + + @Override + public void setClassName(String className) { + MDC.put(ILogConfiguration.MDC_CLASS_NAME, className); + } + + @Override + public void setServerFQDN(String serverFQDN) { + MDC.put(ILogConfiguration.MDC_SERVER_FQDN, serverFQDN); + } + + @Override + public void setServerIPAddress(String serverIPAddress) { + MDC.put(ILogConfiguration.MDC_SERVER_IP_ADDRESS, serverIPAddress); + } + + @Override + public void setServerFQDNInternally() { + setServerFQDN(fqdn); + } + + @Override + public void setServerIPAddressInternally() { + setServerIPAddress(hostAddress); + } + + @Override + public void setInstanceUUID(String instanceUUID) { + MDC.put(ILogConfiguration.MDC_INSTANCE_UUID, instanceUUID); + } + + @Override + public void setProcessKey(String processKey) { + MDC.put(ILogConfiguration.MDC_PROCESS_KEY, processKey); + } + + @Override + public void setAlertSeverity(Severity alertSeverity) { + MDC.put(ILogConfiguration.MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType())); + } + + @Override + public void setOptCustomField1(String customField1) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD1, customField1); + } + + @Override + public void setOptCustomField2(String customField2) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD2, customField2); + } + + @Override + public void setOptCustomField3(String customField3) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD3, customField3); + } + + @Override + public void setOptCustomField4(String customField4) { + MDC.put(ILogConfiguration.MDC_OPT_FIELD4, customField4); + } + + @Override + public void setKeyRequestId(String keyRequestId) { + MDC.put(ILogConfiguration.MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId() + } + + @Override + public void setRemoteHost(String remoteHost) { + MDC.put(ILogConfiguration.MDC_REMOTE_HOST, remoteHost); + } + + @Override + public void setServiceName(String serviceName) { + MDC.put(ILogConfiguration.MDC_SERVICE_NAME, serviceName); + } + + @Override + public void setStatusCode(String statusCode) { + MDC.put(ILogConfiguration.MDC_STATUS_CODE, statusCode); + } + + @Override + public void setPartnerName(String partnerName) { + MDC.put(ILogConfiguration.MDC_PARTNER_NAME, partnerName); + } + + @Override + public void setResponseCode(int responseCode) { + MDC.put(ILogConfiguration.MDC_RESPONSE_CODE, Integer.toString(responseCode)); + } + + @Override + public void setResponseDesc(String responseDesc) { + MDC.put(ILogConfiguration.MDC_RESPONSE_DESC, responseDesc); + } + + @Override + public void setServiceInstanceId(String serviceInstanceId) { + MDC.put(ILogConfiguration.MDC_SERVICE_INSTANCE_ID, serviceInstanceId); + } + + @Override + public void setTargetEntity(String targetEntity) { + MDC.put(ILogConfiguration.MDC_TARGET_ENTITY, targetEntity); + } + + @Override + public void setTargetServiceName(String targetServiceName) { + MDC.put(ILogConfiguration.MDC_TARGET_SERVICE_NAME, targetServiceName); + } + + @Override + public void setTargetVirtualEntity(String targetVirtualEntity) { + MDC.put(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + } + + @Override + public void setErrorCode(int errorCode) { + MDC.put(ILogConfiguration.MDC_ERROR_CODE, valueOf(errorCode).toString()); + } + + @Override + public void setErrorCategory(String errorCategory) { + MDC.put(ILogConfiguration.MDC_ERROR_CATEGORY, errorCategory); + } + + @Override + public String getErrorCode() { + return MDC.get(ILogConfiguration.MDC_ERROR_CODE); + } + + @Override + public String getServiceName() { + return MDC.get(ILogConfiguration.MDC_SERVICE_NAME); + } + + @Override + public String getErrorCategory() { + return MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY); + } + + @Override + public void clear() { + MDC.clear(); + } + + @Override + public boolean isMDCParamEmpty(String mdcKeyName) { + return StringUtils.isEmpty(MDC.get(mdcKeyName)); + } + + @Override + public String getFqdn() { + return fqdn; + } + + @Override + public String getHostAddress() { + return hostAddress; + } + + @Override + public String getKeyRequestId() { + return MDC.get(ILogConfiguration.MDC_KEY_REQUEST_ID); + } + + @Override + public void removeStatusCode() { + MDC.remove(ILogConfiguration.MDC_STATUS_CODE); + } + + @Override + public void removePartnerName(){ + MDC.remove(ILogConfiguration.MDC_PARTNER_NAME); + } + + @Override + public void removeResponseCode(){ + MDC.remove(ILogConfiguration.MDC_RESPONSE_CODE); + } + + @Override + public void removeResponseDesc(){ + MDC.remove(ILogConfiguration.MDC_RESPONSE_DESC); + } + + @Override + public void removeServiceInstanceId(){ + MDC.remove(ILogConfiguration.MDC_SERVICE_INSTANCE_ID); + } + + @Override + public void removeTargetEntity(){ + MDC.remove(ILogConfiguration.MDC_TARGET_ENTITY); + } + + @Override + public void removeTargetServiceName(){ + MDC.remove(ILogConfiguration.MDC_TARGET_SERVICE_NAME); + } + + @Override + public void removeTargetVirtualEntity(){ + MDC.remove(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY); + } + + @Override + public void removeErrorCode(){ + MDC.remove(ILogConfiguration.MDC_ERROR_CODE); + } + + @Override + public void removeErrorCategory(){ + MDC.remove(ILogConfiguration.MDC_ERROR_CATEGORY); + } + + @Override + public void removeErrorDescription(){ + MDC.remove(ILogConfiguration.MDC_ERROR_DESC); + } + + @Override + public void setAuditMessage(String message) { + MDC.put(ILogConfiguration.MDC_AUDIT_MESSAGE, message); + } + + @Override + public String getAuditMessage() { + return MDC.get(ILogConfiguration.MDC_AUDIT_MESSAGE); + } + + private void setElapsedTime(String beginTimestamp) { + try { + final LocalDateTime startTime = LocalDateTime.parse(beginTimestamp, dateTimeFormatter); + final LocalDateTime endTime = LocalDateTime.parse(MDC.get(ILogConfiguration.MDC_END_TIMESTAMP), dateTimeFormatter); + final Duration timeDifference = Duration.between(startTime, endTime); + + MDC.put(ILogConfiguration.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); + + } catch(Exception ex) { + log.error("failed to calculate elapsed time",ex); + } + } + + private String generatedTimeNow() { + return dateTimeFormatter + .withZone(ZoneOffset.UTC) + .format(Instant.now()); + } + +}
\ No newline at end of file diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java new file mode 100644 index 0000000000..61ae477caf --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java @@ -0,0 +1,166 @@ +package org.openecomp.sdc.common.log.elements; + + +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.log.enums.StatusCode; +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class LoggerAudit extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_AUDIT_BEGIN_TIMESTAMP, + ILogConfiguration.MDC_END_TIMESTAMP, + ILogConfiguration.MDC_KEY_REQUEST_ID, + ILogConfiguration.MDC_SERVICE_NAME, + ILogConfiguration.MDC_PARTNER_NAME, + ILogConfiguration.MDC_STATUS_CODE, + ILogConfiguration.MDC_RESPONSE_CODE, + ILogConfiguration.MDC_SERVICE_INSTANCE_ID, + ILogConfiguration.MDC_RESPONSE_DESC, + ILogConfiguration.MDC_ELAPSED_TIME, + ILogConfiguration.MDC_SERVER_IP_ADDRESS, + ILogConfiguration.MDC_SERVER_FQDN)); + + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_INSTANCE_UUID, + ILogConfiguration.MDC_ALERT_SEVERITY, + ILogConfiguration.MDC_REMOTE_HOST, + ILogConfiguration.MDC_CLASS_NAME, + ILogConfiguration.MDC_PROCESS_KEY, + ILogConfiguration.MDC_OPT_FIELD1, + ILogConfiguration.MDC_OPT_FIELD2, + ILogConfiguration.MDC_OPT_FIELD3, + ILogConfiguration.MDC_OPT_FIELD4)); + + LoggerAudit(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super (ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.AUDIT_MARKER.text()), logger); + //put the remote host and FQDN values from another thread if they are set + ecompMdcWrapper.setServerIPAddressInternally(); + ecompMdcWrapper.setServerFQDNInternally(); + } + + @Override + public LoggerAudit startTimer() { + ecompLogFieldsHandler.startAuditTimer(); + return this; + } + + public LoggerAudit stopTimer() { + ecompLogFieldsHandler.stopAuditTimer(); + return this; + } + + public LoggerAudit setInstanceUUID(String instanceUUID) { + ecompLogFieldsHandler.setInstanceUUID(instanceUUID); + return this; + } + + public LoggerAudit setOptClassName(String className) { + MDC.put("ClassName", className); + return this; + } + + public LoggerAudit setOptProcessKey(String processKey) { + ecompLogFieldsHandler.setProcessKey(processKey); + return this; + } + + public LoggerAudit setOptAlertSeverity(Severity alertSeverity) { + ecompLogFieldsHandler.setAlertSeverity(alertSeverity); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField1(String customField1) { + ecompLogFieldsHandler.setOptCustomField1(customField1); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField2(String customField2) { + ecompLogFieldsHandler.setOptCustomField2(customField2); + return this; + } + + // log optional parameter + public LoggerAudit setOptCustomField3(String customField3) { + ecompLogFieldsHandler.setOptCustomField3(customField3); + return this; + } + + public LoggerAudit setOptCustomField4(String customField4) { + ecompLogFieldsHandler.setOptCustomField4(customField4); + return this; + } + + @Override + public LoggerAudit setKeyRequestId(String keyRequestId) { + return (LoggerAudit) super.setKeyRequestId(keyRequestId); + } + + public LoggerAudit setRemoteHost(String remoteHost) { + ecompLogFieldsHandler.setRemoteHost(remoteHost); + return this; + } + + public LoggerAudit setServiceName(String serviceName) { + ecompLogFieldsHandler.setServiceName(serviceName); + return this; + } + + public LoggerAudit setStatusCode(String statusCode) { + // status code is either success (COMPLETE) or failure (ERROR) of the request. + String respStatus = Integer.parseInt(statusCode) / 100 == 2 ? StatusCode.COMPLETE.getStatusCodeEnum() : StatusCode.ERROR.getStatusCodeEnum(); + ecompLogFieldsHandler.setStatusCode(respStatus); + return this; + } + + public LoggerAudit setPartnerName(String partnerName) { + ecompLogFieldsHandler.setPartnerName(partnerName); + return this; + } + + public LoggerAudit setResponseCode(EcompLoggerErrorCode responseCode) { + ecompLogFieldsHandler.setResponseCode(responseCode.getErrorCode()); + return this; + } + + public LoggerAudit setResponseDesc(String responseDesc) { + ecompLogFieldsHandler.setResponseDesc(responseDesc); + return this; + } + + public LoggerAudit setOptServiceInstanceId(String serviceInstanceId) { + ecompLogFieldsHandler.setServiceInstanceId(serviceInstanceId); + return this; + } + + public String getAuditMessage() { + return ecompLogFieldsHandler.getAuditMessage(); + } + + + @Override + public List<String> getMandatoryFields() { + return Collections.unmodifiableList(mandatoryFields); + } + + @Override + public LoggerAudit clear() { + super.clear(); + ecompLogFieldsHandler.setServerFQDNInternally(); + ecompLogFieldsHandler.setServerIPAddressInternally(); + return this; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java new file mode 100644 index 0000000000..c449f6fdaf --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java @@ -0,0 +1,145 @@ +package org.openecomp.sdc.common.log.elements; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.api.ILogger; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.Logger; +import org.slf4j.Marker; +import org.slf4j.MarkerFactory; + +import java.util.Arrays; +import java.util.List; + + +/** + * Created by mm288v on 12/27/2017. + * This class holds the common behavior of all Loger-Typed classes. + * The Concrete loggers shoudl derive from this one. + */ +public abstract class LoggerBase implements ILogger { + private final Logger myLogger; + private final Marker myMarker; + protected final ILogFieldsHandler ecompLogFieldsHandler; + private final static String missingLogFieldsMsg = "mandatory parameters for ECOMP logging, missing fields: %s, original message: %s"; + + LoggerBase(ILogFieldsHandler ecompLogFieldsHandler, Marker marker, Logger logger) { + this.ecompLogFieldsHandler = ecompLogFieldsHandler; + this.myMarker = marker; + this.myLogger = logger; + setKeyRequestIdIfNotSetYet(); + } + + protected void setKeyRequestIdIfNotSetYet() { + if (StringUtils.isEmpty(ecompLogFieldsHandler.getKeyRequestId())) { + setKeyRequestId(ThreadLocalsHolder.getUuid()); + } + } + private void validateMandatoryFields(String originMsg) { + // this method only checks if the mandatory fields have been initialized + String filedNameThatHasNotBeenInitialized = checkMandatoryFieldsExistInMDC(); + + if (myLogger.isDebugEnabled() && !"".equalsIgnoreCase(filedNameThatHasNotBeenInitialized)) { + myLogger.debug(MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), + String.format(missingLogFieldsMsg, filedNameThatHasNotBeenInitialized, originMsg)); + } + } + + @VisibleForTesting + String checkMandatoryFieldsExistInMDC() { + // this method returns a String of uninitialised fields + StringBuilder missingFields = new StringBuilder(); + getMandatoryFields().forEach(field -> { + if (ecompLogFieldsHandler.isMDCParamEmpty(field)) { + missingFields.append(field).append(" "); + } + }); + return missingFields.toString(); + } + + public abstract List<String> getMandatoryFields(); + + protected String convertExceptionStackToString(Exception ex) { + StringBuilder stackTrack = new StringBuilder(); + Arrays.asList(ex.getStackTrace()).forEach(item -> stackTrack.append(item.toString()).append("\n")); + return stackTrack.toString(); + } + + @Override + public void log(LogLevel logLevel, String message) { + log(logLevel, message, (Object) null); + } + + @Override + public void log(LogLevel logLevel, String message, Object...params) { + validateMandatoryFields(message); + + switch(logLevel) { + case ERROR: + case FATAL: //TODO check how to log "FATAL" word + myLogger.error(myMarker, message, params); + break; + case WARN: + myLogger.warn(myMarker, message, params); + break; + case INFO: + myLogger.info(myMarker, message, params); + break; + case DEBUG: + myLogger.debug(myMarker, message, params); + break; + case TRACE: + myLogger.trace(myMarker, message, params); + break; + default: + break; + } + } + + @Override + public void log(LogLevel logLevel, String message, Throwable throwable) { + validateMandatoryFields(message); + + switch(logLevel) { + case ERROR: + case FATAL: //TODO check how to log "FATAL" word + myLogger.error(myMarker, createErrorMessage(message, throwable)); + break; + case WARN: + myLogger.warn(myMarker, createErrorMessage(message, throwable)); + break; + case INFO: + myLogger.info(myMarker, createErrorMessage(message, throwable)); + break; + case DEBUG: + myLogger.debug(myMarker, message, throwable); + break; + case TRACE: + myLogger.trace(myMarker, message, throwable); + break; + default: + break; + } + } + + protected String createErrorMessage(String message, Throwable throwable) { + return String.format("%s: %s", message, throwable.getLocalizedMessage()); + } + + + @Override + public ILogger clear() { + ecompLogFieldsHandler.clear(); + return this; + } + + @Override + public ILogger setKeyRequestId(String keyRequestId) { + ecompLogFieldsHandler.setKeyRequestId(keyRequestId); + return this; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java new file mode 100644 index 0000000000..6ac1267ed6 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java @@ -0,0 +1,55 @@ +package org.openecomp.sdc.common.log.elements; + +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class LoggerDebug extends LoggerBase { + + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList(ILogConfiguration.MDC_KEY_REQUEST_ID)); + + LoggerDebug(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), logger); + } + + @Override + public LoggerDebug clear() { + //nothing to clean up + return this; + } + + @Override + public void log(LogLevel logLevel, String message, Object...params){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message, params); + } + + @Override + public void log(LogLevel logLevel, String message, Throwable throwable){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message, throwable); + } + + @Override + public void log(LogLevel logLevel, String message){ + setKeyRequestIdIfNotSetYet(); + super.log(logLevel, message); + } + + @Override + public LoggerDebug startTimer() { + return this; + } + + @Override + public List<String> getMandatoryFields() { + return mandatoryFields; + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java new file mode 100644 index 0000000000..97878ec7a1 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java @@ -0,0 +1,130 @@ +package org.openecomp.sdc.common.log.elements; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.config.EcompErrorConfiguration; +import org.openecomp.sdc.common.log.api.ILogConfiguration; +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class LoggerError extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_KEY_REQUEST_ID, + ILogConfiguration.MDC_SERVICE_NAME, + ILogConfiguration.MDC_ERROR_CATEGORY, + ILogConfiguration.MDC_ERROR_CODE)); + + public static final String defaultServiceName = "SDC catalog"; + + LoggerError(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.ERROR_MARKER.text()), logger); + } + + @Override + public List<String> getMandatoryFields() { + return Collections.unmodifiableList(mandatoryFields); + } + + @Override + public LoggerError setKeyRequestId(String keyRequestId) { + return (LoggerError) super.setKeyRequestId(keyRequestId); + } + + @Override + public LoggerError startTimer() { + return this; + } + + @Override + public LoggerError clear() { + ecompLogFieldsHandler.removeErrorCategory(); + ecompLogFieldsHandler.removeErrorDescription(); + ecompLogFieldsHandler.removeErrorCode(); + return this; + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String message, Object...params) { + fillFieldsBeforeLogging(logLevel, errorCodeEnum, serviceName, targetEntity); + super.log(logLevel, message, params); + } + + private void fillFieldsBeforeLogging(LogLevel logLevel, EcompLoggerErrorCode errorCodeEnum, String serviceName, String targetEntity) { + clear(); + ecompLogFieldsHandler.setErrorCode(errorCodeEnum.getErrorCode()); + ecompLogFieldsHandler.setErrorCategory(logLevel.name()); + if (!StringUtils.isEmpty(targetEntity)) { + //avoid overriding this parameter in MDC + ecompLogFieldsHandler.setTargetEntity(targetEntity); + } + if (StringUtils.isEmpty(ecompLogFieldsHandler.getServiceName())) { + ecompLogFieldsHandler.setServiceName(serviceName); + } + setKeyRequestIdIfNotSetYet(); + } + + public void log(EcompErrorConfiguration.EcompErrorSeverity errorSeverity, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String message, Object... params) { + log(convertFromSeverityErrorLevel(errorSeverity), errorCodeEnum, serviceName, targetEntity, message, params); + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String message, Object...params) { + log(logLevel, errorCodeEnum, serviceName, null, message, params); + } + + public void log(LogLevel logLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String message) { + log(logLevel, errorCodeEnum, serviceName, message); + } + + @Override + public void log(LogLevel logLevel, String message, Object...params) { + log(logLevel, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, defaultServiceName, null, message, params); + } + + public void log(LogLevel logLevel, String message, Throwable throwable) { + log(logLevel, createErrorMessage(message, throwable)); + } + + public void log(LogLevel logLevel, String message) { + log(logLevel, EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, defaultServiceName, null, message); + } + + public void logInfo(LogLevel logLevel, String message, Object... params) { + log(logLevel, EcompLoggerErrorCode.SUCCESS, defaultServiceName, null, message, params); + } + + private LogLevel convertFromSeverityErrorLevel(EcompErrorConfiguration.EcompErrorSeverity severityLevel) { + switch(severityLevel) { + case INFO: + return LogLevel.INFO; + case FATAL: + return LogLevel.FATAL; + case ERROR: + return LogLevel.ERROR; + case WARN: + return LogLevel.WARN; + } + return LogLevel.ERROR; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java new file mode 100644 index 0000000000..de02c067c8 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java @@ -0,0 +1,58 @@ +package org.openecomp.sdc.common.log.elements; + +import org.slf4j.Logger; + +/** + * Created by dd4296 on 12/26/2017. + * this factory helps decouple the classes for Stopwatch and LogFieldsMdcHandler from + * the EcompLogger classes + */ +public class LoggerFactory { + + private LoggerFactory() { + } + + @SuppressWarnings("unchecked") + public static <T, V> V getLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(new LogFieldsMdcHandler(), logger); + } + + return null; + } + + @SuppressWarnings("unchecked") + public static <T, V> V getMdcLogger(Class<T> type, Logger logger) { + + if (type.getName().equals(LoggerAudit.class.getName())) { + return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerDebug.class.getName())) { + return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerMetric.class.getName())) { + return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); + } + + if (type.getName().equals(LoggerError.class.getName())) { + return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger); + } + + return null; + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java new file mode 100644 index 0000000000..3be3c48946 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java @@ -0,0 +1,211 @@ +package org.openecomp.sdc.common.log.elements; + +import org.openecomp.sdc.common.log.api.ILogFieldsHandler; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.LogMarkers; +import org.openecomp.sdc.common.log.enums.Severity; +import org.slf4j.Logger; +import org.slf4j.MarkerFactory; + +import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; + + +public class LoggerMetric extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + MDC_METRIC_BEGIN_TIMESTAMP, + MDC_END_TIMESTAMP, + MDC_KEY_REQUEST_ID, + MDC_SERVICE_NAME, + MDC_PARTNER_NAME, + MDC_STATUS_CODE, + MDC_RESPONSE_CODE, + MDC_SERVICE_INSTANCE_ID, + MDC_RESPONSE_DESC, + MDC_ELAPSED_TIME, + MDC_TARGET_ENTITY, + MDC_TARGET_SERVICE_NAME, + MDC_TARGET_VIRTUAL_ENTITY, + MDC_SERVER_IP_ADDRESS, + MDC_SERVER_FQDN)); + + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( + MDC_INSTANCE_UUID, + MDC_ALERT_SEVERITY, + MDC_REMOTE_HOST, + MDC_CLASS_NAME, + MDC_PROCESS_KEY, + MDC_OPT_FIELD1, + MDC_OPT_FIELD2, + MDC_OPT_FIELD3, + MDC_OPT_FIELD4)); + + LoggerMetric(ILogFieldsHandler ecompMdcWrapper, Logger logger) { + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text()), logger); + //put the remote host and FQDN values from another thread if they are set + ecompMdcWrapper.setServerIPAddressInternally(); + ecompMdcWrapper.setServerFQDNInternally(); + } + + public void log(Response.StatusType statusInfo, + String className, + LogLevel logLevel, + Severity securityLevel, + String message) { + log(statusInfo,className, logLevel, securityLevel, message); + } + + @Override + public void log(LogLevel logLevel, String message) { + setKeyRequestIdIfNotSetYet(); + log(logLevel, message, (Object) null); + } + + @Override + public LoggerMetric startTimer() { + clear(); + ecompLogFieldsHandler.startMetricTimer(); + return this; + } + + public LoggerMetric stopTimer() { + ecompLogFieldsHandler.stopMetricTimer(); + return this; + } + + @Override + public LoggerMetric setKeyRequestId(String keyRequestId) { + return (LoggerMetric) super.setKeyRequestId(keyRequestId); + } + + @Override + public List<String> getMandatoryFields() { + return mandatoryFields; + } + + @Override + public LoggerMetric clear() { + ecompLogFieldsHandler.removeTargetEntity(); + ecompLogFieldsHandler.removeTargetServiceName(); + ecompLogFieldsHandler.removeResponseCode(); + ecompLogFieldsHandler.removeResponseDesc(); + ecompLogFieldsHandler.removeStatusCode(); + return this; + } + + // automatic parameter this is optional + public LoggerMetric setAutoServerFQDN(String serverFQDN) { + ecompLogFieldsHandler.setServerFQDN(serverFQDN); + return this; + } + + // automatic parameter this is optional + public LoggerMetric setAutoServerIPAddress(String serverIPAddress) { + ecompLogFieldsHandler.setServerIPAddress(serverIPAddress); + return this; + } + + public LoggerMetric setInstanceUUID(String instanceUUID) { + ecompLogFieldsHandler.setInstanceUUID(instanceUUID); + return this; + } + + // log optional parameter + public LoggerMetric setOptProcessKey(String processKey) { + ecompLogFieldsHandler.setProcessKey(processKey); + return this; + } + + // log optional parameter + public LoggerMetric setOptAlertSeverity(Severity alertSeverity) { + ecompLogFieldsHandler.setAlertSeverity(alertSeverity); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField1(String customField1) { + ecompLogFieldsHandler.setOptCustomField1(customField1); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField2(String customField2) { + ecompLogFieldsHandler.setOptCustomField2(customField2); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField3(String customField3) { + ecompLogFieldsHandler.setOptCustomField3(customField3); + return this; + } + + // log optional parameter + public LoggerMetric setOptCustomField4(String customField4) { + ecompLogFieldsHandler.setOptCustomField4(customField4); + return this; + } + + public LoggerMetric setRemoteHost(String remoteHost) { + ecompLogFieldsHandler.setRemoteHost(remoteHost); + return this; + } + + public LoggerMetric setServiceName(String serviceName) { + ecompLogFieldsHandler.setServiceName(serviceName); + return this; + } + + public LoggerMetric setStatusCode(String statusCode) { + ecompLogFieldsHandler.setStatusCode(statusCode); + return this; + } + + public LoggerMetric setPartnerName(String partnerName) { + ecompLogFieldsHandler.setPartnerName(partnerName); + return this; + } + + public LoggerMetric setResponseCode(int responseCode) { + ecompLogFieldsHandler.setResponseCode(responseCode); + return this; + } + + public LoggerMetric setResponseDesc(String responseDesc) { + ecompLogFieldsHandler.setResponseDesc(responseDesc); + return this; + } + + public LoggerMetric setOptServiceInstanceId(String serviceInstanceId) { + ecompLogFieldsHandler.setServiceInstanceId(serviceInstanceId); + return this; + } + + public LoggerMetric setOptClassName(String className) { + ecompLogFieldsHandler.setClassName(className); + return this; + } + + public LoggerMetric setTargetEntity(String targetEntity) { + ecompLogFieldsHandler.setTargetEntity(targetEntity); + return this; + } + + public LoggerMetric setTargetServiceName(String targetServiceName) { + ecompLogFieldsHandler.setTargetServiceName(targetServiceName); + return this; + } + + public LoggerMetric setTargetVirtualEntity(String targetVirtualEntity) { + ecompLogFieldsHandler.setTargetVirtualEntity(targetVirtualEntity); + return this; + } + + + + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java new file mode 100644 index 0000000000..6f7fc1a876 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java @@ -0,0 +1,47 @@ +package org.openecomp.sdc.common.log.enums; + +import java.util.Arrays; +import java.util.Optional; + +/** + * Created by dd4296 on 12/26/2017. + */ +public enum EcompLoggerErrorCode { + SUCCESS(0), + PERMISSION_ERROR(100), + AVAILABILITY_TIMEOUTS_ERROR(200), + DATA_ERROR(300), + SCHEMA_ERROR(400), + BUSINESS_PROCESS_ERROR(500), + UNKNOWN_ERROR(900); + + private int errorCode; + + EcompLoggerErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public int getErrorCode() { + return errorCode; + } + + public static EcompLoggerErrorCode getByValue(String ecompErrorCode) { + String errorPrefix = parseCode(ecompErrorCode); + Optional<EcompLoggerErrorCode> optionalCode = Arrays.stream(values()).filter(v->isCode(v, errorPrefix)).findFirst(); + return optionalCode.orElse(UNKNOWN_ERROR); + } + + private static boolean isCode(EcompLoggerErrorCode ecompLoggerErrorCode, String errorPrefix) { + return String.valueOf(ecompLoggerErrorCode.getErrorCode()).contains(errorPrefix); + } + + private static String parseCode(String errorCode) { + try { + return errorCode.substring("E_".length(), 3); + } catch (StringIndexOutOfBoundsException ex) { + return UNKNOWN_ERROR.name(); + } + } + + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogLevel.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java index 2fc7d7f26f..d044f6eaea 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogLevel.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by dd4296 on 12/14/2017. @@ -7,6 +7,7 @@ public enum LogLevel { INFO, WARN, DEBUG, + TRACE, ERROR, FATAL } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogMarkers.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java index b26e8c105d..5623294b3d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/LogMarkers.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by mm288v on 12/27/2017. diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/Severity.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java index f842927af2..56f35a707b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/Severity.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; /** * Created by dd4296 on 12/14/2017. diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/StatusCode.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java index 2fdd96f11b..f61bd67964 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Enums/StatusCode.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java @@ -1,4 +1,4 @@ -package org.openecomp.sdc.common.ecomplog.Enums; +package org.openecomp.sdc.common.log.enums; public enum StatusCode { ERROR("ERROR"), diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java new file mode 100644 index 0000000000..c9fccba303 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java @@ -0,0 +1,526 @@ +package org.openecomp.sdc.common.log.wrappers; + +import com.google.common.annotations.VisibleForTesting; +import org.openecomp.sdc.common.config.EcompErrorConfiguration; +import org.openecomp.sdc.common.log.elements.LoggerDebug; +import org.openecomp.sdc.common.log.elements.LoggerError; +import org.openecomp.sdc.common.log.elements.LoggerFactory; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.slf4j.Marker; + + +/** + * This class wraps {@link org.slf4j.Logger} object and provides mandatory information required by Ecomp logging rules. + * Note: All deprecated methods are supported to be compatible to the legacy code + * and have not be used by the new code + */ +public class Logger implements org.slf4j.Logger { + private final LoggerDebug debug; + private final LoggerError error; + private final org.slf4j.Logger logger; + + @VisibleForTesting + private Logger(org.slf4j.Logger logger) { + this.logger = logger; + this.debug = LoggerFactory.getMdcLogger(LoggerDebug.class, logger); + this.error = LoggerFactory.getMdcLogger(LoggerError.class, logger); + } + + private Logger(String className) { + this(org.slf4j.LoggerFactory.getLogger(className)); + } + + public static Logger getLogger(String className) { + return new Logger(className); + } + + public static Logger getLogger(Class<?> clazz) { + return new Logger(clazz.getName()); + } + + + public boolean isDebugEnabled() { + return logger.isDebugEnabled(); + } + + @Override + public String getName() { + return logger.getName(); + } + + public boolean isTraceEnabled() { + return logger.isTraceEnabled(); + } + + public boolean isErrorEnabled() { return logger.isErrorEnabled(); } + + public boolean isWarnEnabled() { return logger.isWarnEnabled(); } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object o) { + + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o); + } + } + + public boolean isInfoEnabled() { return logger.isInfoEnabled(); } + + @Override + public void info(String msg) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg); + } + } + + @Override + public void info(String msg, Object o) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o); + } + } + + @Override + public void info(String msg, Object o, Object o1) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o, o1); + } + } + + public void debug(String msg, Object... params) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, params); + } + } + + @Override + public void debug(String msg, Throwable throwable) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, throwable); + } + } + + @Override + public boolean isDebugEnabled(Marker marker) { + return false; + } + + @Override + public void debug(Marker marker, String msg) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg); + } + } + + @Override + public void debug(Marker marker, String msg, Object o) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o); + } + } + + @Override + public void debug(Marker marker, String msg, Object o, Object o1) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o, o1); + } + } + + @Override + public void debug(Marker marker, String msg, Object... objects) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, objects); + } + } + + @Override + public void debug(Marker marker, String msg, Throwable throwable) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, throwable); + } + } + + public void debug(String message) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, message); + } + } + + @Override + public void debug(String msg, Object o) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o); + } + } + + @Override + public void debug(String msg, Object o, Object o1) { + if (isDebugEnabled()) { + debug.log(LogLevel.DEBUG, msg, o, o1); + } + } + + public void trace(String message, Object... params) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, message, params); + } + } + + @Override + public void trace(String msg, Throwable throwable) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, throwable); + } + } + + @Override + public boolean isTraceEnabled(Marker marker) { + return false; + } + + @Override + public void trace(Marker marker, String msg) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg); + } + } + + @Override + public void trace(Marker marker, String msg, Object o) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o); + } + } + + @Override + public void trace(Marker marker, String msg, Object o, Object o1) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o, o1); + } + } + + @Override + public void trace(Marker marker, String msg, Object... objects) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, objects); + } + } + + @Override + public void trace(Marker marker, String msg, Throwable throwable) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, throwable); + } + } + + public void trace(String msg) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg); + } + } + + @Override + public void trace(String msg, Object o) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o); + } + } + + @Override + public void trace(String msg, Object o, Object o1) { + if (isTraceEnabled()) { + debug.log(LogLevel.TRACE, msg, o, o1); + } + } + + public void info(String msg, Object... params) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, params); + } + } + + @Override + public void info(String msg, Throwable throwable) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, throwable); + } + } + + @Override + public boolean isInfoEnabled(Marker marker) { + return false; + } + + @Override + public void info(Marker marker, String msg) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg); + } + } + + @Override + public void info(Marker marker, String msg, Object o) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o); + } + } + + @Override + public void info(Marker marker, String msg, Object o, Object o1) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, o, o1); + } + } + + @Override + public void info(Marker marker, String msg, Object... objects) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, objects); + } + } + + @Override + public void info(Marker marker, String msg, Throwable throwable) { + if (isInfoEnabled()) { + error.logInfo(LogLevel.INFO, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object... params){ + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Object o, Object o1) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(String msg, Throwable throwable) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, throwable); + } + } + + @Override + public boolean isWarnEnabled(Marker marker) { + return false; + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object o) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object o, Object o1) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Object... objects) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, objects); + } + } + + @Override + @Deprecated /** Please use method {@link #warn(EcompLoggerErrorCode, String, String)} **/ + public void warn(Marker marker, String msg, Throwable throwable) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object... params){ + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Throwable throwable) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, throwable); + } + } + + @Override + public boolean isErrorEnabled(Marker marker) { + return false; + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object o) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object o, Object o1) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o, o1); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Object... params) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, params); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(Marker marker, String msg, Throwable throwable) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, throwable); + } + } + + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg){ + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object o) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o); + } + } + + @Override + @Deprecated /** Please use method {@link #error(EcompLoggerErrorCode, String, String)} **/ + public void error(String msg, Object o, Object o1) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, msg, o, o1); + } + } + + /** + * Writes out ERROR logging level message to the application error log + * @param errorLevel code representing the error severity level + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void error(EcompErrorConfiguration.EcompErrorSeverity errorLevel, + EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(errorLevel, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out ERROR logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void error(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(LogLevel.ERROR, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out WARN logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void warn(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isWarnEnabled()) { + error.log(LogLevel.WARN, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + /** + * Writes out FATAL logging level message to the application error log + * @param errorCodeEnum code representing the error condition + * @param serviceName name of the API invoked at the logging component + * @param targetEntity name of the ECOMP component or sub-component, or external entity at which the error occurred or null + * @param errorDescription a human readable description of the error condition + * @param params optional parameters of a given error description + */ + public void fatal(EcompLoggerErrorCode errorCodeEnum, + String serviceName, + String targetEntity, + String errorDescription, Object...params) { + if (isErrorEnabled()) { + error.log(LogLevel.FATAL, errorCodeEnum, serviceName, targetEntity, errorDescription, params); + } + } + + + + + + + +} + diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java new file mode 100644 index 0000000000..1760701aa1 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java @@ -0,0 +1,86 @@ +package org.openecomp.sdc.common.log.wrappers; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.log.elements.LoggerAudit; +import org.openecomp.sdc.common.log.elements.LoggerFactory; +import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; +import org.openecomp.sdc.common.util.ThreadLocalsHolder; +import org.slf4j.MDC; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Response; + + +/** + * Created by dd4296 on 12/19/2017. + * + * audit log for asdc using the log library + * this is adapted for filter classes + */ +public class LoggerSdcAudit extends LoggerSdcUtilBase { + + private static String AUDIT_ON = "auditOn"; + private String className; + private final LoggerAudit ecompLoggerAudit; + + public LoggerSdcAudit(Class<?> clazz) { + this.className = clazz.getName(); + ecompLoggerAudit = LoggerFactory.getMdcLogger(LoggerAudit.class, org.slf4j.LoggerFactory.getLogger(clazz)); + } + + public void startLog(ContainerRequestContext requestContext) { + ecompLoggerAudit.clear() + .startTimer() + .setPartnerName(getPartnerName( + requestContext.getHeaderString("user-agent"), + requestContext.getHeaderString("USER_ID"), + getUrl(requestContext))) + .setServiceName(getServiceName(requestContext)) + .setKeyRequestId(ThreadLocalsHolder.getUuid()); + MDC.put(AUDIT_ON, "true"); + } + + public static boolean isFlowBeingTakenCare() { + String auditOn = MDC.get(AUDIT_ON); + return !StringUtils.isEmpty(auditOn) && "true".equals(auditOn); + } + + //this function clears the MDC data that relevant for this class + public void clearMyData(){ + ecompLoggerAudit.clear(); + } + + public void log(String remoteAddress, + ContainerRequestContext requestContext, + Response.StatusType statusInfo, + LogLevel logLevel, + Severity securityLevel, + String message) { + + try { + + String msg = ecompLoggerAudit.getAuditMessage() == null ? + message : ecompLoggerAudit.getAuditMessage(); + ecompLoggerAudit.stopTimer() + .setRemoteHost(remoteAddress) + .setResponseCode(convertHttpCodeToErrorCode(statusInfo.getStatusCode())) + .setStatusCode(Integer.toString(statusInfo.getStatusCode())) + .setResponseDesc(statusInfo.getReasonPhrase()) + .setInstanceUUID(requestContext.getHeaderString(Constants.X_ECOMP_INSTANCE_ID_HEADER)) + .setOptServiceInstanceId(requestContext.getHeaderString(Constants.X_ECOMP_SERVICE_ID_HEADER)) + .setOptClassName(className) + .setOptAlertSeverity(securityLevel) + .setOptCustomField1(requestContext.getMethod() + ": " + getUrl(requestContext)) + .setOptCustomField2(Integer.toString(statusInfo.getStatusCode())) + .log(logLevel, msg); + } + catch (Exception e) { + log.warn("Failed to write to Audit Log. Original Message: {}", message, e); + } + finally { + MDC.put(AUDIT_ON,"false"); + } + } +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcUtilBase.java b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java index 3fe49c17e6..4a539f3c2e 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplogwrapper/EcompLoggerSdcUtilBase.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java @@ -1,40 +1,25 @@ -package org.openecomp.sdc.common.ecomplogwrapper; - -import static java.net.HttpURLConnection.HTTP_BAD_METHOD; -import static java.net.HttpURLConnection.HTTP_BAD_REQUEST; -import static java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT; -import static java.net.HttpURLConnection.HTTP_CONFLICT; -import static java.net.HttpURLConnection.HTTP_ENTITY_TOO_LARGE; -import static java.net.HttpURLConnection.HTTP_FORBIDDEN; -import static java.net.HttpURLConnection.HTTP_GONE; -import static java.net.HttpURLConnection.HTTP_LENGTH_REQUIRED; -import static java.net.HttpURLConnection.HTTP_NOT_ACCEPTABLE; -import static java.net.HttpURLConnection.HTTP_NOT_FOUND; -import static java.net.HttpURLConnection.HTTP_PAYMENT_REQUIRED; -import static java.net.HttpURLConnection.HTTP_PRECON_FAILED; -import static java.net.HttpURLConnection.HTTP_PROXY_AUTH; -import static java.net.HttpURLConnection.HTTP_REQ_TOO_LONG; -import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED; -import static java.net.HttpURLConnection.HTTP_UNSUPPORTED_TYPE; +package org.openecomp.sdc.common.log.wrappers; -import java.util.List; -import java.util.StringTokenizer; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.ws.rs.container.ContainerRequestContext; +import java.util.List; +import java.util.StringTokenizer; -import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static java.net.HttpURLConnection.*; /** * Created by dd4296 on 12/20/2017. * - * base class for metric and audit ecomplog logging + * base class for metric and audit log logging * holding the specific logic for data extraction */ -public class EcompLoggerSdcUtilBase { +public class LoggerSdcUtilBase { - protected static Logger log = LoggerFactory.getLogger(EcompLoggerSdcUtilBase.class.getName()); + protected static Logger log = LoggerFactory.getLogger(LoggerSdcUtilBase.class.getName()); String getRequestIDfromHeaders(List<Object> requestHeader) { // this method gets list of type object. @@ -44,28 +29,29 @@ public class EcompLoggerSdcUtilBase { } + // this method translates http error code to ECOMP Logger Error code // this is a naive translation and is not a result of any documented format ECOMP specification protected EcompLoggerErrorCode convertHttpCodeToErrorCode(int httpResponseCode) { - if (isSuccessError(httpResponseCode)) + if (isSuccessError(httpResponseCode)) { return EcompLoggerErrorCode.SUCCESS; + } - if (isSchemaError(httpResponseCode)) + if (isSchemaError(httpResponseCode)) { return EcompLoggerErrorCode.SCHEMA_ERROR; - - if (isDataError(httpResponseCode)) + } + if (isDataError(httpResponseCode)) { return EcompLoggerErrorCode.DATA_ERROR; - - if (isPermissionsError(httpResponseCode)) + } + if (isPermissionsError(httpResponseCode)) { return EcompLoggerErrorCode.PERMISSION_ERROR; - - if (isTimeoutOrAvailabilityError(httpResponseCode)) + } + if (isTimeoutOrAvailabilityError(httpResponseCode)) { return EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR; - - if (isBusinessProcessError(httpResponseCode)) + } + if (isBusinessProcessError(httpResponseCode)) { return EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR; - - + } return EcompLoggerErrorCode.UNKNOWN_ERROR; } @@ -78,9 +64,10 @@ public class EcompLoggerSdcUtilBase { case HTTP_CLIENT_TIMEOUT: case HTTP_GONE: return true; + default: + return false; } - return false; } private boolean isPermissionsError(int httpResponseCode) { @@ -125,18 +112,18 @@ public class EcompLoggerSdcUtilBase { protected String getPartnerName(String userAgent, String userId, String url) { - if (!isNullOrEmpty(userId)) { + if (!StringUtils.isEmpty(userId)) { return userId; } String urlUser = getUserIdFromUrl(url); - if (!isNullOrEmpty(urlUser)) + if (!StringUtils.isEmpty(urlUser)) return urlUser; String userAgentName = getUserIdFromUserAgent(userAgent); - if (!isNullOrEmpty(userAgentName)) + if (!StringUtils.isEmpty(userAgentName)) return userAgentName; return ""; @@ -187,10 +174,6 @@ public class EcompLoggerSdcUtilBase { return url; } - private boolean isNullOrEmpty(String str) { - return (str == null || str.isEmpty()); - } - protected String getServiceName(ContainerRequestContext requestContext) { return (requestContext.getUriInfo().getRequestUri().toString()) .replace(requestContext.getUriInfo().getBaseUri().toString(), "/"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java index e5c62d4772..ea92156ce1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/monitoring/MonitoringMetricsFetcher.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.common.monitoring; +import org.hyperic.sigar.FileSystem; +import org.hyperic.sigar.Sigar; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.management.MBeanServer; +import javax.management.ObjectName; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.RuntimeMXBean; @@ -27,15 +35,6 @@ import java.lang.management.ThreadMXBean; import java.util.HashMap; import java.util.Map; -import javax.management.MBeanServer; -import javax.management.ObjectName; - -import org.hyperic.sigar.FileSystem; -import org.hyperic.sigar.Sigar; -import org.openecomp.sdc.common.impl.ExternalConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class MonitoringMetricsFetcher { private static Logger monitoringLogger = LoggerFactory.getLogger("asdc.fe.monitoring.fetcher"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java index 18ec011868..fb9fb1c037 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java @@ -20,19 +20,17 @@ package org.openecomp.sdc.common.rest.impl.validator; -import java.util.List; -import java.util.Map; +import org.apache.commons.codec.binary.Base64; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.log.wrappers.Logger; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MediaType; - -import org.apache.commons.codec.binary.Base64; -import org.openecomp.sdc.common.api.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.List; +import java.util.Map; public class RequestHeadersValidator { - private static Logger log = LoggerFactory.getLogger(RequestHeadersValidator.class.getName()); + private static Logger log = Logger.getLogger(RequestHeadersValidator.class.getName()); public static void validateContentType(HttpServletRequest request, MediaType expectedContentType, Map<String, String> headersMap) throws RestRequestValidationException { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java index 48661a0eea..ce4f2a6e6b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/servlets/BasicServlet.java @@ -20,17 +20,8 @@ package org.openecomp.sdc.common.servlets; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.openecomp.sdc.common.api.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -import javax.servlet.http.HttpServletRequest; -import java.util.concurrent.TimeUnit; public abstract class BasicServlet { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java index df639c70e3..49caf61bcc 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/test/BaseConfDependent.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.common.test; -import java.io.File; - import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; +import java.io.File; + public class BaseConfDependent { protected static ConfigurationManager configurationManager; protected static String componentName; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java index 8890b14dd1..a6cdd90993 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java @@ -20,15 +20,15 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; +import org.openecomp.sdc.common.api.Constants; + import java.io.File; import java.io.IOException; import java.util.List; import java.util.regex.Pattern; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; -import org.openecomp.sdc.common.api.Constants; - public class GeneralUtility { public static boolean generateTextFile(String fileName, String fileData) { @@ -163,4 +163,5 @@ public class GeneralUtility { public static boolean isEmptyString(String str) { return str == null || str.trim().isEmpty(); } + } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java index 91222a049c..7c35e4e3b7 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java @@ -2,8 +2,7 @@ package org.openecomp.sdc.common.util; import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.common.api.HealthCheckInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; import java.util.ArrayList; import java.util.Collection; @@ -13,7 +12,7 @@ import static org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus.DOW public class HealthCheckUtil { - private static Logger log = LoggerFactory.getLogger(HealthCheckUtil.class.getName()); + private static Logger log = Logger.getLogger(HealthCheckUtil.class.getName()); public boolean getAggregateStatus(List<HealthCheckInfo> healthCheckInfos, Collection<String> excludes) { boolean status = true; excludes = CollectionUtils.isEmpty(excludes) ? new ArrayList<>() : excludes; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java index 4cbd9a7760..c9086fc272 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HtmlCleaner.java @@ -20,16 +20,15 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.lang3.StringEscapeUtils; + +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTML.Tag; import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTML.Tag; - -import org.apache.commons.lang3.StringEscapeUtils; - public class HtmlCleaner { private static Set<String> htmlTags = new HashSet<>(); @@ -57,7 +56,7 @@ public class HtmlCleaner { public static String stripHtml(String input, boolean toEscape) { - if (input == null || true == input.isEmpty()) { + if (input == null || input.isEmpty()) { return input; } @@ -77,7 +76,7 @@ public class HtmlCleaner { if (groupCount > 0) { String tag = matcher.group(1); if (tag != null && htmlTags.contains(tag.toLowerCase())) { - if (false == tagsToRemove.contains(matchTag)) { + if (!tagsToRemove.contains(matchTag)) { tagsToRemove.add(matchTag); } } @@ -87,7 +86,7 @@ public class HtmlCleaner { String stripHtmlStr = removeTagsFromString(tagsToRemove, input); if (stripHtmlStr != null) { - if (true == toEscape) { + if (toEscape) { stripHtmlStr = StringEscapeUtils.escapeHtml4(stripHtmlStr); } } @@ -99,7 +98,7 @@ public class HtmlCleaner { private static String removeTagsFromString(Set<String> tagsToRemove, String input) { String stripStr = input; - if (input == null || true == tagsToRemove.isEmpty()) { + if (input == null || tagsToRemove.isEmpty()) { return input; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java index f4f34a9934..d9f099876a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HttpUtil.java @@ -20,17 +20,15 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; - import fj.data.Either; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + public class HttpUtil { public static Either<String, IOException> readJsonStringFromRequest(HttpServletRequest request) { Either<String, IOException> eitherResult; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java index 1f60632f1b..fbf94eaaed 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/JsonUtils.java @@ -31,8 +31,8 @@ public class JsonUtils { return null; } - if (false == jsonElement.isJsonNull()) { - if (false == jsonElement.isJsonObject()) { + if (!jsonElement.isJsonNull()) { + if (!jsonElement.isJsonObject()) { return jsonElement.getAsString(); } else { return jsonElement.toString(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java index d58b9a970d..eb6c29ce4a 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.common.util; -import java.util.List; -import java.util.stream.Collectors; - import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import java.util.List; +import java.util.stream.Collectors; + public class PairUtils { public static <L, R> List<L> leftSequence(List<ImmutablePair<L, R>> pairs) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java index 4574d3ff86..cf49718600 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/SerializationUtils.java @@ -20,24 +20,17 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInput; -import java.io.ObjectInputStream; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; - +import fj.data.Either; import org.nustaq.serialization.FSTConfiguration; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.openecomp.sdc.common.log.wrappers.Logger; -import fj.data.Either; +import java.io.*; public class SerializationUtils { - private static Logger log = LoggerFactory.getLogger(SerializationUtils.class.getName()); + private static Logger log = Logger.getLogger(SerializationUtils.class.getName()); private static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration(); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java index 90371a3403..2d07069388 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/StreamUtils.java @@ -51,7 +51,7 @@ public final class StreamUtils { */ public static <T> Stream<T> takeWhilePlusOneNoEval(Stream<T> stream, Predicate<T> predicate) { List<T> results = new ArrayList<>(); - Consumer<T> listAdder = e -> results.add(e); + Consumer<T> listAdder = results::add; stream.map(e -> { listAdder.accept(e); return e; @@ -64,11 +64,11 @@ public final class StreamUtils { } public static <T> Stream<T> takeWhilePlusOne(Stream<T> stream, Predicate<T> predicate) { - return StreamSupport.stream(takeWhile(stream.spliterator(), new StopAfterFailPredicate<T>(predicate)), false); + return StreamSupport.stream(takeWhile(stream.spliterator(), new StopAfterFailPredicate<>(predicate)), false); } private static <T> Spliterator<T> takeWhile(Spliterator<T> splitr, Predicate<T> predicate) { - return new MySplitIterator<T>(splitr, predicate); + return new MySplitIterator<>(splitr, predicate); } public static class MySplitIterator<T> extends AbstractSpliterator<T> implements Spliterator<T> { @@ -94,18 +94,17 @@ public final class StreamUtils { } private Consumer<? super T> createConsumerWrapper(Consumer<? super T> action) { - Consumer<? super T> cons = new Consumer<T>() { - @Override - public void accept(T t) { - stillGoing = innerPred.test(t); - if (stillGoing) { - action.accept(t); - } - - } - }; - - return cons; + + return new Consumer<T>() { + @Override + public void accept(T t) { + stillGoing = innerPred.test(t); + if (stillGoing) { + action.accept(t); + } + + } + }; } } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java index 864d79eb39..1e4792f4ce 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java @@ -30,11 +30,7 @@ import org.jsoup.Jsoup; import org.jsoup.helper.StringUtil; import org.jsoup.safety.Whitelist; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.regex.Pattern; public class ValidationUtils { @@ -92,8 +88,8 @@ public class ValidationUtils { public final static Pattern COLON_PATTERN = Pattern.compile("[:]+"); public final static Pattern AT_PATTERN = Pattern.compile("[@]+"); public final static Pattern AND_PATTERN = Pattern.compile(" [aA][Nn][Dd] "); - protected final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<String>( - Arrays.asList("of", "to", "for", "as", "a", "an", "the")); + public final static Set<String> CATEGORY_CONJUNCTIONS = new HashSet<>( + Arrays.asList("of", "to", "for", "as", "a", "an", "the")); public final static Pattern COST_PATTERN = Pattern.compile("^[0-9]{1,5}\\.[0-9]{1,3}$"); public final static Pattern ARTIFACT_LABEL_PATTERN = Pattern.compile("^[a-zA-Z0-9 \\-+]+$"); @@ -259,8 +255,7 @@ public class ValidationUtils { public static String removeAllTags(String htmlText) { - String stripped = TAGS_PATTERN.matcher(htmlText).replaceAll("").trim(); - return stripped; + return TAGS_PATTERN.matcher(htmlText).replaceAll("").trim(); } public static String normaliseWhitespace(String str) { @@ -281,9 +276,7 @@ public class ValidationUtils { public static boolean validateIsAscii(String input) { - boolean isAscii = CharMatcher.ASCII.matchesAllOf(input); - - return isAscii; + return CharMatcher.ASCII.matchesAllOf(input); } public static String convertHtmlTagsToEntities(String input) { @@ -384,15 +377,13 @@ public class ValidationUtils { private static String[] splitComponentName(String name) { String normalizedName = name.toLowerCase(); normalizedName = COMPONENT_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } private static String[] splitComponentInstanceName(String name) { String normalizedName = name.toLowerCase(); normalizedName = COMPONENT_INCTANCE_NAME_DELIMETER_PATTERN.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } public static String convertToSystemName(String name) { @@ -524,13 +515,11 @@ public class ValidationUtils { private static String[] splitComponentName(Pattern pattern, String name) { String normalizedName = name.toLowerCase(); normalizedName = pattern.matcher(normalizedName).replaceAll(" "); - String[] split = normalizedName.split(" "); - return split; + return normalizedName.split(" "); } public static String removeHtmlTagsOnly(String htmlText) { - String stripped = HtmlCleaner.stripHtml(htmlText, false); - return stripped; + return HtmlCleaner.stripHtml(htmlText, false); } public static boolean validateForwardingPathNamePattern(String forwardingPathName) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java index e8feb1b8e0..93160330fd 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java @@ -20,46 +20,37 @@ package org.openecomp.sdc.common.util; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - import org.apache.commons.codec.binary.Base64; -import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.Configuration.BeMonitoringConfig; -import org.openecomp.sdc.be.config.Configuration.EcompPortalConfig; -import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig; +import org.openecomp.sdc.be.config.Configuration.*; import org.openecomp.sdc.be.config.Configuration.ElasticSearchConfig.IndicesTimeFrequencyEntry; -import org.openecomp.sdc.be.config.Configuration.OnboardingConfig; -import org.openecomp.sdc.be.config.Configuration.SwitchoverDetectorConfig; -import org.openecomp.sdc.be.config.Configuration.ToscaValidatorsConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.ComponentArtifactTypesConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.CreateTopicConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionNotificationTopicConfig; import org.openecomp.sdc.be.config.DistributionEngineConfiguration.DistributionStatusTopicConfig; import org.openecomp.sdc.be.config.validation.DeploymentArtifactHeatConfiguration; +import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.fe.config.Configuration.FeMonitoringConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.introspector.PropertyUtils; import org.yaml.snakeyaml.nodes.Node; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; + public class YamlToObjectConverter { - private static Logger log = LoggerFactory.getLogger(YamlToObjectConverter.class.getName()); + private static Logger log = Logger.getLogger(YamlToObjectConverter.class.getName()); - private static HashMap<String, Yaml> yamls = new HashMap<String, Yaml>(); + private static HashMap<String, Yaml> yamls = new HashMap<>(); private static Yaml defaultYaml = new Yaml(); @@ -165,7 +156,7 @@ public class YamlToObjectConverter { } public class MyYamlConstructor extends org.yaml.snakeyaml.constructor.Constructor { - private HashMap<String, Class<?>> classMap = new HashMap<String, Class<?>>(); + private HashMap<String, Class<?>> classMap = new HashMap<>(); public MyYamlConstructor(Class<? extends Object> theRoot) { super(theRoot); @@ -204,7 +195,7 @@ public class YamlToObjectConverter { try { File f = new File(fullFileName); - if (false == f.exists()) { + if (!f.exists()) { log.warn("The file " + fullFileName + " cannot be found. Ignore reading configuration."); return null; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java index f60cc16abe..cac94a5820 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ZipUtil.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.common.util; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.file.Files; @@ -31,13 +34,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import org.apache.commons.io.output.ByteArrayOutputStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ZipUtil { - private static Logger log = LoggerFactory.getLogger(ZipUtil.class.getName()); + private static Logger log = Logger.getLogger(ZipUtil.class.getName()); private ZipUtil() { } @@ -52,7 +51,7 @@ public class ZipUtil { public static Map<String, byte[]> readZip(ZipInputStream zis) { - Map<String, byte[]> fileNameToByteArray = new HashMap<String, byte[]>(); + Map<String, byte[]> fileNameToByteArray = new HashMap<>(); byte[] buffer = new byte[1024]; try { @@ -63,7 +62,7 @@ public class ZipUtil { String fileName = ze.getName(); - if (false == ze.isDirectory()) { + if (!ze.isDirectory()) { ByteArrayOutputStream os = new ByteArrayOutputStream(); try { @@ -129,14 +128,13 @@ public class ZipUtil { public static byte[] zipBytes(byte[] input) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ZipOutputStream zos = new ZipOutputStream(baos)) { - ZipEntry entry = new ZipEntry("zip"); - entry.setSize(input.length); - zos.putNextEntry(entry); - zos.write(input); - zos.closeEntry(); - zos.close(); - } + ZipOutputStream zos = new ZipOutputStream(baos); + ZipEntry entry = new ZipEntry("zip"); + entry.setSize(input.length); + zos.putNextEntry(entry); + zos.write(input); + zos.closeEntry(); + zos.close(); return baos.toByteArray(); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java index 83e8321ea6..fada7193ed 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/exception/AbstractSdncException.java @@ -20,14 +20,13 @@ package org.openecomp.sdc.exception; +import org.openecomp.sdc.common.log.wrappers.Logger; + import java.util.Arrays; import java.util.Formatter; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public abstract class AbstractSdncException { private String messageId; @@ -36,7 +35,7 @@ public abstract class AbstractSdncException { private String[] variables; - private static Logger log = LoggerFactory.getLogger(AbstractSdncException.class.getName()); + private static Logger log = Logger.getLogger(AbstractSdncException.class.getName()); private final static Pattern ERROR_PARAM_PATTERN = Pattern.compile("%\\d"); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java b/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java deleted file mode 100644 index 3baec2067e..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/exception/AlreadyExistException.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.exception; - -/** - * Exception to be thrown when trying to insert an existing an element that - * already exists. - * - * @author luc boutier - */ -public class AlreadyExistException extends TechnicalException { - private static final long serialVersionUID = -6151150122897145634L; - - /** - * Create a new {@link AlreadyExistException} with the cause. - * - * @param message - * Message. - */ - public AlreadyExistException(String message) { - super(message); - } -} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java index 0b19c6c910..413c8f825f 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java @@ -20,9 +20,6 @@ package org.openecomp.sdc.fe.config; -import java.util.HashMap; -import java.util.Map; - import org.openecomp.sdc.common.api.BasicConfiguration; import org.openecomp.sdc.common.api.ConfigurationListener; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -33,6 +30,9 @@ import org.openecomp.sdc.common.rest.api.RestConfigurationInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.HashMap; +import java.util.Map; + public class ConfigurationManager implements FileChangeCallback, IEcompConfigurationManager { ConfigurationSource configurationSource = null; @@ -46,7 +46,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura instance = this; } - Map<String, Object> configurations = new HashMap<String, Object>(); + Map<String, Object> configurations = new HashMap<>(); private void loadConfigurationFiles() { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java index fbf56216a5..55c7a11cf4 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/PluginsConfiguration.java @@ -1,11 +1,11 @@ package org.openecomp.sdc.fe.config; +import org.openecomp.sdc.common.api.BasicConfiguration; + import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.openecomp.sdc.common.api.BasicConfiguration; - public class PluginsConfiguration extends BasicConfiguration { private List<Plugin> pluginsList; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java index 68078071f3..0bb33190f8 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/monitoring/FeMonitoringService.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.fe.monitoring; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -import javax.servlet.ServletContext; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.entity.ContentType; @@ -43,8 +38,11 @@ import org.openecomp.sdc.fe.config.ConfigurationManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import javax.servlet.ServletContext; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; public class FeMonitoringService { |