@@ -0,0 +1,1462 @@
+package org.opentosca.csarrepo.service;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.util.Date;%0A%0Aimport org.opentosca.csarrepo.filesystem.FileSystem;%0Aimport org.opentosca.csarrepo.model.CsarFile;%0Aimport org.opentosca.csarrepo.model.repository.CsarFileRepository;%0A%0A/**%0A * @author eiselems (marcus.eisele@gmail.com)%0A *%0A */%0Apublic class UploadCsarService extends AbstractService %7B%0A%0A%09private long csarFileId;%0A%0A%09/**%0A%09 * @param userId%0A%09 * @param file%0A%09 */%0A%09public UploadCsarService(long userId, long csarID, FileInputStream fis) %7B%0A%09%09// FIXME: is csarID optional (has it to be nullable)%0A%09%09super(userId);%0A%0A%09%09storeFile(csarID, fis);%0A%0A%09%7D%0A%0A%09private void storeFile(Long csarID, FileInputStream fis) %7B%0A%09%09// TODO: if csarID is null create new Csar, otherwise add csarFile as%0A%09%09// new revision to csar%0A%09%09File file = null;%0A%09%09CsarFileRepository csarFileRepository = new CsarFileRepository();%0A%0A%09%09try %7B%0A%09%09%09FileSystem fs = new FileSystem();%0A%09%09%09file = fs.saveTempFile(fis);%0A%09%09%09String absPath = fs.saveToFileSystem(file);%0A%09%09%09CsarFile csarFile = new CsarFile();%0A%09%09%09csarFile.setHash(%2212345%22);%0A%09%09%09csarFile.setSize(file.length());%0A%09%09%09//TODO: set Date correctly%0A%09%09%09//check if file.lastModified() uses same long as Date(long)%0A%09%09%09csarFile.setUploadDate(new Date());%0A%09%09%09csarFile.setPath(absPath);%0A%09%09%09csarFileId = csarFileRepository.save(csarFile);%0A%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09this.addError(e.getMessage());%0A%09%09%7D%0A%09%7D%0A%0A%09public long getResult() %7B%0A%09%09return csarFileId;%0A%09%7D%0A%0A%7D%0A

add UploadCsarService refs #19