Search in sources :

Example 16 with SimpleBranch

use of org.gluu.persist.model.base.SimpleBranch in project oxAuth by GluuFederation.

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;
        }
    }
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch) EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException)

Example 17 with SimpleBranch

use of org.gluu.persist.model.base.SimpleBranch in project oxAuth by GluuFederation.

the class UmaPctService method addBranch.

public void addBranch() {
    SimpleBranch branch = new SimpleBranch();
    branch.setOrganizationalUnitName("pct");
    branch.setDn(branchBaseDn());
    ldapEntryManager.persist(branch);
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch)

Example 18 with SimpleBranch

use of org.gluu.persist.model.base.SimpleBranch in project oxCore by GluuFederation.

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);
    }
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch) EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.persist.exception.operation.DuplicateEntryException)

Example 19 with SimpleBranch

use of org.gluu.persist.model.base.SimpleBranch in project oxCore by GluuFederation.

the class MetricService method addBranch.

public void addBranch(String branchDn, String ou) {
    if (getEntryManager().hasBranchesSupport(branchDn)) {
        SimpleBranch branch = new SimpleBranch();
        branch.setOrganizationalUnitName(ou);
        branch.setDn(branchDn);
        getEntryManager().persist(branch);
    }
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch)

Example 20 with SimpleBranch

use of org.gluu.persist.model.base.SimpleBranch in project oxTrust by GluuFederation.

the class PasswordResetService method addBranch.

public void addBranch() {
    SimpleBranch branch = new SimpleBranch();
    branch.setOrganizationalUnitName("resetPasswordRequests");
    branch.setDn(getDnForPasswordResetRequest(null));
    ldapEntryManager.persist(branch);
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch)

Aggregations

SimpleBranch (org.gluu.persist.model.base.SimpleBranch)20 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)2 DefaultBatchOperation (org.gluu.persist.model.DefaultBatchOperation)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 MetricEntry (org.gluu.model.metric.ldap.MetricEntry)1 DuplicateEntryException (org.gluu.persist.exception.operation.DuplicateEntryException)1 MetricEntry (org.xdi.model.metric.ldap.MetricEntry)1