/** {@inheritDoc} */
public final void execute () throws InternetSCSIException {
final ProtocolDataUnit protocolDataUnit = connection.receive();
if (!(protocolDataUnit.getBasicHeaderSegment().getParser() instanceof LogoutResponseParser)) { throw new InternetSCSIException("This PDU type (" + protocolDataUnit.getBasicHeaderSegment().getParser() + ") is not expected. "); }
final LogoutResponseParser parser = (LogoutResponseParser) protocolDataUnit.getBasicHeaderSegment().getParser();
if (parser.getResponse() == LogoutResponse.CONNECTION_CLOSED_SUCCESSFULLY) {
// exception rethrow
try {
// FIXME: Implement Connection close
connection.getSession().close();
} catch (IOException e) {
throw new InternetSCSIException("Closing the connection throws this error: " + e.getLocalizedMessage());
}
} else {
throw new InternetSCSIException("The connection could not be closed successfully.");
}
// return false;
}