Commit f4f3b68e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when procesing file content return 400 if content is too big

parent ca4c11e0
......@@ -9,8 +9,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.api.ObjectNotFoundException;
import lcsb.mapviewer.api.*;
import lcsb.mapviewer.services.interfaces.IUserService;
@RestController
......@@ -43,7 +42,7 @@ public class FileController extends BaseController {
@PreAuthorize("@fileService.getOwnerByFileId(#id)?.login == authentication.name")
@PostMapping(value = "/{id}:uploadContent")
public Map<String, Object> uploadContent(@PathVariable(value = "id") Integer id, @RequestBody byte[] data)
throws ObjectNotFoundException {
throws QueryException {
return fileRest.uploadContent(id, data);
}
......
......@@ -4,13 +4,11 @@ import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.lang3.ArrayUtils;
import org.hibernate.QueryException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.api.ObjectNotFoundException;
import lcsb.mapviewer.api.*;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.user.User;
......@@ -63,7 +61,7 @@ public class FileRestImpl extends BaseRestImpl {
return result;
}
public Map<String, Object> uploadContent(Integer id, byte[] data) throws ObjectNotFoundException {
public Map<String, Object> uploadContent(Integer id, byte[] data) throws QueryException {
int fileId = Integer.valueOf(id);
UploadedFileEntry fileEntry = uploadedFileEntryDao.getById(fileId);
if (fileEntry == null) {
......
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