Search in sources :

Example 1 with ApiContentListBean

use of org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean in project entando-core by entando.

the class ApiContentInterface method extractContents.

protected List<String> extractContents(Properties properties) throws Throwable {
    List<String> contentsId = null;
    try {
        ApiContentListBean bean = this.buildSearchBean(properties);
        UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
        contentsId = this.getContentListHelper().getContentsId(bean, user);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("error in extractContents", t);
        throw new ApsSystemException("Error into API method", t);
    }
    return contentsId;
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) ApiContentListBean(org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 2 with ApiContentListBean

use of org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean in project entando-core by entando.

the class ApiContentInterface method buildSearchBean.

protected ApiContentListBean buildSearchBean(Properties properties) throws ApiException, Throwable {
    ApiContentListBean bean = null;
    try {
        String contentType = properties.getProperty("contentType");
        if (null == this.getContentManager().getSmallContentTypesMap().get(contentType)) {
            throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Content Type '" + contentType + "' does not exist", Response.Status.CONFLICT);
        }
        String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
        String filtersParam = properties.getProperty("filters");
        EntitySearchFilter[] filters = this.getContentListHelper().getFilters(contentType, filtersParam, langCode);
        String[] categoryCodes = null;
        String categoriesParam = properties.getProperty("categories");
        if (null != categoriesParam && categoriesParam.trim().length() > 0) {
            categoryCodes = categoriesParam.split(IContentListHelper.CATEGORIES_SEPARATOR);
        }
        bean = new ApiContentListBean(contentType, filters, categoryCodes);
    } catch (ApiException ae) {
        throw ae;
    } catch (Throwable t) {
        _logger.error("error in buildSearchBean", t);
        throw new ApsSystemException("Error into API method", t);
    }
    return bean;
}
Also used : ApiContentListBean(org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 ApiContentListBean (org.entando.entando.plugins.jacms.aps.system.services.api.model.ApiContentListBean)2 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1