1 64 65 package com.jcorporate.expresso.services.dbobj; 66 67 import com.jcorporate.expresso.core.controller.ControllerRequest; 68 import com.jcorporate.expresso.core.db.DBException; 69 import com.jcorporate.expresso.core.dbobj.Schema; 70 import com.jcorporate.expresso.core.dbobj.SchemaFactory; 71 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 72 import com.jcorporate.expresso.core.dbobj.ValidValue; 73 import com.jcorporate.expresso.core.job.Job; 74 75 import java.util.Enumeration ; 76 import java.util.Iterator ; 77 import java.util.Vector ; 78 79 80 89 public class JobSecurity 90 extends SecurityDBObject { 91 private static Vector jobList = null; 92 93 96 public JobSecurity() 97 throws DBException { 98 super(); 99 } 100 101 102 105 public JobSecurity(int uid) 106 throws DBException { 107 super(uid); 108 } 109 110 116 public JobSecurity(ControllerRequest request) 117 throws DBException { 118 super(request); 119 } 120 121 124 public void add() 125 throws DBException { 126 127 jobList = null; 129 130 if (getField("Functions").equals("")) { 131 setField("Functions", "*"); 132 } 133 134 super.add(); 135 } 136 137 138 144 protected void checkAllRefs() 145 throws DBException { 146 checkRef("GroupName", new UserGroup(SecuredDBObject.SYSTEM_ACCOUNT), 147 "Invalid " + getString(getMetaData().getDescription("GroupName"))); 148 } 149 150 151 156 protected synchronized void setupFields() 157 throws DBException { 158 setTargetTable("JOBSECURITY"); 159 setDescription("DBjobSecurity"); 160 setCharset("ISO-8859-1"); 161 addField("JobClass", "varchar", 130, false, "jobObjectName"); 162 addField("GroupName", "char", 10, false, "groupName"); 163 addField("Functions", "text", 0, false, "allowedFunctions"); 164 setStringFilter("JobClass", "stripFilter"); 165 setStringFilter("GroupName", "stripFilter"); 166 setStringFilter("Functions", "rawFilter"); 167 addKey("JobClass"); 168 addKey("GroupName"); 169 setMultiValued("GroupName"); 170 setMultiValued("JobClass"); 171 setLookupObject("GroupName", 172 "com.jcorporate.expresso.services.dbobj.UserGroup"); 173 } 174 175 176 184 public synchronized Vector getValidValues(String fieldName) 185 throws DBException { 186 if (fieldName.equals("JobClass")) { 187 if (jobList == null) { 188 SchemaList myList = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT); 189 myList.setDataContext(getDataContext()); 190 191 SchemaList oneList = null; 192 jobList = new Vector (10); 193 doSchema("com.jcorporate.expresso.core.ExpressoSchema", 194 "Expresso"); 195 196 197 for (Iterator sl = myList.searchAndRetrieveList().iterator(); 198 sl.hasNext();) { 199 oneList = (SchemaList) sl.next(); 200 doSchema(oneList.getField("SchemaClass"), 201 oneList.getField("Descrip")); 202 } 203 204 } 205 206 return jobList; 207 } 208 209 return super.getValidValues(fieldName); 210 } 211 212 213 217 private void doSchema(String schemaName, String schemaDescrip) 218 throws DBException { 219 Schema oneSchema = SchemaFactory.getInstance().getSchema(schemaName); 220 if (oneSchema == null) { 221 throw new DBException("Error instantiating class '" + schemaName); 222 223 } 224 225 Job oneJob = null; 226 ValidValue oneVal = null; 227 228 229 for (Enumeration e = oneSchema.getJobs(); e.hasMoreElements();) { 230 oneJob = (Job) e.nextElement(); 231 oneVal = new ValidValue(oneJob.getClass().getName(), 232 schemaDescrip + ": " + oneJob.getTitle()); 233 jobList.addElement(oneVal); 234 } 235 } 236 237 238 } 239 240 | Popular Tags |