Package file

Examples of file.LocalFileOperation


  public void process(Message inMessage,ILog log) {

    String fileCommand = inMessage.getCommand();
    String fileContents = inMessage.getFileContents();
    String fileId = inMessage.getFileId();
    LocalFileOperation   oFileOperation = new LocalFileOperation ();
    int numFiles = 0;
    File localFile;
   
    try {
     
    if (fileCommand.equals("add"))
    {
      oFileOperation.add(fileId,fileContents,log);
    }
    else
      //Some other node is looking for a file
      //so we send a message directly back to them
      //with file contents
      if   (fileCommand.equals ("get"))
      {
        //try and get the local file
        try{
          Message responseMessage = new Message();
          Transmitter directTransmit = new Transmitter(2002);
         
          responseMessage.setCommand("add");
          responseMessage.setFileId(fileId);
          responseMessage.setFileContents(new File(fileId));
          //responseMessage.setSenderHostName(myAddress);
          directTransmit.send(responseMessage,inMessage.getSenderHostName(),log);
         
          System.out.println("Add Request Sent Direct to Node:"+ "to other nodes");
        } catch (FileNotFoundException fnfe){
          log.log("Did not have copy of file:"+fileId+" not responding to get request");
        }
       
       
       
      }
      else
        if   (fileCommand.equals ("remove"))
        {
          oFileOperation.remove(fileId,log);
        }       
        else
          if   (fileCommand.equals( "update"))
          {
            oFileOperation.update(fileId,fileContents,log);
          }       
          else
            if   (fileCommand.equals("getFileCount"))
            {
              numFiles = LocalFileOperation.getFileCount();
View Full Code Here

TOP

Related Classes of file.LocalFileOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.