use of com.salesmanager.shop.model.content.ContentFolder in project shopizer by shopizer-ecommerce.
the class ContentFacadeImpl method getContentFolder.
@Override
public ContentFolder getContentFolder(String folder, MerchantStore store) throws Exception {
try {
List<String> imageNames = Optional.ofNullable(contentService.getContentFilesNames(store.getCode(), FileContentType.IMAGE)).orElseThrow(() -> new ResourceNotFoundException("No Folder found for path : " + folder));
// images from CMS
List<ContentImage> contentImages = imageNames.stream().map(name -> convertToContentImage(name, store)).collect(Collectors.toList());
ContentFolder contentFolder = new ContentFolder();
if (!StringUtils.isBlank(folder)) {
contentFolder.setPath(URLEncoder.encode(folder, "UTF-8"));
}
contentFolder.getContent().addAll(contentImages);
return contentFolder;
} catch (ServiceException e) {
throw new ServiceRuntimeException("Error while getting folder " + e.getMessage(), e);
}
}
use of com.salesmanager.shop.model.content.ContentFolder in project shopizer by shopizer-ecommerce.
the class ContentAdministrationApi method list.
/**
* Works with ng-file-man client
*
* @param path
* @param merchantStore
* @param language
* @return
* @throws Exception
*/
@GetMapping(value = "/private/content/list", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public List<ImageFile> list(@RequestParam(value = "parentPath", required = false) String path, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) throws Exception {
String decodedPath = decodeContentPath(path);
ContentFolder folder = contentFacade.getContentFolder(decodedPath, merchantStore);
List<ImageFile> files = folder.getContent().stream().map(x -> convertToImageFile(merchantStore, x)).collect(Collectors.toList());
return files;
}
Aggregations