@Override
    public void updateFile(String clientname, String file, byte[] data) throws RemoteException {


        try {
            DbWrapper db = DbWrapper.getInstance();
            FileEntityDescription fd = db.loadFileEntity(file);
            if (fd.privateFile) {
                //private file
                if (clientname.compareTo(fd.ownerName) != 0) {
                    //user different from owner
                    throw new RemoteException("You are not allowed to update this file, since it is private and you are not the owner");
                }
            } else {
                if ((!fd.writepermission) && clientname.compareTo(fd.ownerName) != 0) {
                    throw new RemoteException("You are not allowed to update this file, since it is public but you don't have write permission on it");
                }
            }

            db.editFileLastModified(file);
            db.editFileSize(file, data.length);

            String path = db.getFileLocation(file);
            FileOutputStream out = new FileOutputStream(path);
            out.write(data);
            out.close();

        } catch (SQLException | IOException ex) {
            throw new RemoteException(ex.getMessage());
        }

    }