Commit 39629551 authored by Matija Obreza's avatar Matija Obreza

Upgrade to file-repository:1.1-SNAPSHOT

- Folders support
- Spring Security: Anons have ROLE_EVERYONE
- ACL editor updated
- Admin file repository controller updated
parent 5db86ed8
......@@ -58,7 +58,7 @@
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<junit.version>4.12</junit.version>
<application.blocks.version>1.4</application.blocks.version>
<application.blocks.version>1.5-SNAPSHOT</application.blocks.version>
<commons.beanutils.version>1.9.2</commons.beanutils.version>
<commons.collections.version>3.2.1</commons.collections.version>
<commons.io.version>2.4</commons.io.version>
......@@ -494,7 +494,7 @@
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>file-repository-ftpserver</artifactId>
<version>1.0</version>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
......
/*
* Copyright 2018 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.catalog.api.v0;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.security.service.CustomAclService;
import org.genesys.catalog.exceptions.InvalidApiUsageException;
import org.genesys.catalog.exceptions.NotFoundElement;
import org.genesys.filerepository.InvalidRepositoryFileDataException;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.NoSuchRepositoryFileException;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.service.RepositoryService;
import org.genesys2.server.api.ApiBaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
/**
* The Class RepositoryController.
*
* @author Matija Obreza
*/
@RestController("repositoryApi0")
@RequestMapping(RepositoryController.CONTROLLER_URL)
@PreAuthorize("isAuthenticated()")
@Api(tags = { "repository" })
public class RepositoryController {
/** The Constant API_BASE. */
protected static final String CONTROLLER_URL = ApiBaseController.APIv0_BASE + "/repository";
private static final Logger LOG = LoggerFactory.getLogger(RepositoryController.class);
private final ObjectMapper objectMapper = new ObjectMapper();
/** The repository service. */
@Autowired
protected RepositoryService repositoryService;
@Autowired
private CustomAclService aclService;
/**
* Adds the file.
*
* @param inputFile the input file
* @param metadataJson the metadata json
* @return the repository file
* @throws NotFoundElement the not found element
* @throws InvalidRepositoryFileDataException the invalid repository file data
* exception
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@PostMapping(value = "/add")
@Transactional
public RepositoryFile addFile(@RequestParam("file") final MultipartFile inputFile, @RequestParam("metadata") final String metadataJson) throws NotFoundElement,
InvalidRepositoryFileDataException, InvalidRepositoryPathException, IOException {
final RepositoryFile metadata = objectMapper.readValue(metadataJson, RepositoryFile.class);
final String fileName = StringUtils.defaultString(metadata.getOriginalFilename(), inputFile.getOriginalFilename());
LOG.info("Uploading {} to repository", fileName);
final RepositoryFile repositoryFile = repositoryService.addFile(metadata.getPath(), fileName, inputFile.getContentType(), inputFile.getBytes(), metadata);
// Automatically public if in /content/ folder
if (metadata.getPath().startsWith("/content/")) {
aclService.makePubliclyReadable(repositoryFile, true);
}
return repositoryFile;
}
/**
* Gets the file.
*
* @param fileUuid the file uuid
* @return the file
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@GetMapping(value = "/{fileUuid}")
public RepositoryFile getFile(@PathVariable("fileUuid") final UUID fileUuid) throws NoSuchRepositoryFileException, IOException {
return repositoryService.getFile(fileUuid);
}
/**
* Update file.
*
* @param fileUuid the file uuid
* @param version the version
* @param metadata the metadata
* @return the repository file
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@PostMapping(value = "/{fileUuid},{version}")
public RepositoryFile updateFile(@PathVariable("fileUuid") final UUID fileUuid, @PathVariable("version") final int version, final RepositoryFile metadata)
throws NoSuchRepositoryFileException, IOException {
if (metadata != null && metadata.getUuid().equals(fileUuid) && metadata.getVersion().equals(version)) {
return repositoryService.updateMetadata(repositoryService.getFile(fileUuid, version));
} else {
throw new InvalidApiUsageException("File uuid and version don't match");
}
}
/**
* Removes the file.
*
* @param fileUuid the file uuid
* @return the repository file
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@DeleteMapping(value = "/{fileUuid}")
public RepositoryFile removeFile(@PathVariable("fileUuid") final UUID fileUuid) throws NoSuchRepositoryFileException, IOException {
return repositoryService.removeFile(repositoryService.getFile(fileUuid));
}
/**
* Download file.
*
* @param fileUuid the file uuid
* @param response the response
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@GetMapping(value = "/download/{fileUuid}")
public void downloadFile(@PathVariable("fileUuid") final UUID fileUuid, final HttpServletResponse response) throws NoSuchRepositoryFileException, IOException {
final RepositoryFile repositoryFile = repositoryService.getFile(fileUuid);
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=86400, s-maxage=86400, public, no-transform");
response.setHeader(HttpHeaders.PRAGMA, "");
response.setDateHeader(HttpHeaders.LAST_MODIFIED, repositoryFile.getLastModifiedDate().getTime());
response.setContentType(repositoryFile.getContentType());
response.addHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", repositoryFile.getOriginalFilename()));
final byte[] data = repositoryService.getFileBytes(repositoryFile);
if (data != null) {
response.setContentLength(data.length);
response.getOutputStream().write(data);
}
response.flushBuffer();
}
}
......@@ -343,7 +343,7 @@ public class DatasetServiceImpl implements DatasetService {
InvalidRepositoryFileDataException {
dataset = datasetRepository.findByUuidAndVersion(dataset.getUuid(), dataset.getVersion());
final RepositoryFile repositoryFile = repositoryService.addFile(Paths.get(datasetRepositoryPath, dataset.getUuid().toString()).toAbsolutePath().toString(), file
final RepositoryFile repositoryFile = repositoryService.addFile(Paths.get(datasetRepositoryPath, dataset.getUuid().toString()).toAbsolutePath(), file
.getOriginalFilename(), file.getContentType(), file.getBytes(), null);
dataset.getRepositoryFiles().add(repositoryFile);
return lazyLoad(datasetRepository.save(dataset));
......
/*
* Copyright 2017 Global Crop Diversity Trust
* Copyright 2018 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.
......@@ -12,7 +12,7 @@
* 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.genesys2.server.aspect;
......@@ -36,31 +36,50 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
// TODO: Auto-generated Javadoc
/**
* The Class GenesysImageGalleryAspects.
*/
@Aspect
public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects implements InitializingBean {
/** The Constant LOG. */
public static final Logger LOG = LoggerFactory.getLogger(GenesysImageGalleryAspects.class);
/** The Constant ACCESSION_IMAGE_PATTERN. */
private static final Pattern ACCESSION_IMAGE_PATTERN = Pattern.compile(InstituteFilesService.REPOSITORY_INSTITUTE_PREFIX + "([A-Z]{3}\\d+)"
+ InstituteFilesService.REPOSITORY_INSTITUTE_ACCESSIONFILES + "/(.+)");
/** The image gallery aspect. */
private ImageGalleryAspectsImpl imageGalleryAspect = new ImageGalleryAspectsImpl();
/** The institute files service. */
@Autowired
private InstituteFilesService instituteFilesService;
/** The image gallery service. */
@Autowired
private ImageGalleryService imageGalleryService;
/**
* Instantiates a new genesys image gallery aspects.
*/
public GenesysImageGalleryAspects() {
LOG.warn("Instantiating {}", getClass().getName());
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
LOG.warn("Instantiating bean {}", getClass().getName());
imageGalleryAspect.setImageGalleryService(imageGalleryService);
}
/* (non-Javadoc)
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#afterRepositoryImageSaveIterable(org.aspectj.lang.JoinPoint, java.lang.Iterable)
*/
@Override
public Object afterRepositoryImageSaveIterable(JoinPoint joinPoint, Iterable<RepositoryImage> repositoryImages) throws Throwable {
if (repositoryImages != null) {
......@@ -72,6 +91,9 @@ public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects impl
return super.afterRepositoryImageSaveIterable(joinPoint, repositoryImages);
}
/* (non-Javadoc)
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#afterRepositoryImageSave(org.aspectj.lang.JoinPoint, org.genesys.filerepository.model.RepositoryImage)
*/
@Override
@AfterReturning(value = "execution(* org.genesys.filerepository.persistence.RepositoryImagePersistence.save(*))", returning = "repositoryImage")
public Object afterRepositoryImageSave(JoinPoint joinPoint, RepositoryImage repositoryImage) throws Throwable {
......@@ -79,6 +101,9 @@ public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects impl
return super.afterRepositoryImageSave(joinPoint, repositoryImage);
}
/* (non-Javadoc)
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#aroundRepositoryImageDelete(org.aspectj.lang.ProceedingJoinPoint, org.genesys.filerepository.model.RepositoryImage)
*/
@Override
@Around(value = "execution(* org.genesys.filerepository.persistence.RepositoryImagePersistence.delete(*)) && args(repositoryImage)")
public Object aroundRepositoryImageDelete(ProceedingJoinPoint joinPoint, RepositoryImage repositoryImage) throws Throwable {
......@@ -86,28 +111,34 @@ public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects impl
}
/**
* Ensures that an {@link ImageGallery} exists for accession images
*
* @param repositoryImage
* Ensures that an {@link ImageGallery} exists for accession images.
*
* @param repositoryImage the repository image
*/
private void ensureImageGallery(RepositoryImage repositoryImage) {
LOG.trace(repositoryImage.getPath());
Matcher matcher = ACCESSION_IMAGE_PATTERN.matcher(repositoryImage.getPath());
LOG.trace(repositoryImage.getOriginalFilename());
Matcher matcher = ACCESSION_IMAGE_PATTERN.matcher(repositoryImage.getFolder().getPath());
if (matcher.matches()) {
LOG.debug("Path {} is within institute accession images prefix instCode={} acceNumb={}", repositoryImage.getPath(), matcher.group(1), matcher.group(2));
LOG.debug("Path {} is within institute accession images prefix instCode={} acceNumb={}", repositoryImage.getFolder().getPath(), matcher.group(1), matcher.group(2));
try {
instituteFilesService.createImageGallery(matcher.group(1), matcher.group(2));
} catch (InvalidRepositoryPathException e) {
LOG.warn("Error creating accession image gallery at {}, error is {}", repositoryImage.getPath(), e.getMessage());
LOG.warn("Error creating accession image gallery at {}, error is {}", repositoryImage.getFolder().getPath(), e.getMessage());
}
}
}
/* (non-Javadoc)
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#addImageToGallery(org.genesys.filerepository.model.RepositoryImage)
*/
@Override
protected void addImageToGallery(RepositoryImage repositoryImage) {
imageGalleryAspect.addImageToGallery(repositoryImage);
}
/* (non-Javadoc)
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#removeImageFromGallery(org.genesys.filerepository.model.RepositoryImage)
*/
@Override
protected void removeImageFromGallery(RepositoryImage repositoryImage) {
imageGalleryAspect.removeImageFromGallery(repositoryImage);
......
......@@ -17,17 +17,19 @@
package org.genesys2.server.mvc;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.genesys.filerepository.NoSuchRepositoryFileException;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.service.BytesStorageService;
import org.genesys.filerepository.service.ImageGalleryService;
import org.genesys.filerepository.service.RepositoryService;
import org.genesys2.spring.ResourceNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -59,7 +61,7 @@ public class RepositoryDownloadController extends BaseController {
LOG.debug("_thumb path={} filename={}", path, filename);
}
data = this.byteStorageService.get(path, filename);
data = this.byteStorageService.get(Paths.get(path, filename));
response.setContentType("image/png");
} else {
......@@ -67,9 +69,9 @@ public class RepositoryDownloadController extends BaseController {
try {
final RepositoryFile repositoryFile = this.repositoryService.getFile(UUID.fromString(uuid));
sanityCheck(path, ext, repositoryFile);
sanityCheck(Paths.get(path), ext, repositoryFile);
data = this.repositoryService.getFileBytes(repositoryFile.getStoragePath(), repositoryFile.getFilename());
data = this.repositoryService.getFileBytes(repositoryFile.storagePath());
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=86400, s-maxage=86400, public, no-transform");
response.setHeader(HttpHeaders.PRAGMA, "");
......@@ -93,7 +95,7 @@ public class RepositoryDownloadController extends BaseController {
response.flushBuffer();
}
private void sanityCheck(final String path, final String ext, final RepositoryFile repositoryFile) {
private void sanityCheck(final Path path, final String ext, final RepositoryFile repositoryFile) {
if (repositoryFile == null) {
throw new ResourceNotFoundException("No such thing");
}
......@@ -153,7 +155,7 @@ public class RepositoryDownloadController extends BaseController {
final RepositoryFile repositoryFile = this.repositoryService.getFile(UUID.fromString(uuid));
sanityCheck(path, ext, repositoryFile);
sanityCheck(Paths.get(path), ext, repositoryFile);
return repositoryFile;
}
......
/**
* Copyright 2016 Global Crop Diversity Trust
/*
* Copyright 2018 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.
......@@ -12,12 +12,14 @@
* 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.genesys2.server.mvc.admin;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
......@@ -29,6 +31,7 @@ import org.genesys.filerepository.InvalidRepositoryFileDataException;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.NoSuchRepositoryFileException;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.model.RepositoryFolder;
import org.genesys.filerepository.service.ImageGalleryService;
import org.genesys.filerepository.service.RepositoryService;
import org.genesys2.server.mvc.BaseController;
......@@ -36,7 +39,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.data.domain.PageRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
......@@ -51,20 +53,40 @@ import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.util.UriUtils;
/**
* The Class RepositoryController.
*/
@Controller("adminRepositoryController")
@RequestMapping(RepositoryController.CONTROLLER_PATH)
@PreAuthorize("hasRole('ADMINISTRATOR')")
public class RepositoryController extends BaseController {
/** The Constant CONTROLLER_PATH. */
public static final String CONTROLLER_PATH = "/admin/r";
/** The Constant JSP_PATH. */
public static final String JSP_PATH = "/admin/repository";
/** The Constant LOG. */
public static final Logger LOG = LoggerFactory.getLogger(RepositoryController.class);
/** The repository service. */
@Autowired
private RepositoryService repositoryService;
/** The image gallery service. */
@Autowired
private ImageGalleryService imageGalleryService;
/**
* List all files.
*
* @param request the request
* @param model the model
* @return the string
* @throws UnsupportedEncodingException the unsupported encoding exception
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
@RequestMapping(value = "/files/**", method = RequestMethod.GET)
public String listAllFiles(HttpServletRequest request, ModelMap model) throws UnsupportedEncodingException, InvalidRepositoryPathException {
String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
......@@ -76,22 +98,42 @@ public class RepositoryController extends BaseController {
return listAllFiles(fullpath, model);
}
/**
* List all files.
*
* @param repositoryPath the repository path
* @param model the model
* @return the string
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
@RequestMapping(value = "/files", method = RequestMethod.GET)
public String listAllFiles(@RequestParam(defaultValue = "/") String repositoryPath, ModelMap model) throws InvalidRepositoryPathException {
Path path = Paths.get(repositoryPath);
if (LOG.isDebugEnabled()) {
LOG.debug("Listing files for path={}", repositoryPath);
LOG.debug("Listing files for path={}", path);
}
List<RepositoryFile> fileList = repositoryService.getFiles(repositoryPath);
RepositoryFolder currentFolder = repositoryService.getFolder(path);
List<RepositoryFile> fileList = repositoryService.getFiles(path);
model.addAttribute("fileList", fileList);
model.addAttribute("currentPath", repositoryPath);
model.addAttribute("subPaths", repositoryService.listPaths(repositoryPath, new PageRequest(0, 10)));
model.addAttribute("currentPath", path);
model.addAttribute("currentFolder", currentFolder);
model.addAttribute("subPaths", repositoryService.getFolders(path));
model.addAttribute("imageGallery", imageGalleryService.loadImageGallery(repositoryPath));
model.addAttribute("imageGallery", imageGalleryService.loadImageGallery(path));
return JSP_PATH + "/index";
}
/**
* Gets the edits the page.
*
* @param uuid the uuid
* @param model the model
* @return the edits the page
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String getEditPage(@RequestParam String uuid, ModelMap model) throws NoSuchRepositoryFileException {
RepositoryFile file = repositoryService.getFile(UUID.fromString(uuid));
......@@ -100,15 +142,24 @@ public class RepositoryController extends BaseController {
return JSP_PATH + "/edit";
}
/**
* Upload file.
*
* @param file the file
* @param repositoryPath the repository path
* @param redirectAttributes the redirect attributes
* @return the string
* @throws IOException Signals that an I/O exception has occurred.
*/
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public String uploadFile(@RequestParam MultipartFile file, @RequestParam String repositoryPath, RedirectAttributes redirectAttributes) throws IOException {
String mimeType = file.getContentType();
try {
if (mimeType.startsWith("image")) {
repositoryService.addImage(repositoryPath, file.getOriginalFilename(), file.getContentType(), file.getBytes(), null);
repositoryService.addImage(Paths.get(repositoryPath), file.getOriginalFilename(), file.getContentType(), file.getBytes(), null);
} else {
repositoryService.addFile(repositoryPath, file.getOriginalFilename(), file.getContentType(), file.getBytes(), null);
repositoryService.addFile(Paths.get(repositoryPath), file.getOriginalFilename(), file.getContentType(), file.getBytes(), null);
}
} catch (InvalidRepositoryPathException e) {
LOG.error("Invalid repository path!", e);
......@@ -119,25 +170,48 @@ public class RepositoryController extends BaseController {
redirectAttributes.addFlashAttribute("errorMessage", "Invalid file data!");
}
return "redirect:" + CONTROLLER_PATH + "/files" + repositoryPath;
return "redirect:" + CONTROLLER_PATH + "/files" + Paths.get(repositoryPath);
}
/**
* Update metadata.
*
* @param fileData the file data
* @param uuid the uuid
* @param redirectAttributes the redirect attributes
* @return the string
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String updateMetadata(@ModelAttribute RepositoryFile fileData, @RequestParam String uuid, RedirectAttributes redirectAttributes)
throws NoSuchRepositoryFileException {
RepositoryFile updatedFile = repositoryService.updateMetadata(fileData);
return "redirect:" + CONTROLLER_PATH + "/files" + updatedFile.getPath();
return "redirect:" + CONTROLLER_PATH + "/files" + updatedFile.getFolder().getPath();
}
/**
* Delete file.
*
* @param uuid the uuid
* @param redirectAttributes the redirect attributes
* @return the string
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public String deleteFile(@RequestParam String uuid, RedirectAttributes redirectAttributes) throws NoSuchRepositoryFileException, IOException {
RepositoryFile repositoryFile = repositoryService.getFile(UUID.fromString(uuid));
repositoryService.removeFile(repositoryFile);
return "redirect:" + CONTROLLER_PATH + "/files" + repositoryFile.getPath();
return "redirect:" + CONTROLLER_PATH + "/files" + repositoryFile.getFolder().getPath();
}
/**
* Inits the binder.
*
* @param binder the binder
*/
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......
......@@ -16,6 +16,8 @@
package org.genesys2.server.mvc.admin;
import java.nio.file.Paths;
import javax.servlet.http.HttpServletRequest;
import org.genesys.filerepository.InvalidRepositoryPathException;
......@@ -70,7 +72,7 @@ public class RepositoryGalleryController extends BaseController {
String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
fullpath = fullpath.substring(CONTROLLER_PATH.length());
ImageGallery imageGallery = imageGalleryService.loadImageGallery(fullpath);
ImageGallery imageGallery = imageGalleryService.loadImageGallery(Paths.get(fullpath));