@Transactional(readOnly = false) public Object doWork(Session session, ServiceFactory sf) { return addOrReplace(session, getSqlAction(), sf, repoFile, old); } });
continue; } else { ofile = addOrReplace(session, sqlAction, sf, file, null); continue; } else { ofile = addOrReplace(session, sqlAction, sf, file, id);
public Long call() throws Exception { EventContext ec = factory.getEventContext(); if ( ! ec.isCurrentUserAdmin() ) { throw new omero.SecurityViolation(null, null, "User is not an administrator"); } try { // ticket:2356 - should only overwrite non-scripts Long scriptID = scripts.findInDb(path, true); Long fileID = scripts.findInDb(path, false); if (scriptID != null) { throw new ApiUsageException(null, null, "Path already exists: " + path + "\n" + "Use editScript to modify existing official scripts."); } else if (fileID != null) { log.info("Overwriting existing non-script: " + fileID); cache.removeParams(fileID); } RepoFile f = scripts.write(path, scriptText); OriginalFile file = scripts.addOrReplace(f, fileID); if (!scripts.isInert(file)) { validateParams(__current, file); } return file.getId(); } catch (IOException e) { omero.ServerError se = new omero.InternalException(null, null, "Cannot write " + path); IceMapper.fillServerError(se, e); throw se; } } });