@Override @Transactional public List<Content> getAllContents() { List<Content> contents = new ArrayList<>(); contents.addAll(streamContentService.retrieveAll()); contents.addAll(stringContentService.retrieveAll()); return contents; }
@Override @Transactional public StringContent getStringContent(String language, String name) throws ContentNotFoundException { StringContent stringContent = stringContentService.findByLanguageAndName(language, name); if (stringContent == null) { throw new ContentNotFoundException(); } return stringContent; }
@Override @Transactional public void addContent(Content content) { if (content == null || content.getLanguage() == null || content.getName() == null) { throw new IllegalArgumentException("Content or language or name should not be null"); } if (content instanceof StreamContent) { streamContentService.createOrUpdate((StreamContent) content); } else if (content instanceof StringContent) { stringContentService.createOrUpdate((StringContent) content); } }
@Override @Transactional public StringContent getStringContent(long stringContentId) { return stringContentService.findById(stringContentId); }
@Override @Transactional public void removeStringContent(String language, String name) throws ContentNotFoundException { stringContentService.delete(getStringContent(language, name)); }
@Override @Transactional public boolean isStringContentAvailable(String language, String name) { StringContent stringContent = stringContentService.findByLanguageAndName(language, name); return stringContent != null; }