Commit 2bd37ed2 authored by Matija Obreza's avatar Matija Obreza
Browse files

Galleries REST API working

parent 2dd7d8e0
......@@ -24,6 +24,7 @@ import org.genesys2.server.filerepository.NoSuchRepositoryFileException;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys2.server.filerepository.service.ImageGalleryService;
import org.genesys2.server.servlet.controller.BaseController;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -70,6 +71,10 @@ public class RepositoryGalleryController extends BaseController {
ImageGallery imageGallery = imageGalleryService.loadImageGallery(fullpath);
if (imageGallery == null) {
throw new ResourceNotFoundException("No image gallery here!");
}
imageGalleryService.ensureThumbnails(imageGallery, 200, 200);
model.addAttribute("thumbnailFormat", "200x200");
model.addAttribute("imageGallery", imageGallery);
......
......@@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
......@@ -236,13 +237,14 @@ public class InstituteGalleriesController extends RestController {
* @throws InvalidRepositoryFileDataException
* @throws InvalidRepositoryPathException
*/
@RequestMapping(value = "/{instCode}/acn/{acceNumb:.+}/{originalFilename:.+}", method = { RequestMethod.PUT, RequestMethod.POST }, consumes = { "image/*" })
@RequestMapping(value = "/{instCode}/acn/{acceNumb:.+}/", method = { RequestMethod.PUT, RequestMethod.POST }, consumes = { "image/*" }, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody RepositoryImage addImage(final HttpServletRequest request, final HttpServletResponse response,
@PathVariable("instCode") final String instCode, @PathVariable("acceNumb") final String acceNumb,
@PathVariable("originalFilename") String originalFilename, HttpEntity<byte[]> requestEntity) throws IOException, NonUniqueAccessionException,
InvalidRepositoryPathException, InvalidRepositoryFileDataException {
@RequestParam(name = "originalFilename", required = true) String originalFilename, HttpEntity<byte[]> requestEntity) throws IOException,
NonUniqueAccessionException, InvalidRepositoryPathException, InvalidRepositoryFileDataException {
// FIXME Could not find acceptable representation
// originalFilename could not be part of the path (and @PathVariable)
// because the wrong content-negotiating strategy kicked in.
final FaoInstitute institute = this.instituteService.findInstitute(instCode);
final Accession accession = this.genesysService.getAccession(instCode, acceNumb);
......@@ -259,12 +261,8 @@ public class InstituteGalleriesController extends RestController {
imageGallery = this.instituteFilesService.createImageGallery(institute, accession);
}
RepositoryImage x = instituteFilesService.addImage(institute, accession, originalFilename, requestEntity.getHeaders().getContentType().toString(),
return instituteFilesService.addImage(institute, accession, originalFilename, requestEntity.getHeaders().getContentType().toString(),
requestEntity.getBody());
LOG.debug("Updated image=" + x);
return x;
}
}
......@@ -164,6 +164,8 @@ h1.page-title {
}
#content-body-content {
padding-bottom: 30px;
.informative-h1 {
font-size: small;
font-weight: normal;
......@@ -175,6 +177,7 @@ h1.page-title {
font-weight: bold;
padding: 10px 0;
}
}
/** Absolutely first H1 in the content section */
......@@ -645,3 +648,9 @@ table.accessions {
span.idx-col {
display: inline-block;
}
.imagegallery-image-frame {
img {
width: 100%;
}
}
\ No newline at end of file
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