use of io.jans.orm.model.base.SimpleBranch in project jans by JanssenProject.
the class PairwiseIdentifierService method addBranch.
public void addBranch(final String userInum) {
SimpleBranch branch = new SimpleBranch();
branch.setOrganizationalUnitName("pairwiseIdentifiers");
branch.setDn(getBaseDnForPairwiseIdentifiers(userInum));
ldapEntryManager.persist(branch);
}
use of io.jans.orm.model.base.SimpleBranch in project jans by JanssenProject.
the class MetricService method removeExpiredMetricEntries.
public void removeExpiredMetricEntries(final Date expirationDate, final ApplicationType applicationType, int count, int chunkSize) {
createApplicationBaseBranch(applicationType);
final Set<String> keepBaseDnForPeriod = getBaseDnForPeriod(applicationType, expirationDate, new Date());
// Remove expired entries
for (final String baseDnForPeriod : keepBaseDnForPeriod) {
DefaultBatchOperation<MetricEntry> metricEntryBatchOperation = new DefaultBatchOperation<MetricEntry>() {
@Override
public boolean collectSearchResult(int size) {
return false;
}
@Override
public void performAction(List<MetricEntry> entries) {
for (MetricEntry metricEntry : entries) {
remove(metricEntry);
}
}
};
getExpiredMetricEntries(metricEntryBatchOperation, applicationType, baseDnForPeriod, expirationDate, count, chunkSize);
}
if (!getEntryManager().hasBranchesSupport(buildDn(null, null, applicationType))) {
DefaultBatchOperation<SimpleBranch> batchOperation = new DefaultBatchOperation<SimpleBranch>() {
@Override
public boolean collectSearchResult(int size) {
return false;
}
@Override
public void performAction(List<SimpleBranch> objects) {
String baseDn = buildDn(null, null, applicationType);
Set<String> periodBranchesStrings = new HashSet<String>();
for (SimpleBranch periodBranch : objects) {
if (!StringHelper.equalsIgnoreCase(baseDn, periodBranch.getDn())) {
periodBranchesStrings.add(periodBranch.getDn());
}
}
periodBranchesStrings.removeAll(keepBaseDnForPeriod);
// Remove expired months
for (String baseDnForPeriod : periodBranchesStrings) {
removeBranch(baseDnForPeriod);
}
}
};
findAllPeriodBranches(batchOperation, applicationType, count, chunkSize);
}
}
use of io.jans.orm.model.base.SimpleBranch in project jans by JanssenProject.
the class UmaResourceService method addBranch.
public void addBranch() {
SimpleBranch branch = new SimpleBranch();
branch.setOrganizationalUnitName("resources");
branch.setDn(getDnForResource(null));
persistenceEntryManager.persist(branch);
}
use of io.jans.orm.model.base.SimpleBranch in project jans by JanssenProject.
the class NativePersistenceCacheProvider method create.
@Override
public void create() {
try {
baseDn = cacheConfiguration.getNativePersistenceConfiguration().getBaseDn();
deleteExpiredOnGetRequest = cacheConfiguration.getNativePersistenceConfiguration().isDeleteExpiredOnGetRequest();
if (StringUtils.isBlank(baseDn)) {
log.error("Failed to create NATIVE_PERSISTENCE cache provider. 'baseDn' in CacheConfiguration is not initialized. It has to be set by client application (e.g. oxAuth has to set it in ApplicationFactory.)");
throw new RuntimeException("Failed to create NATIVE_PERSISTENCE cache provider. 'baseDn' in CacheConfiguration is not initialized. It has to be set by client application.");
}
String branchDn = String.format("ou=cache,%s", baseDn);
if (entryManager.hasBranchesSupport(branchDn)) {
if (!entryManager.contains(branchDn, SimpleBranch.class)) {
SimpleBranch branch = new SimpleBranch();
branch.setOrganizationalUnitName("cache");
branch.setDn(branchDn);
entryManager.persist(branch);
}
}
baseDn = branchDn;
cacheConfiguration.getNativePersistenceConfiguration().setBaseDn(baseDn);
String persistenceType = entryManager.getPersistenceType(baseDn);
// CouchbaseEntryManagerFactory.PERSISTENCE_TYPE
skipRemoveBeforePut = "couchbase".equals(persistenceType);
attemptUpdateBeforeInsert = "sql".equals(persistenceType);
log.info("Created NATIVE_PERSISTENCE cache provider. `baseDn`: " + baseDn);
} catch (Exception e) {
log.error("Failed to create NATIVE_PERSISTENCE cache provider.", e);
throw new RuntimeException("Failed to create NATIVE_PERSISTENCE cache provider.", e);
}
}
use of io.jans.orm.model.base.SimpleBranch in project jans by JanssenProject.
the class StatService method createBranch.
public void createBranch(String branchDn, String ou) {
try {
SimpleBranch branch = new SimpleBranch();
branch.setOrganizationalUnitName(ou);
branch.setDn(branchDn);
entryManager.persist(branch);
} catch (EntryPersistenceException ex) {
// Check if another process added this branch already
if (!entryManager.contains(branchDn, SimpleBranch.class)) {
throw ex;
}
}
}
Aggregations