1 23 24 package org.infoglue.deliver.controllers.kernel.impl.simple; 25 26 import java.net.URLEncoder ; 27 import java.util.ArrayList ; 28 import java.util.Collection ; 29 import java.util.Date ; 30 import java.util.Enumeration ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 import java.util.List ; 34 import java.util.Map ; 35 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpSession ; 38 39 import org.apache.log4j.Logger; 40 import org.exolab.castor.jdo.Database; 41 import org.exolab.castor.jdo.OQLQuery; 42 import org.exolab.castor.jdo.QueryResults; 43 import org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService; 44 import org.infoglue.cms.entities.content.Content; 45 import org.infoglue.cms.entities.content.ContentVO; 46 import org.infoglue.cms.entities.content.impl.simple.ContentImpl; 47 import org.infoglue.cms.entities.management.AvailableServiceBinding; 48 import org.infoglue.cms.entities.management.AvailableServiceBindingVO; 49 import org.infoglue.cms.entities.management.LanguageVO; 50 import org.infoglue.cms.entities.management.RepositoryVO; 51 import org.infoglue.cms.entities.management.ServiceDefinitionVO; 52 import org.infoglue.cms.entities.management.SiteNodeTypeDefinition; 53 import org.infoglue.cms.entities.structure.Qualifyer; 54 import org.infoglue.cms.entities.structure.ServiceBinding; 55 import org.infoglue.cms.entities.structure.SiteNode; 56 import org.infoglue.cms.entities.structure.SiteNodeVO; 57 import org.infoglue.cms.entities.structure.SiteNodeVersion; 58 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 59 import org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl; 60 import org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl; 61 import org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeImpl; 62 import org.infoglue.cms.exception.Bug; 63 import org.infoglue.cms.exception.SystemException; 64 import org.infoglue.cms.security.InfoGluePrincipal; 65 import org.infoglue.cms.services.BaseService; 66 import org.infoglue.cms.util.CmsPropertyHandler; 67 import org.infoglue.cms.util.ConstraintExceptionBuffer; 68 import org.infoglue.deliver.applications.databeans.DeliveryContext; 69 import org.infoglue.deliver.applications.filters.URIMapperCache; 70 import org.infoglue.deliver.applications.filters.ViewPageFilter; 71 import org.infoglue.deliver.controllers.kernel.URLComposer; 72 import org.infoglue.deliver.util.CacheController; 73 import org.infoglue.deliver.util.HttpHelper; 74 import org.infoglue.deliver.util.NullObject; 75 76 77 public class NodeDeliveryController extends BaseDeliveryController 78 { 79 private final static Logger logger = Logger.getLogger(NodeDeliveryController.class.getName()); 80 81 private URLComposer urlComposer = null; 82 83 protected static final String META_INFO_BINDING_NAME = "Meta information"; 84 protected static final String NAV_TITLE_ATTRIBUTE_NAME = "NavigationTitle"; 85 86 private static final boolean USE_INHERITANCE = true; 87 private static final boolean DO_NOT_USE_INHERITANCE = false; 88 89 protected static final Integer NO = new Integer (0); 90 protected static final Integer YES = new Integer (1); 91 protected static final Integer INHERITED = new Integer (2); 92 93 private Integer siteNodeId = null; 94 private Integer languageId = null; 95 private Integer contentId = null; 96 97 100 101 private NodeDeliveryController(Integer siteNodeId, Integer languageId, Integer contentId) throws SystemException, Exception 102 { 103 this.siteNodeId = siteNodeId; 104 this.languageId = languageId; 105 this.contentId = contentId; 106 this.urlComposer = URLComposer.getURLComposer(); 107 } 108 109 112 113 public static NodeDeliveryController getNodeDeliveryController(Integer siteNodeId, Integer languageId, Integer contentId) throws SystemException, Exception 114 { 115 return new NodeDeliveryController(siteNodeId, languageId, contentId); 116 } 117 118 121 122 public static NodeDeliveryController getNodeDeliveryController(DeliveryContext deliveryContext) throws SystemException, Exception 123 { 124 return new NodeDeliveryController(deliveryContext.getSiteNodeId(), deliveryContext.getLanguageId(), deliveryContext.getContentId()); 125 } 126 127 131 132 private Integer getOperatingMode() 133 { 134 Integer operatingMode = new Integer (0); try 136 { 137 operatingMode = new Integer (CmsPropertyHandler.getOperatingMode()); 138 } 140 catch(Exception e) 141 { 142 logger.warn("We could not get the operating mode from the propertyFile:" + e.getMessage(), e); 143 } 144 return operatingMode; 145 } 146 147 150 151 public SiteNodeVersionVO getActiveSiteNodeVersionVO(Database db, Integer siteNodeId) throws Exception 152 { 153 SiteNodeVersionVO siteNodeVersionVO = null; 154 155 SiteNodeVersion siteNodeVersion = getActiveSiteNodeVersion(siteNodeId, db); 156 if(siteNodeVersion != null) 157 siteNodeVersionVO = siteNodeVersion.getValueObject(); 158 159 return siteNodeVersionVO; 160 } 161 162 165 166 public SiteNodeVersion getActiveSiteNodeVersion(Integer siteNodeId, Database db) throws Exception 167 { 168 SiteNodeVersion siteNodeVersion = null; 169 170 SiteNode siteNode = (SiteNode)this.getObjectWithId(SiteNodeImpl.class, siteNodeId, db); 171 logger.info("Loaded siteNode " + siteNode.getName()); 172 Collection siteNodeVersions = siteNode.getSiteNodeVersions(); 173 logger.info("Loaded versions " + siteNodeVersions.size()); 174 175 Iterator versionIterator = siteNodeVersions.iterator(); 176 while(versionIterator.hasNext()) 177 { 178 SiteNodeVersion siteNodeVersionCandidate = (SiteNodeVersion)versionIterator.next(); 179 logger.info("SiteNodeVersionCandidate " + siteNodeVersionCandidate.getId()); 180 if(siteNodeVersionCandidate.getIsActive().booleanValue() && siteNodeVersionCandidate.getStateId().intValue() >= getOperatingMode().intValue()) 181 { 182 if(siteNodeVersionCandidate.getOwningSiteNode().getSiteNodeId().intValue() == siteNodeId.intValue()) 183 { 184 if(siteNodeVersion == null || siteNodeVersion.getSiteNodeVersionId().intValue() < siteNodeVersionCandidate.getId().intValue()) 185 { 186 siteNodeVersion = siteNodeVersionCandidate; 187 } 188 } 189 } 190 } 191 192 return siteNodeVersion; 193 } 194 195 198 199 public ServiceDefinitionVO getInheritedServiceDefinition(List qualifyerList, Integer siteNodeId, AvailableServiceBindingVO availableServiceBindingVO, Database db, boolean inheritParentBindings) throws SystemException, Exception 200 { 201 logger.info("Trying to find binding " + availableServiceBindingVO.getName() + " on siteNodeId:" + siteNodeId); 202 ServiceDefinitionVO serviceDefinitionVO = null; 203 204 SiteNode siteNode = (SiteNode)this.getObjectWithId(SmallSiteNodeImpl.class, siteNodeId, db); 205 logger.info("Loaded siteNode " + siteNode.getName()); 206 207 serviceDefinitionVO = getServiceDefinitionVO(qualifyerList, siteNode, availableServiceBindingVO, db); 208 logger.info("Loaded serviceDefinitionVO " + serviceDefinitionVO); 209 210 if(serviceDefinitionVO == null) 211 { 212 if(availableServiceBindingVO != null && availableServiceBindingVO.getIsInheritable().booleanValue() && inheritParentBindings) 215 { 216 logger.info("No binding found - lets try the parent."); 217 SiteNode parent = siteNode.getParentSiteNode(); 218 if(parent != null) 219 serviceDefinitionVO = getInheritedServiceDefinition(qualifyerList, parent.getSiteNodeId(), availableServiceBindingVO, db, inheritParentBindings); 220 } 221 } 222 223 225 logger.info("Loaded serviceDefinitionVO end..."); 226 227 return serviceDefinitionVO; 228 } 229 230 private ServiceDefinitionVO getServiceDefinitionVO(List qualifyerList, SiteNode siteNode, AvailableServiceBindingVO availableServiceBindingVO, Database db) throws Exception 231 { 232 ServiceDefinitionVO serviceDefinitionVO = null; 233 235 String key = "" + siteNode.getSiteNodeId() + "_" + availableServiceBindingVO.getId(); 236 logger.info("key:" + key); 237 Object object = CacheController.getCachedObject("serviceDefinitionCache", key); 238 Object object2 = CacheController.getCachedObject("qualifyerListCache", key); 239 if(object != null && object2 != null) 240 { 241 logger.info("There was an cached ServiceDefinitionVO:" + object); 242 if(object instanceof ServiceDefinitionVO) 243 serviceDefinitionVO = (ServiceDefinitionVO)object; 244 if(object2 instanceof List ) 245 qualifyerList.addAll((List )object2); 246 } 247 else 248 { 249 OQLQuery oql = db.getOQLQuery( "SELECT sb FROM org.infoglue.cms.entities.structure.impl.simple.ServiceBindingImpl sb WHERE sb.siteNodeVersion.owningSiteNode = $1 AND sb.availableServiceBinding = $2 AND sb.siteNodeVersion.isActive = $3 AND sb.siteNodeVersion.stateId >= $4 order by sb.siteNodeVersion.siteNodeVersionId DESC"); 250 oql.bind(siteNode); 251 oql.bind(availableServiceBindingVO.getId()); 252 oql.bind(new Boolean (true)); 253 oql.bind(getOperatingMode()); 254 255 QueryResults results = oql.execute(Database.ReadOnly); 256 257 if (results.hasMore()) 258 { 259 ServiceBinding serviceBinding = (ServiceBinding)results.next(); 260 SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNode.getId()); 261 logger.info("serviceBinding sitenodeVersion:" + serviceBinding.getSiteNodeVersion().getId() + ":" + latestSiteNodeVersionVO.getId()); 262 if(serviceBinding.getSiteNodeVersion().getId().equals(latestSiteNodeVersionVO.getId())) 263 { 264 serviceDefinitionVO = serviceBinding.getServiceDefinition().getValueObject(); 265 Collection qualifyers = serviceBinding.getBindingQualifyers(); 266 267 qualifyers = sortQualifyers(qualifyers); 268 269 Iterator iterator = qualifyers.iterator(); 270 while(iterator.hasNext()) 271 { 272 Qualifyer qualifyer = (Qualifyer)iterator.next(); 273 HashMap argument = new HashMap (); 274 argument.put(qualifyer.getName(), qualifyer.getValue()); 275 qualifyerList.add(argument); 276 } 277 278 object = serviceDefinitionVO; 279 object2 = qualifyerList; 280 } 281 } 282 else 283 { 284 object = new NullObject(); 285 object2 = new NullObject(); 286 } 287 288 289 results.close(); 290 oql.close(); 291 292 CacheController.cacheObject("serviceDefinitionCache", key, object); 293 CacheController.cacheObject("qualifyerListCache", key, object2); 294 295 } 296 297 298 312 313 return serviceDefinitionVO; 314 } 315 316 320 321 private AvailableServiceBinding getAvailableServiceBindingRecursive(SiteNode siteNode, String availableServiceBindingName, boolean inheritParentBindings) 322 { 323 if(siteNode == null || availableServiceBindingName == null) 324 return null; 325 326 AvailableServiceBinding availableServiceBinding = null; 327 328 SiteNodeTypeDefinition siteNodeTypeDefinition = siteNode.getSiteNodeTypeDefinition(); 329 if(siteNodeTypeDefinition != null) 330 { 331 Collection availableServiceBindings = siteNodeTypeDefinition.getAvailableServiceBindings(); 332 333 Iterator availableServiceBindingsIterator = availableServiceBindings.iterator(); 334 while(availableServiceBindingsIterator.hasNext()) 335 { 336 AvailableServiceBinding currentAvailableServiceBinding = (AvailableServiceBinding)availableServiceBindingsIterator.next(); 337 if(currentAvailableServiceBinding.getName().equalsIgnoreCase(availableServiceBindingName)) 338 { 339 availableServiceBinding = currentAvailableServiceBinding; 340 } 341 } 342 } 343 344 if(availableServiceBinding == null) 345 availableServiceBinding = getAvailableServiceBindingRecursive(siteNode.getParentSiteNode(), availableServiceBindingName, inheritParentBindings); 346 347 return availableServiceBinding; 348 } 349 350 351 354 355 public SiteNode getSiteNode(Database db, Integer siteNodeId) throws SystemException 356 { 357 SiteNode siteNode = null; 358 359 siteNode = (SiteNode)getObjectWithId(SiteNodeImpl.class, siteNodeId, db); 360 361 return siteNode; 362 } 363 364 367 368 public SiteNodeVersionVO getLatestActiveSiteNodeVersionVO(Database db, Integer siteNodeId) throws SystemException, Exception 369 { 370 String key = "" + siteNodeId; 371 logger.info("key:" + key); 372 SiteNodeVersionVO siteNodeVersionVO = (SiteNodeVersionVO)CacheController.getCachedObject("latestSiteNodeVersionCache", key); 373 if(siteNodeVersionVO != null) 374 { 375 if(logger.isInfoEnabled()) 376 logger.info("There was an cached siteNodeVersionVO:" + siteNodeVersionVO); 377 } 378 else 379 { 380 SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersion(siteNodeId, db); 381 if(siteNodeVersion != null) 382 siteNodeVersionVO = siteNodeVersion.getValueObject(); 383 384 CacheController.cacheObject("latestSiteNodeVersionCache", key, siteNodeVersionVO); 385 } 386 387 return siteNodeVersionVO; 388 } 389 390 393 394 public SiteNodeVersionVO getLatestActiveSiteNodeVersionVOForPageCache(Database db, Integer siteNodeId) throws SystemException, Exception 395 { 396 String key = "" + siteNodeId; 397 logger.info("key:" + key); 398 SiteNodeVersionVO siteNodeVersionVO = (SiteNodeVersionVO)CacheController.getCachedObject("pageCacheLatestSiteNodeVersions", key); 399 if(siteNodeVersionVO != null) 400 { 401 if(logger.isInfoEnabled()) 402 logger.info("There was an cached siteNodeVersionVO:" + siteNodeVersionVO); 403 } 404 else 405 { 406 SiteNodeVersion siteNodeVersion = getLatestActiveSiteNodeVersion(siteNodeId, db); 407 if(siteNodeVersion != null) 408 siteNodeVersionVO = siteNodeVersion.getValueObject(); 409 410 CacheController.cacheObject("pageCacheLatestSiteNodeVersions", key, siteNodeVersionVO); 411 } 412 413 return siteNodeVersionVO; 414 } 415 416 417 420 451 452 455 456 public SiteNodeVersion getLatestActiveSiteNodeVersion(Integer siteNodeId, Database db) throws SystemException, Exception 457 { 458 SiteNodeVersion siteNodeVersion = null; 459 460 String versionKey = "" + siteNodeId + "_" + getOperatingMode() + "_siteNodeVersionId"; 461 463 464 Integer siteNodeVersionId = (Integer )CacheController.getCachedObject("latestSiteNodeVersionCache", versionKey); 465 if(siteNodeVersionId != null) 466 { 467 logger.info("There was a cached sitenode version id:" + siteNodeVersionId); 468 siteNodeVersion = (SiteNodeVersion)getObjectWithId(SiteNodeVersionImpl.class, siteNodeVersionId, db); 470 } 473 else 474 { 475 OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeVersionImpl cv WHERE cv.owningSiteNode.siteNodeId = $1 AND cv.stateId >= $2 AND cv.isActive = $3 ORDER BY cv.siteNodeVersionId desc"); 476 oql.bind(siteNodeId); 477 oql.bind(getOperatingMode()); 478 oql.bind(true); 479 480 QueryResults results = oql.execute(Database.ReadOnly); 481 482 if (results.hasMore()) 483 { 484 siteNodeVersion = (SiteNodeVersion)results.next(); 485 CacheController.cacheObject("latestSiteNodeVersionCache", versionKey, siteNodeVersion.getId()); 486 } 487 488 results.close(); 489 oql.close(); 490 } 491 492 495 return siteNodeVersion; 496 } 497 498 499 502 503 public SiteNodeVO getParentSiteNode(Database db, Integer siteNodeId) throws SystemException 504 { 505 String key = "" + siteNodeId; 506 logger.info("key getParentSiteNode:" + key); 507 Object object = CacheController.getCachedObject("parentSiteNodeCache", key); 508 SiteNodeVO parentSiteNodeVO = null; 509 logger.info("object:" + object); 510 if(object instanceof NullObject) 511 { 512 logger.info("There was an cached parentSiteNodeVO but it was null:" + object); 513 } 514 else if(object != null) 515 { 516 logger.info("There was an cached parentSiteNodeVO:" + parentSiteNodeVO); 517 parentSiteNodeVO = (SiteNodeVO)object; 518 } 519 else 520 { 521 logger.info("There was no cached parentSiteNodeVO:" + parentSiteNodeVO); 522 523 SiteNode siteNode = (SiteNode)getObjectWithId(SmallSiteNodeImpl.class, siteNodeId, db); 524 SiteNode parentSiteNode = siteNode.getParentSiteNode(); 525 if(parentSiteNode != null) 526 { 527 parentSiteNodeVO = parentSiteNode.getValueObject(); 528 CacheController.cacheObject("parentSiteNodeCache", key, parentSiteNodeVO); 529 logger.info("Caching parentSiteNodeVO:" + parentSiteNodeVO); 530 } 531 else 532 { 533 logger.info("Caching parentSiteNodeVO: NullObject"); 534 CacheController.cacheObject("parentSiteNodeCache", key, new NullObject()); 535 } 536 537 538 } 539 540 return parentSiteNodeVO; 541 } 542 543 546 547 public SiteNodeVO getParentSiteNodeForPageCache(Database db, Integer siteNodeId) throws SystemException 548 { 549 String key = "" + siteNodeId; 550 logger.info("key getParentSiteNode:" + key); 551 Object object = CacheController.getCachedObject("pageCacheParentSiteNodeCache", key); 552 SiteNodeVO parentSiteNodeVO = null; 553 logger.info("object:" + object); 554 if(object instanceof NullObject) 555 { 556 logger.info("There was an cached parentSiteNodeVO but it was null:" + object); 557 } 558 else if(object != null) 559 { 560 logger.info("There was an cached parentSiteNodeVO:" + parentSiteNodeVO); 561 parentSiteNodeVO = (SiteNodeVO)object; 562 } 563 else 564 { 565 logger.info("There was no cached parentSiteNodeVO:" + parentSiteNodeVO); 566 567 SiteNode siteNode = (SiteNode)getObjectWithId(SmallSiteNodeImpl.class, siteNodeId, db); 568 SiteNode parentSiteNode = siteNode.getParentSiteNode(); 569 if(parentSiteNode != null) 570 { 571 parentSiteNodeVO = parentSiteNode.getValueObject(); 572 CacheController.cacheObject("pageCacheParentSiteNodeCache", key, parentSiteNodeVO); 573 logger.info("Caching parentSiteNodeVO:" + parentSiteNodeVO); 574 } 575 else 576 { 577 logger.info("Caching parentSiteNodeVO: NullObject"); 578 CacheController.cacheObject("pageCacheParentSiteNodeCache", key, new NullObject()); 579 } 580 581 582 } 583 584 return parentSiteNodeVO; 585 } 586 587 588 592 593 public boolean getIsPageCacheDisabled(Database db, Integer siteNodeId) 594 { 595 boolean isPageCacheDisabled = false; 596 597 try 598 { 599 SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNodeId); 600 if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getDisablePageCache() != null) 601 { 602 if(latestSiteNodeVersionVO.getDisablePageCache().intValue() == NO.intValue()) 603 isPageCacheDisabled = false; 604 else if(latestSiteNodeVersionVO.getDisablePageCache().intValue() == YES.intValue()) 605 isPageCacheDisabled = true; 606 else if(latestSiteNodeVersionVO.getDisablePageCache().intValue() == INHERITED.intValue()) 607 { 608 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 609 if(parentSiteNode != null) 610 isPageCacheDisabled = getIsPageCacheDisabled(db, parentSiteNode.getSiteNodeId()); 611 } 612 } 613 614 } 615 catch(Exception e) 616 { 617 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 618 } 619 620 return isPageCacheDisabled; 621 } 622 623 626 627 public String getPageCacheKey(Database db, HttpSession session, HttpServletRequest request, Integer siteNodeId, Integer languageId, Integer contentId, String userAgent, String queryString, String extra) 628 { 629 return getPageCacheKey(db, session, request, siteNodeId, languageId, contentId, userAgent, queryString, extra, true); 630 } 631 632 635 636 public String getPageCacheKey(Database db, HttpSession session, HttpServletRequest request, Integer siteNodeId, Integer languageId, Integer contentId, String userAgent, String queryString, String extra, boolean includeOriginalRequestURL) 637 { 638 String pageKey = CacheController.getPageCacheKey(session, request, siteNodeId, languageId, contentId, userAgent, queryString, extra); 639 try 640 { 641 642 SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVOForPageCache(db, siteNodeId); 643 Integer currentSiteNodeId = siteNodeId; 644 645 while(latestSiteNodeVersionVO == null || latestSiteNodeVersionVO.getPageCacheKey() == null || latestSiteNodeVersionVO.getPageCacheKey().length() == 0 || latestSiteNodeVersionVO.getPageCacheKey().equalsIgnoreCase("default")) 646 { 647 if(currentSiteNodeId == null) 648 break; 649 650 SiteNodeVO parentSiteNodeVO = getParentSiteNode(db, currentSiteNodeId); 651 if(parentSiteNodeVO != null) 652 { 653 latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVOForPageCache(db, parentSiteNodeVO.getId()); 654 if(latestSiteNodeVersionVO != null) 655 currentSiteNodeId = latestSiteNodeVersionVO.getSiteNodeId(); 656 else 657 currentSiteNodeId = null; 658 } 659 else 660 break; 661 } 662 663 if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getPageCacheKey() != null && latestSiteNodeVersionVO.getPageCacheKey().length() > 0 && !latestSiteNodeVersionVO.getPageCacheKey().equalsIgnoreCase("default")) 664 { 665 String originalRequestURL = request.getParameter("originalRequestURL"); 666 if(originalRequestURL == null || originalRequestURL.length() == 0) 667 originalRequestURL = request.getRequestURL().toString(); 668 669 pageKey = originalRequestURL + "_" + latestSiteNodeVersionVO.getPageCacheKey(); 670 pageKey = pageKey.replaceAll("\\$siteNodeId", "" + siteNodeId); 671 pageKey = pageKey.replaceAll("\\$languageId", "" + languageId); 672 pageKey = pageKey.replaceAll("\\$contentId", "" + contentId); 673 pageKey = pageKey.replaceAll("\\$useragent", "" + userAgent); 674 pageKey = pageKey.replaceAll("\\$queryString", "" + queryString); 675 676 int sessionAttributeStartIndex = pageKey.indexOf("$session."); 677 while(sessionAttributeStartIndex > -1) 678 { 679 int sessionAttributeEndIndex = pageKey.indexOf("_", sessionAttributeStartIndex); 680 String sessionAttribute = null; 681 if(sessionAttributeEndIndex > -1) 682 sessionAttribute = pageKey.substring(sessionAttributeStartIndex + 9, sessionAttributeEndIndex); 683 else 684 sessionAttribute = pageKey.substring(sessionAttributeStartIndex + 9); 685 686 pageKey = pageKey.replaceAll("\\$session." + sessionAttribute, "" + session.getAttribute(sessionAttribute)); 687 688 sessionAttributeStartIndex = pageKey.indexOf("$session."); 689 } 690 691 int cookieAttributeStartIndex = pageKey.indexOf("$cookie."); 692 while(cookieAttributeStartIndex > -1) 693 { 694 int cookieAttributeEndIndex = pageKey.indexOf("_", cookieAttributeStartIndex); 695 String cookieAttribute = null; 696 if(cookieAttributeEndIndex > -1) 697 cookieAttribute = pageKey.substring(cookieAttributeStartIndex + 8, cookieAttributeEndIndex); 698 else 699 cookieAttribute = pageKey.substring(cookieAttributeStartIndex + 8); 700 701 HttpHelper httpHelper = new HttpHelper(); 702 pageKey = pageKey.replaceAll("\\$cookie." + cookieAttribute, "" + httpHelper.getCookie(request, cookieAttribute)); 703 704 cookieAttributeStartIndex = pageKey.indexOf("$cookie."); 705 } 706 707 } 708 709 } 710 catch(Exception e) 711 { 712 logger.warn("An error occurred trying to get if the siteNodeVersion had a different pageCacheKey:" + e.getMessage(), e); 713 } 714 715 return pageKey; 716 } 717 718 721 722 public boolean getIsEditOnSightDisabled(Database db, Integer siteNodeId) 723 { 724 logger.info("getIsEditOnSightDisabled:" + siteNodeId); 725 726 boolean isEditOnSightDisabled = false; 727 728 try 729 { 730 SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNodeId); 731 if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getDisableEditOnSight() != null) 732 { 733 if(latestSiteNodeVersionVO.getDisableEditOnSight().intValue() == NO.intValue()) 734 isEditOnSightDisabled = false; 735 else if(latestSiteNodeVersionVO.getDisableEditOnSight().intValue() == YES.intValue()) 736 isEditOnSightDisabled = true; 737 else if(latestSiteNodeVersionVO.getDisableEditOnSight().intValue() == INHERITED.intValue()) 738 { 739 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 740 if(parentSiteNode != null) 741 isEditOnSightDisabled = getIsEditOnSightDisabled(db, parentSiteNode.getSiteNodeId()); 742 } 743 } 744 745 } 746 catch(Exception e) 747 { 748 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 749 } 750 751 logger.info("getIsEditOnSightDisabled:" + isEditOnSightDisabled); 752 753 return isEditOnSightDisabled; 754 } 755 756 760 761 public boolean getIsPageProtected(Database db, Integer siteNodeId) 762 { 763 boolean isPageProtected = false; 764 765 try 766 { 767 SiteNodeVersionVO latestSiteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNodeId); 768 if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getIsProtected() != null) 769 { 770 if(latestSiteNodeVersionVO.getIsProtected().intValue() == NO.intValue()) 771 isPageProtected = false; 772 else if(latestSiteNodeVersionVO.getIsProtected().intValue() == YES.intValue()) 773 isPageProtected = true; 774 else if(latestSiteNodeVersionVO.getIsProtected().intValue() == INHERITED.intValue()) 775 { 776 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 777 if(parentSiteNode != null) 778 isPageProtected = getIsPageProtected(db, parentSiteNode.getSiteNodeId()); 779 } 780 } 781 782 } 783 catch(Exception e) 784 { 785 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 786 } 787 788 return isPageProtected; 789 } 790 791 792 795 796 public Integer getProtectedSiteNodeVersionId(Database db, Integer siteNodeId) 797 { 798 Integer protectedSiteNodeVersionId = null; 799 800 try 801 { 802 SiteNodeVersionVO siteNodeVersionVO = getLatestActiveSiteNodeVersionVO(db, siteNodeId); 803 logger.info("siteNodeId:" + siteNodeId); 804 if(siteNodeVersionVO != null && siteNodeVersionVO.getIsProtected() != null) 805 { 806 logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId() + ":" + siteNodeVersionVO.getIsProtected()); 807 if(siteNodeVersionVO.getIsProtected().intValue() == NO.intValue()) 808 protectedSiteNodeVersionId = null; 809 else if(siteNodeVersionVO.getIsProtected().intValue() == YES.intValue()) 810 protectedSiteNodeVersionId = siteNodeVersionVO.getId(); 811 else if(siteNodeVersionVO.getIsProtected().intValue() == INHERITED.intValue()) 812 { 813 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 814 if(parentSiteNode != null) 815 protectedSiteNodeVersionId = getProtectedSiteNodeVersionId(db, parentSiteNode.getSiteNodeId()); 816 } 817 } 818 819 } 820 catch(Exception e) 821 { 822 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 823 } 824 825 return protectedSiteNodeVersionId; 826 } 827 828 829 832 833 public Integer getProtectedSiteNodeVersionIdForPageCache(Database db, Integer siteNodeId) 834 { 835 Integer protectedSiteNodeVersionId = null; 836 837 try 838 { 839 SiteNodeVersionVO siteNodeVersionVO = this.getLatestActiveSiteNodeVersionVOForPageCache(db, siteNodeId); 840 logger.info("siteNodeId:" + siteNodeId); 841 if(siteNodeVersionVO != null && siteNodeVersionVO.getIsProtected() != null) 842 { 843 logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId() + ":" + siteNodeVersionVO.getIsProtected()); 844 if(siteNodeVersionVO.getIsProtected().intValue() == NO.intValue()) 845 protectedSiteNodeVersionId = null; 846 else if(siteNodeVersionVO.getIsProtected().intValue() == YES.intValue()) 847 protectedSiteNodeVersionId = siteNodeVersionVO.getId(); 848 else if(siteNodeVersionVO.getIsProtected().intValue() == INHERITED.intValue()) 849 { 850 SiteNodeVO parentSiteNode = this.getParentSiteNodeForPageCache(db, siteNodeId); 851 if(parentSiteNode != null) 852 protectedSiteNodeVersionId = getProtectedSiteNodeVersionIdForPageCache(db, parentSiteNode.getSiteNodeId()); 853 } 854 } 855 856 } 857 catch(Exception e) 858 { 859 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 860 } 861 862 return protectedSiteNodeVersionId; 863 } 864 865 866 869 870 public Integer getDisabledLanguagesSiteNodeVersionId(Database db, Integer siteNodeId) 871 { 872 Integer disabledLanguagesSiteNodeVersionId = null; 873 874 try 875 { 876 SiteNodeVersionVO siteNodeVersionVO = this.getLatestActiveSiteNodeVersionVOForPageCache(db, siteNodeId); 877 logger.info("siteNodeId:" + siteNodeId); 878 if(siteNodeVersionVO != null && siteNodeVersionVO.getDisableLanguages() != null) 879 { 880 logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId() + ":" + siteNodeVersionVO.getDisableLanguages()); 881 if(siteNodeVersionVO.getDisableLanguages().intValue() == NO.intValue()) 882 disabledLanguagesSiteNodeVersionId = null; 883 else if(siteNodeVersionVO.getDisableLanguages().intValue() == YES.intValue()) 884 disabledLanguagesSiteNodeVersionId = siteNodeVersionVO.getId(); 885 else if(siteNodeVersionVO.getDisableLanguages().intValue() == INHERITED.intValue()) 886 { 887 SiteNodeVO parentSiteNode = this.getParentSiteNodeForPageCache(db, siteNodeId); 888 if(parentSiteNode != null) 889 disabledLanguagesSiteNodeVersionId = getDisabledLanguagesSiteNodeVersionId(db, parentSiteNode.getSiteNodeId()); 890 } 891 } 892 893 } 894 catch(Exception e) 895 { 896 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled languages:" + e.getMessage(), e); 897 } 898 899 return disabledLanguagesSiteNodeVersionId; 900 } 901 902 905 906 public ContentVO getBoundContent(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, boolean useLanguageFallback, String availableServiceBindingName, boolean inheritParentBindings, DeliveryContext deliveryContext) throws SystemException, Exception 907 { 908 List contents = getBoundContents(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, availableServiceBindingName, inheritParentBindings, false, deliveryContext); 909 return (contents != null && contents.size() > 0) ? (ContentVO)contents.get(0) : null; 910 } 911 912 913 916 917 public ContentVO getBoundContent(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, boolean useLanguageFallback, String availableServiceBindingName, boolean inheritParentBindings, boolean includeFolders, DeliveryContext deliveryContext) throws SystemException, Exception 918 { 919 List contents = getBoundContents(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, availableServiceBindingName, inheritParentBindings, includeFolders, deliveryContext); 920 return (contents != null && contents.size() > 0) ? (ContentVO)contents.get(0) : null; 921 } 922 923 926 927 public ContentVO getBoundContent(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, boolean useLanguageFallback, String availableServiceBindingName, DeliveryContext deliveryContext) throws SystemException, Exception 928 { 929 logger.info("siteNodeId:" + siteNodeId); 930 logger.info("availableServiceBindingName:" + availableServiceBindingName); 931 List contents = getBoundContents(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, availableServiceBindingName, USE_INHERITANCE, true, deliveryContext); 932 return (contents != null && contents.size() > 0) ? (ContentVO)contents.get(0) : null; 933 } 934 935 938 939 public ContentVO getBoundContent(InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, boolean useLanguageFallback, String availableServiceBindingName, DeliveryContext deliveryContext) throws SystemException, Exception 940 { 941 List contents = null; 942 943 Database db = CastorDatabaseService.getDatabase(); 944 ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 945 946 beginTransaction(db); 947 948 try 949 { 950 contents = getBoundContents(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, availableServiceBindingName, USE_INHERITANCE, true, deliveryContext); 951 952 closeTransaction(db); 953 } 954 catch(Exception e) 955 { 956 logger.error("An error occurred so we should not complete the transaction:" + e, e); 957 rollbackTransaction(db); 958 throw new SystemException(e.getMessage()); 959 } 960 961 return (contents != null && contents.size() > 0) ? (ContentVO)contents.get(0) : null; 962 } 963 964 965 968 969 public List getBoundContents(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, boolean useLanguageFallback, String availableServiceBindingName, boolean inheritParentBindings, boolean includeFolders, DeliveryContext deliveryContext) throws SystemException, Exception 970 { 971 String boundContentsKey = "" + infoGluePrincipal.getName() + "_" + siteNodeId + "_" + languageId + "_" + useLanguageFallback + "_" + includeFolders + "_" + availableServiceBindingName + "_" + USE_INHERITANCE; 972 logger.info("boundContentsKey:" + boundContentsKey); 974 List boundContentVOList = (List )CacheController.getCachedObject("boundContentCache", boundContentsKey); 975 if(boundContentVOList != null) 976 { 977 logger.info("There was an cached content boundContentVOList:" + boundContentVOList.size()); 978 } 979 else 980 { 981 boundContentVOList = new ArrayList (); 982 983 logger.info("Coming in with:" + siteNodeId + " and " + availableServiceBindingName); 984 985 Integer metaInfoContentId = null; 986 if(availableServiceBindingName.equalsIgnoreCase("Meta information")) 987 { 988 SiteNode siteNode = getSiteNode(db, siteNodeId); 989 metaInfoContentId = siteNode.getMetaInfoContentId(); 990 } 991 992 if(metaInfoContentId != null && metaInfoContentId.intValue() > -1) 993 { 994 ContentVO contentVO = ContentDeliveryController.getContentDeliveryController().getContentVO(db, metaInfoContentId, deliveryContext); 995 boundContentVOList.add(contentVO); 996 } 997 else 998 { 999 AvailableServiceBindingVO availableServiceBindingVO = AvailableServiceBindingDeliveryController.getAvailableServiceBindingDeliveryController().getAvailableServiceBindingVO(availableServiceBindingName, db); 1000 1001 List qualifyerList = new ArrayList (); 1002 ServiceDefinitionVO serviceDefinitionVO = getInheritedServiceDefinition(qualifyerList, siteNodeId, availableServiceBindingVO, db, inheritParentBindings); 1003 if(serviceDefinitionVO != null) 1004 { 1005 String serviceClassName = serviceDefinitionVO.getClassName(); 1006 BaseService service = (BaseService)Class.forName(serviceClassName).newInstance(); 1007 1008 HashMap arguments = new HashMap (); 1009 arguments.put("method", "selectContentListOnIdList"); 1010 1011 arguments.put("arguments", qualifyerList); 1012 1013 List contents = service.selectMatchingEntities(arguments, db); 1014 1015 logger.info("Found bound contents:" + contents.size()); 1016 if(contents != null) 1017 { 1018 Iterator i = contents.iterator(); 1019 while(i.hasNext()) 1020 { 1021 ContentVO candidate = (ContentVO)i.next(); 1022 logger.info("candidate:" + candidate.getName()); 1023 Content candidateContent = (Content)getObjectWithId(ContentImpl.class, candidate.getId(), db); 1027 1028 logger.info("candidateContent:" + candidateContent.getName()); 1029 if(ContentDeliveryController.getContentDeliveryController().isValidContent(infoGluePrincipal, candidateContent, languageId, useLanguageFallback, includeFolders, db, deliveryContext)) 1030 { 1031 deliveryContext.addUsedContent("content_" + candidate.getId()); 1032 1033 boundContentVOList.add(candidate); 1034 } 1035 } 1036 } 1037 } 1038 } 1039 1040 CacheController.cacheObject("boundContentCache", boundContentsKey, boundContentVOList); 1041 } 1042 1043 return boundContentVOList; 1044 1045 } 1046 1047 1048 1049 1053 1054 public List getBoundFolderContents(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, String availableServiceBindingName, boolean searchRecursive, Integer maximumNumberOfLevels, String sortAttribute, String sortOrder, boolean useLanguageFallback, boolean includeFolders, DeliveryContext deliveryContext) throws SystemException, Exception 1055 { 1056 List folderContents = new ArrayList (); 1057 1058 deliveryContext.addUsedContent("selectiveCacheUpdateNonApplicable"); 1059 1060 logger.info("Coming in with:" + siteNodeId + " and " + availableServiceBindingName + " and " + searchRecursive + " and " + maximumNumberOfLevels + " and " + sortAttribute + " and " + sortOrder); 1061 1062 ContentVO contentVO = getBoundContent(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, availableServiceBindingName, includeFolders, deliveryContext); 1063 logger.info("contentVO:" + contentVO); 1064 1065 if(contentVO != null) 1066 { 1067 folderContents = ContentDeliveryController.getContentDeliveryController().getSortedChildContents(infoGluePrincipal, languageId, contentVO.getContentId(), siteNodeId, db, searchRecursive, maximumNumberOfLevels, sortAttribute, sortOrder, useLanguageFallback, includeFolders, deliveryContext); 1068 } 1069 1070 return folderContents; 1071 } 1072 1073 1074 1078 1079 public List getBoundFolderContents(Database db, InfoGluePrincipal infoGluePrincipal, Integer contentId, Integer languageId, boolean searchRecursive, Integer maximumNumberOfLevels, String sortAttribute, String sortOrder, boolean useLanguageFallback, boolean includeFolders, DeliveryContext deliveryContext) throws SystemException, Exception 1080 { 1081 List folderContents = new ArrayList (); 1082 1083 folderContents = ContentDeliveryController.getContentDeliveryController().getSortedChildContents(infoGluePrincipal, languageId, contentId, siteNodeId, db, searchRecursive, maximumNumberOfLevels, sortAttribute, sortOrder, useLanguageFallback, includeFolders, deliveryContext); 1084 1085 return folderContents; 1086 } 1087 1088 1089 1092 1093 public SiteNodeVO getBoundSiteNode(Database db, Integer siteNodeId, String availableServiceBindingName) throws SystemException, Exception 1094 { 1095 List siteNodes = getBoundSiteNodes(db, siteNodeId, availableServiceBindingName); 1096 return (siteNodes != null && siteNodes.size() > 0) ? (SiteNodeVO)siteNodes.get(0) : null; 1097 } 1098 1099 1100 1103 1104 public SiteNodeVO getBoundSiteNode(Database db, Integer siteNodeId, String availableServiceBindingName, int position) throws SystemException, Exception 1105 { 1106 List siteNodes = getBoundSiteNodes(db, siteNodeId, availableServiceBindingName); 1107 return (siteNodes != null && siteNodes.size() > position) ? (SiteNodeVO)siteNodes.get(position) : null; 1108 } 1109 1110 1111 1115 1116 public List getBoundSiteNodes(Database db, Integer siteNodeId, String availableServiceBindingName) throws SystemException, Exception 1117 { 1118 String boundSiteNodesKey = "" + siteNodeId + "_" + availableServiceBindingName + "_" + USE_INHERITANCE; 1119 logger.info("boundSiteNodesKey:" + boundSiteNodesKey); 1120 List boundSiteNodeVOList = (List )CacheController.getCachedObject("boundSiteNodeCache", boundSiteNodesKey); 1121 if(boundSiteNodeVOList != null) 1122 { 1123 logger.info("There was an cached content boundSiteNodeVOList:" + boundSiteNodeVOList.size()); 1124 } 1125 else 1126 { 1127 boundSiteNodeVOList = new ArrayList (); 1128 1129 AvailableServiceBindingVO availableServiceBindingVO = AvailableServiceBindingDeliveryController.getAvailableServiceBindingDeliveryController().getAvailableServiceBindingVO(availableServiceBindingName, db); 1130 1131 List qualifyerList = new ArrayList (); 1132 ServiceDefinitionVO serviceDefinitionVO = getInheritedServiceDefinition(qualifyerList, siteNodeId, availableServiceBindingVO, db, USE_INHERITANCE); 1133 1134 if(serviceDefinitionVO != null) 1135 { 1136 String serviceClassName = serviceDefinitionVO.getClassName(); 1137 BaseService service = (BaseService)Class.forName(serviceClassName).newInstance(); 1138 1139 HashMap arguments = new HashMap (); 1140 arguments.put("method", "selectSiteNodeListOnIdList"); 1141 1142 arguments.put("arguments", qualifyerList); 1143 1144 List siteNodes = service.selectMatchingEntities(arguments, db); 1145 1146 logger.info("Found bound siteNodes:" + siteNodes.size()); 1147 if(siteNodes != null) 1148 { 1149 Iterator i = siteNodes.iterator(); 1150 while(i.hasNext()) 1151 { 1152 SiteNodeVO candidate = (SiteNodeVO)i.next(); 1153 logger.info("candidate:" + candidate.getId()); 1154 if(isValidSiteNode(db, candidate.getId())) 1156 boundSiteNodeVOList.add(candidate); 1157 } 1158 } 1159 } 1160 1161 CacheController.cacheObject("boundSiteNodeCache", boundSiteNodesKey, boundSiteNodeVOList); 1162 } 1163 1164 return boundSiteNodeVOList; 1165 } 1166 1167 1168 1169 1172 1173 public String getPageUrl(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, Integer contentId, DeliveryContext deliveryContext) throws SystemException 1174 { 1175 String pageUrl = ""; 1176 1177 pageUrl = urlComposer.composePageUrl(db, infoGluePrincipal, siteNodeId, languageId, contentId, deliveryContext); 1178 1179 return pageUrl; 1180 } 1181 1182 1183 public String getPageUrlAfterLanguageChange(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, Integer contentId, DeliveryContext deliveryContext) throws SystemException 1184 { 1185 1191 return urlComposer.composePageUrlAfterLanguageChange(db, infoGluePrincipal, siteNodeId, languageId, contentId, deliveryContext); 1192 } 1193 1194 public String getPageAsDigitalAssetUrl(Database database, InfoGluePrincipal principal, Integer siteNodeId, Integer languageId, Integer contentId, DeliveryContext context, String fileSuffix) throws SystemException 1195 { 1196 String pageAsDigitalAssetUrl = null; 1197 1198 boolean fullUrl = context.getUseFullUrl(); 1199 context.setUseFullUrl(true); 1200 1201 boolean disableNiceUri = context.getDisableNiceUri(); 1202 context.setDisableNiceUri(true); 1203 1204 try 1205 { 1206 1209 String pageContent = null; 1210 String fileName = null; 1211 1212 int i = 0; 1213 String filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 1214 while(filePath != null) 1215 { 1216 try 1217 { 1218 if(pageContent == null) 1219 { 1220 String pageUrl = getPageUrl(database, principal, siteNodeId, languageId, contentId, context); 1221 logger.info("pageUrl:" + pageUrl); 1222 pageUrl = pageUrl.replaceAll("&", "&"); 1223 if(pageUrl.indexOf("&") > -1) 1224 { 1225 pageUrl = pageUrl + "&includeUsedEntities=true"; 1226 } 1227 else 1228 { 1229 pageUrl = pageUrl + "?includeUsedEntities=true"; 1230 } 1231 logger.info("pageUrl:" + pageUrl); 1232 1233 Map headers = new HashMap (); 1234 1235 Enumeration headersEnumeration = context.getHttpServletRequest().getHeaderNames(); 1236 while(headersEnumeration.hasMoreElements()) 1237 { 1238 String headerName = (String )headersEnumeration.nextElement(); 1239 String headerValue = (String )context.getHttpServletRequest().getHeader(headerName); 1240 logger.info(headerName + "=" + headerValue); 1241 headers.put(headerName, headerValue); 1242 } 1243 1244 headers.put("User-Agent", context.getHttpServletRequest().getHeader("User-Agent") + ";Java"); 1245 1246 HttpHelper helper = new HttpHelper(); 1247 pageContent = helper.getUrlContent(pageUrl, headers); 1248 logger.info("pageContent:" + pageContent); 1249 1250 int usedEntitiesIndex = pageContent.indexOf("<usedEntities>"); 1251 if(usedEntitiesIndex > -1) 1252 { 1253 int usedEntitiesEndIndex = pageContent.indexOf("</usedEntities>"); 1254 String usedEntities = pageContent.substring(usedEntitiesIndex + 14, usedEntitiesEndIndex); 1255 String [] usedEntitiesArray = usedEntities.split(","); 1256 for(int j=0; j < usedEntitiesArray.length; j++) 1257 { 1258 String entity = usedEntitiesArray[j]; 1259 logger.info("entity:" + entity); 1260 1261 if(entity.indexOf("content_") > -1) 1262 context.addUsedContent(entity.substring(8)); 1263 else if(entity.indexOf("contentVersion_") > -1) 1264 context.addUsedContentVersion(entity.substring(15)); 1265 else if(entity.indexOf("siteNode_") > -1) 1266 context.addUsedSiteNode(entity.substring(9)); 1267 else if(entity.indexOf("siteNodeVersion_") > -1) 1268 context.addUsedSiteNodeVersion(entity.substring(16)); 1269 } 1270 } 1271 fileName = "" + pageContent.hashCode() + (fileSuffix == null ? "" : "." + fileSuffix); 1272 logger.info("fileName:" + fileName); 1273 } 1274 1275 DigitalAssetDeliveryController.getDigitalAssetDeliveryController().dumpAttributeToFile(pageContent, fileName, filePath); 1276 } 1277 catch(Exception e) 1278 { 1279 logger.warn("An file could not be written:" + e.getMessage(), e); 1280 } 1281 1282 i++; 1283 filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 1284 } 1285 1286 SiteNode siteNode = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getSiteNode(database, siteNodeId); 1287 String dnsName = CmsPropertyHandler.getWebServerAddress(); 1288 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 1289 dnsName = siteNode.getRepository().getDnsName(); 1290 1291 pageAsDigitalAssetUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, context); 1292 } 1293 catch(Exception e) 1294 { 1295 logger.warn("An error occurred when we fetched the url which we wanted to persist as an digital asset: " + e.getMessage(), e); 1296 throw new SystemException("An error occurred when we fetched the url which we wanted to persist as an digital asset: " + e.getMessage(), e); 1297 } 1298 1299 context.setDisableNiceUri(disableNiceUri); 1300 context.setUseFullUrl(fullUrl); 1301 1302 return pageAsDigitalAssetUrl; 1303 } 1304 1305 1310 1311 public String getPagePath(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, Integer contentId, String bindingName, String attributeName, boolean useLanguageFallBack, DeliveryContext deliveryContext) throws SystemException, Exception 1312 { 1313 String pagePath = "/"; 1314 1315 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 1316 if(parentSiteNode != null) 1317 { 1318 pagePath = getPagePath(db, infoGluePrincipal, parentSiteNode.getId(), languageId, null, bindingName, attributeName, useLanguageFallBack, deliveryContext) + "/"; 1319 } 1320 1321 pagePath += this.getPageNavigationTitle(db, infoGluePrincipal, siteNodeId, languageId, contentId, bindingName, attributeName, useLanguageFallBack, deliveryContext, false); 1322 pagePath = pagePath.replaceAll(" ", "_"); 1323 1324 return pagePath; 1325 } 1326 1327 1328 1331 public String getPageBaseUrl(Database db) throws SystemException 1332 { 1333 String pageUrl = ""; 1334 1335 SiteNode siteNode = this.getSiteNode(db, this.siteNodeId); 1336 String dnsName = CmsPropertyHandler.getWebServerAddress(); 1337 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 1338 dnsName = siteNode.getRepository().getDnsName(); 1339 1340 pageUrl = urlComposer.composePageBaseUrl(dnsName); 1341 1342 return pageUrl; 1343 } 1344 1345 1346 1351 public String getPageNavigationTitle(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, Integer languageId, Integer contentId, String metaBindingName, String attributeName, boolean useLanguageFallback, DeliveryContext deliveryContext, boolean escapeHTML) throws SystemException, Exception 1352 { 1353 String navTitle = ""; 1354 1355 if(contentId == null || contentId.intValue() == -1) 1356 { 1357 ContentVO content = getBoundContent(db, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, metaBindingName, deliveryContext); 1358 if(content != null) 1359 navTitle = ContentDeliveryController.getContentDeliveryController().getContentAttribute(db, content.getContentId(), languageId, attributeName, siteNodeId, useLanguageFallback, deliveryContext, infoGluePrincipal, escapeHTML); 1360 } 1361 else 1362 { 1363 navTitle = ContentDeliveryController.getContentDeliveryController().getContentAttribute(db, contentId, languageId, attributeName, siteNodeId, useLanguageFallback, deliveryContext, infoGluePrincipal, escapeHTML); 1364 } 1365 1366 return navTitle; 1367 } 1368 1369 1370 public Integer getSiteNodeId(Database db, InfoGluePrincipal infogluePrincipal, Integer repositoryId, String path, String attributeName, Integer parentSiteNodeId, Integer languageId, DeliveryContext deliveryContext) throws SystemException, Exception 1371 { 1372 1378 if (repositoryId == null || repositoryId.intValue() == -1) 1379 { 1380 repositoryId = RepositoryDeliveryController.getRepositoryDeliveryController().getMasterRepository(db).getRepositoryId(); 1381 logger.info("RepositoryId not specifed - Resolved master repository to "+repositoryId); 1382 } 1383 1384 if (repositoryId == null) 1385 throw new SystemException("No repository given and unable to resolve master repository"); 1386 1387 List languages = LanguageDeliveryController.getLanguageDeliveryController().getAvailableLanguagesForRepository(db, repositoryId); 1388 1389 List siteNodes = new ArrayList (); 1390 1391 if(parentSiteNodeId == null || parentSiteNodeId.intValue() == -1) 1392 { 1393 SiteNodeVO rootSiteNodeVO = this.getRootSiteNode(db, repositoryId); 1394 siteNodes.add(rootSiteNodeVO); 1395 } 1396 else 1397 { 1398 siteNodes = this.getChildSiteNodes(db, parentSiteNodeId); 1399 } 1400 1401 1403 Iterator siteNodeIterator = siteNodes.iterator(); 1404 while (siteNodeIterator.hasNext()) 1405 { 1406 SiteNodeVO siteNodeVO = (SiteNodeVO)siteNodeIterator.next(); 1407 1408 if (path == null || path.length() == 0) 1409 { 1410 logger.info("Returning siteNode:" + siteNodeVO.getName()); 1411 return siteNodeVO.getId(); 1412 } 1413 1414 logger.info("Continued with siteNode: " + siteNodeVO.getName()); 1415 1417 if(siteNodeVO.getMetaInfoContentId() == null) 1418 throw new SystemException("The site node " + siteNodeVO.getName() + "(" + siteNodeVO.getId() + ") had no meta info. Fix this by editing the site node. Should never happen."); 1419 1420 ContentVO content = ContentDeliveryController.getContentDeliveryController().getContentVO(db, siteNodeVO.getMetaInfoContentId(), deliveryContext); 1421 if(content != null) 1422 { 1423 String pathCandidate = null; 1425 for (int i=0;i<languages.size();i++) 1426 { 1427 LanguageVO language = (LanguageVO) languages.get(i); 1428 1430 if(attributeName.equals("SiteNode.name")) 1431 pathCandidate = siteNodeVO.getName(); 1432 else 1433 { 1434 pathCandidate = ContentDeliveryController.getContentDeliveryController().getContentAttribute(db, content.getContentId(), language.getLanguageId(), attributeName, siteNodeVO.getSiteNodeId(), true, deliveryContext, infogluePrincipal, false); 1435 1436 if((pathCandidate == null || pathCandidate.equals("")) && !attributeName.equals(NAV_TITLE_ATTRIBUTE_NAME)) 1437 pathCandidate = ContentDeliveryController.getContentDeliveryController().getContentAttribute(db, content.getContentId(), language.getLanguageId(), NAV_TITLE_ATTRIBUTE_NAME, siteNodeVO.getSiteNodeId(), true, deliveryContext, infogluePrincipal, false); 1438 } 1439 1440 logger.info(attributeName + " ["+pathCandidate.trim()+"]==[" + path + "]"); 1441 if (pathCandidate != null && pathCandidate.toLowerCase().trim().equals(path.toLowerCase())) 1442 { 1443 return siteNodeVO.getSiteNodeId(); 1444 } 1445 } 1446 } 1447 else 1448 { 1449 throw new SystemException("You must run validation service in the management tool against this db - it needs to become up2date with the new model."); 1450 } 1451 } 1452 1453 1521 1522 return null; 1523 } 1524 1525 public String getPageNavigationPath(Database db, InfoGluePrincipal infogluePrincipal, Integer siteNodeId, Integer languageId, Integer contentId, DeliveryContext deliveryContext) throws SystemException, Exception 1526 { 1527 String path = "/"; 1528 1529 SiteNodeVO parentSiteNode = this.getParentSiteNode(db, siteNodeId); 1530 if (parentSiteNode != null) 1531 { 1532 path = getPageNavigationPath(db, infogluePrincipal, parentSiteNode.getId(), languageId, null, deliveryContext) + "/"; 1533 } 1534 else 1535 { 1536 return ""; 1537 } 1538 1539 String niceURIEncoding = CmsPropertyHandler.getNiceURIEncoding(); 1540 if(niceURIEncoding == null || niceURIEncoding.length() == 0) 1541 niceURIEncoding = "UTF-8"; 1542 1543 String attributeName = ViewPageFilter.attributeName; 1544 1545 String pathPart; 1546 1547 if(attributeName.equals("SiteNode.name")) 1548 { 1549 SiteNode siteNode = this.getSiteNode(db, siteNodeId); 1550 pathPart = siteNode.getName(); 1551 } 1552 else 1553 { 1554 pathPart = this.getPageNavigationTitle(db, infogluePrincipal, siteNodeId, languageId, null, META_INFO_BINDING_NAME, attributeName, true, deliveryContext, false); 1555 if((pathPart == null || pathPart.equals("")) && !attributeName.equals(NAV_TITLE_ATTRIBUTE_NAME)) 1556 pathPart = this.getPageNavigationTitle(db, infogluePrincipal, siteNodeId, languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, true, deliveryContext, false); 1557 } 1558 1559 path += URLEncoder.encode(pathPart, niceURIEncoding); 1560 1561 return path; 1562 } 1563 1564 1565 public static Integer getSiteNodeIdFromPath(Database db, InfoGluePrincipal infogluePrincipal, RepositoryVO repositoryVO, String [] path, String attributeName, Integer languageId, DeliveryContext deliveryContext) throws SystemException, Exception 1566 { 1567 Integer siteNodeId = null; 1568 URIMapperCache uriCache = URIMapperCache.getInstance(); 1569 1570 int idx = path.length; 1571 while (idx >= 0) 1572 { 1573 siteNodeId = uriCache.getCachedSiteNodeId(repositoryVO.getId(), path, idx); 1575 if (siteNodeId != null) 1576 break; 1577 idx = idx - 1; 1578 } 1579 1580 String repositoryPath = null; 1581 int pathStartIndex = repositoryVO.getDnsName().indexOf("path="); 1582 if(pathStartIndex != -1) 1583 { 1584 repositoryPath = repositoryVO.getDnsName().substring(pathStartIndex + 5); 1585 } 1586 1587 logger.info("repositoryPath:" + repositoryPath); 1588 logger.info("path:" + path.length); 1589 1590 if(repositoryPath != null && path.length > 0) 1591 { 1592 String [] repositoryPaths = repositoryPath.split("/"); 1593 String [] newPath = path; 1594 1595 logger.info("repositoryPaths:" + repositoryPaths.length); 1596 logger.info("newPath:" + newPath.length); 1597 1598 for(int repPathIndex = 0; repPathIndex < repositoryPaths.length; repPathIndex++) 1599 { 1600 String repPath = repositoryPaths[repPathIndex]; 1601 logger.info("repPath:" + repPath); 1602 if(path.length > repPathIndex) 1603 { 1604 logger.info("path:" + path[repPathIndex]); 1605 if(path[repPathIndex].equals(repPath)) 1606 { 1607 String [] tempNewPath = new String [newPath.length - 1]; 1608 for(int i=1; i<newPath.length; i++) 1609 tempNewPath[i-1] = newPath[i]; 1610 1611 newPath = tempNewPath; 1612 } 1613 } 1614 } 1615 path = newPath; 1616 } 1617 logger.info("new path:" + path.length); 1618 1619 for (int i = idx;i < path.length; i++) 1621 { 1622 if (i < 0) 1623 { 1624 siteNodeId = NodeDeliveryController.getNodeDeliveryController(null, null, null).getSiteNodeId(db, infogluePrincipal, repositoryVO.getId(), null, attributeName, null, languageId, deliveryContext); 1625 } 1626 else 1627 { 1628 siteNodeId = NodeDeliveryController.getNodeDeliveryController(null, null, null).getSiteNodeId(db, infogluePrincipal, repositoryVO.getId(), path[i], attributeName, siteNodeId, languageId, deliveryContext); 1629 } 1630 1631 if (siteNodeId != null) 1632 uriCache.addCachedSiteNodeId(repositoryVO.getId(), path, i+1, siteNodeId); 1633 } 1634 1635 return siteNodeId; 1636 } 1637 1638 public static Integer getSiteNodeIdFromPath(InfoGluePrincipal infogluePrincipal, RepositoryVO repositoryVO, String [] path, String attributeName, Integer languageId, DeliveryContext deliveryContext) throws SystemException, Exception 1639 { 1640 Integer siteNodeId = null; 1641 1642 Database db = CastorDatabaseService.getDatabase(); 1643 1644 beginTransaction(db); 1645 1646 try 1647 { 1648 URIMapperCache uriCache = URIMapperCache.getInstance(); 1649 1650 int numberOfPaths = path.length; 1651 while (numberOfPaths >= 0) 1652 { 1653 siteNodeId = uriCache.getCachedSiteNodeId(repositoryVO.getId(), path, numberOfPaths); 1655 1656 if (siteNodeId != null) 1657 break; 1658 1659 numberOfPaths = numberOfPaths - 1; 1660 } 1661 1662 String repositoryPath = null; 1663 int pathStartIndex = repositoryVO.getDnsName().indexOf("path="); 1664 if(pathStartIndex != -1) 1665 { 1666 repositoryPath = repositoryVO.getDnsName().substring(pathStartIndex + 5); 1667 } 1668 1669 logger.info("repositoryPath:" + repositoryPath); 1670 logger.info("path:" + path.length); 1671 1672 if(repositoryPath != null && path.length > 0) 1673 { 1674 String [] repositoryPaths = repositoryPath.split("/"); 1675 String [] newPath = path; 1676 1677 logger.info("repositoryPaths:" + repositoryPaths.length); 1678 logger.info("newPath:" + newPath.length); 1679 1680 for(int repPathIndex = 0; repPathIndex < repositoryPaths.length; repPathIndex++) 1681 { 1682 String repPath = repositoryPaths[repPathIndex]; 1683 logger.info("repPath:" + repPath); 1684 if(path.length > repPathIndex) 1685 { 1686 logger.info("path:" + path[repPathIndex]); 1687 if(path[repPathIndex].equals(repPath)) 1688 { 1689 String [] tempNewPath = new String [newPath.length - 1]; 1690 for(int i=1; i<newPath.length; i++) 1691 tempNewPath[i-1] = newPath[i]; 1692 1693 newPath = tempNewPath; 1694 } 1695 } 1696 } 1697 path = newPath; 1698 } 1699 logger.info("new path:" + path.length); 1700 1701 logger.info("numberOfPaths = "+numberOfPaths); 1702 for (int i = numberOfPaths;i < path.length; i++) 1703 { 1704 if (i < 0) 1705 { 1706 logger.info("Getting root node"); 1707 siteNodeId = NodeDeliveryController.getNodeDeliveryController(null, null, null).getSiteNodeId(db, infogluePrincipal, repositoryVO.getId(), null, attributeName, null, languageId, deliveryContext); 1708 } 1709 else 1710 { 1711 logger.info("Getting normal"); 1712 siteNodeId = NodeDeliveryController.getNodeDeliveryController(null, null, null).getSiteNodeId(db, infogluePrincipal, repositoryVO.getId(), path[i], attributeName, siteNodeId, languageId, deliveryContext); 1713 } 1714 1715 if (siteNodeId != null) 1716 uriCache.addCachedSiteNodeId(repositoryVO.getId(), path, i+1, siteNodeId); 1717 } 1718 1719 commitTransaction(db); 1720 } 1721 catch(Exception e) 1722 { 1723 logger.error("An error occurred so we should not complete the transaction:" + e, e); 1724 rollbackTransaction(db); 1725 throw new SystemException(e.getMessage()); 1726 } 1727 1728 return siteNodeId; 1729 } 1730 1731 1734 1735 public Integer getMetaInfoContentId(Database db, InfoGluePrincipal infoGluePrincipal, Integer siteNodeId, String metaBindingName, boolean inheritParentBindings, DeliveryContext deliveryContext) throws SystemException, Exception 1736 { 1737 ContentVO content = getBoundContent(db, infoGluePrincipal, siteNodeId, languageId, true, metaBindingName, inheritParentBindings, deliveryContext); 1738 if(content != null) 1739 return content.getContentId(); 1740 1741 return null; 1742 } 1743 1744 1745 1746 1750 1751 public static SiteNodeVO getRootSiteNode(Database db, String repositoryName) throws SystemException, Exception 1752 { 1753 if(repositoryName == null) 1754 { 1755 repositoryName = RepositoryDeliveryController.getRepositoryDeliveryController().getMasterRepository(db).getName(); 1756 logger.info("Fetched name of master repository as none were given:" + repositoryName); 1757 } 1758 1759 SiteNode siteNode = null; 1760 1761 logger.info("Fetching the root siteNode for the repository " + repositoryName); 1762 OQLQuery oql = db.getOQLQuery( "SELECT c FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl c WHERE is_undefined(c.parentSiteNode) AND c.repository.name = $1"); 1763 oql.bind(repositoryName); 1764 1765 QueryResults results = oql.execute(Database.ReadOnly); 1766 1767 if (results.hasMore()) 1768 { 1769 siteNode = (SiteNode)results.next(); 1770 logger.info("The root node was found:" + siteNode.getName()); 1771 } 1772 1773 results.close(); 1774 oql.close(); 1775 1776 logger.info("siteNode:" + siteNode); 1777 1778 return (siteNode == null) ? null : siteNode.getValueObject(); 1779 } 1780 1781 1782 1786 1787 public SiteNodeVO getRootSiteNode(Database db, Integer repositoryId) throws SystemException, Exception 1788 { 1789 SiteNodeVO siteNodeVO = null; 1790 1791 String key = "" + repositoryId; 1792 logger.info("key in getRootSiteNode:" + key); 1793 siteNodeVO = (SiteNodeVO)CacheController.getCachedObject("rootSiteNodeCache", key); 1794 if(siteNodeVO != null) 1795 { 1796 logger.info("There was an cached master root siteNode:" + siteNodeVO.getName()); 1797 } 1798 else 1799 { 1800 if(repositoryId == null) 1801 { 1802 repositoryId = RepositoryDeliveryController.getRepositoryDeliveryController().getMasterRepository(db).getRepositoryId(); 1803 logger.info("Fetched name of master repository as none were given:" + repositoryId); 1804 } 1805 1806 logger.info("Fetching the root siteNode for the repository " + repositoryId); 1807 OQLQuery oql = db.getOQLQuery( "SELECT c FROM org.infoglue.cms.entities.structure.impl.simple.SiteNodeImpl c WHERE is_undefined(c.parentSiteNode) AND c.repository = $1"); 1808 oql.bind(repositoryId); 1809 1810 QueryResults results = oql.execute(Database.ReadOnly); 1811 1812 if (results.hasMore()) 1813 { 1814 siteNodeVO = ((SiteNode)results.next()).getValueObject(); 1815 logger.info("The root node was found:" + siteNodeVO.getName()); 1816 } 1817 1818 results.close(); 1819 oql.close(); 1820 1821 logger.info("siteNodeVO:" + siteNodeVO); 1822 1823 CacheController.cacheObject("rootSiteNodeCache", key, siteNodeVO); 1824 } 1825 1826 return siteNodeVO; 1827 } 1828 1829 1830 1831 1834 1835 public List getChildSiteNodes(Database db, Integer siteNodeId) throws SystemException, Exception 1836 { 1837 1839 if(siteNodeId == null) 1840 { 1841 return null; 1842 } 1843 1844 String key = "" + siteNodeId; 1845 logger.info("key in getChildSiteNodes:" + key); 1846 List siteNodeVOList = (List )CacheController.getCachedObject("childSiteNodesCache", key); 1847 if(siteNodeVOList != null) 1848 { 1849 logger.info("There was a cached list of child sitenodes:" + siteNodeVOList.size()); 1850 } 1851 else 1852 { 1853 siteNodeVOList = new ArrayList (); 1854 1855 OQLQuery oql = db.getOQLQuery( "SELECT s FROM org.infoglue.cms.entities.structure.impl.simple.SmallSiteNodeImpl s WHERE s.parentSiteNode.siteNodeId = $1 ORDER BY s.siteNodeId"); 1856 oql.bind(siteNodeId); 1857 1858 QueryResults results = oql.execute(Database.ReadOnly); 1859 1860 while (results.hasMore()) 1861 { 1862 SiteNode siteNode = (SiteNode)results.next(); 1863 1864 if(isValidSiteNode(siteNode, db)) 1865 siteNodeVOList.add(siteNode.getValueObject()); 1866 } 1867 1868 results.close(); 1869 oql.close(); 1870 1871 CacheController.cacheObject("childSiteNodesCache", key, siteNodeVOList); 1872 } 1873 1874 1876 return siteNodeVOList; 1877 } 1878 1879 1880 1883 1884 private List getBindingQualifyers(Integer serviceBindingId, Database db) throws SystemException, Bug, Exception 1885 { 1886 List qualifyers = new ArrayList (); 1887 1888 OQLQuery oql = db.getOQLQuery( "SELECT q FROM org.infoglue.cms.entities.structure.impl.simple.QualifyerImpl q WHERE q.serviceBinding.serviceBindingId = $1 ORDER BY q.sortOrder"); 1889 oql.bind(serviceBindingId); 1890 1891 QueryResults results = oql.execute(Database.ReadOnly); 1892 while(results.hasMore()) 1893 { 1894 Qualifyer qualifyer = (Qualifyer)results.next(); 1895 qualifyers.add(qualifyer); 1896 } 1897 1898 results.close(); 1899 oql.close(); 1900 1901 return qualifyers; 1902 } 1903 1904 1905 1908 1909 private boolean isValidOnDates(Date publishDate, Date expireDate) 1910 { 1911 boolean isValid = true; 1912 Date now = new Date (); 1913 1914 if(publishDate.after(now) || expireDate.before(now)) 1915 isValid = false; 1916 1917 return isValid; 1918 } 1919 1920 1924 1925 public boolean isValidSiteNode(Database db, Integer siteNodeId) throws Exception 1926 { 1927 boolean isValidSiteNode = false; 1928 1929 SiteNode siteNode = (SiteNode)getObjectWithId(SiteNodeImpl.class, siteNodeId, db); 1930 isValidSiteNode = isValidSiteNode(siteNode, db); 1931 1932 return isValidSiteNode; 1933 } 1934 1935 1939 1940 public boolean isValidSiteNode(SiteNode siteNode, Database db) throws Exception 1941 { 1942 boolean isValidContent = false; 1943 1944 if(isValidOnDates(siteNode.getPublishDateTime(), siteNode.getExpireDateTime())) 1945 { 1946 if(this.getLatestActiveSiteNodeVersion(siteNode.getId(), db) != null) 1947 isValidContent = true; 1948 1958 } 1959 1960 if(isValidContent && !siteNode.getExpireDateTime().before(new Date ())) 1961 { 1962 Date expireDateTimeCandidate = siteNode.getExpireDateTime(); 1963 if(CacheController.expireDateTime == null || expireDateTimeCandidate.before(CacheController.expireDateTime)) 1964 { 1965 CacheController.expireDateTime = expireDateTimeCandidate; 1966 } 1967 } 1968 else if(siteNode.getPublishDateTime().after(new Date ())) { 1970 Date publishDateTimeCandidate = siteNode.getPublishDateTime(); 1971 if(CacheController.publishDateTime == null || publishDateTimeCandidate.after(CacheController.publishDateTime)) 1972 { 1973 CacheController.publishDateTime = publishDateTimeCandidate; 1974 } 1975 } 1976 1977 return isValidContent; 1978 } 1979 1980 1983 1984 private List sortQualifyers(Collection qualifyers) 1985 { 1986 List sortedQualifyers = new ArrayList (); 1987 1988 try 1989 { 1990 Iterator iterator = qualifyers.iterator(); 1991 while(iterator.hasNext()) 1992 { 1993 Qualifyer qualifyer = (Qualifyer)iterator.next(); 1994 int index = 0; 1995 Iterator sortedListIterator = sortedQualifyers.iterator(); 1996 while(sortedListIterator.hasNext()) 1997 { 1998 Qualifyer sortedQualifyer = (Qualifyer)sortedListIterator.next(); 1999 if(sortedQualifyer.getSortOrder().intValue() > qualifyer.getSortOrder().intValue()) 2000 { 2001 break; 2002 } 2003 index++; 2004 } 2005 sortedQualifyers.add(index, qualifyer); 2006 2007 } 2008 } 2009 catch(Exception e) 2010 { 2011 logger.warn("The sorting of qualifyers failed:" + e.getMessage(), e); 2012 } 2013 2014 return sortedQualifyers; 2015 } 2016 2017} | Popular Tags |