Skip to content

Commit

Permalink
Corrections proprties url + missing annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jusabatier committed Sep 11, 2024
1 parent c3a5377 commit 9cd87b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@PropertySource(
value = {
"file:${georchestra.datadir}/default.properties",
"file:${georchestra.datadir}/cadastrapp/cadastrapp.properties}"
"file:${georchestra.datadir}/cadastrapp/cadastrapp.properties"
},
ignoreResourceNotFound = true
)
@EnableScheduling
public class LdapConfig {
@Autowired
private Environment env;
Expand All @@ -30,4 +33,9 @@ public LdapContextSource contextSource() {

return contextSource;
}

@Bean
public LdapTemplate ldapTemplate() {
return new LdapTemplate(contextSource());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -13,22 +15,25 @@
import org.springframework.core.env.Environment;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class LDAPGroupsAutorisationsSync {
private static final Logger LOGGER = LogManager.getLogger( LDAPGroupsAutorisationsSync.class );

@Autowired
private Environment env;
Environment env;

@Autowired
LdapTemplate lt;

@Autowired
GroupeAutorisationRepository gar;

@PostConstruct
@Scheduled(cron = "${ldapAreas.cronExpression}")
public void refreshOrganisationsPermissions() {
if( env.containsProperty("ldapAreas.enable") && env.getProperty("ldapAreas.enable") == "true" ) {
if( env.containsProperty("ldapAreas.enable") && env.getProperty("ldapAreas.enable").contentEquals("true") ) {
List<Organisation> lstOrg = lt.findAll(Organisation.class);
List<GroupeAutorisation> lstGA = new ArrayList<>();
for (Organisation o : lstOrg) {
Expand Down

0 comments on commit 9cd87b1

Please sign in to comment.