use of org.survey.model.file.File in project survey by markoniemi.
the class FileServiceTestBase method delete.
@Test
public void delete() {
create();
for (int i = 0; i < ENTITY_COUNT; i++) {
File entity = savedEntities.get(i);
entityService.delete(entity.getId());
Assert.assertFalse(entityService.exists(entity.getId()));
}
Assert.assertEquals(0, entityService.count());
}
use of org.survey.model.file.File in project survey by markoniemi.
the class FileServiceTestBase method exists.
@Test
public void exists() {
create();
for (int i = 0; i < ENTITY_COUNT; i++) {
File entity = savedEntities.get(i);
entityService.exists(entity.getId());
}
// TODO how to test if exists fails?
// Assert.assertFalse(entityRepository.exists((ID) new Object()));
}
use of org.survey.model.file.File in project survey by markoniemi.
the class FileController method createFile.
/**
* Create a File from Part.
*/
private File createFile(MultipartFile uploadedFile, String filename, byte[] fileContent) {
File file = new File();
file.setFilename(filename);
file.setMimeType(uploadedFile.getContentType());
file.setContent(fileContent);
file.setOwner(userService.findOne(SecurityUtil.getUsername()));
file.setCreateTime(System.currentTimeMillis());
// TODO change files rest to files/:user/:filename
file.setUrl("/survey-web/api/rest/files/");
return file;
}
use of org.survey.model.file.File in project survey by markoniemi.
the class FileController method downloadFile.
@RequestMapping(value = "/file/{id}", method = RequestMethod.GET)
public void downloadFile(@PathVariable Long id, HttpServletResponse response) {
File file = fileService.findOne(id);
writeFileToResponse(response, file);
}
use of org.survey.model.file.File in project survey by markoniemi.
the class FileController method newFile.
@RequestMapping(value = "/file/new", method = RequestMethod.GET)
public ModelAndView newFile() {
File file = new File();
ModelAndView model = new ModelAndView();
model.setViewName("/file/file");
model.addObject("file", file);
return model;
}
Aggregations