ImageGalleryApiServiceImpl.java
/*
* Copyright 2024 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.server.api.v2.facade.impl;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.service.ImageGalleryService;
import org.genesys.server.api.v2.facade.ImageGalleryApiService;
import org.genesys.server.api.v2.mapper.MapstructMapper;
import org.genesys.server.api.v2.model.impl.ImageGalleryDTO;
import org.genesys.server.api.v2.model.impl.RepositoryFolderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.nio.file.Path;
import java.util.List;
@Service
@Transactional(readOnly = true)
public class ImageGalleryApiServiceImpl implements ImageGalleryApiService {
@Autowired
private ImageGalleryService service;
@Autowired
private MapstructMapper mapper;
@Override
public ImageGalleryDTO loadImageGallery(Path path) throws InvalidRepositoryPathException {
return mapper.map(service.loadImageGallery(path));
}
@Override
public List<ImageGalleryDTO> loadImageGalleries(List<Path> paths) throws InvalidRepositoryPathException {
return mapper.map(service.loadImageGalleries(paths), mapper::map);
}
@Override
public ImageGalleryDTO getImageGallery(RepositoryFolderDTO folder) throws InvalidRepositoryPathException {
return mapper.map(service.getImageGallery(mapper.map(folder)));
}
@Override
@Transactional
public ImageGalleryDTO createImageGallery(Path path, String title, String description) throws InvalidRepositoryPathException {
return mapper.map(service.createImageGallery(path, title, description));
}
@Override
@Transactional
public ImageGalleryDTO removeGallery(ImageGalleryDTO dto) throws InvalidRepositoryPathException {
return mapper.map(service.removeGallery(mapper.map(dto)));
}
@Override
@Transactional
public ImageGalleryDTO updateImageGalery(ImageGalleryDTO dto, String title, String description) {
return mapper.map(service.updateImageGalery(mapper.map(dto), title, description));
}
@Override
@Transactional
public ImageGalleryDTO saveImageOrder(ImageGalleryDTO dto) {
return mapper.map(service.saveImageOrder(mapper.map(dto)));
}
@Override
@Transactional
public void ensureThumbnails(ImageGalleryDTO dto) {
service.ensureThumbnails(mapper.map(dto));
}
@Override
public Page<ImageGalleryDTO> listImageGalleries(Pageable pageable) {
return mapper.map(service.listImageGalleries(pageable), mapper::map);
}
@Override
public Page<ImageGalleryDTO> listImageGalleries(Path root, Pageable pageable) throws InvalidRepositoryPathException {
return mapper.map(service.listImageGalleries(root, pageable), mapper::map);
}
}