/** * Build a group LDAP repository from the given node. * * @param node * The node, also used as cache key. * @param template * The {@link LdapTemplate} used to query the repository. * @return The {@link UserLdapRepository} instance. Cache is involved. */ public GroupLdapRepository newGroupLdapRepository(final String node, final LdapTemplate template) { final Map<String, String> parameters = pvResource.getNodeParameters(node); // A new repository instance final GroupLdapRepository repository = new GroupLdapRepository(); repository.setTemplate(template); repository.setGroupsBaseDn(StringUtils.trimToEmpty(parameters.get(PARAMETER_GROUPS_DN))); // Complete the bean SpringUtils.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(repository); return repository; }
/** * Build a group LDAP repository from the given node. * * @param node * The node, also used as cache key. * @param template * The {@link LdapTemplate} used to query the repository. * @return The {@link UserLdapRepository} instance. Cache is involved. */ public CompanyLdapRepository newCompanyLdapRepository(final String node, final LdapTemplate template) { final Map<String, String> parameters = pvResource.getNodeParameters(node); // A new repository instance final CompanyLdapRepository repository = new CompanyLdapRepository(); repository.setTemplate(template); repository.setCompanyBaseDn(parameters.get(PARAMETER_COMPANIES_DN)); repository.setQuarantineBaseDn(parameters.get(PARAMETER_QUARANTINE_DN)); // Complete the bean SpringUtils.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(repository); return repository; }
SpringUtils.getApplicationContext().getAutowireCapableBeanFactory().autowireBean(repository);
@Override protected void executeInternal(final JobExecutionContext arg0) { // Extract the job data to execute the operation final int schedule = arg0.getMergedJobDataMap().getInt("schedule"); final ApplicationContext context = ObjectUtils.defaultIfNull((ApplicationContext) arg0.getMergedJobDataMap().get("context"), SpringUtils.getApplicationContext()); final VmSchedule entity = context.getBean(VmScheduleRepository.class).findOneExpected(schedule); log.info("Executing {} for schedule {}, subscription {}", entity.getOperation(), entity.getId(), entity.getSubscription().getId()); // Set the user context.getBean(SecurityHelper.class).setUserName(SecurityHelper.SYSTEM_USERNAME); // Execute the operation context.getBean(VmExecutionResource.class).execute(entity.getSubscription(), entity.getOperation()); log.info("Succeed {} for schedule {}, subscription {}", entity.getOperation(), entity.getId(), entity.getSubscription().getId()); }