1 17 package org.alfresco.filesys.server.filesys; 18 19 import java.util.Enumeration ; 20 21 import org.alfresco.config.ConfigElement; 22 import org.alfresco.filesys.server.SrvSession; 23 import org.alfresco.filesys.server.auth.InvalidUserException; 24 import org.alfresco.filesys.server.config.InvalidConfigurationException; 25 import org.alfresco.filesys.server.config.ServerConfiguration; 26 import org.alfresco.filesys.server.core.ShareMapper; 27 import org.alfresco.filesys.server.core.SharedDevice; 28 import org.alfresco.filesys.server.core.SharedDeviceList; 29 30 38 public class DefaultShareMapper implements ShareMapper 39 { 40 42 private ServerConfiguration m_config; 43 44 46 private boolean m_debug; 47 48 51 public DefaultShareMapper() 52 { 53 } 54 55 62 public void initializeMapper(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException 63 { 64 65 67 m_config = config; 68 69 71 if (params != null && params.getChild("debug") != null) 72 m_debug = true; 73 } 74 75 80 public final boolean hasDebug() 81 { 82 return m_debug; 83 } 84 85 96 public SharedDevice findShare(String host, String name, int typ, SrvSession sess, boolean create) 97 throws InvalidUserException 98 { 99 100 102 SharedDevice share = null; 103 104 106 if ( sess.hasDynamicShares()) { 107 108 110 share = sess.getDynamicShareList().findShare(name, typ, true); 111 } 112 113 115 if ( share == null) 116 { 117 120 share = m_config.getShares().findShare(name, typ, false); 121 122 if (share == null) 123 { 124 125 127 share = m_config.getShares().findShare(name, typ, true); 128 } 129 } 130 131 133 if (share != null && share.getContext() != null && share.getContext().isAvailable() == false) 134 share = null; 135 136 138 return share; 139 } 140 141 146 public void deleteShares(SrvSession sess) 147 { 148 150 if ( sess.hasDynamicShares() == false) 151 return; 152 153 155 SharedDeviceList shares = sess.getDynamicShareList(); 156 Enumeration <SharedDevice> enm = shares.enumerateShares(); 157 158 while ( enm.hasMoreElements()) { 159 160 162 SharedDevice shr = (SharedDevice) enm.nextElement(); 163 164 166 shr.getContext().CloseContext(); 167 } 168 169 171 shares.removeAllShares(); 172 } 173 174 182 public SharedDeviceList getShareList(String host, SrvSession sess, boolean allShares) 183 { 184 185 187 189 SharedDeviceList shrList = new SharedDeviceList(m_config.getShares()); 190 191 if ( sess != null && sess.hasDynamicShares()) { 192 193 195 shrList.addShares(sess.getDynamicShareList()); 196 } 197 198 200 if (allShares == false) 201 shrList.removeUnavailableShares(); 202 return shrList; 203 } 204 205 208 public void closeMapper() 209 { 210 } 211 } 212 | Popular Tags |