use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.
the class EsAbstractBehavior method delegateQueryDelete.
@Override
protected int delegateQueryDelete(final ConditionBean cb, final DeleteOption<? extends ConditionBean> option) {
SearchResponse response = null;
int count = 0;
while (true) {
if (response == null) {
final SearchRequestBuilder builder = client.prepareSearch(asEsIndex()).setTypes(asEsIndexType()).setScroll(scrollForDelete).setSize(sizeForDelete);
final EsAbstractConditionBean esCb = (EsAbstractConditionBean) cb;
if (esCb.getPreference() != null) {
esCb.setPreference(esCb.getPreference());
}
esCb.request().build(builder);
response = esCb.build(builder).execute().actionGet(scrollSearchTimeout);
} else {
final String scrollId = response.getScrollId();
response = client.prepareSearchScroll(scrollId).setScroll(scrollForDelete).execute().actionGet(scrollSearchTimeout);
}
final SearchHits searchHits = response.getHits();
final SearchHit[] hits = searchHits.getHits();
if (hits.length == 0) {
break;
}
final BulkRequestBuilder bulkRequest = client.prepareBulk();
for (final SearchHit hit : hits) {
bulkRequest.add(client.prepareDelete(asEsIndex(), asEsIndexType(), hit.getId()));
}
count += hits.length;
final BulkResponse bulkResponse = bulkRequest.execute().actionGet(bulkTimeout);
if (bulkResponse.hasFailures()) {
throw new IllegalBehaviorStateException(bulkResponse.buildFailureMessage());
}
}
return count;
}
use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.
the class GroupBhv method createEntity.
@Override
protected <RESULT extends Group> RESULT createEntity(final Map<String, Object> source, final Class<? extends RESULT> entityType) {
try {
final RESULT result = entityType.newInstance();
result.setName(DfTypeUtil.toString(source.get("name")));
result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey())).map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond())));
return result;
} catch (InstantiationException | IllegalAccessException e) {
final String msg = "Cannot create a new instance: " + entityType.getName();
throw new IllegalBehaviorStateException(msg, e);
}
}
use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.
the class RoleBhv method createEntity.
@Override
protected <RESULT extends Role> RESULT createEntity(final Map<String, Object> source, final Class<? extends RESULT> entityType) {
try {
final RESULT result = entityType.newInstance();
result.setName(DfTypeUtil.toString(source.get("name")));
result.setAttributes(source.entrySet().stream().filter(e -> !"name".equals(e.getKey())).map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(t -> t.getFirst(), t -> t.getSecond())));
return result;
} catch (InstantiationException | IllegalAccessException e) {
final String msg = "Cannot create a new instance: " + entityType.getName();
throw new IllegalBehaviorStateException(msg, e);
}
}
use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.
the class BsThumbnailQueueBhv method createEntity.
@Override
protected <RESULT extends ThumbnailQueue> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
try {
final RESULT result = entityType.newInstance();
result.setCreatedBy(DfTypeUtil.toString(source.get("createdBy")));
result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime")));
result.setTarget(DfTypeUtil.toString(source.get("target")));
result.setGenerator(DfTypeUtil.toString(source.get("generator")));
result.setThumbnailId(DfTypeUtil.toString(source.get("thumbnail_id")));
result.setPath(DfTypeUtil.toString(source.get("path")));
result.setUrl(DfTypeUtil.toString(source.get("url")));
return updateEntity(source, result);
} catch (InstantiationException | IllegalAccessException e) {
final String msg = "Cannot create a new instance: " + entityType.getName();
throw new IllegalBehaviorStateException(msg, e);
}
}
use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.
the class BsWebAuthenticationBhv method createEntity.
@Override
protected <RESULT extends WebAuthentication> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
try {
final RESULT result = entityType.newInstance();
result.setAuthRealm(DfTypeUtil.toString(source.get("authRealm")));
result.setCreatedBy(DfTypeUtil.toString(source.get("createdBy")));
result.setCreatedTime(DfTypeUtil.toLong(source.get("createdTime")));
result.setHostname(DfTypeUtil.toString(source.get("hostname")));
result.setParameters(DfTypeUtil.toString(source.get("parameters")));
result.setPassword(DfTypeUtil.toString(source.get("password")));
result.setPort(DfTypeUtil.toInteger(source.get("port")));
result.setProtocolScheme(DfTypeUtil.toString(source.get("protocolScheme")));
result.setUpdatedBy(DfTypeUtil.toString(source.get("updatedBy")));
result.setUpdatedTime(DfTypeUtil.toLong(source.get("updatedTime")));
result.setUsername(DfTypeUtil.toString(source.get("username")));
result.setWebConfigId(DfTypeUtil.toString(source.get("webConfigId")));
return updateEntity(source, result);
} catch (InstantiationException | IllegalAccessException e) {
final String msg = "Cannot create a new instance: " + entityType.getName();
throw new IllegalBehaviorStateException(msg, e);
}
}
Aggregations