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

Method names refactored

parent b828a15a
......@@ -23,7 +23,6 @@ import org.genesys2.server.filerepository.InvalidRepositoryFileDataException;
import org.genesys2.server.filerepository.InvalidRepositoryPathException;
import org.genesys2.server.filerepository.NoSuchRepositoryFileException;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys2.server.filerepository.model.RepositoryFile;
import org.genesys2.server.filerepository.model.RepositoryImage;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.impl.FaoInstitute;
......@@ -39,7 +38,7 @@ public interface InstituteFilesService {
RepositoryImage getImage(FaoInstitute institute, Accession accession, UUID uuid) throws NoSuchRepositoryFileException;
RepositoryFile updateFile(FaoInstitute institute, Accession accession, RepositoryImage repositoryImage) throws NoSuchRepositoryFileException;
RepositoryImage updateImageMetadata(FaoInstitute institute, Accession accession, RepositoryImage repositoryImage) throws NoSuchRepositoryFileException;
byte[] getFileBytes(FaoInstitute institute, Accession accession, RepositoryImage repositoryImage) throws NoSuchRepositoryFileException;
......
......@@ -104,9 +104,9 @@ public class InstituteFilesServiceImpl implements InstituteFilesService {
@Override
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#institute, 'WRITE') or hasPermission(#institute, 'CREATE')")
public RepositoryFile updateFile(final FaoInstitute institute, final Accession accession, final RepositoryImage repositoryImage)
public RepositoryImage updateImageMetadata(final FaoInstitute institute, final Accession accession, final RepositoryImage repositoryImage)
throws NoSuchRepositoryFileException {
return this.repositoryService.updateFile(repositoryImage);
return this.repositoryService.updateMetadata(repositoryImage);
}
@Override
......
......@@ -127,7 +127,7 @@ public class RepositoryController extends BaseController {
redirectAttributes.addAttribute("uuid", updatedFile.getUuid().toString());
return "redirect:" + CONTROLLER_PATH + "/edit";
}
updatedFile = repositoryService.updateFile(updatedFile);
updatedFile = repositoryService.updateMetadata(updatedFile);
return "redirect:" + CONTROLLER_PATH + "/files" + updatedFile.getPath();
}
......
......@@ -30,7 +30,6 @@ import org.genesys2.server.filerepository.InvalidRepositoryFileDataException;
import org.genesys2.server.filerepository.InvalidRepositoryPathException;
import org.genesys2.server.filerepository.NoSuchRepositoryFileException;
import org.genesys2.server.filerepository.model.ImageGallery;
import org.genesys2.server.filerepository.model.RepositoryFile;
import org.genesys2.server.filerepository.model.RepositoryImage;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.impl.FaoInstitute;
......@@ -145,7 +144,7 @@ public class InstituteGalleriesController extends RestController {
throw new ResourceNotFoundException("No such thing");
}
return this.instituteFilesService.updateFile(institute, accession, repositoryImage);
return this.instituteFilesService.updateImageMetadata(institute, accession, repositoryImage);
} catch (final NoSuchRepositoryFileException e) {
LOG.warn("404 - No such repository file ", e);
......@@ -237,14 +236,14 @@ public class InstituteGalleriesController extends RestController {
* @throws InvalidRepositoryFileDataException
* @throws InvalidRepositoryPathException
*/
@RequestMapping(value = "/{instCode}/acn/{acceNumb:.+}/{originalFilename:.+}", method = { RequestMethod.PUT, RequestMethod.POST }, consumes = { "image/*" }, produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/{instCode}/acn/{acceNumb:.+}/{originalFilename:.+}", method = { RequestMethod.PUT, RequestMethod.POST }, consumes = { "image/*" })
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 {
// FIXME Could not find acceptable representation
final FaoInstitute institute = this.instituteService.findInstitute(instCode);
final Accession accession = this.genesysService.getAccession(instCode, acceNumb);
if (institute == null || accession == null) {
......@@ -260,8 +259,12 @@ public class InstituteGalleriesController extends RestController {
imageGallery = this.instituteFilesService.createImageGallery(institute, accession);
}
return instituteFilesService.addImage(institute, accession, originalFilename, requestEntity.getHeaders().getContentType().toString(),
RepositoryImage x = instituteFilesService.addImage(institute, accession, originalFilename, requestEntity.getHeaders().getContentType().toString(),
requestEntity.getBody());
LOG.debug("Updated image=" + x);
return x;
}
}
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