Search in sources :

Example 16 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class CurrentUserProfileAction method addLabelGroups.

protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
    try {
        ApsProperties properties = new ApsProperties();
        Lang defaultLang = super.getLangManager().getDefaultLang();
        properties.put(defaultLang.getCode(), defaultValue);
        this.getI18nManager().addLabelGroup(key, properties);
    } catch (Throwable t) {
        _logger.error("Error adding label groups - key '{}'", key, t);
        // ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
        throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 17 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class PageService method updatePage.

private IPage updatePage(IPage oldPage, PageRequest pageRequest) {
    Page page = new Page();
    PageMetadata metadata = oldPage.getMetadata();
    if (metadata == null) {
        metadata = new PageMetadata();
    }
    this.valueMetadataFromRequest(metadata, pageRequest);
    page.setMetadata(metadata);
    page.setCode(pageRequest.getCode());
    page.setShowable(pageRequest.isDisplayedInMenu());
    if (!oldPage.getModel().getCode().equals(pageRequest.getPageModel())) {
        PageModel model = this.getPageModelManager().getPageModel(pageRequest.getPageModel());
        model.setCode(pageRequest.getPageModel());
        page.setModel(model);
        page.setWidgets(new Widget[model.getFrames().length]);
    } else {
        page.setWidgets(oldPage.getWidgets());
    }
    page.setCharset(pageRequest.getCharset());
    page.setMimeType(pageRequest.getContentType());
    page.setParentCode(pageRequest.getParentCode());
    page.setUseExtraTitles(pageRequest.isSeo());
    Optional<Map<String, String>> titles = Optional.ofNullable(pageRequest.getTitles());
    ApsProperties apsTitles = new ApsProperties();
    titles.ifPresent(values -> values.keySet().forEach((lang) -> {
        apsTitles.put(lang, values.get(lang));
    }));
    page.setTitles(apsTitles);
    page.setGroup(pageRequest.getOwnerGroup());
    if (page.getExtraGroups() != null) {
        List<String> oldGroups = new ArrayList<>(page.getExtraGroups());
        oldGroups.forEach(page::removeExtraGroup);
    }
    if (pageRequest.getJoinGroups() != null) {
        pageRequest.getJoinGroups().forEach(page::addExtraGroup);
    }
    page.setParentCode(pageRequest.getParentCode());
    page.setPosition(oldPage.getPosition());
    page.setChildrenCodes(oldPage.getChildrenCodes());
    return page;
}
Also used : ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) Arrays(java.util.Arrays) BeanComparator(org.apache.commons.beanutils.BeanComparator) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Group(com.agiletec.aps.system.services.group.Group) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) PageSearchDto(org.entando.entando.aps.system.services.page.model.PageSearchDto) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) PageDtoBuilder(org.entando.entando.aps.system.services.page.model.PageDtoBuilder) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) JsonNode(com.fasterxml.jackson.databind.JsonNode) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) PageSearchRequest(org.entando.entando.web.page.model.PageSearchRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataBinder(org.springframework.validation.DataBinder) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity) Collectors(java.util.stream.Collectors) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) Optional(java.util.Optional) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) PageUtils(org.entando.entando.aps.util.PageUtils) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) BeanUtils(org.springframework.beans.BeanUtils) JsonPatchService(org.entando.entando.aps.system.services.jsonpatch.JsonPatchService) Page(com.agiletec.aps.system.services.page.Page) HashMap(java.util.HashMap) BindingResult(org.springframework.validation.BindingResult) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageUtilizer(com.agiletec.aps.system.services.page.PageUtilizer) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IPageManager(com.agiletec.aps.system.services.page.IPageManager) IManager(com.agiletec.aps.system.common.IManager) PagedMetadataMapper(org.entando.entando.web.common.assembler.PagedMetadataMapper) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) PageSearchMapper(org.entando.entando.web.common.assembler.PageSearchMapper) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PageRequest(org.entando.entando.web.page.model.PageRequest) PagesStatusDto(org.entando.entando.aps.system.services.page.model.PagesStatusDto) BeansException(org.springframework.beans.BeansException) PageValidator(org.entando.entando.web.page.validator.PageValidator) ApplicationContext(org.springframework.context.ApplicationContext) PageModelServiceUtilizer(org.entando.entando.aps.system.services.pagemodel.PageModelServiceUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Collections(java.util.Collections) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 18 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class LabelService method addLabelGroup.

@Override
public LabelDto addLabelGroup(LabelDto labelRequest) {
    try {
        BeanPropertyBindingResult validationResult = this.validateAddLabelGroup(labelRequest);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        String code = labelRequest.getKey();
        ApsProperties languages = new ApsProperties();
        languages.putAll(labelRequest.getTitles());
        this.getI18nManager().addLabelGroup(code, languages);
        return labelRequest;
    } catch (ApsSystemException t) {
        logger.error("error in add label group with code {}", labelRequest.getKey(), t);
        throw new RestServerError("error in add label group", t);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 19 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class LabelService method updateLabelGroup.

@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
    try {
        String code = labelRequest.getKey();
        ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
        if (null == labelGroup) {
            logger.warn("no label found with key {}", code);
            throw new ResourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
        }
        BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
        if (validationResult.hasErrors()) {
            throw new ValidationGenericException(validationResult);
        }
        ApsProperties languages = new ApsProperties();
        languages.putAll(labelRequest.getTitles());
        this.getI18nManager().updateLabelGroup(code, languages);
        return labelRequest;
    } catch (ApsSystemException t) {
        logger.error("error in update label group with code {}", labelRequest.getKey(), t);
        throw new RestServerError("error in update label group", t);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 20 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class ApiI18nLabelInterface method getLabel.

public JAXBI18nLabel getLabel(Properties properties) throws ApiException, ApsSystemException {
    JAXBI18nLabel jaxbI18nLabel = null;
    try {
        String key = properties.getProperty("key");
        ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
        if (null == labelGroups) {
            throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label with key '" + key + "' does not exist", Response.Status.CONFLICT);
        }
        jaxbI18nLabel = new JAXBI18nLabel(key, labelGroups);
    } catch (ApiException ae) {
        throw ae;
    } catch (ApsSystemException t) {
        _logger.error("error loading labels", t);
        throw new ApsSystemException("Error loading labels", t);
    }
    return jaxbI18nLabel;
}
Also used : JAXBI18nLabel(org.entando.entando.aps.system.services.i18n.model.JAXBI18nLabel) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApsProperties(com.agiletec.aps.util.ApsProperties) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)157 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)35 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)28 HashMap (java.util.HashMap)22 IPage (com.agiletec.aps.system.services.page.IPage)18 Lang (com.agiletec.aps.system.services.lang.Lang)14 Test (org.junit.Test)12 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 Page (com.agiletec.aps.system.services.page.Page)8 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)8 List (java.util.List)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)5