Package handlers.files

Source Code of handlers.files.GetInfoHandler

package handlers.files;


import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import common.ClientServerProtocol;
import common.files.SerializableFile;

import connection.ClientConnection;
import files.IndexedFile;
import handlers.AbstractServerHandler;

import static main.ServerMain.*;


public class GetInfoHandler extends AbstractServerHandler
{
  public void execute(ClientConnection connection, ObjectInputStream is,
      ObjectOutputStream os) throws IOException, ClassNotFoundException
  {
    SerializableFile file = (SerializableFile) is.readObject();
    IndexedFile indexedFile = getFileManager().retrieveIndexedFile(file);

    os.write(ClientServerProtocol.PROTOCOL_FILES);
    if (indexedFile == null)
    {
      os.write(ClientServerProtocol.Files.OP_INVALID_FILE);
      os.writeObject(file);
    }
    else
    {
      os.write(ClientServerProtocol.Files.OP_FILE_INFO);
      os.writeObject(file);
      os.writeLong(indexedFile.getChunkLength());
    }
  }

}
TOP

Related Classes of handlers.files.GetInfoHandler

TOP
Copyright © 2018 www.massapi.com. 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.