/** {@inheritDoc} */ @Cacheable(value = "categoryService-currentCategoryMenu") public List<Category> getCurrentContentMenu(final long currentContentId, final long shopId) { if (currentContentId > 0L && shopService.getShopContentIds(shopId).contains(currentContentId)) { final List<Category> categories = new ArrayList<Category>(contentService.getChildContent(currentContentId)); final Iterator<Category> itCat = categories.iterator(); while (itCat.hasNext()) { final Category cat = itCat.next(); if (CentralViewLabel.INCLUDE.equals(cat.getUitemplate())) { itCat.remove(); } } return categories; } return Collections.emptyList(); }
/** {@inheritDoc} */ @Override public boolean doImageImport( final JobStatusListener statusListener, final String fileName, final String code, final String suffix, final String locale) { final Category category = categoryService.findCategoryIdBySeoUriOrGuid(code); if (category == null) { final String warn = MessageFormat.format("category with code {0} not found.", code); statusListener.notifyWarning(warn); return false; } validateAccessBeforeUpdate(category, Category.class); final String attributeCode = AttributeNamesKeys.Category.CATEGORY_IMAGE_PREFIX + suffix + (StringUtils.isNotEmpty(locale) ? "_" + locale : ""); AttrValueCategory imageAttributeValue = (AttrValueCategory) category.getAttributeByCode(attributeCode); if (imageAttributeValue == null) { final List<Attribute> imageAttributes = attributeService.getAvailableImageAttributesByGroupCode(AttributeGroupNames.CATEGORY); Attribute attribute = null; for (final Attribute imageAttribute : imageAttributes) { if (attributeCode.equals(imageAttribute.getCode())) { attribute = imageAttribute; break; } } if (attribute == null) { final String warn = MessageFormat.format("attribute with code {0} not found.", attributeCode); statusListener.notifyWarning(warn); return false; } imageAttributeValue = categoryService.getGenericDao().getEntityFactory().getByIface(AttrValueCategory.class); imageAttributeValue.setCategory(category); imageAttributeValue.setAttribute(attribute); category.getAttributes().add(imageAttributeValue); } else if (isInsertOnly()) { return false; } imageAttributeValue.setVal(fileName); final String info = MessageFormat.format( "file {0} attached as {1} to category {2}", fileName, attributeCode, category.getName()); statusListener.notifyMessage(info); try { categoryService.update(category); return true; } catch (DataIntegrityViolationException e) { final String err = MessageFormat.format( "image {0} for category with code {1} could not be added (db error).", fileName, category.getGuid()); statusListener.notifyError(err, e); return false; } }