Esempio n. 1
0
        public void Post(DeleteFile request)
        {
            logger.Info("****Request received for deleting file : " + request.filepath + " owned by user : "******"Authentication failed");
                }

                FileMetaData metadata = filesystem.getFileMetaDataCloneSynchronized(request.clientId, request.password, request.filepath);

                FileServerComm serverComm     = FileServerComm.getInstance();
                Address []     memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

                List <Address> where = new List <Address> ();
                where.AddRange(memberAdresses);

                if (true == serverComm.getFileHandler().sendsynchdeleteFile(metadata, serverComm.getOOBHandler(),
                                                                            serverComm.getFileServerGroup()))
                {
                    bool delete = filesystem.deleteFileSynchronized(request.clientId, request.filepath);

                    if (!delete)
                    {
                        logger.Debug("The file : " + request.filepath + " was already marked for deletion, skipping");
                    }
                }
            } catch (Exception e) {
                logger.Warn(e);
                throw e;
            }
        }
Esempio n. 2
0
        public void Post(UnShareFileWithUser request)
        {
            logger.Info("****Request received for un-sharing file owned by user : "******" by user : "******" for file name : " + request.filename
                        );
            if (!filesystem.AuthenticateUser(request.clientId, request.password))
            {
                throw new AuthenticationException("Authentication failed");
            }

            FileServerComm serverComm = FileServerComm.getInstance();

            Address [] memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

            List <Address> where = new List <Address> ();
            where.AddRange(memberAdresses);

            try {
                if (true == serverComm.getFileHandler().sendSynchUnShareRequest(request, serverComm.getOOBHandler(),
                                                                                serverComm.getFileServerGroup()))
                {
                    filesystem.unShareFileWithUser(request.clientId, request.filename, request.sharedWithUser);
                }
                else
                {
                    throw new Exception("Internal Server Error");
                }
            } catch (Exception e) {
                logger.Warn(e);
                throw e;
            }
        }
Esempio n. 3
0
        public void Post(AddUser request)
        {
            logger.Info("****Request received for adding user with client id :" + request.clientId
                        + " and password : "******"User is already present in inmemory map, throwing back exception");
                        throw new Exception("User is already present in memory");
                    }
                    else
                    {
                        logger.Debug("User added succesfully");
                    }
                } catch (Exception e) {
                    logger.Debug(e);
                    throw e;
                }
            }
            else
            {
                throw new Exception("User Add Exception");
            }
        }
Esempio n. 4
0
        public void Post(UpdateFile request)
        {
            logger.Info("****Request received for updating user file for client id  : " + request.clientId
                        + " and file name : " + request.file.filemetadata.filepath
                        );

            if (!filesystem.AuthenticateUser(request.clientId, request.password))
            {
                throw new AuthenticationException("Authentication failed");
            }

            // Send the File to the All other Nodes in a Ordered Way
            FileServerComm serverComm = FileServerComm.getInstance();

            Address [] memberAdresses = serverComm.getFileServerGroup().getLiveMembers();

            List <Address> where = new List <Address>();
            where.AddRange(memberAdresses);

            if (true == serverComm.getFileHandler().sendsynchaddFileToMemory(request.clientId, request.file,
                                                                             serverComm.getOOBHandler(), serverComm.getFileServerGroup(),
                                                                             where))
            {
                try {
                    filesystem.addFileSynchronized(request.clientId, request.file);
                } catch (Exception e) {
                    logger.Debug("Exception occured while updating user file for client id  : " + request.clientId
                                 + " and file name : " + request.file.filemetadata.filepath, e);
                    throw e;
                }
            }
            else
            {
                throw new Exception("File Cannot be Added, Some Internal error");
            }
        }