Commit cfc82777 authored by Matija Obreza's avatar Matija Obreza

Image galleries fixed, updates for new file-repository:1.1-SNAPSHOT

parent ace9c3a4
......@@ -56,7 +56,7 @@ public class AsAdminAspect {
if (prevAuth == null
// or is not admin
|| ! prevAuth.getAuthorities().contains(UserRole.ADMINISTRATOR.getAuthority())
|| ! prevAuth.getAuthorities().contains(UserRole.ADMINISTRATOR)
// or not already SYS_ADMIN
|| !prevAuth.getName().equals(adminAuthorization.getName())) {
......
......@@ -140,7 +140,7 @@ public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects impl
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#addImageToGallery(org.genesys.filerepository.model.RepositoryImage)
*/
@Override
protected void addImageToGallery(RepositoryImage repositoryImage) {
protected void addImageToGallery(RepositoryImage repositoryImage) throws InvalidRepositoryPathException {
imageGalleryAspect.addImageToGallery(repositoryImage);
}
......@@ -148,7 +148,7 @@ public class GenesysImageGalleryAspects extends AbstractImageGalleryAspects impl
* @see org.genesys.filerepository.service.aspect.AbstractImageGalleryAspects#removeImageFromGallery(org.genesys.filerepository.model.RepositoryImage)
*/
@Override
protected void removeImageFromGallery(RepositoryImage repositoryImage) {
protected void removeImageFromGallery(RepositoryImage repositoryImage) throws InvalidRepositoryPathException {
imageGalleryAspect.removeImageFromGallery(repositoryImage);
}
......
......@@ -71,7 +71,7 @@ public class RepositoryDownloadController extends BaseController {
sanityCheck(Paths.get(path), ext, repositoryFile);
data = this.repositoryService.getFileBytes(repositoryFile.storagePath());
data = this.repositoryService.getFileBytes(repositoryFile);
response.setHeader(HttpHeaders.CACHE_CONTROL, "max-age=86400, s-maxage=86400, public, no-transform");
response.setHeader(HttpHeaders.PRAGMA, "");
......
......@@ -652,12 +652,11 @@ public class WiewsController extends BaseController {
}
@GetMapping(value = "/{wiewsCode}/files/gallery/details")
public String viewInstituteGallery(ModelMap model, HttpServletRequest request, @PathVariable("wiewsCode") String wiewsCode, @RequestParam String galleryPath) {
public String viewInstituteGallery(ModelMap model, HttpServletRequest request, @PathVariable("wiewsCode") String wiewsCode, @RequestParam String galleryPath) throws InvalidRepositoryPathException {
// check user permissions
instituteService.getInstituteForEdit(wiewsCode);
final Path wiewsPath = Paths.get("/wiews/", wiewsCode);
ImageGallery imageGallery = imageGalleryService.loadImageGallery(wiewsPath.resolve(galleryPath));
ImageGallery imageGallery = imageGalleryService.loadImageGallery(Paths.get(galleryPath));
if (imageGallery == null) {
throw new ResourceNotFoundException("No image gallery here!");
......@@ -665,6 +664,7 @@ public class WiewsController extends BaseController {
imageGalleryService.ensureThumbnails(imageGallery, 200, 200);
model.addAttribute("thumbnailFormat", "200x200");
model.addAttribute("galleryPath", galleryPath);
model.addAttribute("imageGallery", imageGallery);
model.addAttribute("wiewsCode", wiewsCode);
......@@ -672,7 +672,7 @@ public class WiewsController extends BaseController {
}
@GetMapping(value = "/{wiewsCode}/files/gallery/edit")
public String editInstituteGallery(@RequestParam String galleryPath, @PathVariable("wiewsCode") String wiewsCode, ModelMap model) throws NoSuchRepositoryFileException {
public String editInstituteGallery(@RequestParam String galleryPath, @PathVariable("wiewsCode") String wiewsCode, ModelMap model) throws NoSuchRepositoryFileException, InvalidRepositoryPathException {
// check user permissions
instituteService.getInstituteForEdit(wiewsCode);
final Path wiewsPath = Paths.get("/wiews/", wiewsCode);
......@@ -682,6 +682,7 @@ public class WiewsController extends BaseController {
imageGallery = new ImageGallery();
imageGallery.setPath(galleryPath);
}
model.addAttribute("galleryPath", galleryPath);
model.addAttribute("imageGallery", imageGallery);
model.addAttribute("wiewsCode", wiewsCode);
......
......@@ -68,7 +68,7 @@ public class RepositoryGalleryController extends BaseController {
}
@RequestMapping(value = "/**", method = RequestMethod.GET)
public String listAllFiles(ModelMap model, HttpServletRequest request) {
public String listAllFiles(ModelMap model, HttpServletRequest request) throws InvalidRepositoryPathException {
String fullpath = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
fullpath = fullpath.substring(CONTROLLER_PATH.length());
......@@ -86,12 +86,13 @@ public class RepositoryGalleryController extends BaseController {
}
@RequestMapping(value = "/edit", method = RequestMethod.GET)
public String getEditPage(@RequestParam String galleryPath, ModelMap model) throws NoSuchRepositoryFileException {
public String getEditPage(@RequestParam String galleryPath, ModelMap model) throws NoSuchRepositoryFileException, InvalidRepositoryPathException {
ImageGallery imageGallery = imageGalleryService.loadImageGallery(Paths.get(galleryPath));
if (imageGallery == null) {
imageGallery = new ImageGallery();
imageGallery.setPath(galleryPath);
}
model.addAttribute("galleryPath", galleryPath);
model.addAttribute("imageGallery", imageGallery);
return JSP_PATH + "/edit";
......
......@@ -15,7 +15,10 @@
*/
package org.genesys2.spring.config;
import java.nio.file.Paths;
import org.genesys.blocks.security.service.CustomAclService;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.migration.RepositoryUpgrade20180920;
import org.genesys.filerepository.model.RepositoryFolder;
import org.genesys.filerepository.service.RepositoryService;
......@@ -80,15 +83,19 @@ public class ApplicationUpgrades implements InitializingBean {
LOG.warn("Updating permissions on public folders");
asAdminInvoker.invoke(() -> {
for (RepositoryFolder repositoryFolder : repositoryService.getFolders(null)) {
for (RepositoryFolder repositoryFolder : repositoryService.getFolders(Paths.get("/"))) {
LOG.warn("Making {} publicly readable", repositoryFolder.getPath());
aclService.addCreatorPermissions(repositoryFolder);
repositoryService.listPaths(repositoryFolder.getFolderPath()).forEach(subFolder -> {
aclService.addCreatorPermissions(subFolder);
repositoryService.getFiles(subFolder.getFolderPath()).forEach(file -> {
aclService.addCreatorPermissions(file);
});
try {
repositoryService.getFiles(subFolder.getFolderPath()).forEach(file -> {
aclService.addCreatorPermissions(file);
});
} catch (InvalidRepositoryPathException e) {
LOG.error("Error updating permissions: {}", e.getMessage());
}
});
}
......
......@@ -11,7 +11,7 @@
<c:out value="${imageGallery.description}" />
</div>
<a href="<c:url value="/admin/r/g" />" class="btn btn-default"><spring:message code="cancel" /></a>
<a href="<c:url value="/admin/r/files${imageGallery.path}" />" class="btn btn-default"><spring:message code="navigate.back" /></a>
<a href="<c:url value="/admin/r/files${imageGallery.path}/" />" class="btn btn-default"><spring:message code="navigate.back" /></a>
<div class="row" id="imagegallery-thumbs">
<c:forEach items="${imageGallery.images}" var="image">
......
......@@ -13,12 +13,12 @@
code="cancel" /></a>
<h4>
Updating metadata for image gallery
<c:out value="${imageGallery.path}" />
<c:out value="${galleryPath}" />
</h4>
<form action="<c:url value="/admin/r/g/update" />" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input type="hidden" name="galleryPath" value="<c:out value="${imageGallery.folder.path}" />">
<input type="hidden" name="galleryPath" value="<c:out value="${galleryPath}" />">
<div class="form-group">
<label for="title"><spring:message
......
......@@ -15,7 +15,7 @@
</div>
<div class="margin-top-20">
<a href="<c:url value="/wiews/${wiewsCode}/files/gallery" />" class="btn btn-default"><spring:message code="cancel"/></a>
<a href="<c:url value="/wiews/${wiewsCode}/files${gallerySubPath}" />" class="btn btn-default"><spring:message code="navigate.back"/></a>
<a href="<c:url value="/wiews/${wiewsCode}/files${galleryPath.substring(galleryPath.indexOf('/', 8))}/" />" class="btn btn-default"><spring:message code="navigate.back"/></a>
</div>
<div class="row" id="imagegallery-thumbs">
<c:forEach items="${imageGallery.images}" var="image">
......
......@@ -15,12 +15,12 @@
<h4>
Updating metadata for image gallery
<strong><c:out value="${imageGallery.path}" /></strong>
<strong><c:out value="${galleryPath}" /></strong>
</h4>
<form action="<c:url value="/wiews/${wiewsCode}/files/gallery/update" />" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input type="hidden" name="galleryPath" value="<c:out value="${imageGallery.folder.path}" />">
<input type="hidden" name="galleryPath" value="<c:out value="${galleryPath}" />">
<div class="row">
<div class="col-md-6 margin-top-20">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment