1 17 package org.alfresco.filesys.smb.server; 18 19 import java.io.IOException ; 20 21 import org.alfresco.filesys.server.filesys.DiskDeviceContext; 22 import org.alfresco.filesys.server.filesys.DiskInterface; 23 import org.alfresco.filesys.server.filesys.DiskSizeInterface; 24 import org.alfresco.filesys.server.filesys.DiskVolumeInterface; 25 import org.alfresco.filesys.server.filesys.SrvDiskInfo; 26 import org.alfresco.filesys.server.filesys.TooManyConnectionsException; 27 import org.alfresco.filesys.server.filesys.VolumeInfo; 28 import org.alfresco.filesys.smb.PacketType; 29 30 35 abstract class ProtocolHandler 36 { 37 38 40 protected SMBSrvSession m_sess; 41 42 45 protected ProtocolHandler() 46 { 47 } 48 49 54 protected ProtocolHandler(SMBSrvSession sess) 55 { 56 m_sess = sess; 57 } 58 59 64 public abstract String getName(); 65 66 72 public abstract boolean runProtocol() throws IOException , SMBSrvException, TooManyConnectionsException; 73 74 79 protected final SMBSrvSession getSession() 80 { 81 return m_sess; 82 } 83 84 89 protected final void setSession(SMBSrvSession sess) 90 { 91 m_sess = sess; 92 } 93 94 101 protected final boolean hasChainedCommand(SMBSrvPacket pkt) 102 { 103 104 106 int cmd = pkt.getCommand(); 107 108 if (cmd == PacketType.SessionSetupAndX || cmd == PacketType.TreeConnectAndX || cmd == PacketType.OpenAndX 109 || cmd == PacketType.WriteAndX || cmd == PacketType.ReadAndX || cmd == PacketType.LogoffAndX 110 || cmd == PacketType.LockingAndX || cmd == PacketType.NTCreateAndX) 111 { 112 113 115 return pkt.hasAndXCommand(); 116 } 117 118 120 return false; 121 } 122 123 131 protected final SrvDiskInfo getDiskInformation(DiskInterface disk, DiskDeviceContext ctx) throws IOException 132 { 133 134 136 SrvDiskInfo diskInfo = ctx.getDiskInformation(); 137 138 142 if (diskInfo == null) 143 diskInfo = new SrvDiskInfo(); 144 145 148 if (disk instanceof DiskSizeInterface) 149 { 150 151 153 DiskSizeInterface sizeInterface = (DiskSizeInterface) disk; 154 sizeInterface.getDiskInformation(ctx, diskInfo); 155 } 156 157 159 return diskInfo; 160 } 161 162 169 protected final VolumeInfo getVolumeInformation(DiskInterface disk, DiskDeviceContext ctx) 170 { 171 172 174 VolumeInfo volInfo = ctx.getVolumeInformation(); 175 176 180 if (disk instanceof DiskVolumeInterface) 181 { 182 183 185 DiskVolumeInterface volInterface = (DiskVolumeInterface) disk; 186 volInfo = volInterface.getVolumeInformation(ctx); 187 } 188 189 191 if (volInfo == null) 192 volInfo = new VolumeInfo(""); 193 194 196 return volInfo; 197 } 198 } | Popular Tags |