Search in sources :

Example 91 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class DataObjectViewerHelper method getRenderizationInfo.

@Override
public DataObjectRenderizationInfo getRenderizationInfo(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
    DataObjectRenderizationInfo renderizationInfo = null;
    try {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        ApsProperties widgetConfig = widget.getConfig();
        dataobjectId = this.extractDataId(dataobjectId, widgetConfig, reqCtx);
        modelId = this.extractModelId(dataobjectId, modelId, widgetConfig, reqCtx);
        if (dataobjectId != null && modelId != null) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(dataobjectId, longModelId, langCode, reqCtx, true);
            if (null == renderizationInfo) {
                _logger.info("Null Renderization informations: dataobject={}", dataobjectId);
                return null;
            }
            this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
        } else {
            _logger.warn("Parametri visualizzazione dataobject incompleti: dataobject={} modello={}", dataobjectId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting renderization info", t);
        throw new ApsSystemException("Error extracting renderization info", t);
    }
    return renderizationInfo;
}
Also used : DataObjectRenderizationInfo(org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 92 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class DataObjectViewerHelper method getAuthorizationInfo.

@Override
public PublicDataTypeAuthorizationInfo getAuthorizationInfo(String dataobjectId, RequestContext reqCtx) throws ApsSystemException {
    PublicDataTypeAuthorizationInfo authInfo = null;
    try {
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        dataobjectId = this.extractDataId(dataobjectId, widget.getConfig(), reqCtx);
        if (null == dataobjectId) {
            _logger.info("Null dataobjectId");
            return null;
        }
        authInfo = this.getDataAuthorizationHelper().getAuthorizationInfo(dataobjectId, true);
        if (null == authInfo) {
            _logger.info("Null authorization info by dataobject '" + dataobjectId + "'");
        }
    } catch (Throwable t) {
        _logger.error("Error extracting dataobject authorization info by dataobject {}", dataobjectId, t);
        throw new ApsSystemException("Error extracting dataobject authorization info by dataobject '" + dataobjectId + "'", t);
    }
    return authInfo;
}
Also used : PublicDataTypeAuthorizationInfo(org.entando.entando.aps.system.services.dataobject.helper.PublicDataTypeAuthorizationInfo) Widget(com.agiletec.aps.system.services.page.Widget) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 93 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class UserFilterOptionBean method getEntityFilter.

public EntitySearchFilter getEntityFilter() throws ApsSystemException {
    EntitySearchFilter filter = null;
    try {
        if (!this.isAttributeFilter() || null == this.getFormFieldValues()) {
            return null;
        }
        AttributeInterface attribute = this.getAttribute();
        if (attribute instanceof ITextAttribute) {
            String text = this.getFormFieldValues().get(this.getFormFieldNames()[0]);
            filter = new EntitySearchFilter(attribute.getName(), true, text, true);
            if (attribute.isMultilingual()) {
                filter.setLangCode(this.getCurrentLang().getCode());
            }
        } else if (attribute instanceof DateAttribute) {
            String start = this.getFormFieldValues().get(this.getFormFieldNames()[0]);
            String end = this.getFormFieldValues().get(this.getFormFieldNames()[1]);
            Date startDate = DateConverter.parseDate(start, this.getDateFormat());
            Date endDate = DateConverter.parseDate(end, this.getDateFormat());
            filter = new EntitySearchFilter(attribute.getName(), true, startDate, endDate);
        } else if (attribute instanceof BooleanAttribute) {
            String value = this.getFormFieldValues().get(this.getFormFieldNames()[0]);
            String ignore = this.getFormFieldValues().get(this.getFormFieldNames()[1]);
            if (null != ignore) {
                return null;
            } else if (null == value || value.equals("both")) {
                // special option for three state Attribute
                filter = new EntitySearchFilter(attribute.getName(), true);
                filter.setNullOption(true);
            } else {
                filter = new EntitySearchFilter(attribute.getName(), true, value, false);
            }
        } else if (attribute instanceof NumberAttribute) {
            String start = this.getFormFieldValues().get(this.getFormFieldNames()[0]);
            String end = this.getFormFieldValues().get(this.getFormFieldNames()[1]);
            BigDecimal startNumber = null;
            try {
                Integer startNumberInt = Integer.parseInt(start);
                startNumber = new BigDecimal(startNumberInt);
            } catch (Throwable t) {
            }
            BigDecimal endNumber = null;
            try {
                Integer endNumberInt = Integer.parseInt(end);
                endNumber = new BigDecimal(endNumberInt);
            } catch (Throwable t) {
            }
            filter = new EntitySearchFilter(attribute.getName(), true, startNumber, endNumber);
        }
    } catch (Throwable t) {
        _logger.error("Error extracting entity search filters", t);
        throw new ApsSystemException("Error extracting entity search filters", t);
    }
    return filter;
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) NumberAttribute(com.agiletec.aps.system.common.entity.model.attribute.NumberAttribute) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) Date(java.util.Date) BigDecimal(java.math.BigDecimal) DateAttribute(com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)

Example 94 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class DataObjectModelManager method addDataObjectModel.

@Override
public void addDataObjectModel(DataObjectModel model) throws ApsSystemException {
    try {
        this.getDataModelDAO().addDataModel(model);
        // Long wrapLongId = new Long(model.getId());
        this.getCacheWrapper().addModel(model);
        this.notifyDataModelChanging(model, DataObjectModelChangedEvent.INSERT_OPERATION_CODE);
    } catch (Throwable t) {
        logger.error("Error saving a dataObjectModel", t);
        throw new ApsSystemException("Error saving a dataObjectModel", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 95 with ApsSystemException

use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.

the class DataObjectModelManager method removeDataObjectModel.

@Override
public void removeDataObjectModel(DataObjectModel model) throws ApsSystemException {
    try {
        this.getDataModelDAO().deleteDataModel(model);
        this.getCacheWrapper().removeModel(model);
        this.notifyDataModelChanging(model, DataObjectModelChangedEvent.REMOVE_OPERATION_CODE);
    } catch (Throwable t) {
        logger.error("Error deleting a dataObject model", t);
        throw new ApsSystemException("Error deleting a dataObject model", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Aggregations

ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)452 ArrayList (java.util.ArrayList)53 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)48 RestServerError (org.entando.entando.aps.system.exception.RestServerError)39 ApsProperties (com.agiletec.aps.util.ApsProperties)26 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)23 HashMap (java.util.HashMap)23 UserDetails (com.agiletec.aps.system.services.user.UserDetails)21 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)21 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)20 Date (java.util.Date)20 StringReader (java.io.StringReader)18 IPage (com.agiletec.aps.system.services.page.IPage)17 List (java.util.List)17 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)16 File (java.io.File)16 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)16 Widget (com.agiletec.aps.system.services.page.Widget)15 IOException (java.io.IOException)15 Cache (org.springframework.cache.Cache)15