Search in sources :

Example 11 with SimpleBranch

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

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);
    }
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch) MetricEntry(org.gluu.model.metric.ldap.MetricEntry) DefaultBatchOperation(org.gluu.persist.model.DefaultBatchOperation)

Example 12 with SimpleBranch

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

the class PushApplicationService method addBranch.

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

Example 13 with SimpleBranch

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

the class PushDeviceService method addBranch.

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

Example 14 with SimpleBranch

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

the class MetricService method removeExpiredMetricEntries.

public void removeExpiredMetricEntries(final Date expirationDate, final ApplicationType applicationType, final String applianceInum, int sizeLimit, int chunkSize) {
    final Set<String> keepBaseDnForPeriod = getBaseDnForPeriod(applicationType, applianceInum, 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, baseDnForPeriod, expirationDate, sizeLimit, chunkSize);
    }
    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, applianceInum);
            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, applianceInum, sizeLimit, chunkSize);
}
Also used : SimpleBranch(org.gluu.persist.model.base.SimpleBranch) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) MetricEntry(org.xdi.model.metric.ldap.MetricEntry) DefaultBatchOperation(org.gluu.persist.model.DefaultBatchOperation) Date(java.util.Date) HashSet(java.util.HashSet)

Example 15 with SimpleBranch

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

the class ClientAuthorizationsService method addBranch.

public void addBranch() {
    SimpleBranch branch = new SimpleBranch();
    branch.setOrganizationalUnitName("authorizations");
    branch.setDn(createDn(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