Changeset 6700
- Timestamp:
- 09/30/06 22:27:30 (5 years ago)
- Location:
- trunk/Jav_CO/com/scenari/m/co/univers
- Files:
-
- 2 edited
-
WUnivers.java (modified) (2 diffs)
-
XParamUniversSaxHandler.java (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_CO/com/scenari/m/co/univers/WUnivers.java
r2647 r6700 47 47 import com.scenari.m.co.service.HServicesMgr; 48 48 import com.scenari.m.co.service.IWService; 49 import com.scenari.m.co.univers. fs.XInstancesMgr;49 import com.scenari.m.co.univers.wsp.WContenuMgrWsp; 50 50 import com.scenari.m.co.univespace.HEspaceUnivers; 51 51 import com.scenari.m.co.user.IWUser; … … 60 60 public class WUnivers implements IWUnivers { 61 61 62 /** Code de l'univers. */ 63 protected String fCode = null; 64 65 /** Liste des doc serveurs de l'univers. */ 66 protected HEspaceUnivers fEspaceSource = null; 67 68 protected HEspaceUnivers fEspaceComposants = null; 69 70 protected HEspaceUnivers fEspacePublication = null; 71 72 protected HEspaceUnivers fEspaceFormations = null; 73 74 protected HEspaceUnivers fEspaceUnivers = null; 75 76 protected HashMap fEspaces = new HashMap(); 77 78 /** Manager des acteurs. */ 79 protected IWUserMgr fActeursMgr = null; 80 81 /** Liste des Classes de composants déclarés principaux. */ 82 //sprotected HashMap fClasseComposantsPrinc = new HashMap(); 83 /** Liste des Classes de composants. */ 84 protected HashMap fClasseComposants = new HashMap(); 85 86 /** Liste des services de l'univers. */ 87 protected HashMap fServices = new HashMap(); 88 89 /** Contextes d'execution de l'univers de type HttpServlet. */ 90 protected HContextExecHttpServlet fContextExecHttpServlet = null; 91 92 /** Contextes d'execution de l'univers. */ 93 protected IWContextExec[] fContextsExecs = null; 94 95 /** Manager d'instances. */ 96 protected IWInstancesMgr fInstancesMgr = null; 97 98 /** Manager des contenus. */ 99 protected IWContenuMgr fContenuMgr = null; 100 101 /** Intitule de l'univers. */ 102 protected String fIntitule = null; 103 104 /** Factory de templates XSL. */ 105 //protected Stack fTransformerFactoryStack = null; 106 protected TransformerFactory fTransformerFactory = null; 107 108 static { 109 //Ajout des services de base 110 HServicesMgr.hAddServiceLoader("Libre", com.scenari.m.co.service.libre.HServiceLoaderLibre.class); 111 HServicesMgr.hAddServiceLoader("Quit", com.scenari.m.co.service.quit.HServiceLoaderQuit.class); 112 } 113 114 /** 115 * WUnivers constructor comment. 116 */ 117 public WUnivers(String pCode) { 118 super(); 119 fCode = pCode; 120 fIntitule = pCode; 121 } 122 123 /** 124 * Met à jour l'univers et les prescriptions chargées en mémoire. 125 */ 126 public void hCheckUpdate(HUpdates pUpdates) throws Exception { 127 if (fContenuMgr != null) { 128 fContenuMgr.hCheckUpdate(pUpdates); 129 } 130 } 131 132 /** 133 * Reourne l'acteur de compte pCompte. Si pCompte == IWUser.COMPTE_INVITE, un acteur "invité" est retourné. 134 * 135 * @return com.scenari.m.co.acteur.IWUser 136 * @param pCompte 137 * java.lang.String 138 */ 139 public final IWUser hGetUser(String pCompte) throws Exception { 140 return fActeursMgr.hGetUser(pCompte); 141 } 142 143 /** 144 * 145 */ 146 public com.scenari.m.co.user.IWUserMgr hGetUserMgr() { 147 return fActeursMgr; 148 } 149 150 /** 151 * Renvoit la classe de composant correspondant à l'URN. 152 * 153 * @return Classe de composant. 154 */ 155 public final IWClasseComposant hGetClasseComposantByUrn(String pUrn) throws Exception { 156 /* 157 * IWClasseComposant vResult = null; StringTokenizer vTok = new StringTokenizer(pUrn, "/"); if 158 * (vTok.hasMoreElements()) { vResult = (IWClasseComposant)fClasseComposants.get(vTok.nextToken()); while 159 * (vTok.hasMoreElements() && vResult != null) { vResult = vResult.hGetClasseCompAssoc(vTok.nextToken()); } } 160 * return vResult; 161 */ 162 return (IWClasseComposant) fClasseComposants.get(pUrn); 163 } 164 165 /** 166 * Renvoit la classe de composant déclarée comme principale de code pCode. 167 * 168 * @return Classe de composant. 169 */ 170 public final IWClasseComposant hGetClasseComposantPrincByCode(String pCode) throws Exception { 171 return (IWClasseComposant) fClasseComposants.get(pCode); 172 } 173 174 /** 175 * @return String Code 176 */ 177 public final String hGetCode() { 178 return fCode; 179 } 180 181 /** 182 * @return com.scenari.m.co.univers.IWInstancesMgr 183 */ 184 public final IWContenuMgr hGetContenuMgr() throws Exception { 185 return fContenuMgr; 186 } 187 188 /** 189 * Renvoit le cotexte d'execution de type pType. 190 * 191 * @return com.scenari.m.co.univers.IWContextExec 192 * @param pType 193 * java.lang.String 194 */ 195 public final IWContextExec hGetContextExec(java.lang.String pType) { 196 197 IWContextExec vResult = null; 198 199 if (fContextsExecs != null) { 200 for (int i = 0; i < fContextsExecs.length; i++) { 201 if (fContextsExecs[i].hGetType().equals(pType)) { 202 vResult = fContextsExecs[i]; 203 break; 204 } 205 } 206 } 207 208 return vResult; 209 } 210 211 /** 212 * Renvoit le contexte d'execution de type HttpServlet. 213 * 214 * @return com.scenari.m.co.univers.HContextExecHttpServlet 215 */ 216 public final HContextExecHttpServlet hGetContextExecHttpServlet() { 217 return fContextExecHttpServlet; 218 } 219 220 /** 221 * 222 */ 223 public final IHSource hGetEspace(String pCodeEspace) { 224 HEspaceUnivers vEspace = (HEspaceUnivers) fEspaces.get(pCodeEspace); 225 if (vEspace != null) { 226 return vEspace.hGetRoot(); 227 } 228 return null; 229 } 230 231 /* 232 * (non-Javadoc) 233 * 234 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceComposants() 235 */ 236 public final IHSource hGetEspaceComposants() { 237 return fEspaceComposants.hGetRoot(); 238 } 239 240 /* 241 * (non-Javadoc) 242 * 243 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceFormations() 244 */ 245 public final IHSource hGetEspaceFormations() { 246 return fEspaceFormations.hGetRoot(); 247 } 248 249 /* 250 * (non-Javadoc) 251 * 252 * @see com.scenari.m.co.univers.IWUnivers#hGetEspacePublications() 253 */ 254 public final IHSource hGetEspacePublications() { 255 return fEspacePublication.hGetRoot(); 256 } 257 258 /* 259 * (non-Javadoc) 260 * 261 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceSources() 262 */ 263 public final IHSource hGetEspaceSources() { 264 return fEspaceSource.hGetRoot(); 265 } 266 267 /* 268 * (non-Javadoc) 269 * 270 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceUnivers() 271 */ 272 public final IHSource hGetEspaceUnivers() { 273 return fEspaceUnivers.hGetRoot(); 274 } 275 276 /** 277 * 278 */ 279 public final IWInstancesMgr hGetInstancesMgr() throws Exception { 280 return fInstancesMgr; 281 } 282 283 /** 284 * 285 */ 286 public final java.lang.String hGetIntitule() { 287 return fIntitule; 288 } 289 290 /** 291 * Retourne le service de l'univers de code pCode. 292 * 293 * @return Service de l'univers. 294 * @param pCode 295 * Code du service. 296 */ 297 public final IWService hGetService(String pCode) { 298 return (IWService) fServices.get(pCode); 299 } 300 301 /** 302 * Retourne le service par défaut de l'univers ("home page" de l'univers). 303 */ 304 public final IWService hGetServiceAccueil() throws Exception { 305 IWService vService = hGetService("accueil"); 306 if (vService == null) { 307 vService = hGetService("acceuil"); //Faute d'orthographe historique (!) maintenu pour la compatibilité avec 308 // l'IHM2 et le projet Espass. 309 if (vService == null) { 310 throw HLogMgr.hNewException("Erreur de paramétrage de l'univers : il n'existe aucun service d'univers avec le code 'accueil' (ou 'acceuil')."); 311 } 312 } 313 return vService; 314 } 315 316 /** 317 * 318 */ 319 public boolean hHaveService(java.lang.String pCode) { 320 return fServices.get(pCode) != null; 321 } 322 323 /** 324 * 325 */ 326 public final void hSetEspace(HEspaceUnivers pEspace) { 327 String vCode = pEspace.hGetCodeEspace(); 328 if (ESPACE_COMPOSANT.equals(vCode)) { 329 fEspaceComposants = pEspace; 330 } else if (ESPACE_FORMATION.equals(vCode)) { 331 fEspaceFormations = pEspace; 332 } else if (ESPACE_PUBLICATION.equals(vCode)) { 333 fEspacePublication = pEspace; 334 } else if (ESPACE_SOURCE.equals(vCode)) { 335 fEspaceSource = pEspace; 336 } else if (ESPACE_UNIVERS.equals(vCode)) { 337 fEspaceUnivers = pEspace; 338 } 339 fEspaces.put(vCode, pEspace); 340 } 341 342 /** 343 * 344 */ 345 public final void hSetIntitule(java.lang.String pIntitule) { 346 fIntitule = pIntitule; 347 } 348 349 /** 350 * 351 */ 352 public String toString() { 353 return "<univers code=\"" + fCode + "\"/>"; 354 } 355 356 /** 357 * Ajoute une classe de composant à l'univers. 358 * 359 * @param pClasseComp 360 * Classe de composant principal 361 */ 362 public final void wAddClasseComposant(IWClasseComposant pClasseComp) { 363 fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 364 } 365 366 /** 367 * Ajoute une classe de composant principal à l'univers. 368 * 369 * @param pClasseComp 370 * Classe de composant principal 371 */ 372 public final void wAddClasseComposantPrincipal(IWClasseComposant pClasseComp) { 373 fClasseComposants.put(pClasseComp.hGetCode(), pClasseComp); 374 fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 375 } 376 377 /** 378 * Ajoute un contexte d'execution à l'univers. Si un contexte du même type existait déjà, ce contexte est remplacé 379 * par le nouveau. 380 * 381 * @param pContextExec 382 * com.scenari.m.co.univers.IWContextExec 383 */ 384 public final synchronized void wAddContextExec(IWContextExec pContextExec) { 385 386 if (fContextsExecs == null) { 387 //Aucun contexte d'associe, on ajoute ce 1er contexte. 388 fContextsExecs = new IWContextExec[1]; 389 fContextsExecs[0] = pContextExec; 390 } else { 391 392 //On cherche un contexte du même type. 393 for (int i = 0; i < fContextsExecs.length; i++) { 394 if (fContextsExecs[i].hGetType().equals(pContextExec.hGetType())) { 395 //On a trouvé un ancien context du même type, on le remplace. 396 fContextsExecs[i] = pContextExec; 397 return; 398 } 399 } 400 401 //Aucun contexte du meme type, on l'ajoute. 402 IWContextExec[] vNewTab = new IWContextExec[fContextsExecs.length + 1]; 403 System.arraycopy(fContextsExecs, 0, vNewTab, 0, fContextsExecs.length); 404 vNewTab[fContextsExecs.length] = pContextExec; 405 fContextsExecs = vNewTab; 406 407 } 408 409 //Traitement spécifique du context HttpServlet 410 if (IWContextExec.TYPE_HTTP_SERVLET.equals(pContextExec.hGetType())) { 411 fContextExecHttpServlet = (HContextExecHttpServlet) pContextExec; 412 } 413 414 } 415 416 /** 417 * Ajoute un service à l'univers. 418 * 419 * @param pService 420 * Service de l'univers. 421 */ 422 public synchronized final void wAddService(IWService pService) throws Exception { 423 fServices.put(pService.hGetCode(), pService); 424 hGetContenuMgr().hInitServiceUnivers(pService); 425 } 426 427 /** 428 * Supprime définitivement l'univers. 429 */ 430 public final void wRemove() throws Exception { 431 432 //Suppression des univers. 433 if (fServices != null) { 434 Iterator vIt = fServices.values().iterator(); 435 while (vIt.hasNext()) { 436 try { 437 ((IWService) vIt.next()).wRemoveService(); 438 } catch (Exception e) { 439 HLogMgr.hPublishException(e, "Echec à la suprression d'un service de l'univers " + this); 440 } 441 } 442 } 443 444 fActeursMgr = new HUserMgrFs(this); 445 446 // Manager d'instances 447 if (fInstancesMgr != null) { 448 fInstancesMgr.wRemoveUnivers(); 449 } 450 451 //On supprime tous les fichiers de l'espace publications 452 if (hGetEspacePublications() != null) { 453 hGetEspacePublications().hFindElemByPath(null).hRemove(); 454 } 455 456 //On supprime tous les fichiers de l'espace composants 457 if (hGetEspaceComposants() != null) { 458 hGetEspaceComposants().hFindElemByPath(null).hRemove(); 459 } 460 //On supprime tous les fichiers de l'espace Formations (instances) 461 if (hGetEspaceFormations() != null) { 462 hGetEspaceFormations().hFindElemByPath(null).hRemove(); 463 } 464 //On supprime tous les fichiers de l'espace Formations (instances) 465 if (hGetEspaceUnivers() != null) { 466 hGetEspaceUnivers().hFindElemByPath(null).hRemove(); 467 } 468 } 469 470 /** 471 * @see com.scenari.m.co.univers.IWUnivers#wSetContenuMgr(com.scenari.m.co.univers.IWContenuMgr) 472 */ 473 public final void wSetContenuMgr(IWContenuMgr pContenuMgr) throws Exception { 474 fContenuMgr = pContenuMgr; 475 fContenuMgr.wInitBegin(this); 476 } 477 478 /** 479 * @see com.scenari.m.co.univers.IWUnivers#wSetInstancesMgr(com.scenari.m.co.univers.IWInstancesMgr) 480 */ 481 public final void wSetInstancesMgr(IWInstancesMgr pInstancesMgr) throws Exception { 482 fInstancesMgr = pInstancesMgr; 483 fInstancesMgr.wInitBegin(this); 484 } 485 486 /** 487 * Désactive et décharge l'univers de la mémoire. 488 * 489 */ 490 public final void wUnload() throws Exception { 491 492 //On laisse le garbage collector faire le ménage. On ne tue rien pour laisser le tratiement en cours 493 //s'exécuter correctement. 494 495 //###### Envisager fonction Unload des services, etc. 496 497 /* 498 fEspaceSource = null; 499 fEspaceComposants = null; 500 fEspacePublication = null; 501 fEspaceFormations = null; 502 fEspaceActeurs = null; 503 fEspaceUnivers = null; 504 fPrescFormations = null; 505 fActeurs = null; 506 fClasseComposants = null; 507 fServices = null; 508 fContextExecHttpServlet = null; 509 fContextsExecs = null; 510 fInstancesMgr = null; 511 fPrefixResolverDefault = null; 512 */ 513 try { 514 if(fContenuMgr!=null) fContenuMgr.wUnloadUnivers(); 515 } catch (Exception e) { 516 HLogMgr.hPublishException(e); 517 } 518 try { 519 if(fInstancesMgr!=null) fInstancesMgr.wUnloadUnivers(); 520 } catch (Exception e) { 521 HLogMgr.hPublishException(e); 522 } 523 if(fServices != null){ 524 for (Iterator vIt = fServices.values().iterator(); vIt.hasNext();) { 525 IWService vService = (IWService) vIt.next(); 526 try { 527 vService.wRemoveService(); 528 } catch (Exception e) { 529 HLogMgr.hPublishException(e); 530 } 531 } 532 } 533 } 534 535 /** 536 * Initialisation de l'univers. 537 * Appelé juste après l'instanciation de l'objet. 538 * 539 */ 540 public final void xInitBegin() throws Exception { 541 542 fActeursMgr = new HUserMgrFs(this); 543 544 //fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 545 //fContenuMgr.wInitBegin(this); 546 } 547 548 /** 549 * Fin de l'Initialisation de l'univers. 550 * Appelé après le parsing du fichier d'init. 551 * 552 */ 553 public final void xInitEnd() throws Exception { 554 555 if (fContenuMgr == null) { 556 //Pas de ContenuMgr déclaré, on en crée un par défaut. 557 fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 558 fContenuMgr.wInitBegin(this); 559 } 560 fContenuMgr.wInitEnd(this); 561 562 if (fInstancesMgr == null) { 563 //Pas d'instance Mgr de paramétré = Donc on crée l'IntanceMgr par défaut. 564 fInstancesMgr = XInstancesMgr.wGetInstancesMgr(this); 565 fInstancesMgr.wInitBegin(this); 566 } 567 fInstancesMgr.wInitEnd(this); 568 } 62 /** Code de l'univers. */ 63 protected String fCode = null; 64 65 /** Liste des doc serveurs de l'univers. */ 66 protected HEspaceUnivers fEspaceSource = null; 67 68 protected HEspaceUnivers fEspaceComposants = null; 69 70 protected HEspaceUnivers fEspacePublication = null; 71 72 protected HEspaceUnivers fEspaceFormations = null; 73 74 protected HEspaceUnivers fEspaceUnivers = null; 75 76 protected HashMap fEspaces = new HashMap(); 77 78 /** Manager des acteurs. */ 79 protected IWUserMgr fActeursMgr = null; 80 81 /** Liste des Classes de composants déclarés principaux. */ 82 // sprotected HashMap fClasseComposantsPrinc = new HashMap(); 83 /** Liste des Classes de composants. */ 84 protected HashMap fClasseComposants = new HashMap(); 85 86 /** Liste des services de l'univers. */ 87 protected HashMap fServices = new HashMap(); 88 89 /** Contextes d'execution de l'univers de type HttpServlet. */ 90 protected HContextExecHttpServlet fContextExecHttpServlet = null; 91 92 /** Contextes d'execution de l'univers. */ 93 protected IWContextExec[] fContextsExecs = null; 94 95 /** Manager d'instances. */ 96 protected IWInstancesMgr fInstancesMgr = null; 97 98 /** Manager des contenus. */ 99 protected IWContenuMgr fContenuMgr = null; 100 101 /** Intitule de l'univers. */ 102 protected String fIntitule = null; 103 104 /** Factory de templates XSL. */ 105 // protected Stack fTransformerFactoryStack = null; 106 protected TransformerFactory fTransformerFactory = null; 107 108 static { 109 // Ajout des services de base 110 HServicesMgr.hAddServiceLoader("Libre", com.scenari.m.co.service.libre.HServiceLoaderLibre.class); 111 HServicesMgr.hAddServiceLoader("Quit", com.scenari.m.co.service.quit.HServiceLoaderQuit.class); 112 } 113 114 /** 115 * WUnivers constructor comment. 116 */ 117 public WUnivers(String pCode) { 118 super(); 119 fCode = pCode; 120 fIntitule = pCode; 121 } 122 123 /** 124 * Met à jour l'univers et les prescriptions chargées en mémoire. 125 */ 126 public void hCheckUpdate(HUpdates pUpdates) throws Exception { 127 if (fContenuMgr != null) { 128 fContenuMgr.hCheckUpdate(pUpdates); 129 } 130 } 131 132 /** 133 * Reourne l'acteur de compte pCompte. Si pCompte == IWUser.COMPTE_INVITE, 134 * un acteur "invité" est retourné. 135 * 136 * @return com.scenari.m.co.acteur.IWUser 137 * @param pCompte 138 * java.lang.String 139 */ 140 public final IWUser hGetUser(String pCompte) throws Exception { 141 return fActeursMgr.hGetUser(pCompte); 142 } 143 144 /** 145 * 146 */ 147 public com.scenari.m.co.user.IWUserMgr hGetUserMgr() { 148 return fActeursMgr; 149 } 150 151 /** 152 * Renvoit la classe de composant correspondant à l'URN. 153 * 154 * @return Classe de composant. 155 */ 156 public final IWClasseComposant hGetClasseComposantByUrn(String pUrn) throws Exception { 157 /* 158 * IWClasseComposant vResult = null; StringTokenizer vTok = new 159 * StringTokenizer(pUrn, "/"); if (vTok.hasMoreElements()) { vResult = 160 * (IWClasseComposant)fClasseComposants.get(vTok.nextToken()); while 161 * (vTok.hasMoreElements() && vResult != null) { vResult = 162 * vResult.hGetClasseCompAssoc(vTok.nextToken()); } } return vResult; 163 */ 164 return (IWClasseComposant) fClasseComposants.get(pUrn); 165 } 166 167 /** 168 * Renvoit la classe de composant déclarée comme principale de code pCode. 169 * 170 * @return Classe de composant. 171 */ 172 public final IWClasseComposant hGetClasseComposantPrincByCode(String pCode) throws Exception { 173 return (IWClasseComposant) fClasseComposants.get(pCode); 174 } 175 176 /** 177 * @return String Code 178 */ 179 public final String hGetCode() { 180 return fCode; 181 } 182 183 /** 184 * @return com.scenari.m.co.univers.IWInstancesMgr 185 */ 186 public final IWContenuMgr hGetContenuMgr() throws Exception { 187 return fContenuMgr; 188 } 189 190 /** 191 * Renvoit le cotexte d'execution de type pType. 192 * 193 * @return com.scenari.m.co.univers.IWContextExec 194 * @param pType 195 * java.lang.String 196 */ 197 public final IWContextExec hGetContextExec(java.lang.String pType) { 198 199 IWContextExec vResult = null; 200 201 if (fContextsExecs != null) { 202 for (int i = 0; i < fContextsExecs.length; i++) { 203 if (fContextsExecs[i].hGetType().equals(pType)) { 204 vResult = fContextsExecs[i]; 205 break; 206 } 207 } 208 } 209 210 return vResult; 211 } 212 213 /** 214 * Renvoit le contexte d'execution de type HttpServlet. 215 * 216 * @return com.scenari.m.co.univers.HContextExecHttpServlet 217 */ 218 public final HContextExecHttpServlet hGetContextExecHttpServlet() { 219 return fContextExecHttpServlet; 220 } 221 222 /** 223 * 224 */ 225 public final IHSource hGetEspace(String pCodeEspace) { 226 HEspaceUnivers vEspace = (HEspaceUnivers) fEspaces.get(pCodeEspace); 227 if (vEspace != null) { return vEspace.hGetRoot(); } 228 return null; 229 } 230 231 /* 232 * (non-Javadoc) 233 * 234 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceComposants() 235 */ 236 public final IHSource hGetEspaceComposants() { 237 return fEspaceComposants.hGetRoot(); 238 } 239 240 /* 241 * (non-Javadoc) 242 * 243 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceFormations() 244 */ 245 public final IHSource hGetEspaceFormations() { 246 return fEspaceFormations.hGetRoot(); 247 } 248 249 /* 250 * (non-Javadoc) 251 * 252 * @see com.scenari.m.co.univers.IWUnivers#hGetEspacePublications() 253 */ 254 public final IHSource hGetEspacePublications() { 255 return fEspacePublication.hGetRoot(); 256 } 257 258 /* 259 * (non-Javadoc) 260 * 261 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceSources() 262 */ 263 public final IHSource hGetEspaceSources() { 264 return fEspaceSource.hGetRoot(); 265 } 266 267 /* 268 * (non-Javadoc) 269 * 270 * @see com.scenari.m.co.univers.IWUnivers#hGetEspaceUnivers() 271 */ 272 public final IHSource hGetEspaceUnivers() { 273 return fEspaceUnivers.hGetRoot(); 274 } 275 276 /** 277 * 278 */ 279 public final IWInstancesMgr hGetInstancesMgr() throws Exception { 280 return fInstancesMgr; 281 } 282 283 /** 284 * 285 */ 286 public final java.lang.String hGetIntitule() { 287 return fIntitule; 288 } 289 290 /** 291 * Retourne le service de l'univers de code pCode. 292 * 293 * @return Service de l'univers. 294 * @param pCode 295 * Code du service. 296 */ 297 public final IWService hGetService(String pCode) { 298 return (IWService) fServices.get(pCode); 299 } 300 301 /** 302 * Retourne le service par défaut de l'univers ("home page" de l'univers). 303 */ 304 public final IWService hGetServiceAccueil() throws Exception { 305 IWService vService = hGetService("accueil"); 306 if (vService == null) { 307 vService = hGetService("acceuil"); // Faute d'orthographe 308 // historique (!) maintenu pour 309 // la compatibilité avec 310 // l'IHM2 et le projet Espass. 311 if (vService == null) { throw HLogMgr.hNewException("Erreur de paramétrage de l'univers : il n'existe aucun service d'univers avec le code 'accueil' (ou 'acceuil')."); } 312 } 313 return vService; 314 } 315 316 /** 317 * 318 */ 319 public boolean hHaveService(java.lang.String pCode) { 320 return fServices.get(pCode) != null; 321 } 322 323 /** 324 * 325 */ 326 public final void hSetEspace(HEspaceUnivers pEspace) { 327 String vCode = pEspace.hGetCodeEspace(); 328 if (ESPACE_COMPOSANT.equals(vCode)) { 329 fEspaceComposants = pEspace; 330 } else if (ESPACE_FORMATION.equals(vCode)) { 331 fEspaceFormations = pEspace; 332 } else if (ESPACE_PUBLICATION.equals(vCode)) { 333 fEspacePublication = pEspace; 334 } else if (ESPACE_SOURCE.equals(vCode)) { 335 fEspaceSource = pEspace; 336 } else if (ESPACE_UNIVERS.equals(vCode)) { 337 fEspaceUnivers = pEspace; 338 } 339 fEspaces.put(vCode, pEspace); 340 } 341 342 /** 343 * 344 */ 345 public final void hSetIntitule(java.lang.String pIntitule) { 346 fIntitule = pIntitule; 347 } 348 349 /** 350 * 351 */ 352 public String toString() { 353 return "<univers code=\"" + fCode + "\"/>"; 354 } 355 356 /** 357 * Ajoute une classe de composant à l'univers. 358 * 359 * @param pClasseComp 360 * Classe de composant principal 361 */ 362 public final void wAddClasseComposant(IWClasseComposant pClasseComp) { 363 fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 364 } 365 366 /** 367 * Ajoute une classe de composant principal à l'univers. 368 * 369 * @param pClasseComp 370 * Classe de composant principal 371 */ 372 public final void wAddClasseComposantPrincipal(IWClasseComposant pClasseComp) { 373 fClasseComposants.put(pClasseComp.hGetCode(), pClasseComp); 374 fClasseComposants.put(pClasseComp.hGetUrn(), pClasseComp); 375 } 376 377 /** 378 * Ajoute un contexte d'execution à l'univers. Si un contexte du même type 379 * existait déjà, ce contexte est remplacé par le nouveau. 380 * 381 * @param pContextExec 382 * com.scenari.m.co.univers.IWContextExec 383 */ 384 public final synchronized void wAddContextExec(IWContextExec pContextExec) { 385 386 if (fContextsExecs == null) { 387 // Aucun contexte d'associe, on ajoute ce 1er contexte. 388 fContextsExecs = new IWContextExec[1]; 389 fContextsExecs[0] = pContextExec; 390 } else { 391 392 // On cherche un contexte du même type. 393 for (int i = 0; i < fContextsExecs.length; i++) { 394 if (fContextsExecs[i].hGetType().equals(pContextExec.hGetType())) { 395 // On a trouvé un ancien context du même type, on le 396 // remplace. 397 fContextsExecs[i] = pContextExec; 398 return; 399 } 400 } 401 402 // Aucun contexte du meme type, on l'ajoute. 403 IWContextExec[] vNewTab = new IWContextExec[fContextsExecs.length + 1]; 404 System.arraycopy(fContextsExecs, 0, vNewTab, 0, fContextsExecs.length); 405 vNewTab[fContextsExecs.length] = pContextExec; 406 fContextsExecs = vNewTab; 407 408 } 409 410 // Traitement spécifique du context HttpServlet 411 if (IWContextExec.TYPE_HTTP_SERVLET.equals(pContextExec.hGetType())) { 412 fContextExecHttpServlet = (HContextExecHttpServlet) pContextExec; 413 } 414 415 } 416 417 /** 418 * Ajoute un service à l'univers. 419 * 420 * @param pService 421 * Service de l'univers. 422 */ 423 public synchronized final void wAddService(IWService pService) throws Exception { 424 fServices.put(pService.hGetCode(), pService); 425 hGetContenuMgr().hInitServiceUnivers(pService); 426 } 427 428 /** 429 * Supprime définitivement l'univers. 430 */ 431 public final void wRemove() throws Exception { 432 433 // Suppression des univers. 434 if (fServices != null) { 435 Iterator vIt = fServices.values().iterator(); 436 while (vIt.hasNext()) { 437 try { 438 ((IWService) vIt.next()).wRemoveService(); 439 } catch (Exception e) { 440 HLogMgr.hPublishException(e, "Echec à la suprression d'un service de l'univers " + this); 441 } 442 } 443 } 444 445 fActeursMgr = new HUserMgrFs(this); 446 447 // Manager d'instances 448 if (fInstancesMgr != null) { 449 fInstancesMgr.wRemoveUnivers(); 450 } 451 452 // On supprime tous les fichiers de l'espace publications 453 if (hGetEspacePublications() != null) { 454 hGetEspacePublications().hFindElemByPath(null).hRemove(); 455 } 456 457 // On supprime tous les fichiers de l'espace composants 458 if (hGetEspaceComposants() != null) { 459 hGetEspaceComposants().hFindElemByPath(null).hRemove(); 460 } 461 // On supprime tous les fichiers de l'espace Formations (instances) 462 if (hGetEspaceFormations() != null) { 463 hGetEspaceFormations().hFindElemByPath(null).hRemove(); 464 } 465 // On supprime tous les fichiers de l'espace Formations (instances) 466 if (hGetEspaceUnivers() != null) { 467 hGetEspaceUnivers().hFindElemByPath(null).hRemove(); 468 } 469 } 470 471 /** 472 * @see com.scenari.m.co.univers.IWUnivers#wSetContenuMgr(com.scenari.m.co.univers.IWContenuMgr) 473 */ 474 public final void wSetContenuMgr(IWContenuMgr pContenuMgr) throws Exception { 475 fContenuMgr = pContenuMgr; 476 fContenuMgr.wInitBegin(this); 477 } 478 479 /** 480 * @see com.scenari.m.co.univers.IWUnivers#wSetInstancesMgr(com.scenari.m.co.univers.IWInstancesMgr) 481 */ 482 public final void wSetInstancesMgr(IWInstancesMgr pInstancesMgr) throws Exception { 483 fInstancesMgr = pInstancesMgr; 484 fInstancesMgr.wInitBegin(this); 485 } 486 487 /** 488 * Désactive et décharge l'univers de la mémoire. 489 * 490 */ 491 public final void wUnload() throws Exception { 492 493 // On laisse le garbage collector faire le ménage. On ne tue rien pour 494 // laisser le tratiement en cours 495 // s'exécuter correctement. 496 497 // ###### Envisager fonction Unload des services, etc. 498 499 /* 500 * fEspaceSource = null; fEspaceComposants = null; fEspacePublication = 501 * null; fEspaceFormations = null; fEspaceActeurs = null; fEspaceUnivers = 502 * null; fPrescFormations = null; fActeurs = null; fClasseComposants = 503 * null; fServices = null; fContextExecHttpServlet = null; 504 * fContextsExecs = null; fInstancesMgr = null; fPrefixResolverDefault = 505 * null; 506 */ 507 try { 508 if (fContenuMgr != null) fContenuMgr.wUnloadUnivers(); 509 } catch (Exception e) { 510 HLogMgr.hPublishException(e); 511 } 512 try { 513 if (fInstancesMgr != null) fInstancesMgr.wUnloadUnivers(); 514 } catch (Exception e) { 515 HLogMgr.hPublishException(e); 516 } 517 if (fServices != null) { 518 for (Iterator vIt = fServices.values().iterator(); vIt.hasNext();) { 519 IWService vService = (IWService) vIt.next(); 520 try { 521 vService.wRemoveService(); 522 } catch (Exception e) { 523 HLogMgr.hPublishException(e); 524 } 525 } 526 } 527 } 528 529 /** 530 * Initialisation de l'univers. Appelé juste après l'instanciation de 531 * l'objet. 532 * 533 */ 534 public final void xInitBegin() throws Exception { 535 536 fActeursMgr = new HUserMgrFs(this); 537 538 // fContenuMgr = new com.scenari.m.co.univers.fs.WContenuMgrFs(); 539 // fContenuMgr.wInitBegin(this); 540 } 541 542 /** 543 * Fin de l'Initialisation de l'univers. Appelé après le parsing du fichier 544 * d'init. 545 * 546 */ 547 public final void xInitEnd() throws Exception { 548 549 if (fContenuMgr == null) { 550 // Pas de ContenuMgr déclaré, on en crée un par défaut. 551 fContenuMgr = new WContenuMgrWsp(); 552 fContenuMgr.wInitBegin(this); 553 } 554 fContenuMgr.wInitEnd(this); 555 556 if (fInstancesMgr == null) { 557 // Pas d'instance Mgr de paramétré = Donc on crée l'IntanceMgr par 558 // défaut. 559 throw HLogMgr.hNewException("No instancemgr defined in universe " + fCode); 560 } 561 fInstancesMgr.wInitEnd(this); 562 } 569 563 } -
trunk/Jav_CO/com/scenari/m/co/univers/XParamUniversSaxHandler.java
r1856 r6700 51 51 import com.scenari.m.co.service.HServicesMgr; 52 52 import com.scenari.m.co.service.IWServiceLoader; 53 import com.scenari.m.co.univers.fs.HContenuMgrFsLoader; 54 import com.scenari.m.co.univers.fs.HInstancesMgrFsLoader; 53 import com.scenari.m.co.univers.wsp.HContenuMgrWspLoader; 55 54 import com.scenari.m.co.univespace.HEspaceUnivers; 56 55 import com.scenari.m.co.user.fs.HUserMgrFs; … … 62 61 63 62 /** 64 * 63 * 65 64 */ 66 65 public class XParamUniversSaxHandler extends HExtraitSaxHandler { 67 66 68 67 public static final String TAG_UNIVERS = "univers"; 68 69 69 public static final String TAG_UNIVERS_ATT_CODE = "code"; 70 70 71 public static final String TAG_UNIVERS_ATT_INTITULE = "intitule"; 71 72 72 73 public static final String TAG_ESPACE = "espace"; 74 73 75 public static final String TAG_ESPACE_SOURCES = "espace-sources"; 76 74 77 public static final String TAG_ESPACE_COMPOSANTS = "espace-composants"; 78 75 79 public static final String TAG_ESPACE_PUBLICATIONS = "espace-publications"; 80 76 81 public static final String TAG_ESPACE_FORMATIONS = "espace-formations"; 82 77 83 public static final String TAG_ESPACE_ACTEURS = "espace-acteurs"; 84 78 85 public static final String TAG_ESPACE_UNIVERS = "espace-univers"; 79 86 80 87 public static final String TAG_ESPACE_ATT_TYPE = "type"; 88 81 89 public static final String TAG_ESPACE_ATT_CODE = "code"; 82 90 83 91 public static final String TAG_SERVICE = "service"; 92 84 93 public static final String TAG_SERVICE_ATT_TYPE = "type"; 94 85 95 public static final String TAG_SERVICE_ATT_CODE = "code"; 86 96 87 97 public static final String TAG_COMPOSANT = "composant"; 98 88 99 public static final String TAG_COMPOSANT_ATT_REF = "ref"; 100 89 101 public static final String TAG_SPUL = "spul"; 102 90 103 public static final String TAG_COMP_LECTEUR = "lecteur"; 104 91 105 public static final String TAG_COMP_DIALOGUE = "dialogue"; 106 92 107 public static final String TAG_COMP_PARAM = "param"; 108 93 109 public static final String TAG_COMP_PAGERESULTAT = "pageresultat"; 110 94 111 public static final String TAG_COMP_PAGERESULTAT_ATT_RES = "coderesultat"; 95 112 96 113 public static final String TAG_CONTEXT_EXEC = "contexte-execution"; 114 97 115 public static final String TAG_CONTEXT_EXEC_TYPE = "type"; 98 116 … … 104 122 105 123 public static final String TAG_XXX_ATT_HREF = "href"; 124 106 125 public static final String TAG_XXX_ATT_CLASSE = "classe"; 126 107 127 public static final String TAG_XXX_ATT_CODE = "code"; 128 108 129 public static final String TAG_XXX_ATT_TYPE = "type"; 109 130 … … 114 135 protected boolean fSousDocument = false; 115 136 116 /** Handle de l'Univers en cours de définition. */137 /** Handle de l'Univers en cours de définition. */ 117 138 protected WUniversHandle fUniversHandle = null; 118 139 119 /** Univers en cours de définition. */140 /** Univers en cours de définition. */ 120 141 protected WUnivers fUnivers = null; 121 142 … … 148 169 149 170 /** 150 * On execute la méthode endDocument() uniquement si on n'est pas en train de lire un sous document. 171 * On execute la méthode endDocument() uniquement si on n'est pas en train 172 * de lire un sous document. 151 173 */ 152 174 public void endDocument() throws org.xml.sax.SAXException { … … 155 177 } 156 178 } 157 179 158 180 /** 159 181 * … … 164 186 fCurrentDocSource = pDocSource; 165 187 } 166 167 /** 168 * 169 * 170 * @param pUnivers com.scenari.m.co.univers.IWUnivers 188 189 /** 190 * 191 * 192 * @param pUnivers 193 * com.scenari.m.co.univers.IWUnivers 171 194 */ 172 195 public void hSetUnivers(WUniversHandle pUniversHandle, WUnivers pUnivers) { … … 174 197 fUnivers = pUnivers; 175 198 } 176 177 /** 178 * On execute la méthode startDocument() uniquement si on n'est pas en train de lire un sous document. 199 200 /** 201 * On execute la méthode startDocument() uniquement si on n'est pas en train 202 * de lire un sous document. 179 203 */ 180 204 public void startDocument() throws org.xml.sax.SAXException { … … 195 219 // 196 220 else if (pLocalName.equals(TAG_COMPOSANT) || pLocalName.equals(TAG_SPUL)) { 197 // Fin d'un tag composant221 // Fin d'un tag composant 198 222 fStackClasseComposants.remove(fStackClasseComposants.size() - 1); 199 223 } 200 224 201 225 // 202 226 else if (fCurrentParamCode != null) { … … 215 239 return (IWClasseComposant) fStackClasseComposants.get(fStackClasseComposants.size() - 1); 216 240 } 217 241 218 242 /** 219 243 * Création d'un nouvel espace. … … 234 258 } 235 259 } 236 260 237 261 /** 238 262 * Doit envoyer false si le tag n'a pas été exploité. 263 * 239 264 * @return boolean 240 265 */ … … 252 277 } 253 278 } 254 } 255 279 } 280 256 281 // 257 282 else if (pLocalName.equals(TAG_ESPACE_SOURCES)) { 258 283 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), IWUnivers.ESPACE_SOURCE, pUri, pLocalName, pQName, pAttributes); 259 } 260 284 } 285 261 286 // 262 287 else if (pLocalName.equals(TAG_ESPACE_COMPOSANTS)) { 263 288 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), IWUnivers.ESPACE_COMPOSANT, pUri, pLocalName, pQName, pAttributes); 264 } 265 289 } 290 266 291 // 267 292 else if (pLocalName.equals(TAG_ESPACE_PUBLICATIONS)) { 268 293 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), IWUnivers.ESPACE_PUBLICATION, pUri, pLocalName, pQName, pAttributes); 269 } 270 294 } 295 271 296 // 272 297 else if (pLocalName.equals(TAG_ESPACE_FORMATIONS)) { 273 298 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), IWUnivers.ESPACE_FORMATION, pUri, pLocalName, pQName, pAttributes); 274 } 275 299 } 300 276 301 // DEPRECATED !! 277 302 else if (pLocalName.equals(TAG_ESPACE_ACTEURS)) { 278 303 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), HUserMgrFs.ESPACE_USER, pUri, pLocalName, pQName, pAttributes); 279 304 } 280 305 281 306 // 282 307 else if (pLocalName.equals(TAG_ESPACE_UNIVERS)) { 283 308 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), IWUnivers.ESPACE_UNIVERS, pUri, pLocalName, pQName, pAttributes); 284 } 285 309 } 310 286 311 // 287 312 else if (pLocalName.equals(TAG_ESPACE)) { 288 313 xNewEspace(pAttributes.getValue(TAG_ESPACE_ATT_TYPE), pAttributes.getValue(TAG_ESPACE_ATT_CODE), pUri, pLocalName, pQName, pAttributes); 289 } 290 314 } 315 291 316 // 292 317 else if (pLocalName.equals(TAG_CONTEXT_EXEC)) { … … 303 328 vContext.hSetUrlJsp(pAttributes.getValue("urljsp")); 304 329 vContext.hSetConnecteurByClassName(pAttributes.getValue("classe-connecteur")); 305 // *** A supprimer ***330 // *** A supprimer *** 306 331 vContext.hSetUrlServletAcceuilUnivers(pAttributes.getValue("urlservlet-acceuilunivers")); 307 332 } catch (Exception e) { … … 313 338 } 314 339 } 315 340 316 341 // 317 342 else if (pLocalName.equals(TAG_SPUL)) { … … 324 349 fStackClasseComposants.add(vComp); 325 350 } 326 351 327 352 // 328 353 else if (pLocalName.equals(TAG_COMPOSANT)) { … … 330 355 String vRef = pAttributes.getValue(TAG_COMPOSANT_ATT_REF); 331 356 if (vRef != null) { 332 // On pointe sur un composant déclaré en modèle.357 // On pointe sur un composant déclaré en modèle. 333 358 vComp = fUnivers.hGetClasseComposantByUrn("/".concat(vRef)); 334 359 if (vComp == null) { 335 360 HLogMgr.hPublishException("Une classe de composant référencée '" + vRef + "' est introuvable dans la déclaration des classes de composants de l'univers '" + fUnivers.hGetCode() + "'."); 336 361 } 337 // vComp = vComp.hGetClone();362 // vComp = vComp.hGetClone(); 338 363 } else { 339 // On définit un nouveau composant associe364 // On définit un nouveau composant associe 340 365 vComp = new HClasseComposant(pAttributes.getValue(TAG_XXX_ATT_CODE)); 341 366 if (!fStackClasseComposants.isEmpty()) { … … 345 370 if (vComp != null) { 346 371 if (!fStackClasseComposants.isEmpty()) { 347 // On est dans un SPUL372 // On est dans un SPUL 348 373 xGetCurrentClasseComposant().wAddClasseCompAssoc(vComp); 349 // On informe l'univers de l'ajout de cette classe.374 // On informe l'univers de l'ajout de cette classe. 350 375 fUnivers.wAddClasseComposant(vComp); 351 376 } else { 352 //On est à la racine : on déclare un modèle de composant associé. 377 // On est à la racine : on déclare un modèle de composant 378 // associé. 353 379 fUnivers.wAddClasseComposant(vComp); 354 380 } … … 357 383 358 384 } 359 385 360 386 // 361 387 else if (pLocalName.equals(TAG_COMP_LECTEUR)) { … … 368 394 } 369 395 } 370 396 371 397 // 372 398 else if (pLocalName.equals(TAG_COMP_DIALOGUE)) { … … 379 405 } 380 406 } 381 407 382 408 // 383 409 else if (pLocalName.equals(TAG_COMP_PAGERESULTAT)) { … … 386 412 } 387 413 } 388 414 389 415 // 390 416 else if (pLocalName.equals(TAG_COMP_PARAM)) { … … 393 419 } 394 420 } 395 421 396 422 // 397 423 else if (pLocalName.equals(TAG_CONTENUMGR)) { … … 399 425 String vType = pAttributes.getValue(TAG_XXX_ATT_TYPE); 400 426 HMgrLoader vSaxHandler = null; 401 if (vType!=null) {427 if (vType != null) { 402 428 Class vClass = Class.forName(vType); 403 429 try { 404 430 vClass = Class.forName(vType); 405 vSaxHandler = (HMgrLoader) vClass.newInstance();431 vSaxHandler = (HMgrLoader) vClass.newInstance(); 406 432 } catch (Exception e) { 407 433 HLogMgr.hPublishException(e); 408 434 } 409 435 } 410 if (vSaxHandler == null) {411 vSaxHandler = new HContenuMgr FsLoader();436 if (vSaxHandler == null) { 437 vSaxHandler = new HContenuMgrWspLoader(); 412 438 } 413 439 vSaxHandler.hSetUnivers(fUnivers); … … 419 445 } 420 446 } 421 447 422 448 // 423 449 else if (pLocalName.equals(TAG_INSTANCESMGR)) { … … 425 451 String vType = pAttributes.getValue(TAG_XXX_ATT_TYPE); 426 452 HMgrLoader vSaxHandler = null; 427 if (vType!=null) {453 if (vType != null) { 428 454 Class vClass = Class.forName(vType); 429 try { 430 vClass = Class.forName(vType); 431 vSaxHandler = (HMgrLoader)vClass.newInstance(); 432 } catch (Exception e) { 433 HLogMgr.hPublishException(e); 434 } 435 } 436 if(vSaxHandler == null) { 437 vSaxHandler = new HInstancesMgrFsLoader(); 455 vSaxHandler = (HMgrLoader) vClass.newInstance(); 438 456 } 439 457 vSaxHandler.hSetUnivers(fUnivers); … … 445 463 } 446 464 } 447 465 448 466 // 449 467 else if (pLocalName.equals(TAG_SERVICE)) { … … 462 480 } 463 481 464 // Import d'un fichier externe482 // Import d'un fichier externe 465 483 else if (pLocalName.equals(TAG_IMPORT)) { 466 // Import d'un autre fichier.484 // Import d'un autre fichier. 467 485 String vUriImport = pAttributes.getValue(TAG_XXX_ATT_HREF); 468 486 IHSource vCurrentDocSource = fCurrentDocSource; … … 482 500 } catch (Exception e) { 483 501 HLogMgr.hPublishException(e, "Echec à l'import du fichier '" + vUriImport + "."); 484 if (vSource != null) {502 if (vSource != null) { 485 503 vSource.getByteStream().close(); 486 504 }
Note: See TracChangeset
for help on using the changeset viewer.