Search in sources :

Example 46 with IllegalBehaviorStateException

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);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 47 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsGroupBhv method createEntity.

@Override
protected <RESULT extends Group> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setGidNumber(DfTypeUtil.toLong(source.get("gidNumber")));
        result.setName(DfTypeUtil.toString(source.get("name")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 48 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsFavoriteLogBhv method createEntity.

@Override
protected <RESULT extends FavoriteLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setCreatedAt(toLocalDateTime(source.get("createdAt")));
        result.setDocId(DfTypeUtil.toString(source.get("docId")));
        result.setQueryId(DfTypeUtil.toString(source.get("queryId")));
        result.setUrl(DfTypeUtil.toString(source.get("url")));
        result.setUserInfoId(DfTypeUtil.toString(source.get("userInfoId")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 49 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class BsUserInfoBhv method createEntity.

@Override
protected <RESULT extends UserInfo> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
    try {
        final RESULT result = entityType.newInstance();
        result.setCreatedAt(toLocalDateTime(source.get("createdAt")));
        result.setUpdatedAt(toLocalDateTime(source.get("updatedAt")));
        return updateEntity(source, result);
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException)

Example 50 with IllegalBehaviorStateException

use of org.dbflute.exception.IllegalBehaviorStateException in project fess by codelibs.

the class UserBhv method createEntity.

@Override
protected <RESULT extends User> 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.setPassword(DfTypeUtil.toString(source.get(PASSWORD)));
        result.setGroups(toStringArray(source.get(GROUPS)));
        result.setRoles(toStringArray(source.get(ROLES)));
        result.setAttributes(source.entrySet().stream().filter(e -> isAttribute(e.getKey())).map(e -> new Pair<>(e.getKey(), (String) e.getValue())).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));
        return result;
    } catch (InstantiationException | IllegalAccessException e) {
        final String msg = "Cannot create a new instance: " + entityType.getName();
        throw new IllegalBehaviorStateException(msg, e);
    }
}
Also used : ComponentUtil(org.codelibs.fess.util.ComponentUtil) DfTypeUtil(org.dbflute.util.DfTypeUtil) Map(java.util.Map) Pair(org.codelibs.core.misc.Pair) BsUserBhv(org.codelibs.fess.es.user.bsbhv.BsUserBhv) Pattern(java.util.regex.Pattern) User(org.codelibs.fess.es.user.exentity.User) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) Collectors(java.util.stream.Collectors) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) Pair(org.codelibs.core.misc.Pair)

Aggregations

IllegalBehaviorStateException (org.dbflute.exception.IllegalBehaviorStateException)50 Map (java.util.Map)4 Pair (org.codelibs.core.misc.Pair)4 Pattern (java.util.regex.Pattern)3 Collectors (java.util.stream.Collectors)3 ComponentUtil (org.codelibs.fess.util.ComponentUtil)3 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)3 DfTypeUtil (org.dbflute.util.DfTypeUtil)3 BulkRequestBuilder (org.opensearch.action.bulk.BulkRequestBuilder)3 BulkResponse (org.opensearch.action.bulk.BulkResponse)3 SearchRequestBuilder (org.opensearch.action.search.SearchRequestBuilder)3 SearchResponse (org.opensearch.action.search.SearchResponse)3 SearchHit (org.opensearch.search.SearchHit)3 SearchHits (org.opensearch.search.SearchHits)3 DateTimeParseException (java.time.format.DateTimeParseException)1 List (java.util.List)1 BsGroupBhv (org.codelibs.fess.es.user.bsbhv.BsGroupBhv)1 BsRoleBhv (org.codelibs.fess.es.user.bsbhv.BsRoleBhv)1 BsUserBhv (org.codelibs.fess.es.user.bsbhv.BsUserBhv)1 Group (org.codelibs.fess.es.user.exentity.Group)1