{{- if .Values.explore.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "cmem.name-explore" . }}
  labels:
    {{- include "cmem.labels-explore" . | nindent 4 }}
data:
  JAVA_TOOL_OPTIONS: "{{ if .Values.explore.cache.enabled }}-Djava.io.tmpdir={{ .Values.explore.cache.javaTempPath }} {{ end }} {{ .Values.explore.config.javaToolOptions }}"
  {{- if .Values.global.license }}
  LICENSE_FILE: /license/license.asc
  {{- end }}
  CERTIFICATE_DIRECTORY: /cacerts
  SERVER_PORT: {{ .Values.explore.service.port | quote }}
  SERVER_SERVLET_CONTEXTPATH: {{ .Values.explore.config.contextPath | quote }}
  SPRING_SERVLET_MULTIPART_MAX-FILE-SIZE: {{ .Values.explore.config.maxFileSize | quote }}
  SPRING_SERVLET_MULTIPART_MAX-REQUEST-SIZE: {{ .Values.explore.config.maxRequestSize | quote }}
  SPRING_PROFILES_ACTIVE: "default"
  # AuthOntologyProperties
  AUTHORIZATION_ABOX_ADMINGROUP: {{ .Values.explore.config.authorizationAboxAdminGroup | quote }}
  AUTHORIZATION_ABOX_ACCESSCONDITIONS_GRAPH: "urn:elds-backend-access-conditions-graph"
  SPRINGDOC_SWAGGER_UI_ENABLED:  {{ .Values.explore.config.springdocSwaggerUIEnabled | quote }}
  SPRINGDOC_SWAGGER_UI_SUPPORTED_SUBMIT_METHODS: {{ .Values.explore.config.springdocSwaggerUISubmitMethod | quote }}
  SPRINGDOC_API_DOCS_ENABLED: {{ .Values.explore.config.springdocApiDocsEnabled | quote }}
  OPENAPI_SERVER_URLS: {{ .Values.explore.config.openapiServerUrls | quote }}
  # Enable store independent query logging if set to DEBUG or TRACE
  LOGGING_LEVEL_COM_ECCENCA_ELDS_BACKEND_SPARQL_QUERY_LOGGING: {{ .Values.explore.config.logSPARQLQueryLogging | quote }}
  EXPLORE_ANONYMOUS: {{ .Values.explore.config.anonymousLogin | quote }}
  DEPLOY_BASE_URL: {{ .Values.global.protocol }}://{{ .Values.global.hostname }}
  OAUTH_CLIENT_ID: {{ .Values.global.oauthClientId | default "cmem" | quote }} 
  OAUTH_JWK_SET_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/certs" | quote }}
  OAUTH_AUTHORIZATION_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/auth" | quote }}
  OAUTH_TOKEN_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/token" | quote }}
  OAUTH_USERINFO_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/userinfo" | quote }}
  DEPLOY_POST_LOGOUT_REDIRECT_URI: {{ tpl .Values.global.validPostLogoutRedirectUri . }}

  # Spring security settings, removed from application.yaml
  SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_AUTHORIZATIONGRANTTYPE: "authorization_code"
  SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENTAUTHENTICATIONMETHOD: "client_secret_basic"

  {{- if .Values.explore.config.metrics.enabled }}
  DEPLOY_ADDITIONAL_PROMETHEUS_ENDPOINT_ENABLED: "true"
  DEPLOY_ADDITIONAL_PROMETHEUS_ENDPOINT_PORT: {{ .Values.explore.config.metrics.port | quote }}
  DEPLOY_ADDITIONAL_PROMETHEUS_ENDPOINT_CONTEXT: {{ .Values.explore.config.metrics.context | quote }}
  MANAGEMENT_METRICS_TAGS_APP: {{ .Values.explore.config.metrics.appName | quote }}
  {{- end }}
  {{- if .Values.explore.store.graphdb.enabled }}
  STORE_TYPE: "graphdb"
  # In CMEM 22.2, the "STORE_GRAPHDB_HOST" variable must contain the GraphDB _hostname_, not the URL.
  STORE_GRAPHDB_HOST: {{ .Values.explore.store.graphdb.host | quote }}
  STORE_GRAPHDB_PORT: {{ .Values.explore.store.graphdb.port | quote }}
  STORE_GRAPHDB_SSL_ENABLED: {{ .Values.explore.store.graphdb.sslEnabled | quote }}
  STORE_GRAPHDB_REPOSITORY: {{ .Values.explore.store.graphdb.repository | quote }}
  STORE_GRAPHDB_CREATE_REPOSITORY_ON_STARTUP: {{ .Values.explore.store.graphdb.createRepoOnStartup | quote }}
  STORE_GRAPHDB_GRAPHDBCHANGETRACKINGACTIVE: {{ .Values.explore.store.graphdb.changeTrackingActive | quote  }}
  STORE_GRAPHDB_GRAPHDBCHANGETRACKINGMAXQUADMEMORY: {{ .Values.explore.store.graphdb.changeTrackingMaxQuadsMem  | quote }}
  {{- else if .Values.explore.store.virtuoso.enabled }}
  STORE_TYPE: "virtuoso"
  STORE_VIRTUOSO_HOST: {{ .Values.explore.store.virtuoso.host | quote }}
  STORE_VIRTUOSO_PORT: {{ .Values.explore.store.virtuoso.port | quote }}
  {{- end }}
  STORE_OWLIMPORTSRESOLUTION: "true"
  STORE_AUTHORIZATION: "REWRITE_FROM"

  {{- if .Values.explore.config.additionalEnvVars }}
  {{- .Values.explore.config.additionalEnvVars | toYaml | nindent 2 }}
  {{- end }}
{{- end }}

# SERVER_COMPRESSION_MIME_TYPES: text/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/json, text/turtle, application/n-triples, application/trig, application/n-quads, application/ld+json