1 22 package org.jboss.test.security.ejb.project; 23 24 import java.rmi.RemoteException ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.SessionBean ; 27 import javax.ejb.SessionContext ; 28 import javax.naming.Name ; 29 import javax.naming.NamingException ; 30 import javax.naming.directory.Attributes ; 31 import javax.naming.directory.BasicAttributes ; 32 import javax.naming.directory.DirContext ; 33 34 import org.jboss.test.security.ejb.project.support.HeirMemoryMap; 35 import org.jboss.test.security.interfaces.IProjRepository; 36 import org.jboss.logging.Logger; 37 38 47 public class ProjRepositoryBean implements SessionBean , IProjRepository 48 { 49 static Logger log = Logger.getLogger(ProjRepositoryBean.class); 50 51 private SessionContext context; 52 private HeirMemoryMap projRepository; 53 54 public void createFolder(Name folderPath) throws NamingException , RemoteException 56 { 57 log.debug("createFolder, "+folderPath); 58 } 59 60 public void deleteFolder(Name folderPath,boolean recursive) throws NamingException , RemoteException 61 { 62 log.debug("deleteFolder, "+folderPath); 63 } 64 65 public void createItem(Name itemPath,Attributes attributes) throws NamingException , RemoteException 66 { 67 log.debug("createItem, "+itemPath); 68 } 69 70 public void updateItem(Name itemPath,Attributes attributes) throws NamingException , RemoteException 71 { 72 log.debug("updateItem, "+itemPath); 73 } 74 75 public void deleteItem(Name itemPath) throws NamingException , RemoteException 76 { 77 try 78 { 79 projRepository.unbind(itemPath); 80 } 81 catch(Exception e) 82 { 83 log.debug("failed", e); 84 } 85 } 86 87 public Attributes getItem(Name itemPath) throws NamingException , RemoteException 88 { 89 log.debug("ProjRepositoryBean.getItem() itemPath="+itemPath); 90 Attributes attributes = projRepository.getAttributes(itemPath); 91 return attributes; 92 } 93 95 public void ejbCreate(Name projectName) throws CreateException 97 { 98 log.debug("ProjRepositoryBean.ejbCreate() projectName="+projectName); 99 projRepository = new HeirMemoryMap(); 101 try 102 { 103 BasicAttributes attributes = new BasicAttributes (); 104 attributes.put("name", projectName); 105 attributes.put("owner", "scott"); 106 DirContext projectCtx = projRepository.createSubcontext(projectName, attributes); 107 attributes = new BasicAttributes (); 108 attributes.put("name", "Drawings"); 109 attributes.put("isFolder", "false"); 110 attributes.put("contentType", "text/html"); 111 attributes.put("size", "1024"); 112 projectCtx.bind("readme.html", null, attributes); 113 attributes.put("owner", "scott"); 114 attributes = new BasicAttributes (); 116 attributes.put("name", "Documents"); 117 attributes.put("isFolder", "true"); 118 attributes.put("owner", "scott"); 119 DirContext dctx = projectCtx.createSubcontext("Documents", attributes); 120 attributes = new BasicAttributes (); 121 attributes.put("name", "index.html"); 122 attributes.put("isFolder", "false"); 123 attributes.put("contentType", "text/html"); 124 attributes.put("size", "1234"); 125 dctx.bind("index.html", null, attributes); 126 attributes.put("owner", "scott"); 127 attributes = new BasicAttributes (); 129 attributes.put("name", "Private"); 130 attributes.put("isFolder", "true"); 131 attributes.put("owner", "scott"); 132 dctx = projectCtx.createSubcontext("Documents/Private", attributes); 133 attributes = new BasicAttributes (); 134 attributes.put("name", "passwords"); 135 attributes.put("isFolder", "false"); 136 attributes.put("contentType", "text/plain"); 137 attributes.put("size", "8173"); 138 attributes.put("owner", "scott"); 139 dctx.bind("passwords", null, attributes); 140 attributes = new BasicAttributes (); 142 attributes.put("name", "Public"); 143 attributes.put("isFolder", "true"); 144 attributes.put("owner", "scott"); 145 dctx = projectCtx.createSubcontext("Documents/Public", attributes); 146 attributes = new BasicAttributes (); 147 attributes.put("name", "readme.txt"); 148 attributes.put("isFolder", "false"); 149 attributes.put("contentType", "text/plain"); 150 attributes.put("size", "13584"); 151 attributes.put("owner", "scott"); 152 dctx.bind("readme.txt", null, attributes); 153 attributes = new BasicAttributes (); 155 attributes.put("name", "starksm"); 156 attributes.put("isFolder", "true"); 157 attributes.put("owner", "starksm"); 158 dctx = projectCtx.createSubcontext("Documents/Public/starksm", attributes); 159 attributes = new BasicAttributes (); 160 attributes.put("name", ".bashrc"); 161 attributes.put("isFolder", "false"); 162 attributes.put("contentType", "text/plain"); 163 attributes.put("size", "1167"); 164 attributes.put("owner", "starksm"); 165 dctx.bind(".bashrc", null, attributes); 166 attributes = new BasicAttributes (); 168 attributes.put("name", "Drawings"); 169 attributes.put("isFolder", "true"); 170 attributes.put("owner", "scott"); 171 dctx = projectCtx.createSubcontext("Drawings", attributes); 172 attributes = new BasicAttributes (); 173 attributes.put("name", "view1.jpg"); 174 attributes.put("isFolder", "false"); 175 attributes.put("contentType", "image/jpeg"); 176 attributes.put("owner", "scott"); 177 dctx.bind("view1.jpg", null, attributes); 178 } 179 catch(NamingException e) 180 { 181 throw new CreateException (e.toString(true)); 182 } 183 } 184 185 187 public void setSessionContext(SessionContext context) 189 { 190 this.context = context; 191 } 192 193 public void ejbRemove() 194 { 195 } 196 197 public void ejbActivate() 198 { 199 } 200 201 public void ejbPassivate() 202 { 203 } 204 } 206 | Popular Tags |