/** * Make the file, this is a temporary file which will be changed when the * script is validated. * * @param script * script. * @return OriginalFile tempfile.. * @throws ServerError */ private OriginalFile makeFile(final String path, final String script, Ice.Current current) throws ServerError { OriginalFile file = new OriginalFile(); file.setName(FilenameUtils.getName(path)); file.setPath(FilenameUtils.getFullPath(path)); file.setSize((long) script.getBytes().length); file.setHasher(new ChecksumAlgorithm("SHA1-160")); file.setHash(cpf.getProvider(ChecksumType.SHA1) .putBytes(script.getBytes()).checksumAsString()); scripts.setMimetype(file); return updateFile(file, current); }
private OriginalFile update(Session session, final RepoFile repoFile, SqlAction sqlAction, ServiceFactory sf, OriginalFile ofile) { ExperimenterGroup group = loadUserGroup(session); ChecksumAlgorithm hasher = loadChecksum(session, repoFile.hasher().getValue()); ofile.setPath(repoFile.dirname()); ofile.setName(fileRepoSecretKey + repoFile.basename()); ofile.setRepo(uuid); ofile.setHasher(hasher); ofile.setHash(repoFile.hash()); ofile.setSize(repoFile.length()); ofile.getDetails().setGroup(group); setMimetype(ofile); ofile = sf.getUpdateService().saveAndReturnObject(ofile); final String name = ofile.getName(); if (name.startsWith(fileRepoSecretKey)) { ofile.setName(name.substring(fileRepoSecretKey.length())); } return ofile; }
scripts.setMimetype(file); file = updateFile(file, __current);