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; } }
public bool sendSynchUnShareRequest(UnShareFileWithUser request, OOBHandler handler, Group group, bool waitToFinish = true) { try { Logger.Debug("File Operations Synch - sendSynchUnShareRequest >> BEGIN"); bool operationResult = false; if (waitToFinish) { string transactionId = FileServerComm.getInstance().transManager.generateTransactionId(request.filename); Transaction trans = new Transaction(transactionId); if (true == FileServerComm.getInstance().transManager.insertTransaction(trans)) { SyncUnSharedUser sync = new SyncUnSharedUser(transactionId, IsisSystem.GetMyAddress(), request.clientId, request.password, request.filename, request.sharedWithUser); group.OrderedSend(FileServerComm.UnshareWithUser, sync); trans.waitTillSignalled(); FileServerComm.getInstance().transManager.removeAndGetTransaction(transactionId); operationResult = !trans.isTimedOut; } else { Logger.Debug("File Operations Synch - sendsynchdeleteFile >> Generation of Transaction ID Failed: " + transactionId); } } else { SyncUnSharedUser sync = new SyncUnSharedUser("", IsisSystem.GetMyAddress(), request.clientId, request.password, request.filename, request.sharedWithUser); group.OrderedSend(FileServerComm.UnshareWithUser, sync); operationResult = true; } Logger.Debug("File Operations Synch - sendsynchdeleteFileFromMemory >> END Operation Status " + operationResult); return(operationResult); } catch (Exception e) { Logger.Debug("File Operations Synch - sendSynchUnShareRequest Encountered a Exeption: " + e.ToString()); return(false); } }