use of io.jans.orm.exception.EntryDeleteException in project jans by JanssenProject.
the class SpannerEntryManager method removeImpl.
protected <T> int removeImpl(String dn, Class<T> entryClass, Filter filter, int count) {
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
Filter searchFilter;
if (objectClasses.length > 0) {
LOG.trace("Filter: {}", filter);
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
throw new EntryDeleteException(String.format("Failed to delete entries with DN: '%s', filter: '%s' because objectClass is not specified", dn, filter));
}
// Find entries
LOG.trace("-------------------------------------------------------");
LOG.trace("Filter: {}", filter);
LOG.trace("objectClasses count: {} ", objectClasses.length);
LOG.trace("objectClasses: {}", objectClasses.toString());
LOG.trace("Search filter: {}", searchFilter);
// Prepare properties types to allow build filter properly
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Map<String, PropertyAnnotation> propertiesAnnotationsMap = prepareEntryPropertiesTypes(entryClass, propertiesAnnotations);
String key = toSQLKey(dn).getKey();
ConvertedExpression convertedExpression;
try {
convertedExpression = toSqlFilterWithEmptyAlias(key, objectClasses[0], searchFilter, propertiesAnnotationsMap);
} catch (SearchException ex) {
throw new EntryDeleteException(String.format("Failed to convert filter '%s' to expression", searchFilter));
}
try {
int processed = (int) getOperationService().delete(key, objectClasses[0], convertedExpression, count);
return processed;
} catch (Exception ex) {
throw new EntryDeleteException(String.format("Failed to delete entries with key: '%s', expression: '%s'", key, convertedExpression), ex);
}
}
use of io.jans.orm.exception.EntryDeleteException in project jans by JanssenProject.
the class CouchbaseEntryManager method removeImpl.
protected <T> int removeImpl(String dn, Class<T> entryClass, Filter filter, int count) {
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
Filter searchFilter;
if (objectClasses.length > 0) {
LOG.trace("Filter: {}", filter);
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
searchFilter = filter;
}
// Find entries
LOG.trace("-------------------------------------------------------");
LOG.trace("Filter: {}", filter);
LOG.trace("objectClasses count: {} ", objectClasses.length);
LOG.trace("objectClasses: {}", objectClasses.toString());
LOG.trace("Search filter: {}", searchFilter);
// Prepare properties types to allow build filter properly
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Map<String, PropertyAnnotation> propertiesAnnotationsMap = prepareEntryPropertiesTypes(entryClass, propertiesAnnotations);
ParsedKey keyWithInum = toCouchbaseKey(dn);
ConvertedExpression convertedExpression;
try {
convertedExpression = toCouchbaseFilter(searchFilter, propertiesAnnotationsMap);
} catch (SearchException ex) {
throw new EntryDeleteException(String.format("Failed to convert filter %s to expression", searchFilter), ex);
}
try {
int processed = getOperationService().delete(keyWithInum.getKey(), getScanConsistency(convertedExpression), convertedExpression.expression(), count);
return processed;
} catch (Exception ex) {
throw new EntryDeleteException(String.format("Failed to delete entries with key: %s, expression: %s", keyWithInum.getKey(), convertedExpression), ex);
}
}
use of io.jans.orm.exception.EntryDeleteException in project jans by JanssenProject.
the class LdapEntryManager method remove.
@Override
public <T> int remove(String baseDN, Class<T> entryClass, Filter filter, int count) {
if (StringHelper.isEmptyString(baseDN)) {
throw new MappingException("Base DN to find entries is null");
}
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
// Find entries
Filter searchFilter;
if (objectClasses.length > 0) {
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
searchFilter = filter;
}
DeleteBatchOperation batchOperation = new DeleteBatchOperation<T>(this);
SearchResult searchResult = null;
try {
LdapBatchOperationWraper<T> batchOperationWraper = new LdapBatchOperationWraper<T>(batchOperation, this, entryClass, propertiesAnnotations);
searchResult = getOperationService().search(baseDN, toLdapFilter(searchFilter), toLdapSearchScope(SearchScope.SUB), batchOperationWraper, 0, 100, count, null, LdapOperationService.DN);
} catch (Exception ex) {
throw new EntryDeleteException(String.format("Failed to delete entries with baseDN: %s, filter: %s", baseDN, searchFilter), ex);
}
if (!ResultCode.SUCCESS.equals(searchResult.getResultCode())) {
throw new EntryDeleteException(String.format("Failed to delete entries with baseDN: %s, filter: %s", baseDN, searchFilter));
}
return batchOperation.getCountEntries();
}
use of io.jans.orm.exception.EntryDeleteException in project jans by JanssenProject.
the class LdapEntryManager method removeSubtreeThroughIteration.
private void removeSubtreeThroughIteration(String dn) {
SearchScope scope = SearchScope.SUB;
SearchResult searchResult = null;
try {
searchResult = getOperationService().search(dn, toLdapFilter(Filter.createPresenceFilter("objectClass")), toLdapSearchScope(scope), null, 0, 0, 0, null, "dn");
if (!ResultCode.SUCCESS.equals(searchResult.getResultCode())) {
throw new EntryPersistenceException(String.format("Failed to find sub-entries of entry '%s' for removal", dn));
}
} catch (SearchScopeException ex) {
throw new AuthenticationException(String.format("Failed to convert scope: %s", scope), ex);
} catch (SearchException ex) {
throw new EntryDeleteException(String.format("Failed to find sub-entries of entry '%s' for removal", dn), ex);
}
List<String> removeEntriesDn = new ArrayList<String>(searchResult.getEntryCount());
for (SearchResultEntry searchResultEntry : searchResult.getSearchEntries()) {
removeEntriesDn.add(searchResultEntry.getDN());
}
Collections.sort(removeEntriesDn, LINE_LENGHT_COMPARATOR);
for (String removeEntryDn : removeEntriesDn) {
remove(removeEntryDn);
}
}
use of io.jans.orm.exception.EntryDeleteException in project jans by JanssenProject.
the class SqlEntryManager method removeImpl.
protected <T> int removeImpl(String dn, Class<T> entryClass, Filter filter, int count) {
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
Filter searchFilter;
if (objectClasses.length > 0) {
LOG.trace("Filter: {}", filter);
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
throw new EntryDeleteException(String.format("Failed to delete entries with DN: '%s', filter: '%s' because objectClass is not specified", dn, filter));
}
// Find entries
LOG.trace("-------------------------------------------------------");
LOG.trace("Filter: {}", filter);
LOG.trace("objectClasses count: {} ", objectClasses.length);
LOG.trace("objectClasses: {}", objectClasses.toString());
LOG.trace("Search filter: {}", searchFilter);
// Prepare properties types to allow build filter properly
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
Map<String, PropertyAnnotation> propertiesAnnotationsMap = prepareEntryPropertiesTypes(entryClass, propertiesAnnotations);
ParsedKey keyWithInum = toSQLKey(dn);
ConvertedExpression convertedExpression;
try {
convertedExpression = toSqlFilterWithEmptyAlias(searchFilter, propertiesAnnotationsMap);
} catch (SearchException ex) {
throw new EntryDeleteException(String.format("Failed to convert filter '%s' to expression", searchFilter), ex);
}
try {
int processed = (int) getOperationService().delete(keyWithInum.getKey(), objectClasses[0], convertedExpression, count);
return processed;
} catch (Exception ex) {
throw new EntryDeleteException(String.format("Failed to delete entries with key: '%s', expression: '%s'", keyWithInum.getKey(), convertedExpression), ex);
}
}
Aggregations