1 package com.ca.directory.jxplorer.broker; 2 3 import javax.naming.*; 4 import javax.naming.directory.*; 5 6 import com.ca.directory.jxplorer.*; 7 import com.ca.commons.naming.*; 9 import com.ca.commons.jndi.SchemaOps; 10 11 import java.util.*; 12 import java.util.logging.Logger ; 13 14 20 21 public class SchemaBroker extends Broker 22 { 23 JNDIBroker jndiBroker; 24 25 SchemaOps schemaOps; 26 27 private final static Logger log = Logger.getLogger(SchemaBroker.class.getName()); 28 29 public SchemaBroker(JNDIBroker jb) 30 { 31 registerDirectoryConnection(jb); 32 } 33 34 public void registerDirectoryConnection(JNDIBroker broker) 35 { 36 jndiBroker = broker; 37 schemaOps = jndiBroker.getSchemaOps(); 38 } 39 40 44 80 86 93 100 107 116 124 151 152 159 165 166 234 241 243 244 245 248 249 public DataQuery doExistsQuery(DataQuery request) 250 { 251 return request.setException(new Exception ("schemaOps exists not yet implemented")); } 253 254 255 protected DataQuery doSearchQuery(DataQuery request) 256 { 257 return request.setException(new Exception ("schemaOps search not allowed")); 258 } 259 260 263 264 protected DataQuery doModifyQuery(DataQuery request) 265 { 266 return request.setException(new Exception ("schemaOps modification not allowed")); 267 } 268 269 272 273 protected DataQuery doCopyQuery(DataQuery request) 274 { 275 return request.setException(new Exception ("schemaOps copy not allowed")); 276 } 277 278 281 282 protected DataQuery doGetAllOCsQuery(DataQuery request) 283 { 284 return request.setException(new Exception ("schemaOps object class list not allowed")); 285 } 286 287 290 291 protected DataQuery doGetRecOCsQuery(DataQuery request) 292 { 293 return request.setException(new Exception ("schemaOps rec. object class list not allowed")); 294 } 295 296 297 304 305 public DXNamingEnumeration unthreadedList(DN searchbase) 306 { 307 try 308 { 309 if (schemaOps == null) return null; 311 312 ArrayList nextLevel = schemaOps.listEntryNames(searchbase.toString()); 313 int size = nextLevel.size(); 314 for (int i=0; i<size; i++) 315 { 316 nextLevel.set(i, new NameClassPair("schema="+ (String )nextLevel.get(i),"schema", false)); 317 } 318 return new DXNamingEnumeration(nextLevel); 319 } 320 catch (NamingException e) 321 { 322 System.out.println("hurm."); 323 return null; 324 } 325 } 326 327 336 337 public DXNamingEnumeration unthreadedSearch(DN dn, String filter, int search_level, String [] returnAttributes) { return null; } 338 339 346 public void unthreadedCopy(DN oldNodeDN, DN newNodeDN) 347 throws NamingException 348 { 349 throw new NamingException("unable to modify schema"); 350 } 351 352 356 357 public boolean unthreadedExists(DN checkMe) {return false;} 358 359 362 363 public Vector unthreadedGetAllOCs() { return null; } 364 365 373 374 public DXEntry unthreadedReadEntry(DN entryDN, String [] returnAttributes) 375 throws NamingException 376 { 377 if (schemaOps == null) return null; 379 380 DXEntry returnEntry = new DXEntry(entryDN); 381 382 Attributes atts = schemaOps.getAttributes(entryDN.toString()); 383 384 if (atts == null || atts.size() == 0) 385 { 386 returnEntry = null; } 388 else if (returnAttributes == null) 389 { 390 returnEntry.put(atts.getAll()); } 392 else if (returnAttributes.length == 0) 393 { 394 } 396 else { 398 log.warning("return of partial schemaOps attributes not implemented - returning all"); 399 returnEntry.put(atts.getAll()); 400 } 401 402 return returnEntry; 403 437 } 438 439 444 445 public void unthreadedModify(DXEntry oldEntry, DXEntry newEntry) 446 throws NamingException 447 { 448 throw new NamingException("unable to modify schema"); 449 } 450 451 457 458 public ArrayList unthreadedGetRecOCs(DN dn) { return null; } 459 460 461 462 463 464 465 466 467 468 469 470 471 472 475 476 public DirContext getDirContext() { return jndiBroker.getDirContext(); } 477 478 481 482 public boolean isModifiable() { return false; } 483 484 488 489 public boolean isActive() { return true; } 490 491 494 495 public SchemaOps getSchemaOps() { return schemaOps; } 496 497 498 } | Popular Tags |