1 23 24 package org.infoglue.deliver.controllers.kernel.impl.simple; 25 26 import java.awt.Color ; 27 import java.awt.Font ; 28 import java.io.File ; 29 import java.io.PrintWriter ; 30 import java.io.StringWriter ; 31 import java.io.UnsupportedEncodingException ; 32 import java.net.URLEncoder ; 33 import java.security.Principal ; 34 import java.text.NumberFormat ; 35 import java.util.ArrayList ; 36 import java.util.Collection ; 37 import java.util.Collections ; 38 import java.util.Enumeration ; 39 import java.util.HashMap ; 40 import java.util.Iterator ; 41 import java.util.List ; 42 import java.util.Locale ; 43 import java.util.Map ; 44 import java.util.Set ; 45 import java.util.Vector ; 46 47 import javax.servlet.http.Cookie ; 48 import javax.servlet.http.HttpServletRequest ; 49 50 import org.apache.log4j.Logger; 51 import org.apache.oro.text.regex.MalformedPatternException; 52 import org.apache.oro.text.regex.MatchResult; 53 import org.apache.oro.text.regex.Pattern; 54 import org.apache.oro.text.regex.PatternCompiler; 55 import org.apache.oro.text.regex.PatternMatcher; 56 import org.apache.oro.text.regex.PatternMatcherInput; 57 import org.apache.oro.text.regex.Perl5Compiler; 58 import org.apache.oro.text.regex.Perl5Matcher; 59 import org.dom4j.Document; 60 import org.dom4j.Element; 61 import org.exolab.castor.jdo.Database; 62 import org.infoglue.cms.applications.common.VisualFormatter; 63 import org.infoglue.cms.controllers.kernel.impl.simple.AccessRightController; 64 import org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService; 65 import org.infoglue.cms.controllers.kernel.impl.simple.CategoryConditions; 66 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 67 import org.infoglue.cms.controllers.kernel.impl.simple.ExtendedSearchController; 68 import org.infoglue.cms.controllers.kernel.impl.simple.GroupControllerProxy; 69 import org.infoglue.cms.controllers.kernel.impl.simple.GroupPropertiesController; 70 import org.infoglue.cms.controllers.kernel.impl.simple.InfoGluePrincipalControllerProxy; 71 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy; 72 import org.infoglue.cms.controllers.kernel.impl.simple.RolePropertiesController; 73 import org.infoglue.cms.controllers.kernel.impl.simple.UserControllerProxy; 74 import org.infoglue.cms.controllers.kernel.impl.simple.WorkflowController; 75 import org.infoglue.cms.entities.content.Content; 76 import org.infoglue.cms.entities.content.ContentVO; 77 import org.infoglue.cms.entities.content.ContentVersionVO; 78 import org.infoglue.cms.entities.management.ContentTypeAttribute; 79 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 80 import org.infoglue.cms.entities.management.LanguageVO; 81 import org.infoglue.cms.entities.structure.SiteNode; 82 import org.infoglue.cms.entities.structure.SiteNodeVO; 83 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 84 import org.infoglue.cms.exception.SystemException; 85 import org.infoglue.cms.security.AuthenticationModule; 86 import org.infoglue.cms.security.InfoGlueGroup; 87 import org.infoglue.cms.security.InfoGluePrincipal; 88 import org.infoglue.cms.security.InfoGlueRole; 89 import org.infoglue.cms.util.CmsPropertyHandler; 90 import org.infoglue.cms.util.DesEncryptionHelper; 91 import org.infoglue.cms.util.dom.DOMBuilder; 92 import org.infoglue.cms.util.sorters.SiteNodeComparator; 93 import org.infoglue.deliver.applications.databeans.ComponentProperty; 94 import org.infoglue.deliver.applications.databeans.DatabaseWrapper; 95 import org.infoglue.deliver.applications.databeans.DeliveryContext; 96 import org.infoglue.deliver.applications.databeans.WebPage; 97 import org.infoglue.deliver.applications.filters.FilterConstants; 98 import org.infoglue.deliver.controllers.kernel.URLComposer; 99 import org.infoglue.deliver.invokers.DecoratedComponentBasedHTMLPageInvoker; 100 import org.infoglue.deliver.util.BrowserBean; 101 import org.infoglue.deliver.util.CacheController; 102 import org.infoglue.deliver.util.HttpHelper; 103 import org.infoglue.deliver.util.MathHelper; 104 import org.infoglue.deliver.util.ObjectConverter; 105 import org.infoglue.deliver.util.VelocityTemplateProcessor; 106 import org.infoglue.deliver.util.charts.ChartHelper; 107 import org.infoglue.deliver.util.forms.FormHelper; 108 import org.infoglue.deliver.util.graphics.AdvancedImageRenderer; 109 import org.infoglue.deliver.util.graphics.ColorHelper; 110 import org.infoglue.deliver.util.graphics.FOPHelper; 111 import org.infoglue.deliver.util.graphics.FontHelper; 112 import org.infoglue.deliver.util.graphics.ImageRenderer; 113 import org.infoglue.deliver.util.rss.RssHelper; 114 import org.infoglue.deliver.util.webservices.InfoGlueWebServices; 115 import org.infoglue.deliver.util.webservices.WebServiceHelper; 116 117 122 123 public class BasicTemplateController implements TemplateController 124 { 125 private final static Logger logger = Logger.getLogger(BasicTemplateController.class.getName()); 126 127 private URLComposer urlComposer = null; 128 129 public static final String META_INFO_BINDING_NAME = "Meta information"; 130 public static final String TEMPLATE_ATTRIBUTE_NAME = "Template"; 131 public static final String TITLE_ATTRIBUTE_NAME = "Title"; 132 public static final String NAV_TITLE_ATTRIBUTE_NAME = "NavigationTitle"; 133 139 protected static final boolean USE_LANGUAGE_FALLBACK = true; 140 protected static final boolean DO_NOT_USE_LANGUAGE_FALLBACK = false; 141 protected static final boolean USE_INHERITANCE = true; 142 protected static final boolean DO_NOT_USE_INHERITANCE = false; 143 144 protected Integer siteNodeId = null; 145 protected Integer languageId = null; 146 protected Integer contentId = null; 147 148 protected HttpServletRequest request = null; 149 protected DeliveryContext deliveryContext = null; 150 151 protected BrowserBean browserBean = null; 152 153 protected NodeDeliveryController nodeDeliveryController = null; 154 protected ContentDeliveryController contentDeliveryController = null; 155 protected IntegrationDeliveryController integrationDeliveryController = null; 156 157 protected ComponentLogic componentLogic = null; 158 159 protected InfoGluePrincipal infoGluePrincipal = null; 160 161 protected Map templateLogicContext = new HashMap (); 164 protected boolean persistedContext = false; 165 166 protected DatabaseWrapper databaseWrapper = null; 167 168 private boolean threatFoldersAsContents = false; 169 170 174 175 public BasicTemplateController(DatabaseWrapper databaseWrapper, InfoGluePrincipal infoGluePrincipal) 176 { 177 this.databaseWrapper = databaseWrapper; 178 this.infoGluePrincipal = infoGluePrincipal; 179 this.urlComposer = URLComposer.getURLComposer(); 180 } 181 182 183 186 187 public Database getDatabase() throws SystemException 188 { 189 if(this.databaseWrapper.getDatabase() == null || this.databaseWrapper.getDatabase().isClosed() || !this.databaseWrapper.getDatabase().isActive()) 190 { 191 beginTransaction(); 192 } 193 194 return this.databaseWrapper.getDatabase(); 195 } 196 197 public DatabaseWrapper getDatabaseWrapper() 198 { 199 return databaseWrapper; 200 } 201 202 205 206 public void commitDatabase() throws SystemException 207 { 208 logger.debug("Committing database in the middle of the run...."); 209 try 210 { 211 this.databaseWrapper.getDatabase().commit(); 212 this.databaseWrapper.getDatabase().close(); 213 logger.info("Closed transaction..."); 214 this.databaseWrapper.setDatabase(CastorDatabaseService.getDatabase()); 215 beginTransaction(); 217 logger.info("Begun a new transaction..."); 218 } 219 catch(Exception e) 220 { 221 e.printStackTrace(); 222 throw new SystemException("An error occurred when we tried to commit an transaction. Reason:" + e.getMessage(), e); 223 } 224 } 225 226 229 230 public void closeTransaction() throws SystemException 231 { 232 try 233 { 234 this.databaseWrapper.getDatabase().commit(); 235 logger.info("Closed transaction..."); 237 } 238 catch(Exception e) 239 { 240 e.printStackTrace(); 241 throw new SystemException("An error occurred when we tried to commit an transaction. Reason:" + e.getMessage(), e); 242 } 243 } 244 245 248 249 private void beginTransaction() throws SystemException 250 { 251 try 252 { 253 this.databaseWrapper.getDatabase().begin(); 254 logger.info("Started new transaction..."); 255 } 256 catch(Exception e) 257 { 258 e.printStackTrace(); 259 throw new SystemException("An error occurred when we tried to begin an transaction. Reason:" + e.getMessage(), e); 260 } 261 } 262 263 264 265 266 270 public void addToContext(String name, Object object) 271 { 272 templateLogicContext.put(name, object); 273 } 274 275 284 protected void addToContext(Map context) 285 { 286 templateLogicContext.putAll(context); 287 } 288 289 292 public Object getFromContext(String name) 293 { 294 return templateLogicContext.get(name); 295 } 296 297 300 301 public void setStandardRequestParameters(Integer siteNodeId, Integer languageId, Integer contentId) 302 { 303 this.siteNodeId = siteNodeId; 304 this.languageId = languageId; 305 this.contentId = contentId; 306 } 307 308 311 312 public void setHttpRequest(HttpServletRequest request) 313 { 314 this.request = request; 315 } 316 317 318 321 322 public void setBrowserBean(BrowserBean browserBean) 323 { 324 this.browserBean = browserBean; 325 } 326 327 330 331 public String getTemplateAttributeName() 332 { 333 return TEMPLATE_ATTRIBUTE_NAME; 334 } 335 336 339 340 public Integer getSiteNodeId() 341 { 342 return this.siteNodeId; 343 } 344 345 348 349 public Integer getLanguageId() 350 { 351 return this.languageId; 352 } 353 354 355 356 359 360 public Integer getContentId() 361 { 362 return this.contentId; 363 } 364 365 368 369 public ComponentLogic getComponentLogic() 370 { 371 return this.componentLogic; 372 } 373 374 377 378 public void setComponentLogic(ComponentLogic componentLogic) 379 { 380 this.componentLogic = componentLogic; 381 } 382 383 384 387 388 public VisualFormatter getVisualFormatter() 389 { 390 return new VisualFormatter(); 391 } 392 393 396 397 public ColorHelper getColorHelper() 398 { 399 return new ColorHelper(); 400 } 401 402 405 406 public FormHelper getFormHelper() 407 { 408 return new FormHelper(); 409 } 410 411 414 415 public FontHelper getFontHelper() 416 { 417 return new FontHelper(); 418 } 419 420 423 424 public MathHelper getMathHelper() 425 { 426 return new MathHelper(); 427 } 428 429 432 433 public HttpHelper getHTTPHelper() 434 { 435 return new HttpHelper(); 436 } 437 438 441 442 public ChartHelper getChartHelper() 443 { 444 return new ChartHelper(this); 445 } 446 447 450 451 public WebServiceHelper getWebServiceHelper() 452 { 453 return new WebServiceHelper(); 454 } 455 456 459 460 public InfoGlueWebServices getInfoGlueWebServiceHelper() 461 { 462 return new InfoGlueWebServices(); 463 } 464 465 468 public NumberFormat getNumberFormatHelper() throws SystemException 469 { 470 return NumberFormat.getInstance ( 471 LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), this.languageId) 472 ); 473 } 474 475 478 479 public DesEncryptionHelper getDesEncryptionHelper() 480 { 481 return new DesEncryptionHelper(); 482 } 483 484 487 488 public RssHelper getRssHelper() 489 { 490 return new RssHelper(); 491 } 492 493 496 497 public ObjectConverter getObjectConverter() 498 { 499 return new ObjectConverter(); 500 } 501 502 503 506 public Map getContentAttributes(Integer contentId) 507 { 508 Map result = new HashMap (); 509 ContentTypeDefinitionVO typeDefinitionVO = getContentTypeDefinitionVO(contentId); 510 List contentAttributes = getContentAttributes(typeDefinitionVO.getSchemaValue()); 511 512 for(Iterator i=contentAttributes.iterator();i.hasNext();) 513 { 514 ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute) i.next(); 515 String name = contentTypeAttribute.getName(); 516 result.put(name, getContentAttribute(contentId, name)); 517 } 518 return result; 519 } 520 521 524 public Map getParsedContentAttributes(Integer contentId) 525 { 526 Map result = new HashMap (); 527 ContentTypeDefinitionVO typeDefinitionVO = getContentTypeDefinitionVO(contentId); 528 List contentAttributes = getContentAttributes(typeDefinitionVO.getSchemaValue()); 529 530 for(Iterator i=contentAttributes.iterator();i.hasNext();) 531 { 532 ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute) i.next(); 533 String name = contentTypeAttribute.getName(); 534 result.put(name, getParsedContentAttribute(contentId, name)); 535 } 536 return result; 537 } 538 539 540 543 544 public ContentVO getContent() 545 { 546 ContentVO content = null; 547 548 try 549 { 550 content = ContentDeliveryController.getContentDeliveryController().getContentVO(getDatabase(), this.contentId, this.deliveryContext); 551 } 552 catch(Exception e) 553 { 554 logger.warn("An error occurred trying to get the current content:" + e.getMessage(), e); 555 } 556 557 return content; 558 } 559 560 563 564 public ContentVO getContent(Integer contentId) 565 { 566 ContentVO content = null; 567 568 try 569 { 570 content = ContentDeliveryController.getContentDeliveryController().getContentVO(getDatabase(), contentId, this.deliveryContext); 571 } 572 catch(Exception e) 573 { 574 logger.warn("An error occurred trying to get the content with id " + contentId + ":" + e.getMessage(), e); 575 } 576 577 return content; 578 } 579 580 583 584 public ContentVersionVO getContentVersion(Integer contentId) 585 { 586 ContentVersionVO contentVersionVO = null; 587 588 try 589 { 590 contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, true, this.deliveryContext, this.infoGluePrincipal); 591 } 592 catch(Exception e) 593 { 594 logger.warn("An error occurred trying to get the contentVersion with contentId " + contentId + ":" + e.getMessage(), e); 595 } 596 597 return contentVersionVO; 598 } 599 600 603 604 public ContentVersionVO getContentVersion(Integer contentId, Integer languageId, boolean useLanguageFallback) 605 { 606 ContentVersionVO contentVersionVO = null; 607 608 try 609 { 610 contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, languageId, useLanguageFallback, this.deliveryContext, this.infoGluePrincipal); 611 } 612 catch(Exception e) 613 { 614 logger.warn("An error occurred trying to get the contentVersion with contentId " + contentId + ":" + e.getMessage(), e); 615 } 616 617 return contentVersionVO; 618 } 619 620 623 public InfoGluePrincipal getPrincipal() 624 { 625 return this.infoGluePrincipal; 626 } 627 628 631 public List getAllRoles() throws Exception 632 { 633 return RoleControllerProxy.getController(this.getDatabase()).getAllRoles(); 634 } 635 636 639 public List getAllGroups() throws Exception 640 { 641 return GroupControllerProxy.getController(this.getDatabase()).getAllGroups(); 642 } 643 644 649 650 public InfoGluePrincipal getPrincipal(String userName) 651 { 652 if(userName == null || userName.equals("")) 653 return null; 654 655 InfoGluePrincipal infoGluePrincipal = null; 656 657 try 658 { 659 infoGluePrincipal = UserControllerProxy.getController(getDatabase()).getUser(userName); 660 } 661 catch(Exception e) 662 { 663 logger.warn("An error occurred when getting principal:" + e.getMessage(), e); 664 } 665 666 return infoGluePrincipal; 667 } 668 669 670 675 676 public String getPrincipalPropertyValue(String propertyName) 677 { 678 return getPrincipalPropertyValue(propertyName, true); 679 } 680 681 686 687 public Map getPrincipalPropertyHashValues(String propertyName) 688 { 689 return getPrincipalPropertyHashValues(propertyName, true); 690 } 691 692 697 698 public String getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String propertyName) 699 { 700 return getPrincipalPropertyValue(infoGluePrincipal, propertyName, true); 701 } 702 703 708 709 public Map getPrincipalPropertyHashValues(InfoGluePrincipal infoGluePrincipal, String propertyName) 710 { 711 return getPrincipalPropertyHashValues(infoGluePrincipal, propertyName, true); 712 } 713 714 715 720 721 public String getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String propertyName, boolean escapeSpecialCharacters) 722 { 723 String value = ""; 724 725 try 726 { 727 value = getPrincipalPropertyValue(infoGluePrincipal, propertyName, escapeSpecialCharacters, false); 729 } 730 catch(Exception e) 731 { 732 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 733 } 734 735 return value; 736 } 737 738 743 744 public String getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String propertyName, boolean escapeSpecialCharacters, boolean findLargestValue) 745 { 746 String value = ""; 747 748 try 749 { 750 value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters, findLargestValue); 752 } 753 catch(Exception e) 754 { 755 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 756 } 757 758 return value; 759 } 760 761 762 767 768 public String getPrincipalPropertyValue(String propertyName, boolean escapeSpecialCharacters) 769 { 770 String value = ""; 771 772 try 773 { 774 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 775 value = getPrincipalPropertyValue(propertyName, escapeSpecialCharacters, false); 777 } 778 catch(Exception e) 779 { 780 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 781 } 782 783 return value; 784 } 785 786 787 792 793 public String getPrincipalPropertyValue(String propertyName, boolean escapeSpecialCharacters, boolean findLargestValue) 794 { 795 String value = ""; 796 797 try 798 { 799 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 800 value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters, findLargestValue); 802 } 803 catch(Exception e) 804 { 805 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 806 } 807 808 return value; 809 } 810 811 812 817 818 public Map getPrincipalPropertyHashValues(InfoGluePrincipal infoGluePrincipal, String propertyName, boolean escapeSpecialCharacters) 819 { 820 Map value = new HashMap (); 821 822 try 823 { 824 value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyHashValues(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters); 826 } 827 catch(Exception e) 828 { 829 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 830 } 831 832 return value; 833 } 834 835 836 841 842 public Map getPrincipalPropertyHashValues(String propertyName, boolean escapeSpecialCharacters) 843 { 844 Map value = new HashMap (); 845 846 try 847 { 848 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 849 value = getPrincipalPropertyHashValues(this.infoGluePrincipal, propertyName, escapeSpecialCharacters); 851 } 852 catch(Exception e) 853 { 854 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 855 } 856 857 return value; 858 } 859 860 861 public boolean getHasPrincipalGroup(InfoGluePrincipal infoGluePrincipal, String groupName) 862 { 863 boolean isValid = false; 864 Iterator groupsIterator = infoGluePrincipal.getGroups().iterator(); 865 while(groupsIterator.hasNext()) 866 { 867 InfoGlueGroup infoglueGroup = (InfoGlueGroup)groupsIterator.next(); 868 if(infoglueGroup.getName().equalsIgnoreCase(groupName)) 869 { 870 isValid = true; 871 } 872 } 873 874 return isValid; 875 } 876 877 880 881 public List getPrincipalGroupRelatedContents(String groupName, String propertyName) 882 { 883 return getPrincipalGroupRelatedContents(this.infoGluePrincipal, groupName, propertyName); 884 } 885 886 889 890 public List getPrincipalGroupRelatedContents(InfoGluePrincipal infoGluePrincipal, String groupName, String propertyName) 891 { 892 List contents = new ArrayList (); 893 894 try 895 { 896 if(getHasPrincipalGroup(infoGluePrincipal, groupName)) 897 contents = GroupPropertiesController.getController().getRelatedContents(groupName, this.languageId, propertyName); 898 } 899 catch(Exception e) 900 { 901 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 902 } 903 904 return contents; 905 } 906 907 910 911 public List getPrincipalGroupRelatedPages(String groupName, String propertyName) 912 { 913 return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName); 914 } 915 916 919 920 public List getPrincipalGroupRelatedPages(String groupName, String propertyName, boolean escapeHTML) 921 { 922 return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName, escapeHTML); 923 } 924 925 926 929 930 public List getPrincipalGroupRelatedPages(InfoGluePrincipal infoGluePrincipal, String groupName, String propertyName) 931 { 932 return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName, false); 933 } 934 935 938 939 public List getPrincipalGroupRelatedPages(InfoGluePrincipal infoGluePrincipal, String groupName, String propertyName, boolean escapeHTML) 940 { 941 List pages = new ArrayList (); 942 943 try 944 { 945 if(getHasPrincipalGroup(infoGluePrincipal, groupName)) 946 { 947 List siteNodeVOList = GroupPropertiesController.getController().getRelatedSiteNodes(groupName, this.languageId, propertyName); 948 949 Iterator i = siteNodeVOList.iterator(); 950 while(i.hasNext()) 951 { 952 SiteNodeVO siteNodeVO = (SiteNodeVO)i.next(); 953 try 954 { 955 WebPage webPage = new WebPage(); 956 webPage.setSiteNodeId(siteNodeVO.getSiteNodeId()); 957 webPage.setLanguageId(this.languageId); 958 webPage.setContentId(null); 959 webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML)); 960 webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext)); 961 webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext)); 962 pages.add(webPage); 963 } 964 catch(Exception e) 965 { 966 logger.info("An error occurred when looking up one of the related pages:" + e.getMessage(), e); 967 } 968 } 969 } 970 } 971 catch(Exception e) 972 { 973 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 974 } 975 976 return pages; 977 } 978 979 982 983 public List getPrincipalGroupCategories(String groupName, String propertyName) 984 { 985 return getPrincipalGroupCategories(this.infoGluePrincipal, groupName, propertyName); 986 } 987 988 991 992 public List getPrincipalGroupCategories(InfoGluePrincipal infoGluePrincipal, String groupName, String propertyName) 993 { 994 List categories = new ArrayList (); 995 996 try 997 { 998 if(getHasPrincipalGroup(infoGluePrincipal, groupName)) 999 categories = GroupPropertiesController.getController().getRelatedCategories(groupName, this.languageId, propertyName); 1000 } 1001 catch(Exception e) 1002 { 1003 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 1004 } 1005 1006 return categories; 1007 } 1008 1009 1010 public boolean getHasPrincipalRole(InfoGluePrincipal infoGluePrincipal, String roleName) 1011 { 1012 boolean isValid = false; 1013 Iterator groupsIterator = infoGluePrincipal.getRoles().iterator(); 1014 while(groupsIterator.hasNext()) 1015 { 1016 InfoGlueRole infoglueRole = (InfoGlueRole)groupsIterator.next(); 1017 if(infoglueRole.getName().equalsIgnoreCase(roleName)) 1018 { 1019 isValid = true; 1020 } 1021 } 1022 1023 return isValid; 1024 } 1025 1026 1029 1030 public List getPrincipalRoleRelatedContents(String roleName, String propertyName) 1031 { 1032 return getPrincipalRoleRelatedContents(this.infoGluePrincipal, roleName, propertyName); 1033 } 1034 1035 1038 1039 public List getPrincipalRoleRelatedContents(InfoGluePrincipal infoGluePrincipal, String roleName, String propertyName) 1040 { 1041 List contents = new ArrayList (); 1042 1043 try 1044 { 1045 if(getHasPrincipalRole(infoGluePrincipal, roleName)) 1046 contents = RolePropertiesController.getController().getRelatedContents(roleName, this.languageId, propertyName); 1047 } 1048 catch(Exception e) 1049 { 1050 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 1051 } 1052 1053 return contents; 1054 } 1055 1056 1059 1060 public List getPrincipalRoleRelatedPages(String roleName, String propertyName) 1061 { 1062 return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName); 1063 } 1064 1065 1068 1069 public List getPrincipalRoleRelatedPages(String roleName, String propertyName, boolean escapeHTML) 1070 { 1071 return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName, escapeHTML); 1072 } 1073 1074 1077 1078 public List getPrincipalRoleRelatedPages(InfoGluePrincipal infoGluePrincipal, String roleName, String propertyName) 1079 { 1080 return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName, false); 1081 } 1082 1083 1086 1087 public List getPrincipalRoleRelatedPages(InfoGluePrincipal infoGluePrincipal, String roleName, String propertyName, boolean escapeHTML) 1088 { 1089 List pages = new ArrayList (); 1090 1091 try 1092 { 1093 if(getHasPrincipalRole(infoGluePrincipal, roleName)) 1094 { 1095 List siteNodeVOList = GroupPropertiesController.getController().getRelatedSiteNodes(roleName, this.languageId, propertyName); 1096 1097 Iterator i = siteNodeVOList.iterator(); 1098 while(i.hasNext()) 1099 { 1100 SiteNodeVO siteNodeVO = (SiteNodeVO)i.next(); 1101 try 1102 { 1103 WebPage webPage = new WebPage(); 1104 webPage.setSiteNodeId(siteNodeVO.getSiteNodeId()); 1105 webPage.setLanguageId(this.languageId); 1106 webPage.setContentId(null); 1107 webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML)); 1108 webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext)); 1109 webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext)); 1110 pages.add(webPage); 1111 } 1112 catch(Exception e) 1113 { 1114 logger.info("An error occurred when looking up one of the related pages:" + e.getMessage(), e); 1115 } 1116 } 1117 } 1118 } 1119 catch(Exception e) 1120 { 1121 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 1122 } 1123 1124 return pages; 1125 } 1126 1127 1130 1131 public List getPrincipalRoleCategories(String roleName, String propertyName) 1132 { 1133 return getPrincipalRoleCategories(this.infoGluePrincipal, roleName, propertyName); 1134 } 1135 1136 1139 1140 public List getPrincipalRoleCategories(InfoGluePrincipal infoGluePrincipal, String roleName, String propertyName) 1141 { 1142 List categories = new ArrayList (); 1143 1144 try 1145 { 1146 if(getHasPrincipalRole(infoGluePrincipal, roleName)) 1147 categories = GroupPropertiesController.getController().getRelatedCategories(roleName, this.languageId, propertyName); 1148 } 1149 catch(Exception e) 1150 { 1151 logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e); 1152 } 1153 1154 return categories; 1155 } 1156 1157 1160 1161 public HttpServletRequest getHttpServletRequest() 1162 { 1163 return this.request; 1164 } 1165 1166 1167 1170 1171 public Enumeration getRequestParamenterNames() 1172 { 1173 return this.request.getParameterNames(); 1174 } 1175 1176 1179 public String getRequestParameter(String parameterName) 1180 { 1181 String value = ""; 1182 try 1183 { 1184 value = this.request.getParameter(parameterName); 1185 if(value == null) 1186 value = ""; 1187 } 1188 catch(Exception e) 1189 { 1190 logger.warn("An error occurred trying to get parameterName " + parameterName + " from request:" + e.getMessage(), e); 1191 } 1192 1193 return value; 1194 } 1195 1196 1199 public String [] getRequestParameterValues(String parameterName) 1200 { 1201 String value[] = null; 1202 try 1203 { 1204 value = this.request.getParameterValues(parameterName); 1205 } 1206 catch(Exception e) 1207 { 1208 logger.warn("An error occurred trying to get parameterName " + parameterName + " from request:" + e.getMessage(), e); 1209 } 1210 1211 return value; 1212 } 1213 1214 1217 1218 public BrowserBean getBrowserBean() 1219 { 1220 return browserBean; 1221 } 1222 1223 1224 1227 public void setDeliveryControllers(NodeDeliveryController nodeDeliveryController, ContentDeliveryController contentDeliveryController, IntegrationDeliveryController integrationDeliveryController) 1228 { 1229 this.nodeDeliveryController = nodeDeliveryController; 1230 this.contentDeliveryController = contentDeliveryController; 1231 this.integrationDeliveryController = integrationDeliveryController; 1232 } 1233 1234 1238 1239 public String getContentAttribute(String contentBindningName, String attributeName, boolean clean) 1240 { 1241 return getContentAttribute(contentBindningName, attributeName); 1242 } 1243 1244 1248 public String getContentAttribute(String attributeName, boolean clean) 1249 { 1250 return getContentAttribute(attributeName); 1251 } 1252 1253 1268 public String getContentAttribute(Integer contentId, String attributeName, boolean clean) 1269 { 1270 return getContentAttribute(contentId, attributeName); 1271 } 1272 1273 1277 1278 public String getContentAttribute(Integer contentId, Integer languageId, String attributeName, boolean clean) 1279 { 1280 return getContentAttribute(contentId, languageId, attributeName); 1281 } 1282 1283 1288 1289 public String getContentAttributeWithReturningId(Integer contentId, Integer languageId, String attributeName, boolean clean, List contentVersionId) 1290 { 1291 return getContentAttribute(contentId, languageId, attributeName, contentVersionId); 1292 } 1293 1294 1298 1299 public String getContentAttribute(String attributeName) 1300 { 1301 String attributeValue = ""; 1302 1303 try 1304 { 1305 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), this.contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1306 } 1307 catch(Exception e) 1308 { 1309 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + this.contentId + ":" + e.getMessage(), e); 1310 } 1311 1312 return attributeValue; 1313 } 1314 1315 1320 1321 public String getContentAttribute(String contentBindningName, String attributeName) 1322 { 1323 String attributeValue = ""; 1324 1325 try 1326 { 1327 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1328 if(contentVO != null) 1329 { 1330 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getContentId(), this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1331 } 1332 } 1333 catch(Exception e) 1334 { 1335 logger.error("An error occurred trying to get attributeName=" + attributeName + " on contentBindning " + contentBindningName + ":" + e.getMessage(), e); 1336 } 1337 1338 return attributeValue; 1339 } 1340 1341 1342 1347 1348 public String getContentAttribute(Integer contentId, String attributeName) 1349 { 1350 String attributeValue = ""; 1351 1352 this.deliveryContext.addUsedContent("content_" + contentId); 1353 1354 try 1355 { 1356 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1357 } 1358 catch(Exception e) 1359 { 1360 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e); 1361 } 1362 1363 return attributeValue; 1364 } 1365 1366 1367 1372 1373 public String getContentAttributeValue(Integer contentId, String attributeName, boolean escapeHTML) 1374 { 1375 return getContentAttributeValue(contentId, this.getLanguageId(), attributeName, escapeHTML); 1376 } 1377 1378 1383 1384 public String getContentAttributeValue(Integer contentId, String attributeName, boolean clean, boolean escapeHTML) 1385 { 1386 return getContentAttributeValue(contentId, this.getLanguageId(), attributeName, escapeHTML); 1387 } 1388 1389 1394 1395 public String getContentAttributeValue(Integer contentId, Integer languageId, String attributeName, boolean escapeHTML) 1396 { 1397 String attributeValue = ""; 1398 1399 this.deliveryContext.addUsedContent("content_" + contentId); 1400 1401 try 1402 { 1403 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, escapeHTML); 1404 } 1405 catch(Exception e) 1406 { 1407 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e); 1408 } 1409 1410 return attributeValue; 1411 } 1412 1413 1414 1415 1420 1421 public String getContentAttribute(Integer contentId, Integer languageId, String attributeName) 1422 { 1423 String attributeValue = ""; 1424 1425 this.deliveryContext.addUsedContent("content_" + contentId); 1426 1427 try 1428 { 1429 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1430 } 1431 catch(Exception e) 1432 { 1433 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e); 1434 } 1435 1436 return attributeValue; 1437 } 1438 1439 1440 1445 1446 public String getContentAttribute(Integer contentId, Integer languageId, String attributeName, List contentVersionId) 1447 { 1448 String attributeValue = ""; 1449 1450 this.deliveryContext.addUsedContent("content_" + contentId); 1451 1452 try 1453 { 1454 attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false, contentVersionId); 1455 } 1456 catch(Exception e) 1457 { 1458 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e); 1459 } 1460 1461 return attributeValue; 1462 } 1463 1464 1467 public String getContentAttribute(ContentVersionVO version, String attributeName) 1468 { 1469 try 1470 { 1471 return ContentDeliveryController.getContentDeliveryController().getAttributeValue(getDatabase(), version, attributeName, false); 1472 } 1473 catch(Exception e) 1474 { 1475 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content version" + version.getId() + ":" + e.getMessage(), e); 1476 } 1477 1478 return ""; 1479 } 1480 1481 1485 1486 public String getContentAttributeUsingLanguageFallback(Integer contentId, String attributeName, boolean disableEditOnSight) 1487 { 1488 logger.info("getContentAttributeUsingLanguageFallback: " + contentId + ":" + attributeName + ":" + disableEditOnSight); 1489 String attributeValue = ""; 1490 1491 try 1492 { 1493 attributeValue = this.getContentAttribute(contentId, attributeName, true); 1494 if(attributeValue != null && attributeValue.trim().equals("")) 1495 { 1496 LanguageVO masteLanguageVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(getDatabase(), this.siteNodeId); 1497 attributeValue = this.getContentAttribute(contentId, masteLanguageVO.getLanguageId(), attributeName, disableEditOnSight); 1498 } 1499 } 1500 catch(Exception e) 1501 { 1502 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e); 1503 } 1504 1505 return attributeValue; 1506 } 1507 1508 1513 1514 public String getParsedContentAttribute(String attributeName) 1515 { 1516 String attributeValue = ""; 1517 1518 try 1519 { 1520 if(this.contentId != null) 1521 { 1522 String unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), this.contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1523 logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue); 1524 1525 templateLogicContext.put("inlineContentId", this.contentId); 1526 1527 Map context = new HashMap (); 1528 context.put("inheritedTemplateLogic", this); 1529 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 1530 1531 context.putAll(templateLogicContext); 1533 1534 StringWriter cacheString = new StringWriter (); 1535 PrintWriter cachedStream = new PrintWriter (cacheString); 1536 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true); 1537 attributeValue = cacheString.toString(); 1538 } 1540 } 1541 catch(Exception e) 1542 { 1543 logger.error("An error occurred trying to get attributeName=" + attributeName + " on sent in content with id:" + this.contentId + ":" + e.getMessage(), e); 1544 } 1545 1546 return attributeValue; 1547 } 1548 1549 1550 1555 1556 public String getParsedContentAttribute(String contentBindningName, String attributeName) 1557 { 1558 logger.info("getParsedContentAttribute:" + contentBindningName + ":" + attributeName); 1559 1560 String attributeValue = ""; 1561 1562 try 1563 { 1564 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1565 if(contentVO != null) 1566 { 1567 logger.info("contentVO:" + contentVO.getContentId()); 1568 1569 String unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getId(), this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1570 logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue); 1571 1572 templateLogicContext.put("inlineContentId", contentVO.getId()); 1573 1574 Map context = new HashMap (); 1575 context.put("inheritedTemplateLogic", this); 1576 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, contentVO.getId(), this.request, this.infoGluePrincipal, this.deliveryContext)); 1577 1578 context.putAll(templateLogicContext); 1580 1581 StringWriter cacheString = new StringWriter (); 1582 PrintWriter cachedStream = new PrintWriter (cacheString); 1583 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true); 1584 attributeValue = cacheString.toString(); 1585 } 1586 } 1587 catch(Exception e) 1588 { 1589 logger.error("An error occurred trying to get attributeName=" + attributeName + " on contentBindning " + contentBindningName + ":" + e.getMessage(), e); 1590 } 1591 1592 return attributeValue; 1593 } 1594 1595 1596 1597 1601 1602 public String getParsedContentAttribute(Integer contentId, String attributeName) 1603 { 1604 String attributeValue = ""; 1605 1606 try 1607 { 1608 if(contentId != null) 1609 { 1610 String unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1611 logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue); 1612 1613 templateLogicContext.put("inlineContentId", contentId); 1614 1615 Map context = new HashMap (); 1616 context.put("inheritedTemplateLogic", this); 1617 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 1618 1619 context.putAll(templateLogicContext); 1621 1622 StringWriter cacheString = new StringWriter (); 1623 PrintWriter cachedStream = new PrintWriter (cacheString); 1624 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true); 1625 attributeValue = cacheString.toString(); 1626 } 1627 } 1628 catch(Exception e) 1629 { 1630 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content with id " + contentId + ":" + e.getMessage(), e); 1631 } 1632 1633 return attributeValue; 1634 } 1635 1636 1640 1641 public String getParsedContentAttribute(Integer contentId, Integer languageId, String attributeName) 1642 { 1643 String attributeValue = ""; 1644 1645 try 1646 { 1647 if(contentId != null) 1648 { 1649 String unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 1650 logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue); 1651 1652 templateLogicContext.put("inlineContentId", contentId); 1653 1654 Map context = new HashMap (); 1655 context.put("inheritedTemplateLogic", this); 1656 context.put("templateLogic", getTemplateController(this.siteNodeId, languageId, contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 1657 1658 context.putAll(templateLogicContext); 1660 1661 StringWriter cacheString = new StringWriter (); 1662 PrintWriter cachedStream = new PrintWriter (cacheString); 1663 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true); 1664 attributeValue = cacheString.toString(); 1665 } 1666 } 1667 catch(Exception e) 1668 { 1669 logger.error("An error occurred trying to get attributeName=" + attributeName + " on content with id " + contentId + ":" + e.getMessage(), e); 1670 } 1671 1672 return attributeValue; 1673 } 1674 1675 1679 1680 public String getParsedContentAttribute(String attributeName, boolean clean) 1681 { 1682 return getParsedContentAttribute(attributeName); 1683 } 1684 1685 1689 1690 public String getParsedContentAttribute(String contentBindningName, String attributeName, boolean clean) 1691 { 1692 return getParsedContentAttribute(contentBindningName, attributeName); 1693 } 1694 1695 1699 1700 public String getParsedContentAttribute(Integer contentId, String attributeName, boolean clean) 1701 { 1702 return getParsedContentAttribute(contentId, attributeName); 1703 } 1704 1705 1709 1710 public String getParsedContentAttribute(Integer contentId, Integer languageId, String attributeName, boolean clean) 1711 { 1712 return getParsedContentAttribute(contentId, languageId, attributeName); 1713 } 1714 1715 1718 1719 public Collection getAssetKeys(String contentBindningName) 1720 { 1721 Collection assetKeys = new ArrayList (); 1722 1723 try 1724 { 1725 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1726 assetKeys = ContentDeliveryController.getContentDeliveryController().getAssetKeys(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1727 } 1728 catch(Exception e) 1729 { 1730 logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e); 1731 } 1732 1733 return assetKeys; 1734 } 1735 1736 1739 1740 public Collection getAssetKeys(Integer contentId) 1741 { 1742 Collection assetKeys = new ArrayList (); 1743 1744 try 1745 { 1746 assetKeys = ContentDeliveryController.getContentDeliveryController().getAssetKeys(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1747 } 1748 catch(Exception e) 1749 { 1750 logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e); 1751 } 1752 1753 return assetKeys; 1754 } 1755 1756 1759 1760 public Collection getContentTypeDefinitionAssetKeys(String schemaValue) 1761 { 1762 Collection assetKeys = new ArrayList (); 1763 1764 try 1765 { 1766 assetKeys = ContentTypeDefinitionController.getController().getDefinedAssetKeys(schemaValue); 1767 } 1768 catch(Exception e) 1769 { 1770 logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e); 1771 } 1772 1773 return assetKeys; 1774 } 1775 1776 1780 1781 public String getAssetThumbnailUrl(Integer contentId, int width, int height) 1782 { 1783 String assetThumbnailUrl = ""; 1784 1785 try 1786 { 1787 assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal); 1788 } 1789 catch(Exception e) 1790 { 1791 logger.error("An error occurred trying to get assetThumbnailUrl on contentId " + contentId + ":" + e.getMessage(), e); 1792 } 1793 1794 return assetThumbnailUrl; 1795 } 1796 1797 1801 1802 public String getAssetThumbnailUrl(Integer contentId, String assetKey, int width, int height) 1803 { 1804 String assetThumbnailUrl = ""; 1805 1806 try 1807 { 1808 assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal); 1809 } 1810 catch(Exception e) 1811 { 1812 logger.error("An error occurred trying to get assetThumbnailUrl on contentId " + contentId + ":" + e.getMessage(), e); 1813 } 1814 1815 return assetThumbnailUrl; 1816 } 1817 1818 1823 1824 public String getAssetThumbnailUrl(String contentBindningName, int width, int height) 1825 { 1826 String assetUrl = ""; 1827 1828 try 1829 { 1830 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1831 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal); 1832 } 1833 catch(Exception e) 1834 { 1835 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 1836 } 1837 1838 return assetUrl; 1839 } 1840 1841 1846 1847 public String getAssetThumbnailUrl(String contentBindningName, String assetKey, int width, int height) 1848 { 1849 String assetThumbnailUrl = ""; 1850 1851 try 1852 { 1853 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1854 assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal); 1855 } 1856 catch(Exception e) 1857 { 1858 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 1859 } 1860 1861 return assetThumbnailUrl; 1862 } 1863 1864 1869 1870 public String getAssetUrl(String contentBindningName) 1871 { 1872 String assetUrl = ""; 1873 1874 try 1875 { 1876 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1877 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1878 } 1879 catch(Exception e) 1880 { 1881 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 1882 } 1883 1884 return assetUrl; 1885 } 1886 1887 1888 public String getEncodedUrl(String s, String enc) 1889 { 1890 String ret = ""; 1891 try 1892 { 1893 ret = java.net.URLEncoder.encode(s, enc); 1894 } 1895 catch (UnsupportedEncodingException e) 1896 { 1897 logger.error("An error occurred trying to encode the url: " + s + " with encoding: " + enc + ": " + e.getMessage(), e); 1898 } 1899 return ret; 1900 } 1901 1902 1905 1906 public String getAssetUrl(Integer contentId) 1907 { 1908 String assetUrl = ""; 1909 1910 try 1911 { 1912 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1913 } 1914 catch(Exception e) 1915 { 1916 logger.error("An error occurred trying to get assetUrl on content with id: " + contentId + ":" + e.getMessage(), e); 1917 } 1918 1919 return assetUrl; 1920 } 1921 1922 1923 1926 1927 public String getAssetUrl(Integer contentId, String assetKey) 1928 { 1929 String assetUrl = ""; 1930 1931 try 1932 { 1933 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1934 } 1935 catch(Exception e) 1936 { 1937 logger.error("An error occurred trying to get assetUrl on content with id: " + contentId + " and assetKey:" + assetKey + " : " + e.getMessage(), e); 1938 } 1939 1940 return assetUrl; 1941 } 1942 1943 1944 1949 1950 public String getAssetUrl(String contentBindningName, int index) 1951 { 1952 String assetUrl = ""; 1953 1954 try 1955 { 1956 List contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext); 1957 if(contentVOList != null && contentVOList.size() > index) 1958 { 1959 ContentVO contentVO = (ContentVO)contentVOList.get(index); 1960 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1961 } 1962 } 1963 catch(Exception e) 1964 { 1965 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 1966 } 1967 1968 return assetUrl; 1969 } 1970 1971 1972 1977 1978 public String getAssetUrl(String contentBindningName, String assetKey) 1979 { 1980 String assetUrl = ""; 1981 1982 try 1983 { 1984 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 1985 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 1986 } 1987 catch(Exception e) 1988 { 1989 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e); 1990 } 1991 1992 return assetUrl; 1993 } 1994 1995 1996 2001 2002 public String getAssetUrl(InfoGluePrincipal principal, String assetKey, Integer languageId, Integer siteNodeId, boolean useLanguageFallback) 2003 { 2004 String assetUrl = ""; 2005 2006 try 2007 { 2008 assetUrl = ExtranetController.getController().getPrincipalAssetUrl(this.getDatabase(), principal, assetKey, languageId, siteNodeId, useLanguageFallback, deliveryContext); 2009 } 2010 catch(Exception e) 2011 { 2012 logger.error("An error occurred trying to get assetUrl on principal " + principal.getName() + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2013 } 2014 2015 return assetUrl; 2016 } 2017 2018 2023 2024 public String getAssetThumbnailUrl(InfoGluePrincipal principal, String assetKey, Integer languageId, Integer siteNodeId, boolean useLanguageFallback, int width, int height) 2025 { 2026 String assetUrl = ""; 2027 2028 try 2029 { 2030 assetUrl = ExtranetController.getController().getPrincipalThumbnailAssetUrl(this.getDatabase(), principal, assetKey, languageId, siteNodeId, useLanguageFallback, width, height, deliveryContext); 2031 } 2032 catch(Exception e) 2033 { 2034 logger.error("An error occurred trying to get assetUrl on principal " + principal.getName() + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2035 } 2036 2037 return assetUrl; 2038 } 2039 2040 2045 2046 public String getInlineAssetUrl(String assetKey) 2047 { 2048 String assetUrl = ""; 2049 2050 try 2051 { 2052 Integer inlineContentId = this.contentId; 2053 if(inlineContentId == null || inlineContentId.intValue() == -1) 2054 inlineContentId = (Integer )this.templateLogicContext.get("inlineContentId"); 2055 2056 logger.info("getInlineAssetUrl:" + inlineContentId + ":" + this.languageId + ":" + assetKey + ":" + this.siteNodeId); 2057 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), inlineContentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2058 } 2059 catch(Exception e) 2060 { 2061 logger.error("An error occurred trying to get assetUrl on content with id: " + this.contentId + ":" + e.getMessage(), e); 2062 } 2063 2064 return assetUrl; 2065 } 2066 2067 2068 2073 2074 public String getInlineAssetUrl(Integer contentId, String assetKey) 2075 { 2076 String assetUrl = ""; 2077 2078 try 2079 { 2080 Integer inlineContentId = contentId; 2081 logger.info("getInlineAssetUrl:" + inlineContentId + ":" + this.languageId + ":" + assetKey + ":" + this.siteNodeId); 2082 assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), inlineContentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2083 } 2084 catch(Exception e) 2085 { 2086 logger.error("An error occurred trying to get assetUrl on content with id: " + this.contentId + ":" + e.getMessage(), e); 2087 } 2088 2089 return assetUrl; 2090 } 2091 2092 2097 2098 public Integer getAssetFileSize(Integer contentId) 2099 { 2100 Integer AssetFileSize = null; 2101 try 2102 { 2103 AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2104 } 2105 catch(Exception e) 2106 { 2107 logger.error("An error occurred trying to get AssetFileSize on content with id: " + contentId + ":" + e.getMessage(), e); 2108 } 2109 return AssetFileSize; 2110 } 2111 2112 public Integer getAssetFileSize(Integer contentId, String assetKey) 2113 { 2114 Integer AssetFileSize = null; 2115 try 2116 { 2117 AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2118 } 2119 catch(Exception e) 2120 { 2121 logger.error("An error occurred trying to get AssetFileSize on content with id: " + contentId + " and assetKey:" + assetKey + " : " + e.getMessage(), e); 2122 } 2123 return AssetFileSize; 2124 } 2125 2126 public Integer getAssetFileSize(String contentBindningName, int index) 2127 { 2128 Integer AssetFileSize = null; 2129 try 2130 { 2131 List contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext); 2132 if(contentVOList != null && contentVOList.size() > index) 2133 { 2134 ContentVO contentVO = (ContentVO)contentVOList.get(index); 2135 AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2136 } 2137 } 2138 catch(Exception e) 2139 { 2140 logger.error("An error occurred trying to get AssetFileSize on contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 2141 } 2142 return AssetFileSize; 2143 } 2144 2145 public Integer getAssetFileSize(String contentBindningName, String assetKey) 2146 { 2147 Integer AssetFileSize = null; 2148 try 2149 { 2150 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 2151 AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2152 } 2153 catch(Exception e) 2154 { 2155 logger.error("An error occurred trying to get AssetFileSize on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2156 } 2157 return AssetFileSize; 2158 } 2159 2160 2161 2166 2167 public List getRelatedContentsByQualifyer(String qualifyerXML) 2168 { 2169 List relatedContentVOList = new ArrayList (); 2170 2171 try 2172 { 2173 relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML); 2174 } 2175 catch(Exception e) 2176 { 2177 logger.error("An error occurred trying to get related contents from qualifyer: " + qualifyerXML + ":" + e.getMessage(), e); 2178 } 2179 2180 return relatedContentVOList; 2181 } 2182 2183 2188 2189 public List getRelatedContents(String attributeName) 2190 { 2191 List relatedContentVOList = new ArrayList (); 2192 2193 try 2194 { 2195 String qualifyerXML = this.getContentAttribute(attributeName, true); 2196 2197 relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML); 2198 } 2199 catch(Exception e) 2200 { 2201 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2202 } 2203 2204 return relatedContentVOList; 2205 } 2206 2207 2212 2213 public List getRelatedContents(String bindingName, String attributeName) 2214 { 2215 List relatedContentVOList = new ArrayList (); 2216 2217 try 2218 { 2219 String qualifyerXML = this.getContentAttribute(bindingName, attributeName, true); 2220 2221 relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML); 2222 } 2223 catch(Exception e) 2224 { 2225 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2226 } 2227 2228 return relatedContentVOList; 2229 } 2230 2231 2232 2233 2238 2239 public List getRelatedContents(Integer contentId, String attributeName) 2240 { 2241 List relatedContentVOList = new ArrayList (); 2242 2243 try 2244 { 2245 logger.info("contentId " + this.contentId + " with relationName " + attributeName); 2246 String qualifyerXML = this.getContentAttribute(contentId, attributeName, true); 2247 2248 relatedContentVOList = getRelatedContentsFromXML(qualifyerXML); 2249 } 2250 catch(Exception e) 2251 { 2252 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2253 } 2254 2255 return relatedContentVOList; 2256 } 2257 2258 2261 2262 public List getRelatedContents(InfoGluePrincipal infogluePrincipal, String attributeName) 2263 { 2264 List relatedContentVOList = new ArrayList (); 2265 2266 try 2267 { 2268 String qualifyerXML = this.getPrincipalPropertyValue(infogluePrincipal, attributeName, false); 2269 2270 relatedContentVOList = getRelatedContentsFromXML(qualifyerXML); 2271 } 2272 catch(Exception e) 2273 { 2274 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2275 } 2276 2277 return relatedContentVOList; 2278 } 2279 2280 2281 2284 2285 private List getRelatedContentsFromXML(String qualifyerXML) 2286 { 2287 List relatedContentVOList = new ArrayList (); 2288 2289 try 2290 { 2291 if(qualifyerXML != null && !qualifyerXML.equals("")) 2292 { 2293 Document document = new DOMBuilder().getDocument(qualifyerXML); 2294 2295 List children = document.getRootElement().elements(); 2296 Iterator i = children.iterator(); 2297 while(i.hasNext()) 2298 { 2299 Element child = (Element)i.next(); 2300 2301 String id = child.attributeValue("id"); 2302 if(id == null || id.equals("")) 2303 id = child.getText(); 2304 2305 ContentVO contentVO = this.getContent(new Integer (id)); 2306 if(ContentDeliveryController.getContentDeliveryController().isValidContent(this.getDatabase(), contentVO.getId(), this.languageId, USE_LANGUAGE_FALLBACK, true, getPrincipal(), this.deliveryContext)) 2307 relatedContentVOList.add(contentVO); 2308 } 2309 } 2310 } 2311 catch(Exception e) 2312 { 2313 logger.error("An error occurred trying to get related contents from qualifyerXML " + qualifyerXML + ":" + e.getMessage(), e); 2314 } 2315 2316 return relatedContentVOList; 2317 } 2318 2319 2322 2323 private List getRelatedPagesFromXML(String qualifyerXML, boolean escapeHTML) 2324 { 2325 List relatedPages = new ArrayList (); 2326 2327 try 2328 { 2329 if(qualifyerXML != null && !qualifyerXML.equals("")) 2330 { 2331 Document document = new DOMBuilder().getDocument(qualifyerXML); 2332 2333 List children = document.getRootElement().elements(); 2334 Iterator i = children.iterator(); 2335 while(i.hasNext()) 2336 { 2337 Element child = (Element)i.next(); 2338 2339 String id = child.attributeValue("id"); 2340 if(id == null || id.equals("")) 2341 id = child.getText(); 2342 2343 try 2344 { 2345 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), new Integer (id)).getValueObject(); 2346 if(this.nodeDeliveryController.isValidSiteNode(getDatabase(), siteNodeVO.getId())) 2347 { 2348 WebPage webPage = new WebPage(); 2349 webPage.setSiteNodeId(siteNodeVO.getSiteNodeId()); 2350 webPage.setLanguageId(this.languageId); 2351 webPage.setContentId(null); 2352 webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML)); 2353 webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext)); 2354 webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext)); 2355 relatedPages.add(webPage); 2356 } 2357 } 2358 catch(Exception e) 2359 { 2360 logger.info("An error occurred when looking up one of the related Pages FromXML:" + e.getMessage(), e); 2361 } 2362 } 2363 } 2364 } 2365 catch(Exception e) 2366 { 2367 logger.error("An error occurred trying to get related contents from qualifyerXML " + qualifyerXML + ":" + e.getMessage(), e); 2368 } 2369 2370 return relatedPages; 2371 } 2372 2377 2378 public List getRelatedPages(String attributeName) 2379 { 2380 return getRelatedPages(attributeName, false); 2381 } 2382 2383 2388 2389 public List getRelatedPages(String attributeName, boolean escapeHTML) 2390 { 2391 List relatedPages = new ArrayList (); 2392 2393 try 2394 { 2395 String qualifyerXML = this.getContentAttribute(attributeName, true); 2396 2397 relatedPages = getRelatedPagesFromXML(qualifyerXML, escapeHTML); 2398 } 2399 catch(Exception e) 2400 { 2401 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2402 } 2403 2404 return relatedPages; 2405 } 2406 2407 2412 2413 public List getRelatedPages(String bindingName, String attributeName) 2414 { 2415 return getRelatedPages(bindingName, attributeName, false); 2416 } 2417 2418 2423 2424 public List getRelatedPages(String bindingName, String attributeName, boolean escapeHTML) 2425 { 2426 List relatedPages = new ArrayList (); 2427 2428 try 2429 { 2430 String qualifyerXML = this.getContentAttribute(bindingName, attributeName, true); 2431 2432 relatedPages = getRelatedPagesFromXML(qualifyerXML, escapeHTML); 2433 } 2434 catch(Exception e) 2435 { 2436 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2437 } 2438 2439 return relatedPages; 2440 } 2441 2442 2443 2448 2449 public List getRelatedPages(Integer contentId, String attributeName) 2450 { 2451 List relatedPages = new ArrayList (); 2452 2453 try 2454 { 2455 String qualifyerXML = this.getContentAttribute(contentId, attributeName, true); 2456 2457 relatedPages = getRelatedPagesFromXML(qualifyerXML, false); 2458 } 2459 catch(Exception e) 2460 { 2461 logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e); 2462 } 2463 2464 return relatedPages; 2465 } 2466 2467 2472 2473 public List getRelatedPages(InfoGluePrincipal infogluePrincipal, String attributeName) 2474 { 2475 List relatedPages = new ArrayList (); 2476 2477 try 2478 { 2479 String qualifyerXML = this.getPrincipalPropertyValue(infogluePrincipal, attributeName, false); 2480 2481 relatedPages = getRelatedPagesFromXML(qualifyerXML, false); 2482 } 2483 catch(Exception e) 2484 { 2485 logger.error("An error occurred trying to get related pages on infogluePrincipal " + infogluePrincipal + " with relationName " + attributeName + ":" + e.getMessage(), e); 2486 } 2487 2488 return relatedPages; 2489 } 2490 2491 2492 2496 2497 public String getArchiveBaseUrl(String contentBindningName, String assetKey) 2498 { 2499 String assetUrl = ""; 2500 2501 try 2502 { 2503 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 2504 assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2505 } 2506 catch(Exception e) 2507 { 2508 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2509 } 2510 2511 return assetUrl; 2512 } 2513 2514 2515 2519 2520 public String getArchiveBaseUrl(Integer contentId, String assetKey) 2521 { 2522 String assetUrl = ""; 2523 2524 try 2525 { 2526 assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2527 } 2528 catch(Exception e) 2529 { 2530 logger.error("An error occurred trying to get assetUrl on content with id " + contentId + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2531 } 2532 2533 return assetUrl; 2534 } 2535 2536 public Vector getArchiveEntries(Integer contentId, String assetKey) 2537 { 2538 Vector entries = null; 2539 2540 try 2541 { 2542 entries = ContentDeliveryController.getContentDeliveryController().getArchiveEntries(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2543 } 2544 catch(Exception e) 2545 { 2546 logger.error("An error occurred trying to get assetUrl on content with id " + contentId + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2547 } 2548 2549 return entries; 2550 } 2551 2552 2553 2557 2558 public String getArchiveBaseUrl(String contentBindningName, int index, String assetKey) 2559 { 2560 String assetUrl = ""; 2561 2562 try 2563 { 2564 List contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext); 2565 if(contentVOList != null && contentVOList.size() > index) 2566 { 2567 ContentVO contentVO = (ContentVO)contentVOList.get(index); 2568 assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2569 } 2570 } 2571 catch(Exception e) 2572 { 2573 logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e); 2574 } 2575 2576 return assetUrl; 2577 } 2578 2579 2580 2581 2590 public String getContentAttributeAsPDFUrl(String contentBindningName, String attributeName) 2591 { 2592 String pdfUrl = ""; 2593 2594 try 2595 { 2596 String template = getParsedContentAttribute(contentBindningName, attributeName, true); 2597 String uniqueId = siteNodeId + "_" + attributeName + "_" + contentBindningName + template.hashCode(); 2598 String fileName = uniqueId + ".pdf"; 2599 2600 int i = 0; 2601 String filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2602 while(filePath != null) 2603 { 2604 File pdfFile = new File (filePath + java.io.File.separator + fileName); 2605 if(!pdfFile.exists()) 2606 { 2607 logger.info("Creating a foprenderer"); 2608 FOPHelper fop = new FOPHelper(); 2609 fop.generatePDF(template, pdfFile); 2610 } 2611 i++; 2612 filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2613 } 2614 2615 2625 SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId); 2626 String dnsName = CmsPropertyHandler.getWebServerAddress(); 2627 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 2628 dnsName = siteNode.getRepository().getDnsName(); 2629 2630 pdfUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext); 2632 } 2633 catch(Exception e) 2634 { 2635 logger.error("An error occurred trying to get ContentAttribute As PDFUrl:" + e.getMessage(), e); 2636 } 2637 2638 return pdfUrl; 2639 } 2640 2641 2642 2651 public String getContentAttributeAsPDFUrl(Integer contentId, String attributeName) 2652 { 2653 String pdfUrl = ""; 2654 2655 try 2656 { 2657 String template = getParsedContentAttribute(contentId, attributeName, true); 2658 String uniqueId = contentId + "_" + attributeName + template.hashCode(); 2659 String fileName = uniqueId + ".pdf"; 2660 2661 int i = 0; 2662 String filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2663 while(filePath != null) 2664 { 2665 File pdfFile = new File (filePath + java.io.File.separator + fileName); 2666 if(!pdfFile.exists()) 2667 { 2668 logger.info("Creating a foprenderer"); 2669 FOPHelper fop = new FOPHelper(); 2670 fop.generatePDF(template, pdfFile); 2671 } 2672 i++; 2673 filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2674 } 2675 2676 2686 2687 SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId); 2688 String dnsName = CmsPropertyHandler.getWebServerAddress(); 2689 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 2690 dnsName = siteNode.getRepository().getDnsName(); 2691 2692 pdfUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext); 2694 } 2695 catch(Exception e) 2696 { 2697 logger.error("An error occurred trying to get ContentAttribute As PDFUrl:" + e.getMessage(), e); 2698 } 2699 2700 return pdfUrl; 2701 } 2702 2703 2715 2716 public String getContentAttributeAsImageUrl(String contentBindningName, String attributeName, int canvasWidth, int canvasHeight) 2717 { 2718 return getContentAttributeAsImageUrl(contentBindningName, attributeName, canvasWidth, canvasHeight, 5, 20, canvasWidth - 10, canvasHeight - 10, "Verdana", Font.BOLD, 28, Color.black, Color.white); 2720 } 2721 2722 public String getContentAttributeAsImageUrl(String contentBindningName,String attributeName,int canvasWidth, 2723 int canvasHeight,int textStartPosX,int textStartPosY,int textWidth, 2724 int textHeight,String fontName,int fontStyle, 2725 int fontSize,String foregroundColor,String backgroundColor) 2726 { 2727 return getContentAttributeAsImageUrl( contentBindningName,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize, 2729 new Color (getMathHelper().hexToDecimal(foregroundColor)), 2730 new Color (getMathHelper().hexToDecimal(backgroundColor))); 2731 2732 } 2733 2734 public String getContentAttributeAsImageUrl(String contentBindningName,String attributeName,int canvasWidth, 2735 int canvasHeight,int textStartPosX,int textStartPosY,int textWidth, 2736 int textHeight,String fontName,int fontStyle, 2737 int fontSize,String foregroundColor,String backgroundColor, String backgroundImageUrl) 2738 { 2739 return getContentAttributeAsImageUrl( contentBindningName,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize, 2741 new Color (getMathHelper().hexToDecimal(foregroundColor)), 2742 new Color (getMathHelper().hexToDecimal(backgroundColor))); 2743 2744 } 2745 2746 public String getContentAttributeAsImageUrl(Integer contentId,String attributeName,int canvasWidth, 2747 int canvasHeight,int textStartPosX,int textStartPosY, 2748 int textWidth,int textHeight,String fontName,int fontStyle, 2749 int fontSize,String foregroundColor,String backgroundColor) 2750 { 2751 return getContentAttributeAsImageUrl(contentId,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize, 2753 new Color (getMathHelper().hexToDecimal(foregroundColor)), 2754 new Color (getMathHelper().hexToDecimal(backgroundColor))); 2755 } 2756 2757 public String getContentAttributeAsImageUrl(String contentBindningName,String attributeName,int canvasWidth,int canvasHeight,int textStartPosX,int textStartPosY,int textWidth,int textHeight,String fontName,int fontStyle,int fontSize,Color foregroundColor, Color backgroundColor) 2758 { 2759 String assetUrl = ""; 2761 try 2762 { 2763 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 2764 if(contentVO != null) 2765 assetUrl = getContentAttributeAsImageUrl(contentVO.getContentId(),attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor); 2766 } 2767 catch(Exception e) 2768 { 2769 logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e); 2770 } 2771 2772 return assetUrl; 2773 } 2774 2775 public String getContentAttributeAsImageUrl(String contentBindningName, String attributeName, int canvasWidth, int canvasHeight, int textStartPosX, int textStartPosY, int textWidth, int textHeight, String fontName, int fontStyle, int fontSize, Color foregroundColor, Color backgroundColor, String backgroundImageUrl) 2776 { 2777 String assetUrl = ""; 2779 try 2780 { 2781 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 2782 if(contentVO != null) 2783 assetUrl = getContentAttributeAsImageUrl(contentVO.getContentId(),attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor, backgroundImageUrl); 2784 } 2785 catch(Exception e) 2786 { 2787 logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e); 2788 } 2789 2790 return assetUrl; 2791 } 2792 2793 2794 public String getContentAttributeAsImageUrl(Integer contentId,String attributeName,int canvasWidth, 2795 int canvasHeight,int textStartPosX,int textStartPosY, 2796 int textWidth,int textHeight,String fontName, 2797 int fontStyle,int fontSize, 2798 Color foregroundColor,Color backgroundColor) 2799 { 2800 return getContentAttributeAsImageUrl(contentId, attributeName, canvasWidth, canvasHeight, textStartPosX, textStartPosY, textWidth, textHeight, fontName, fontStyle, fontSize, foregroundColor, backgroundColor, null); 2801 } 2802 2803 2804 2815 public String getRenderedTextUrl( Integer contentId, String text, Map renderAttributes ) 2816 { 2817 String assetUrl = ""; 2818 if ( text == null || text.length() == 0 ) 2819 { 2820 logger.warn("Could not render text with a null or 0 lenght value on sitenode: " + this.getSiteNodeId() + ", contentId = " + contentId ); 2821 return assetUrl; 2822 } 2823 try 2824 { 2825 ContentDeliveryController cdc = ContentDeliveryController.getContentDeliveryController(); 2826 ContentTypeDefinitionController ctdc = ContentTypeDefinitionController.getController(); 2827 2828 ContentVersionVO contentVersionVO = cdc.getContentVersionVO(getDatabase(), this.siteNodeId, contentId,this.languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal ); 2829 2830 Integer contentTypeDefinitionId = cdc.getContentVO(contentId, getDatabase() ).getContentTypeDefinitionId(); 2831 2832 ContentTypeDefinitionVO contentTypeDefinitionVO = ctdc.getContentTypeDefinitionVOWithId( contentTypeDefinitionId ); 2833 Iterator attrIterator = ctdc.getContentTypeAttributes(contentTypeDefinitionVO.getSchemaValue() ).iterator(); 2834 2835 String aText = text.replaceAll( "[^\\w]", "" ); 2836 aText = aText.substring( 0, ( aText.length() < 8 ? aText.length() : 8 ) ).toLowerCase(); 2837 StringBuffer uniqueId = new StringBuffer ( aText ); 2838 uniqueId.append( "_" + contentVersionVO.getId() ); 2839 uniqueId.append( "_" + Math.abs( text.hashCode() )); 2840 uniqueId.append( "_" + Math.abs(contentVersionVO.getVersionValue().hashCode() ) ); 2841 uniqueId.append( "_" + Math.abs(contentTypeDefinitionVO.getSchemaValue().hashCode() ) ); 2842 uniqueId.append( "_" + ( renderAttributes != null ? Math.abs( renderAttributes.hashCode() ) : 4711 ) ); 2843 2844 AdvancedImageRenderer imageRenderer = new AdvancedImageRenderer(); 2845 while ( attrIterator.hasNext() ) 2847 { 2848 ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute)(attrIterator.next()); 2849 String attributeName = contentTypeAttribute.getName(); 2850 if ( imageRenderer.hasAttribute( attributeName ) ) 2851 { 2852 String attribute = cdc.getContentAttribute(getDatabase(), contentVersionVO, attributeName, false ); 2853 imageRenderer.setAttribute( attributeName.toLowerCase(), attribute ); 2854 } 2855 } 2856 imageRenderer.renderImage( text, renderAttributes ); 2858 2859 String fileName = uniqueId + "." + imageRenderer.getImageFormatName(); assetUrl = writeRenderedImage( imageRenderer, fileName ); 2862 } 2863 catch ( Exception e ) 2864 { 2865 logger.error( "An error occurred trying to getRenderedTextUrl(), text = " + text + ", on siteNodeId = " + this.siteNodeId + " :" + e.getMessage(), e ); 2866 } 2867 2868 return assetUrl; 2869 } 2870 2871 2880 public String getRenderedTextUrl( String text, Map renderAttributes ) 2881 { 2882 String assetUrl = ""; 2883 if ( text == null || text.length() == 0 ) 2884 { 2885 logger.warn("Could not render text with a null or 0 lenght value on sitenode: " + this.getSiteNodeId() ); 2886 return assetUrl; 2887 } 2888 try 2889 { 2890 String aText = text.replaceAll( "[^\\w]", "" ); 2891 aText = aText.substring( 0, ( aText.length() < 12 ? aText.length() : 11 ) ).toLowerCase(); 2892 StringBuffer uniqueId = new StringBuffer ( aText ); 2893 uniqueId.append( "_" + Math.abs( text.hashCode() ) ); 2894 uniqueId.append( "_" + ( renderAttributes != null ? Math.abs( renderAttributes.hashCode() ) : 4711 ) ); 2895 2896 AdvancedImageRenderer imageRenderer = new AdvancedImageRenderer(); 2897 imageRenderer.renderImage( text, renderAttributes ); 2899 2900 String fileName = uniqueId + "." + imageRenderer.getImageFormatName(); 2902 assetUrl = writeRenderedImage( imageRenderer, fileName ); 2904 } 2905 catch ( Exception e ) 2906 { 2907 logger.error( "An error occurred trying to getRenderedTextUrl(), text = " + text + ", on siteNodeId = " + this.siteNodeId + " :" + e.getMessage(), e ); 2908 } 2909 2910 return assetUrl; 2911 } 2912 2913 2914 2922 private String writeRenderedImage( AdvancedImageRenderer imageRenderer, String fileName ) throws SystemException 2923 { 2924 int i = 0; 2926 String filePath = CmsPropertyHandler.getProperty( "digitalAssetPath." + i ); 2927 while ( filePath != null ) 2928 { 2929 File imageFile = new File ( filePath, fileName ); 2930 if ( !imageFile.exists() ) 2931 { 2932 imageRenderer.writeImage( imageFile ); 2933 } 2934 i++; 2935 filePath = CmsPropertyHandler.getProperty( "digitalAssetPath." + i ); 2936 } 2937 2938 SiteNode siteNode = this.nodeDeliveryController.getSiteNode( getDatabase(), this.siteNodeId ); 2939 String dnsName = CmsPropertyHandler.getWebServerAddress(); 2940 if ( siteNode != null && siteNode.getRepository().getDnsName() != null 2941 && !siteNode.getRepository().getDnsName().equals( "" ) ) 2942 { 2943 dnsName = siteNode.getRepository().getDnsName(); 2944 } 2945 2946 return urlComposer.composeDigitalAssetUrl( dnsName, fileName, deliveryContext ); 2947 } 2948 2949 2950 public String getContentAttributeAsImageUrl(Integer contentId,String attributeName,int canvasWidth, 2951 int canvasHeight,int textStartPosX,int textStartPosY, 2952 int textWidth,int textHeight,String fontName, 2953 int fontStyle,int fontSize, 2954 Color foregroundColor,Color backgroundColor, String backgroundImageUrl) 2955 { 2956 String assetUrl = ""; 2958 2959 try 2960 { 2961 ContentVersionVO contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 2962 2963 String attribute = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVersionVO, attributeName, false); 2964 2965 String uniqueId = contentVersionVO.getId() + "_" + attributeName + canvasWidth + canvasHeight + textStartPosX + textStartPosY + textWidth + textHeight + fontName.replaceAll(" ", "") + fontStyle + fontSize + foregroundColor.getRed() + foregroundColor.getGreen() + foregroundColor.getBlue() + backgroundColor.getRed() + backgroundColor.getGreen() + backgroundColor.getBlue(); 2966 2967 String fileName = uniqueId + ".png"; 2968 2969 int i = 0; 2970 String filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2971 while(filePath != null) 2972 { 2973 File imageFile = new File (filePath + java.io.File.separator + fileName); 2974 if(!imageFile.exists()) 2975 { 2976 logger.info("Creating a imagerenderer"); 2977 ImageRenderer imageRenderer = new ImageRenderer(); 2978 imageRenderer.setCanvasWidth(canvasWidth); 2979 imageRenderer.setCanvasHeight(canvasHeight); 2980 imageRenderer.setTextStartPosX(textStartPosX); 2981 imageRenderer.setTextStartPosY(textStartPosY); 2982 imageRenderer.setTextWidth(textWidth); 2983 imageRenderer.setTextHeight(textHeight); 2984 imageRenderer.setFontName(fontName); 2985 imageRenderer.setFontStyle(fontStyle); 2986 imageRenderer.setFontSize(fontSize); 2987 imageRenderer.setForeGroundColor(foregroundColor); 2988 imageRenderer.setBackgroundColor(backgroundColor); 2989 imageRenderer.setBackgroundImageUrl(backgroundImageUrl); 2990 2991 logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName); 2992 imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, attribute, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset()); 2993 logger.info("Rendered in getContentAttributeAsImageUrl"); 2994 } 2995 2996 i++; 2997 filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 2998 } 2999 3024 3025 SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId); 3026 String dnsName = CmsPropertyHandler.getWebServerAddress(); 3027 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 3028 dnsName = siteNode.getRepository().getDnsName(); 3029 3030 assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext); 3032 } 3033 catch(Exception e) 3034 { 3035 logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e); 3036 } 3037 3038 return assetUrl; 3039 } 3040 3041 3044 3045 public List getContentAttributes(String schemaValue) 3046 { 3047 return ContentTypeDefinitionController.getController().getContentTypeAttributes(schemaValue); 3048 } 3049 3050 3057 public String getStringAsImageUrl(String text, 3058 int canvasWidth, 3059 int canvasHeight, 3060 int textStartPosX, 3061 int textStartPosY, 3062 int textWidth, 3063 int textHeight, 3064 String fontName, 3065 int fontStyle, 3066 int fontSize, 3067 String foregroundColor, 3068 String backgroundColor) 3069 { 3070 return getStringAsImageUrl(text, canvasWidth, canvasHeight,textStartPosX, textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize, 3071 new Color (getMathHelper().hexToDecimal(foregroundColor)), 3072 new Color (getMathHelper().hexToDecimal(backgroundColor))); 3073 } 3074 public String getStringAsImageUrl(String text, 3075 int canvasWidth, 3076 int canvasHeight, 3077 int textStartPosX, 3078 int textStartPosY, 3079 int textWidth, 3080 int textHeight, 3081 String fontName, 3082 int fontStyle, 3083 int fontSize, 3084 String foregroundColor, 3085 String backgroundColor, String backGroundImageUrl) 3086 { 3087 return getStringAsImageUrl(text, canvasWidth, canvasHeight,textStartPosX, textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize, 3088 new Color (getMathHelper().hexToDecimal(foregroundColor)), 3089 new Color (getMathHelper().hexToDecimal(backgroundColor)), backGroundImageUrl); 3090 } 3091 3092 public String getStringAsImageUrl(String text, 3093 int canvasWidth, 3094 int canvasHeight, 3095 int textStartPosX, 3096 int textStartPosY, 3097 int textWidth, 3098 int textHeight, 3099 String fontName, 3100 int fontStyle, 3101 int fontSize, 3102 Color foregroundColor, 3103 Color backgroundColor) 3104 { 3105 return getStringAsImageUrl(text,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor,null); 3106 } 3107 3108 public String getStringAsImageUrl(String text, 3109 int canvasWidth, 3110 int canvasHeight, 3111 int textStartPosX, 3112 int textStartPosY, 3113 int textWidth, 3114 int textHeight, 3115 String fontName, 3116 int fontStyle, 3117 int fontSize, 3118 Color foregroundColor, 3119 Color backgroundColor, String backgroundImageUrl) 3120 { 3121 String assetUrl = ""; 3122 3123 try 3124 { 3125 String uniqueId = text.hashCode() + "_" + canvasWidth + canvasHeight + textStartPosX + textStartPosY + textWidth + textHeight + fontName.replaceAll(" ", "") + fontStyle + fontSize + foregroundColor.getRed() + foregroundColor.getGreen() + foregroundColor.getBlue() + backgroundColor.getRed() + backgroundColor.getGreen() + backgroundColor.getBlue(); 3126 3127 String fileName = uniqueId + ".png"; 3128 3129 int i = 0; 3130 String filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 3131 while(filePath != null) 3132 { 3133 File imageFile = new File (filePath + java.io.File.separator + fileName); 3134 if(!imageFile.exists()) 3135 { 3136 logger.info("Creating a imagerenderer"); 3137 ImageRenderer imageRenderer = new ImageRenderer(); 3138 imageRenderer.setCanvasWidth(canvasWidth); 3139 imageRenderer.setCanvasHeight(canvasHeight); 3140 imageRenderer.setTextStartPosX(textStartPosX); 3141 imageRenderer.setTextStartPosY(textStartPosY); 3142 imageRenderer.setTextWidth(textWidth); 3143 imageRenderer.setTextHeight(textHeight); 3144 imageRenderer.setFontName(fontName); 3145 imageRenderer.setFontStyle(fontStyle); 3146 imageRenderer.setFontSize(fontSize); 3147 imageRenderer.setForeGroundColor(foregroundColor); 3148 imageRenderer.setBackgroundColor(backgroundColor); 3149 imageRenderer.setBackgroundImageUrl(backgroundImageUrl); 3150 3151 logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName); 3152 imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, text, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset()); 3153 logger.info("Rendered in getContentAttributeAsImageUrl"); 3154 } 3155 3156 i++; 3157 filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i); 3158 } 3159 3184 3185 SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId); 3186 String dnsName = CmsPropertyHandler.getWebServerAddress(); 3187 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 3188 dnsName = siteNode.getRepository().getDnsName(); 3189 3190 assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext); 3192 } 3193 catch(Exception e) 3194 { 3195 logger.error("An error occurred trying to render string as an image:" + e.getMessage(), e); 3196 } 3197 3198 return assetUrl; 3199 } 3200 3201 3202 3205 3206 public String getDigitalAssetBaseUrl() throws Exception 3207 { 3208 String url = getRepositoryBaseUrl() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl(); 3209 3210 return url; 3211 } 3212 3213 3216 3217 public Integer getDigitalAssetId(Integer contentId, String assetKey) throws Exception 3218 { 3219 return ContentDeliveryController.getContentDeliveryController().getDigitalAssetId(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 3220 } 3221 3222 3225 3226 public Integer getDigitalAssetId(Integer contentId, Integer languageId, String assetKey) throws Exception 3227 { 3228 return ContentDeliveryController.getContentDeliveryController().getDigitalAssetId(getDatabase(), contentId, languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal); 3229 } 3230 3231 3234 3235 public String getRepositoryBaseUrl() throws Exception 3236 { 3237 String url = ""; 3238 3239 String context = CmsPropertyHandler.getProperty(FilterConstants.CMS_PROPERTY_SERVLET_CONTEXT); 3240 3241 SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId); 3242 String dnsName = CmsPropertyHandler.getWebServerAddress(); 3243 if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals("")) 3244 { 3245 dnsName = siteNode.getRepository().getDnsName(); 3246 3247 String useDNSNameInUrls = CmsPropertyHandler.getUseDNSNameInURI(); 3248 3249 if(!useDNSNameInUrls.equalsIgnoreCase("false")) 3250 { 3251 String operatingMode = CmsPropertyHandler.getOperatingMode(); 3252 String keyword = ""; 3253 if(operatingMode.equalsIgnoreCase("0")) 3254 keyword = "working="; 3255 else if(operatingMode.equalsIgnoreCase("2")) 3256 keyword = "preview="; 3257 if(operatingMode.equalsIgnoreCase("3")) 3258 keyword = "live="; 3259 3260 if(dnsName != null) 3261 { 3262 int startIndex = dnsName.indexOf(keyword); 3263 if(startIndex != -1) 3264 { 3265 int endIndex = dnsName.indexOf(",", startIndex); 3266 if(endIndex > -1) 3267 dnsName = dnsName.substring(startIndex, endIndex); 3268 else 3269 dnsName = dnsName.substring(startIndex); 3270 3271 dnsName = dnsName.split("=")[1]; 3272 } 3273 else 3274 { 3275 int endIndex = dnsName.indexOf(","); 3276 if(endIndex > -1) 3277 dnsName = dnsName.substring(0, endIndex); 3278 else 3279 dnsName = dnsName.substring(0); 3280 3281 } 3282 } 3283 3284 dnsName = dnsName + context; 3285 } 3286 else 3287 { 3288 dnsName = context; 3289 } 3290 } 3291 3292 url = dnsName; 3293 3294 return url; 3295 } 3296 3297 3300 3301 public SiteNodeVO getRepositoryRootSiteNode() throws Exception 3302 { 3303 Integer repositoryId = this.getSiteNode(this.siteNodeId).getRepositoryId(); 3304 SiteNodeVO siteNodeVO = getRepositoryRootSiteNode(repositoryId); 3305 3306 return siteNodeVO; 3307 } 3308 3309 3312 3313 public SiteNodeVO getRepositoryRootSiteNode(Integer repositoryId) throws Exception 3314 { 3315 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getRootSiteNode(getDatabase(), repositoryId); 3316 3317 return siteNodeVO; 3318 } 3319 3320 3323 3324 public Integer getParentRepositoryId(Integer repositoryId) 3325 { 3326 String parentRepository = RepositoryDeliveryController.getRepositoryDeliveryController().getPropertyValue(repositoryId, "parentRepository"); 3327 if(parentRepository != null && !parentRepository.equalsIgnoreCase("")) 3328 return new Integer (parentRepository); 3329 else 3330 return null; 3331 } 3332 3333 3336 3337 public Integer getParentRepositoryId() 3338 { 3339 Integer repositoryId = this.getSiteNode(this.siteNodeId).getRepositoryId(); 3340 return getParentRepositoryId(repositoryId); 3341 } 3342 3343 3348 3349 public String getPageUrl(String structureBindningName) 3350 { 3351 String pageUrl = ""; 3352 3353 try 3354 { 3355 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName); 3356 if(siteNodeVO != null) 3357 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext); 3358 } 3359 catch(Exception e) 3360 { 3361 logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3362 } 3363 3364 return pageUrl; 3365 } 3366 3367 3368 3371 3372 public String getPageUrl(WebPage webpage, Integer contentId) 3373 { 3374 String pageUrl = ""; 3375 3376 try 3377 { 3378 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), webpage.getSiteNodeId(), webpage.getLanguageId(), contentId, this.deliveryContext); 3379 } 3380 catch(Exception e) 3381 { 3382 logger.error("An error occurred trying to get the transformed page url " + contentId + ":" + e.getMessage(), e); 3383 } 3384 3385 return pageUrl; 3386 } 3387 3388 3389 3394 3395 public String getPageBaseUrl(String structureBindningName) 3396 { 3397 String pageUrl = ""; 3398 3399 try 3400 { 3401 pageUrl = this.nodeDeliveryController.getPageBaseUrl(getDatabase()); 3402 } 3403 catch(Exception e) 3404 { 3405 logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3406 } 3407 3408 return pageUrl; 3409 } 3410 3411 3416 3417 public String getPageBaseUrl() 3418 { 3419 String pageUrl = ""; 3420 3421 try 3422 { 3423 pageUrl = this.nodeDeliveryController.getPageBaseUrl(getDatabase()); 3424 } 3425 catch(Exception e) 3426 { 3427 logger.error("An error occurred trying to get page url the current url:" + e.getMessage(), e); 3428 } 3429 3430 return pageUrl; 3431 } 3432 3433 3436 3437 public SiteNodeVO getSiteNode() 3438 { 3439 SiteNodeVO siteNodeVO = null; 3440 3441 try 3442 { 3443 siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId).getValueObject(); 3444 } 3445 catch(Exception e) 3446 { 3447 logger.warn("An error occurred trying to get the current content:" + e.getMessage(), e); 3448 } 3449 3450 return siteNodeVO; 3451 } 3452 3453 3454 3457 3458 public SiteNodeVO getSiteNode(Integer siteNodeId) 3459 { 3460 SiteNodeVO siteNodeVO = null; 3461 3462 try 3463 { 3464 siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), siteNodeId).getValueObject(); 3465 } 3466 catch(Exception e) 3467 { 3468 logger.warn("An error occurred trying to get the siteNode with id " + siteNodeId + ":" + e.getMessage(), e); 3469 } 3470 3471 return siteNodeVO; 3472 } 3473 3474 3477 3478 public Integer getSiteNodeId(String structureBindningName) 3479 { 3480 Integer siteNodeId = null; 3481 3482 try 3483 { 3484 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName); 3485 siteNodeId = siteNodeVO.getSiteNodeId(); 3486 } 3487 catch(Exception e) 3488 { 3489 logger.error("An error occurred trying to get siteNodeId for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3490 } 3491 3492 return siteNodeId; 3493 } 3494 3495 3496 3499 3500 public Integer getContentId(String contentBindningName) 3501 { 3502 Integer contentId = null; 3503 3504 try 3505 { 3506 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 3507 if(contentVO != null) 3508 { 3509 contentId = contentVO.getId(); 3510 } 3511 } 3512 catch(Exception e) 3513 { 3514 logger.error("An error occurred trying to get contentId for contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 3515 } 3516 3517 return contentId; 3518 } 3519 3520 3523 3524 public Integer getMetaInformationContentId() 3525 { 3526 return this.getContentId(META_INFO_BINDING_NAME); 3527 } 3528 3529 3532 3533 public Integer getMetaInformationContentId(Integer siteNodeId) 3534 { 3535 return this.getContentId(siteNodeId, META_INFO_BINDING_NAME); 3536 } 3537 3538 3541 3542 public Collection getChildContents(Integer contentId, boolean includeFolders) 3543 { 3544 List childContents = null; 3545 3546 try 3547 { 3548 childContents = ContentDeliveryController.getContentDeliveryController().getChildContents(getDatabase(), this.getPrincipal(), contentId, this.languageId, USE_LANGUAGE_FALLBACK, includeFolders, this.deliveryContext); 3549 } 3550 catch(Exception e) 3551 { 3552 logger.error("An error occurred trying to get childContents for contentId " + contentId + ":" + e.getMessage(), e); 3553 } 3554 3555 return childContents; 3556 } 3557 3558 3559 3562 3563 public Integer getContentId(Integer siteNodeId, String contentBindningName) 3564 { 3565 Integer contentId = null; 3566 3567 try 3568 { 3569 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 3570 if(contentVO != null) 3571 { 3572 contentId = contentVO.getId(); 3573 } 3574 } 3575 catch(Exception e) 3576 { 3577 logger.warn("An error occurred trying to get contentId for contentBindningName " + contentBindningName + ":" + e.getMessage(), e); 3578 } 3579 3580 return contentId; 3581 } 3582 3583 3586 public List getContentVersionsByCategory(Integer categoryId, String attributeName) 3587 { 3588 try 3589 { 3590 return ContentDeliveryController.getContentDeliveryController().findContentVersionVOsForCategory(getDatabase(), categoryId, attributeName, getPrincipal(), siteNodeId, languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext); 3591 } 3592 catch(Exception e) 3593 { 3594 logger.error("An error occurred trying to get Content for categoryId " + categoryId + ":" + e.getMessage(), e); 3595 } 3596 3597 return Collections.EMPTY_LIST; 3598 } 3599 3600 3603 3604 public List getMatchingContents(String contentTypeDefinitionNamesString, String categoryConditionString, boolean useLanguageFallback) 3605 { 3606 try 3607 { 3608 List contentTypeDefinitionVOList = new ArrayList (); 3609 String [] contentTypeDefinitionNames = contentTypeDefinitionNamesString.split(","); 3610 for(int i=0; i<contentTypeDefinitionNames.length; i++) 3611 { 3612 ContentTypeDefinitionVO contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName(contentTypeDefinitionNames[i], getDatabase()); 3613 contentTypeDefinitionVOList.add(contentTypeDefinitionVO); 3614 } 3615 3616 final CategoryConditions categoryConditions = CategoryConditions.parse(categoryConditionString); 3617 final Set set = ExtendedSearchController.getController().search(getOperatingMode(), contentTypeDefinitionVOList, this.getLanguage(this.getLanguageId()), categoryConditions, getDatabase()); 3618 3619 final List result = new ArrayList (); 3620 for(Iterator i = set.iterator(); i.hasNext(); ) 3621 { 3622 final Content content = (Content) i.next(); 3623 if(ContentDeliveryController.getContentDeliveryController().isValidContent(this.getDatabase(), content.getId(), this.languageId, USE_LANGUAGE_FALLBACK, true, getPrincipal(), this.deliveryContext)) 3625 result.add(content.getValueObject()); 3626 } 3627 return result; 3628 } 3629 catch(Exception e) 3630 { 3631 logger.warn("An error occurred trying to get Matching Contents for contentTypeDefinitionNamesString: " + contentTypeDefinitionNamesString + ":" + e.getMessage(), e); 3632 } 3633 3634 return Collections.EMPTY_LIST; 3635 } 3636 3637 3641 3642 public Integer getOperatingMode() 3643 { 3644 Integer operatingMode = new Integer (0); try 3646 { 3647 operatingMode = new Integer (CmsPropertyHandler.getOperatingMode()); 3648 } 3650 catch(Exception e) 3651 { 3652 logger.warn("We could not get the operating mode from the propertyFile:" + e.getMessage(), e); 3653 } 3654 return operatingMode; 3655 } 3656 3657 3663 3664 public String getPageUrl(String structureBindningName, Integer contentId) 3665 { 3666 String pageUrl = ""; 3667 3668 try 3669 { 3670 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName); 3671 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, contentId, this.deliveryContext); 3672 } 3673 catch(Exception e) 3674 { 3675 logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3676 } 3677 3678 return pageUrl; 3679 } 3680 3681 3682 3688 3689 public String getPageUrlOnPosition(String structureBindningName, int position) 3690 { 3691 String pageUrl = ""; 3692 3693 try 3694 { 3695 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, position); 3696 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext); 3697 } 3698 catch(Exception e) 3699 { 3700 logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3701 } 3702 3703 return pageUrl; 3704 } 3705 3706 3707 3714 3715 public String getPageUrl(String structureBindningName, int position, Integer contentId) 3716 { 3717 String pageUrl = ""; 3718 3719 try 3720 { 3721 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, position); 3722 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, contentId, this.deliveryContext); 3723 } 3724 catch(Exception e) 3725 { 3726 logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e); 3727 } 3728 3729 return pageUrl; 3730 } 3731 3732 3733 3737 3738 public String getCurrentPageUrl() 3739 { 3740 String pageUrl = ""; 3741 3742 try 3743 { 3744 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, this.contentId, this.deliveryContext); 3745 } 3746 catch(Exception e) 3747 { 3748 logger.error("An error occurred trying to get current page url:" + e.getMessage(), e); 3749 } 3750 3751 return pageUrl; 3752 } 3753 3754 3758 3759 public String getOriginalFullURL() 3760 { 3761 String originalRequestURL = this.getHttpServletRequest().getParameter("originalRequestURL"); 3762 if(originalRequestURL == null || originalRequestURL.length() == 0) 3763 originalRequestURL = this.getHttpServletRequest().getRequestURL().toString(); 3764 3765 String originalQueryString = this.getHttpServletRequest().getParameter("originalQueryString"); 3766 if(originalQueryString == null || originalQueryString.length() == 0) 3767 originalQueryString = this.getHttpServletRequest().getQueryString(); 3768 3769 return originalRequestURL + "?" + originalQueryString; 3770 } 3771 3772 3775 3776 public String getPageUrl(Integer siteNodeId, Integer languageId, Integer contentId) 3777 { 3778 String pageUrl = ""; 3779 3780 try 3781 { 3782 pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeId, languageId, contentId, this.deliveryContext); 3783 } 3784 catch(Exception e) 3785 { 3786 logger.error("An error occurred trying to get current page url:" + e.getMessage(), e); 3787 } 3788 3789 return pageUrl; 3790 } 3791 3792 3798 3799 public String getPageAsDigitalAssetUrl(Integer siteNodeId, Integer languageId, Integer contentId, String fileSuffix) 3800 { 3801 String pageDigitalAssetUrl = ""; 3802 3803 try 3804 { 3805 pageDigitalAssetUrl = this.nodeDeliveryController.getPageAsDigitalAssetUrl(getDatabase(), this.getPrincipal(), siteNodeId, languageId, contentId, this.deliveryContext, fileSuffix); 3806 } 3807 catch(Exception e) 3808 { 3809 logger.error("An error occurred trying to get current page digitalAsset url:" + e.getMessage(), e); 3810 } 3811 3812 return pageDigitalAssetUrl; 3813 } 3814 3815 3819 3820 public String getCurrentPagePath() 3821 { 3822 String pagePath = ""; 3823 3824 try 3825 { 3826 pagePath = this.nodeDeliveryController.getPagePath(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, this.contentId, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext); 3827 } 3828 catch(Exception e) 3829 { 3830 logger.error("An error occurred trying to get current page url:" + e.getMessage(), e); 3831 } 3832 3833 return pagePath; 3834 } 3835 3836 3839 3840 public SiteNodeVO getParentSiteNode(Integer siteNodeId) 3841 { 3842 SiteNodeVO siteNodeVO = null; 3843 3844 try 3845 { 3846 siteNodeVO = this.nodeDeliveryController.getParentSiteNode(getDatabase(), siteNodeId); 3847 } 3848 catch(Exception e) 3849 { 3850 logger.warn("An error occurred trying to get parent siteNode:" + e.getMessage(), e); 3851 } 3852 3853 return siteNodeVO; 3854 } 3855 3856 3860 3861 public String getPageUrlAfterLanguageChange(String languageCode) 3862 { 3863 String pageUrl = ""; 3864 3865 try 3866 { 3867 LanguageVO languageVO = LanguageDeliveryController.getLanguageDeliveryController().getLanguageWithCode(getDatabase(), languageCode); 3868 pageUrl = this.nodeDeliveryController.getPageUrlAfterLanguageChange(getDatabase(), this.getPrincipal(), this.siteNodeId, languageVO.getLanguageId(), this.contentId, this.deliveryContext); 3870 } 3871 catch(Exception e) 3872 { 3873 logger.error("An error occurred trying to get the new page-url after language-change:" + e.getMessage(), e); 3874 } 3875 3876 return pageUrl; 3877 } 3878 3879 3880 3884 3885 public String getPageTitle() 3886 { 3887 String navTitle = ""; 3888 3889 try 3890 { 3891 navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, null, META_INFO_BINDING_NAME, TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, false); 3892 } 3893 catch(Exception e) 3894 { 3895 logger.error("An error occurred trying to get the page navigationtitle:" + e.getMessage(), e); 3896 } 3897 3898 return navTitle; 3899 } 3900 3901 3907 3908 public String getPageNavTitle(String structureBindningName) 3909 { 3910 return getPageNavTitle(structureBindningName, false); 3911 } 3912 3913 3919 3920 public String getPageNavTitle(String structureBindningName, boolean escapeHTML) 3921 { 3922 String navTitle = ""; 3923 3924 try 3925 { 3926 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName); 3927 logger.info(siteNodeVO.getName()); 3928 navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML); 3929 } 3930 catch(Exception e) 3931 { 3932 logger.error("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e); 3933 } 3934 3935 return navTitle; 3936 } 3937 3938 3942 3943 public String getPageNavTitle(Integer siteNodeId) 3944 { 3945 return getPageNavTitle(siteNodeId, false); 3946 } 3947 3948 3952 3953 public String getPageNavTitle(Integer siteNodeId, boolean escapeHTML) 3954 { 3955 String navTitle = ""; 3956 3957 try 3958 { 3959 navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML); 3960 } 3961 catch(Exception e) 3962 { 3963 logger.warn("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e); 3964 } 3965 3966 return navTitle; 3967 } 3968 3969 3974 3975 public String getPageNavTitle(String structureBindningName, int index) 3976 { 3977 return getPageNavTitle(structureBindningName, index, false); 3978 } 3979 3980 3985 3986 public String getPageNavTitle(String structureBindningName, int index, boolean escapeHTML) 3987 { 3988 String navTitle = ""; 3989 3990 try 3991 { 3992 SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, index); 3993 logger.info(siteNodeVO.getName()); 3994 navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML); 3995 } 3996 catch(Exception e) 3997 { 3998 logger.error("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e); 3999 } 4000 4001 return navTitle; 4002 } 4003 4004 4005 4009 4010 public boolean getIsPageCacheDisabled() 4011 { 4012 boolean isPageCacheDisabled = false; 4013 4014 try 4015 { 4016 isPageCacheDisabled = this.nodeDeliveryController.getIsPageCacheDisabled(getDatabase(), this.siteNodeId); 4017 } 4018 catch(Exception e) 4019 { 4020 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e); 4021 } 4022 4023 return isPageCacheDisabled; 4024 } 4025 4026 4029 4030 public String getPageContentType() 4031 { 4032 String pageContentType = "text/html"; 4033 4034 try 4035 { 4036 SiteNodeVersionVO latestSiteNodeVersionVO = this.nodeDeliveryController.getLatestActiveSiteNodeVersionVO(getDatabase(), this.siteNodeId); 4037 if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getContentType() != null && latestSiteNodeVersionVO.getContentType().length() > 0) 4038 pageContentType = latestSiteNodeVersionVO.getContentType(); 4039 } 4040 catch(Exception e) 4041 { 4042 logger.warn("An error occurred trying to get the content type of the page:" + e.getMessage(), e); 4043 } 4044 4045 return pageContentType; 4046 } 4047 4048 4052 4053 public boolean getIsPageProtected() 4054 { 4055 boolean isPageProtected = false; 4056 4057 try 4058 { 4059 isPageProtected = this.nodeDeliveryController.getIsPageProtected(getDatabase(), this.siteNodeId); 4060 } 4061 catch(Exception e) 4062 { 4063 logger.warn("An error occurred trying to get if the siteNodeVersion has protect page:" + e.getMessage(), e); 4064 } 4065 4066 return isPageProtected; 4067 } 4068 4069 public boolean getIsInPageComponentMode() 4070 { 4071 boolean isInPageComponentMode = false; 4072 4073 try 4074 { 4075 if(this instanceof EditOnSiteBasicTemplateController) 4076 isInPageComponentMode = true; 4077 } 4078 catch(Exception e) 4079 { 4080 logger.warn("An error occurred trying to get if the user was is editing mode:" + e.getMessage(), e); 4081 } 4082 4083 return isInPageComponentMode; 4084 } 4085 4086 4090 4091 public boolean getIsEditOnSightDisabled() 4092 { 4093 boolean isEditOnSightDisabled = false; 4094 4095 try 4096 { 4097 isEditOnSightDisabled = this.nodeDeliveryController.getIsEditOnSightDisabled(getDatabase(), this.siteNodeId); 4098 } 4099 catch(Exception e) 4100 { 4101 logger.warn("An error occurred trying to get if the siteNodeVersion has disabled editOnSight:" + e.getMessage(), e); 4102 } 4103 4104 return isEditOnSightDisabled; 4105 } 4106 4107 4108 4111 4112 public List getAvailableLanguages() 4113 { 4114 List availableLanguages = new ArrayList (); 4115 4116 try 4117 { 4118 availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getAvailableLanguages(getDatabase(), this.siteNodeId); 4119 } 4120 catch(Exception e) 4121 { 4122 logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e); 4123 } 4124 4125 return availableLanguages; 4126 } 4127 4128 4129 4134 4135 public List getNodeAvailableLanguages() 4136 { 4137 return getNodeAvailableLanguages(this.siteNodeId); 4138 } 4139 4140 4145 4146 public List getNodeAvailableLanguages(Integer siteNodeId) 4147 { 4148 List availableLanguages = new ArrayList (); 4149 4150 try 4151 { 4152 availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getAvailableLanguages(getDatabase(), siteNodeId); 4153 Iterator languageIterator = availableLanguages.iterator(); 4154 while(languageIterator.hasNext()) 4155 { 4156 LanguageVO languageVO = (LanguageVO)languageIterator.next(); 4157 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, META_INFO_BINDING_NAME, this.deliveryContext); 4158 ContentVersionVO contentVersionVO = null; 4159 if(contentVO != null) 4160 { 4161 contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), siteNodeId, contentVO.getId(), languageVO.getId(), false, this.deliveryContext, this.infoGluePrincipal); 4162 } 4163 4164 if(contentVO == null || contentVersionVO == null) 4165 { 4166 logger.warn("The meta-info did not have a version of " + languageVO.getName()); 4167 languageIterator.remove(); 4168 } 4169 } 4170 } 4171 catch(Exception e) 4172 { 4173 logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e); 4174 } 4175 4176 return availableLanguages; 4177 } 4178 4179 4183 4184 public List getPageLanguages() 4185 { 4186 return getPageLanguages(this.siteNodeId); 4187 } 4188 4189 4193 4194 public List getPageLanguages(Integer siteNodeId) 4195 { 4196 List availableLanguages = new ArrayList (); 4197 4198 try 4199 { 4200 availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getLanguagesForSiteNode(getDatabase(), siteNodeId, this.getPrincipal()); 4201 } 4202 catch(Exception e) 4203 { 4204 logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e); 4205 } 4206 4207 return availableLanguages; 4208 } 4209 4210 4211 4215 4216 public List getChildPages() 4217 { 4218 return getChildPages(false); 4219 } 4220 4221 4225 4226 public List getChildPages(boolean escapeHTML) 4227 { 4228 return getChildPages(false, false); 4229 } 4230 4231 4235 4236 public List getChildPages(boolean escapeHTML, boolean hideUnauthorizedPages) 4237 { 4238 List childPages = new ArrayList (); 4239 try 4240 { 4241 List childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), this.siteNodeId); 4242 childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages); 4243 } 4244 catch(Exception e) 4245 { 4246 logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e); 4247 } 4248 4249 return childPages; 4250 } 4251 4252 4253 4257 4258 public List getChildPages(String structureBindingName) 4259 { 4260 return getChildPages(structureBindingName, false); 4261 } 4262 4263 4267 4268 public List getChildPages(String structureBindingName, boolean escapeHTML) 4269 { 4270 return getChildPages(structureBindingName, escapeHTML, false); 4271 } 4272 4273 4277 4278 public List getChildPages(String structureBindingName, boolean escapeHTML, boolean hideUnauthorizedPages) 4279 { 4280 List childPages = new ArrayList (); 4281 try 4282 { 4283 List childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), this.getSiteNodeId(structureBindingName)); 4284 childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages); 4285 } 4286 catch(Exception e) 4287 { 4288 logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e); 4289 } 4290 4291 return childPages; 4292 } 4293 4294 4303 private List getPages(List childNodeVOList, boolean escapeHTML, boolean hideUnauthorizedPages) throws Exception 4304 { 4305 List childPages = new ArrayList (); 4306 4307 Iterator i = childNodeVOList.iterator(); 4308 while(i.hasNext()) 4309 { 4310 SiteNodeVO siteNodeVO = (SiteNodeVO)i.next(); 4311 if(!hideUnauthorizedPages || getHasUserPageAccess(siteNodeVO.getId())) 4312 { 4313 try 4314 { 4315 WebPage webPage = new WebPage(); 4316 webPage.setSiteNodeId(siteNodeVO.getSiteNodeId()); 4317 webPage.setLanguageId(this.languageId); 4318 webPage.setContentId(null); 4319 webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML)); 4320 webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext)); 4321 webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext)); 4322 childPages.add(webPage); 4323 } 4324 catch(Exception e) 4325 { 4326 logger.info("An error occurred when looking up one of the childPages:" + e.getMessage(), e); 4327 } 4328 } 4329 } 4330 4331 return childPages; 4332 } 4333 4334 4338 4339 public List getChildPages(Integer siteNodeId) 4340 { 4341 return getChildPages(siteNodeId, false, false); 4342 } 4343 4344 4348 4349 public List getChildPages(Integer siteNodeId, boolean escapeHTML) 4350 { 4351 return getChildPages(siteNodeId, escapeHTML, false); 4352 } 4353 4354 4358 4359 public List getChildPages(Integer siteNodeId, boolean escapeHTML, boolean hideUnauthorizedPages) 4360 { 4361 List childPages = new ArrayList (); 4362 try 4363 { 4364 List childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), siteNodeId); 4365 childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages); 4366 } 4367 catch(Exception e) 4368 { 4369 logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e); 4370 } 4371 4372 return childPages; 4373 } 4374 4375 4379 4380 public List getChildPages(Integer siteNodeId, String sortAttribute, String sortOrder) 4381 { 4382 return getChildPages(siteNodeId, sortAttribute, sortOrder, false, false); 4383 } 4384 4385 4389 4390 public List getChildPages(Integer siteNodeId, String sortAttribute, String sortOrder, boolean hideUnauthorizedPages) 4391 { 4392 return getChildPages(siteNodeId, sortAttribute, sortOrder, false, hideUnauthorizedPages); 4393 } 4394 4395 4399 4400 public List getChildPages(Integer siteNodeId, String sortAttribute, String sortOrder, boolean escapeHTML, boolean hideUnauthorizedPages) 4401 { 4402 List childPages = new ArrayList (); 4403 try 4404 { 4405 List childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), siteNodeId); 4406 Collections.sort(childNodeVOList, new SiteNodeComparator(sortAttribute, sortOrder, this)); 4407 childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages); 4408 } 4409 catch(Exception e) 4410 { 4411 logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e); 4412 } 4413 4414 return childPages; 4415 } 4416 4417 4418 4422 4423 public List getBoundPages(String structureBindningName) 4424 { 4425 return getBoundPages(structureBindningName, false, false); 4426 } 4427 4428 4432 4433 public List getBoundPages(String structureBindningName, boolean escapeHTML) 4434 { 4435 return getBoundPages(structureBindningName, escapeHTML, false); 4436 } 4437 4438 4442 4443 public List getBoundPages(String structureBindningName, boolean escapeHTML, boolean hideUnauthorizedPages) 4444 { 4445 return getBoundPages(this.siteNodeId, structureBindningName, escapeHTML, false); 4446 } 4447 4448 4449 public List getBoundPages(Integer siteNodeId, String structureBindningName) 4450 { 4451 return getBoundPages(siteNodeId, structureBindningName, false, false); 4452 } 4453 4454 public List getBoundPages(Integer siteNodeId, String structureBindningName, boolean escapeHTML) 4455 { 4456 return getBoundPages(siteNodeId, structureBindningName, escapeHTML, false); 4457 } 4458 4459 private HashMap cachedBindings = new HashMap (); 4460 4461 4464 4465 public List getBoundPages(Integer siteNodeId, String structureBindningName, boolean escapeHTML, boolean hideUnauthorizedPages) 4466 { 4467 if(cachedBindings.containsKey(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages)) 4469 return (List )cachedBindings.get(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages); 4470 4471 List boundPages = new ArrayList (); 4472 try 4473 { 4474 List siteNodeVOList = this.nodeDeliveryController.getBoundSiteNodes(getDatabase(), siteNodeId, structureBindningName); 4475 boundPages = getPages(siteNodeVOList, escapeHTML, hideUnauthorizedPages); 4476 } 4477 catch(Exception e) 4478 { 4479 logger.error("An error occurred trying to get the bound pages:" + e.getMessage(), e); 4480 } 4481 4482 cachedBindings.put(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages, boundPages); 4484 4485 return boundPages; 4486 } 4487 4488 4489 4490 4495 4496 public List getLocalizedBoundPages(String structureBindningName) 4497 { 4498 if(cachedBindings.containsKey(structureBindningName)) 4500 return (List )cachedBindings.get(structureBindningName); 4501 4502 List boundPages = new ArrayList (); 4503 try 4504 { 4505 List siteNodeVOList = this.nodeDeliveryController.getBoundSiteNodes(getDatabase(), this.siteNodeId, structureBindningName); 4506 4507 Iterator i = siteNodeVOList.iterator(); 4508 while(i.hasNext()) 4509 { 4510 SiteNodeVO siteNodeVO = (SiteNodeVO)i.next(); 4511 4512 try 4513 { 4514 Integer metaInfoContentId = this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, DO_NOT_USE_INHERITANCE, this.deliveryContext); 4515 String navigationTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, DO_NOT_USE_LANGUAGE_FALLBACK, this.deliveryContext, false); 4516 if(metaInfoContentId != null && navigationTitle != null && !navigationTitle.equals("")) 4517 { 4518 WebPage webPage = new WebPage(); 4519 webPage.setSiteNodeId(siteNodeVO.getSiteNodeId()); 4520 webPage.setLanguageId(this.languageId); 4521 webPage.setContentId(null); 4522 webPage.setNavigationTitle(navigationTitle); 4523 webPage.setMetaInfoContentId(metaInfoContentId); 4524 webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext)); 4525 boundPages.add(webPage); 4526 } 4527 } 4528 catch(Exception e) 4529 { 4530 logger.info("An error occurred when looking up one of the getLocalizedBoundPages:" + e.getMessage(), e); 4531 } 4532 } 4533 } 4534 catch(Exception e) 4535 { 4536 logger.error("An error occurred trying to get the bound pages:" + e.getMessage(), e); 4537 } 4538 4539 cachedBindings.put(structureBindningName, boundPages); 4541 4542 return boundPages; 4543 } 4544 4545 4546 4547 4551 4552 public ContentVO getBoundContent(String structureBindningName) 4553 { 4554 ContentVO content = null; 4555 4556 List contents = getBoundContents(structureBindningName); 4557 4558 if(contents != null && contents.size() > 0) 4559 content = (ContentVO)contents.get(0); 4560 4561 return content; 4562 } 4563 4564 4565 4569 4570 public List getBoundContents(String structureBindningName) 4571 { 4572 if(cachedBindings.containsKey(structureBindningName)) 4574 return (List )cachedBindings.get(structureBindningName); 4575 4576 List boundContents = new ArrayList (); 4577 try 4578 { 4579 boundContents = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, structureBindningName, USE_INHERITANCE, true, this.deliveryContext); 4580 } 4581 catch(Exception e) 4582 { 4583 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4584 } 4585 4586 cachedBindings.put(structureBindningName, boundContents); 4588 4589 return boundContents; 4590 } 4591 4592 4593 4599 4600 public List getBoundFolderContents(String structureBindningName, boolean searchRecursive, String sortAttribute, String sortOrder) 4601 { 4602 List boundContents = new ArrayList (); 4603 try 4604 { 4605 boundContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, structureBindningName, searchRecursive, new Integer (3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, false, this.deliveryContext); 4606 } 4607 catch(Exception e) 4608 { 4609 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4610 } 4611 4612 return boundContents; 4613 } 4614 4615 4616 4622 4623 public List getBoundFolderContents(Integer siteNodeId, String structureBindningName, boolean searchRecursive, String sortAttribute, String sortOrder) 4624 { 4625 List boundContents = new ArrayList (); 4626 try 4627 { 4628 boundContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, structureBindningName, searchRecursive, new Integer (3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, false, this.deliveryContext); 4629 } 4630 catch(Exception e) 4631 { 4632 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4633 } 4634 4635 return boundContents; 4636 } 4637 4638 4644 4645 public List getChildContents(Integer contentId, boolean searchRecursive, String sortAttribute, String sortOrder) 4646 { 4647 return getChildContents(contentId, searchRecursive, sortAttribute, sortOrder, false); 4648 } 4649 4650 4651 4657 4658 public List getChildContents(Integer contentId, boolean searchRecursive, String sortAttribute, String sortOrder, boolean includeFolders) 4659 { 4660 List childContents = new ArrayList (); 4661 try 4662 { 4663 childContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), contentId, this.languageId, searchRecursive, new Integer (3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, includeFolders, this.deliveryContext); 4664 } 4665 catch(Exception e) 4666 { 4667 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4668 } 4669 4670 return childContents; 4671 } 4672 4673 4674 4677 4678 public ContentTypeDefinitionVO getContentTypeDefinitionVO(Integer contentId) 4679 { 4680 ContentTypeDefinitionVO contentTypeDefinition = null; 4681 4682 try 4683 { 4684 contentTypeDefinition = ContentDeliveryController.getContentDeliveryController().getContentTypeDefinitionVO(this.getDatabase(), contentId); 4685 4686 } 4687 catch(Exception e) 4688 { 4689 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4690 } 4691 4692 return contentTypeDefinition; 4693 } 4694 4695 4698 4699 public ContentTypeDefinitionVO getContentTypeDefinitionVO(String name) 4700 { 4701 ContentTypeDefinitionVO contentTypeDefinition = null; 4702 4703 try 4704 { 4705 contentTypeDefinition = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName(name, getDatabase()); 4706 } 4707 catch(Exception e) 4708 { 4709 logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e); 4710 } 4711 4712 return contentTypeDefinition; 4713 } 4714 4715 4721 4722 public WebPage getBoundPage(String structureBindningName, int position) 4723 { 4724 List boundPages = getBoundPages(structureBindningName); 4725 4726 if(boundPages.size() > position) 4727 return (WebPage)boundPages.get(position); 4728 else 4729 return null; 4730 } 4731 4732 4733 4736 4737 public String renderString(String template) 4738 { 4739 String result = ""; 4740 4741 try 4742 { 4743 Map context = new HashMap (); 4744 context.put("inheritedTemplateLogic", this); 4745 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 4746 4747 context.putAll(templateLogicContext); 4749 4750 StringWriter cacheString = new StringWriter (); 4751 PrintWriter cachedStream = new PrintWriter (cacheString); 4752 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, template); 4753 result = cacheString.toString(); 4754 } 4755 catch(Exception e) 4756 { 4757 logger.error("An error occurred trying to do an include:" + e.getMessage(), e); 4758 } 4759 4760 return result; 4761 } 4762 4763 4766 4767 public String renderString(String template, boolean useSubContext) 4768 { 4769 String result = ""; 4770 4771 try 4772 { 4773 Map context = new HashMap (); 4774 if(!useSubContext) 4775 context.put("templateLogic", this); 4776 else 4777 { 4778 context.put("inheritedTemplateLogic", this); 4779 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 4780 } 4781 4782 context.putAll(templateLogicContext); 4784 4785 StringWriter cacheString = new StringWriter (); 4786 PrintWriter cachedStream = new PrintWriter (cacheString); 4787 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, template); 4788 result = cacheString.toString(); 4789 } 4790 catch(Exception e) 4791 { 4792 logger.error("An error occurred trying to do an include:" + e.getMessage(), e); 4793 } 4794 4795 return result; 4796 } 4797 4798 4803 4804 4805 public String include(String contentBindningName, String attributeName) 4806 { 4807 return include(contentBindningName, attributeName, true); 4808 } 4809 4810 public String include(String contentBindningName, String attributeName, boolean cacheInclude) 4811 { 4812 return include(contentBindningName, attributeName, cacheInclude, null, null); 4813 } 4814 4815 4820 public String include(String contentBindningName, String attributeName, boolean cacheInclude, String cName, Object cObject) 4821 { 4822 String includeKey = "" + this.siteNodeId + "_" + this.languageId + "_" + this.contentId + "_" + browserBean.getUseragent() + "_" + contentBindningName + "_" + attributeName; 4823 logger.info("includeKey:" + includeKey); 4824 String result = (String )CacheController.getCachedObject("includeCache", includeKey); 4825 if(result != null) 4826 { 4827 logger.info("There was an cached include:" + result); 4828 } 4829 else 4830 { 4831 try 4832 { 4833 ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext); 4834 if(contentVO != null) 4835 { 4836 String includedTemplate = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getContentId(), this.languageId, "Template", this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false); 4837 logger.info("Found included template:" + includedTemplate); 4838 4839 Map context = new HashMap (); 4840 context.put("inheritedTemplateLogic", this); 4841 context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext)); 4842 context.put("deliveryContext", this.deliveryContext); 4843 4844 context.putAll(templateLogicContext); 4846 4847 if (cName != null) 4848 context.put(cName, cObject); 4849 4850 StringWriter cacheString = new StringWriter (); 4851 PrintWriter cachedStream = new PrintWriter (cacheString); 4852 new VelocityTemplateProcessor().renderTemplate(context, cachedStream, includedTemplate); 4853 result = cacheString.toString(); 4854 4855 logger.info("result:" + result); 4856 4857 if(cacheInclude) 4858 CacheController.cacheObject("includeCache", includeKey, result); 4859 } 4860 } 4861 catch(Exception e) 4862 { 4863 logger.error("An error occurred trying to do an include:" + e.getMessage(), e); 4864 } 4865 } 4866 4867 return result; 4868 } 4869 4870 4871 4875 4876 public String getUrlContent(String url) 4877 { 4878 String contents = ""; 4879 4880 try 4881 { 4882 logger.info("We are going to do an include on an external webpage: " + url); 4883 contents = this.integrationDeliveryController.getUrlContent(url, request, true); 4884 } 4886 catch(Exception e) 4887 { 4888 logger.error("An error occurred trying to do an include the url:" + url, e); 4889 } 4890 4891 return contents; 4892 } 4893 4894 4898 4899 public String getUrlContent(String url, boolean includeRequest) 4900 { 4901 String contents = ""; 4902 4903 try 4904 { 4905 logger.info("We are going to do an include on an external webpage: " + url); 4906 contents = this.integrationDeliveryController.getUrlContent(url, request, includeRequest); 4907 } 4909 catch(Exception e) 4910 { 4911 logger.error("An error occurred trying to do an include the url:" + url, e); 4912 } 4913 4914 return contents; 4915 } 4916 4917 4921 4922 public String getUrlContent(String url, String encoding) 4923 { 4924 String contents = ""; 4925 4926 try 4927 { 4928 logger.info("We are going to do an include on an external webpage: " + url); 4929 contents = this.integrationDeliveryController.getUrlContent(url, request, true, encoding); 4930 } 4932 catch(Exception e) 4933 { 4934 logger.error("An error occurred trying to do an include the url:" + url, e); 4935 } 4936 4937 return contents; 4938 } 4939 4940 4944 4945 public String getUrlContent(String url, boolean includeRequest, String encoding) 4946 { 4947 String contents = ""; 4948 4949 try 4950 { 4951 logger.info("We are going to do an include on an external webpage: " + url); 4952 contents = this.integrationDeliveryController.getUrlContent(url, request, includeRequest, encoding); 4953 } 4955 catch(Exception e) 4956 { 4957 logger.error("An error occurred trying to do an include the url:" + url, e); 4958 } 4959 4960 return contents; 4961 } 4962 4963 4964 public Object getObjectWithName(String classname) 4965 { 4966 try 4967 { 4968 return this.integrationDeliveryController.getObjectWithName(classname, request); 4969 } 4970 catch (InstantiationException e) 4971 { 4972 e.printStackTrace(); 4973 } 4974 catch (IllegalAccessException e) 4975 { 4976 e.printStackTrace(); 4977 } 4978 catch (ClassNotFoundException e) 4979 { 4980 e.printStackTrace(); 4981 } 4982 return null; 4983 } 4984 4985 4986 4990 4991 public String replace(String originalString, String expressionToReplace, String newString) 4992 { 4993 return originalString.replaceAll(expressionToReplace, newString); 4994 } 4995 4996 5001 5002 public String replace(String originalString, String substring, String stringToReplace, String newString) 5003 { 5004 StringBuffer result = new StringBuffer (); 5005 int startIndex = 0; 5006 int stopIndex = 0; 5007 int offset = 0; 5008 5009 try 5010 { 5011 List substrings = search(originalString, substring); 5012 5013 Iterator substringsIterator = substrings.iterator(); 5014 while(substringsIterator.hasNext()) 5015 { 5016 String currentSubstring = (String )substringsIterator.next(); 5017 String newSubstring = currentSubstring.replaceAll(stringToReplace, newString); 5018 startIndex = originalString.indexOf(currentSubstring, offset); 5019 stopIndex = startIndex + currentSubstring.length(); 5020 result.append(originalString.substring(offset, startIndex)); 5021 result.append(originalString.substring(startIndex, stopIndex)); 5022 result.append(newSubstring); 5023 offset = stopIndex; 5024 } 5025 5026 if(offset < originalString.length()) 5027 { 5028 result.append(originalString.substring(offset)); 5029 } 5030 } 5031 catch(Exception e) 5032 { 5033 logger.error("The replace function experienced an error:" + e.getMessage(), e); 5034 } 5035 5036 return result.toString(); 5037 } 5038 5039 5040 5041 5048 5049 private List search(String containsMatches, String regexp) throws Exception 5050 { 5051 List foundMatches = new ArrayList (); 5052 int matches = 0; 5053 5054 PatternCompiler compiler = new Perl5Compiler(); 5055 PatternMatcher matcher = new Perl5Matcher(); 5056 Pattern pattern = null; 5057 5058 try 5059 { 5060 pattern = compiler.compile(regexp); 5061 } 5062 catch (MalformedPatternException e) 5063 { 5064 throw new Exception ("A bad pattern was entered:" + e.getMessage()); 5065 } 5066 5067 PatternMatcherInput input = new PatternMatcherInput(containsMatches); 5068 5069 while (matcher.contains(input, pattern)) 5070 { 5071 MatchResult result = matcher.getMatch(); 5072 ++matches; 5073 foundMatches.add(result.toString()); 5074 } 5075 5076 return foundMatches; 5077 } 5078 5079 5080 5083 5084 public boolean getIsCurrentSiteNode(Integer siteNodeId) 5085 { 5086 return this.siteNodeId.equals(siteNodeId); 5087 } 5088 5089 5094 5095 public boolean getIsParentToCurrent(Integer siteNodeId) 5096 { 5097 return getIsParentToCurrentRecursive(siteNodeId, this.siteNodeId); 5098 } 5099 5100 5103 5104 private boolean getIsParentToCurrentRecursive(Integer siteNodeId, Integer currentSiteNodeId) 5105 { 5106 boolean isParentToCurrent = false; 5107 5108 try 5109 { 5110 if(currentSiteNodeId != null && siteNodeId != null && currentSiteNodeId.intValue() == siteNodeId.intValue()) 5111 { 5112 isParentToCurrent = true; 5113 } 5114 else 5115 { 5116 SiteNodeVO parentSiteNodeVO = this.nodeDeliveryController.getParentSiteNode(getDatabase(), currentSiteNodeId); 5117 if(parentSiteNodeVO != null) 5118 isParentToCurrent = getIsParentToCurrentRecursive(siteNodeId, parentSiteNodeVO.getSiteNodeId()); 5119 } 5120 } 5121 catch(Exception e) 5122 { 5123 logger.error("An error occurred:" + e.getMessage(), e); 5124 } 5125 5126 return isParentToCurrent; 5127 } 5128 5129 5132 5133 public boolean getHasLocalizedVersion(Integer contentId) 5134 { 5135 boolean ret = false; 5136 try 5137 { 5138 ret = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, false, this.deliveryContext, this.infoGluePrincipal) != null; 5139 } 5140 catch(Exception e) 5141 { 5142 logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e); 5143 } 5144 return ret; 5145 } 5146 5147 5150 5151 public boolean getHasUserPageAccess(Integer siteNodeId) 5152 { 5153 boolean hasUserPageAccess = false; 5154 5155 try 5156 { 5157 Integer protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId); 5158 if(protectedSiteNodeVersionId == null) 5159 { 5160 logger.info("The page was not protected..."); 5161 hasUserPageAccess = true; 5162 } 5163 else 5164 { 5165 logger.info("The page was protected..."); 5166 Principal principal = this.getPrincipal(); 5167 logger.info("Principal:" + principal); 5168 5169 if(principal != null) 5170 { 5171 hasUserPageAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, "SiteNodeVersion.Read", protectedSiteNodeVersionId.toString()); 5173 } 5174 } 5175 } 5176 catch(Exception e) 5177 { 5178 logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e); 5179 } 5180 5181 return hasUserPageAccess; 5182 } 5183 5184 5187 5188 public boolean getHasUserPageAccess(Integer siteNodeId, String interceptionPointName) 5189 { 5190 boolean hasUserPageAccess = false; 5191 5192 try 5193 { 5194 Integer protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId); 5195 if(protectedSiteNodeVersionId == null) 5196 { 5197 logger.info("The page was not protected..."); 5198 hasUserPageAccess = true; 5199 } 5200 else 5201 { 5202 logger.info("The page was protected..."); 5203 Principal principal = this.getPrincipal(); 5204 logger.info("Principal:" + principal); 5205 5206 if(principal != null) 5207 { 5208 hasUserPageAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, interceptionPointName, protectedSiteNodeVersionId.toString()); 5210 } 5211 } 5212 } 5213 catch(Exception e) 5214 { 5215 logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e); 5216 } 5217 5218 return hasUserPageAccess; 5219 } 5220 5221 5222 5225 5226 public boolean getHasUserContentAccess(Integer contentId) 5227 { 5228 boolean hasUserContentAccess = true; 5229 5230 try 5231 { 5232 if(contentId != null) 5233 { 5234 Integer protectedContentId = ContentDeliveryController.getContentDeliveryController().getProtectedContentId(getDatabase(), contentId); 5235 logger.info("IsProtected:" + protectedContentId); 5236 if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Read", protectedContentId.toString())) 5237 { 5238 hasUserContentAccess = false; 5239 } 5240 } 5241 } 5242 catch(Exception e) 5243 { 5244 logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e); 5245 } 5246 5247 return hasUserContentAccess; 5248 } 5249 5250 5254 5255 public boolean getHasUserContentAccess(Integer contentId, String action) 5256 { 5257 boolean hasUserContentAccess = true; 5258 5259 try 5260 { 5261 Integer protectedContentId = ContentDeliveryController.getContentDeliveryController().getProtectedContentId(getDatabase(), contentId); 5262 logger.info("IsProtected:" + protectedContentId); 5263 if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, action, protectedContentId.toString())) 5264 { 5265 hasUserContentAccess = false; 5266 } 5267 } 5268 catch(Exception e) 5269 { 5270 logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e); 5271 } 5272 5273 return hasUserContentAccess; 5274 } 5275 5276 5279 5280 public boolean getHasUserPageWriteAccess(Integer siteNodeId) 5281 { 5282 boolean hasUserPageWriteAccess = false; 5283 5284 try 5285 { 5286 Integer protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId); 5287 if(protectedSiteNodeVersionId == null) 5288 { 5289 logger.info("The page was not protected..."); 5290 hasUserPageWriteAccess = true; 5291 } 5292 else 5293 { 5294 logger.info("The page was protected..."); 5295 Principal principal = this.getPrincipal(); 5296 logger.info("Principal:" + principal); 5297 5298 if(principal != null) 5299 { 5300 hasUserPageWriteAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, "SiteNodeVersion.Write", protectedSiteNodeVersionId.toString()); 5301 } 5302 } 5303 5322 } 5323 catch(Exception e) 5324 { 5325 logger.error("An error occurred trying to find out if the user had write access to page:" + siteNodeId + ": " + e.getMessage(), e); 5326 } 5327 5328 return hasUserPageWriteAccess; 5329 } 5330 5331 5335 5336 public List getFormAttributes(String contentBindningName, String attributeName) 5337 { 5338 String formDefinition = getContentAttribute(contentBindningName, attributeName, true); 5339 return FormDeliveryController.getFormDeliveryController().getContentTypeAttributes(formDefinition); 5340 } 5341 5342 5346 5347 public List getFormAttributes(Integer contentId, String attributeName) 5348 { 5349 String formDefinition = getContentAttribute(contentId, attributeName, true); 5350 return FormDeliveryController.getFormDeliveryController().getContentTypeAttributes(formDefinition); 5351 } 5352 5353 5354 5357 5358 public List getWorkflowSteps(String workflowId) 5359 { 5360 List workflowSteps = null; 5361 5362 try 5363 { 5364 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 5365 if(infoGluePrincipal == null) 5366 { 5367 Map arguments = new HashMap (); 5368 arguments.put("j_username", CmsPropertyHandler.getAnonymousUser()); 5369 arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword()); 5370 5371 infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments); 5372 } 5373 5374 WorkflowController workflowController = WorkflowController.getController(); 5375 logger.info("infoGluePrincipal:" + infoGluePrincipal); 5376 logger.info("workflowId:" + workflowId); 5377 workflowSteps = workflowController.getAllSteps(infoGluePrincipal, new Long (workflowId).longValue()); 5378 } 5379 catch(Exception e) 5380 { 5381 logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e); 5382 } 5383 5384 return workflowSteps; 5385 } 5386 5387 5390 5391 public List getWorkflowHistoricalSteps(String workflowId) 5392 { 5393 List workflowSteps = null; 5394 5395 try 5396 { 5397 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 5398 if(infoGluePrincipal == null) 5399 { 5400 Map arguments = new HashMap (); 5401 arguments.put("j_username", CmsPropertyHandler.getAnonymousUser()); 5402 arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword()); 5403 5404 infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments); 5405 } 5406 5407 WorkflowController workflowController = WorkflowController.getController(); 5408 workflowSteps = workflowController.getHistorySteps(infoGluePrincipal, new Long (workflowId).longValue()); 5409 } 5410 catch(Exception e) 5411 { 5412 logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e); 5413 } 5414 5415 return workflowSteps; 5416 } 5417 5418 5421 5422 public List getWorkflowCurrentSteps(String workflowId) 5423 { 5424 List workflowSteps = null; 5425 5426 try 5427 { 5428 InfoGluePrincipal infoGluePrincipal = this.getPrincipal(); 5429 if(infoGluePrincipal == null) 5430 { 5431 Map arguments = new HashMap (); 5432 arguments.put("j_username", CmsPropertyHandler.getAnonymousUser()); 5433 arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword()); 5434 5435 infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments); 5436 } 5437 5438 WorkflowController workflowController = WorkflowController.getController(); 5439 workflowSteps = workflowController.getCurrentSteps(infoGluePrincipal, new Long (workflowId).longValue()); 5440 } 5441 catch(Exception e) 5442 { 5443 logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e); 5444 } 5445 5446 return workflowSteps; 5447 } 5448 5449 5458 5459 public void setCookie(String cookieName, String value, String domain, String path, Integer maxAge) 5460 { 5461 Cookie cookie = new Cookie (cookieName, value); 5462 if(domain != null) 5463 cookie.setDomain(domain); 5464 5465 if(path != null) 5466 cookie.setPath(path); 5467 5468 if(maxAge != null) 5469 cookie.setMaxAge(maxAge.intValue()); 5470 5471 this.deliveryContext.getHttpServletResponse().addCookie(cookie); 5472 } 5473 5474 5479 5480 public String getCookie(String cookieName) 5481 { 5482 if(this.request != null) 5483 { 5484 Cookie [] cookies = this.request.getCookies(); 5485 if(cookies != null) 5486 { 5487 for(int i=0; i<cookies.length; i++) 5488 { 5489 Cookie cookie = cookies[i]; 5490 if(cookie.getName().equals(cookieName)) 5491 return cookie.getValue(); 5492 } 5493 } 5494 } 5495 5496 return null; 5497 } 5498 5499 5502 5531 5532 5533 5536 5564 5565 5568 5596 5597 5600 5624 5625 5626 5629 5630 public LanguageVO getLanguage(Integer languageId) 5631 { 5632 LanguageVO language = null; 5633 5634 try 5635 { 5636 language = LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), languageId); 5637 } 5638 catch(Exception e) 5639 { 5640 logger.warn("An error occurred when getting language:" + e.getMessage(), e); 5641 } 5642 5643 return language; 5644 } 5645 5646 5649 5650 public LanguageVO getLanguage(String languageCode) 5651 { 5652 LanguageVO language = null; 5653 5654 try 5655 { 5656 language = LanguageDeliveryController.getLanguageDeliveryController().getLanguageWithCode(getDatabase(), languageCode); 5657 } 5658 catch(Exception e) 5659 { 5660 logger.warn("An error occurred when getting language:" + e.getMessage(), e); 5661 } 5662 5663 return language; 5664 } 5665 5666 5669 5670 public Locale getLanguageCode(Integer languageId) throws SystemException 5671 { 5672 return LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), languageId); 5673 } 5674 5675 5678 5679 public Locale getLocale() throws SystemException 5680 { 5681 return LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), this.languageId); 5682 } 5683 5684 5685 5689 5690 public String getLogoutURL() throws Exception 5691 { 5692 AuthenticationModule authenticationModule = AuthenticationModule.getAuthenticationModule(this.getDatabase(), null); 5693 return authenticationModule.getLogoutUrl(); 5694 } 5695 5696 5700 5701 public TemplateController getTemplateController(Integer siteNodeId, Integer languageId, Integer contentId, InfoGluePrincipal infoGluePrincipal, DeliveryContext deliveryContext) throws SystemException, Exception 5702 { 5703 return getTemplateController(siteNodeId, languageId, contentId, this.request, infoGluePrincipal, deliveryContext); 5704 } 5705 5706 public TemplateController getTemplateController(Integer siteNodeId, Integer languageId, Integer contentId, HttpServletRequest request, InfoGluePrincipal infoGluePrincipal, DeliveryContext deliveryContextt) throws SystemException, Exception 5707 { 5708 TemplateController templateController = null; 5709 templateController = new BasicTemplateController(this.databaseWrapper, infoGluePrincipal); 5710 templateController.setStandardRequestParameters(siteNodeId, languageId, contentId); 5711 templateController.setHttpRequest(request); 5712 templateController.setBrowserBean(this.browserBean); 5713 templateController.setDeliveryControllers(this.nodeDeliveryController, null, this.integrationDeliveryController); 5714 templateController.setDeliveryContext(deliveryContext); 5715 if(isPersistedContext()) 5716 { 5717 ((BasicTemplateController) templateController).addToContext(templateLogicContext); 5718 ((BasicTemplateController) templateController).setPersistedContext(true); 5719 } 5720 5721 String operatingMode = CmsPropertyHandler.getOperatingMode(); 5722 String editOnSite = CmsPropertyHandler.getEditOnSite(); 5723 boolean isEditOnSightDisabled = templateController.getIsEditOnSightDisabled(); 5724 boolean allowEditOnSightAtAll = false; 5725 if(request.getRequestURL().indexOf("!renderDecoratedPage") > -1) 5726 allowEditOnSightAtAll = true; 5727 5728 if(!isEditOnSightDisabled && operatingMode != null && (operatingMode.equals("0") || operatingMode.equals("1") || operatingMode.equals("2")) && editOnSite != null && editOnSite.equalsIgnoreCase("true")) 5729 { 5730 templateController = new EditOnSiteBasicTemplateController(this.databaseWrapper, infoGluePrincipal); 5731 templateController.setStandardRequestParameters(siteNodeId, languageId, contentId); 5732 templateController.setHttpRequest(request); 5733 templateController.setBrowserBean(browserBean); 5734 templateController.setDeliveryControllers(this.nodeDeliveryController, null, this.integrationDeliveryController); 5735 templateController.setDeliveryContext(deliveryContext); 5736 } 5737 5738 5739 return templateController; 5740 } 5741 5742 public String decoratePage(String page) 5743 { 5744 return page; 5745 } 5746 5747 5752 5753 public String getEditOnSightTag(Integer contentId, String attributeName, String html, boolean showInPublishedMode) 5754 { 5755 return getEditOnSightTag(contentId, this.getLanguageId(), attributeName, html, showInPublishedMode); 5756 } 5757 5758 5763 5764 public String getEditOnSightTag(Integer contentId, Integer languageId, String attributeName, String html, boolean showInPublishedMode) 5765 { 5766 if(showInPublishedMode == false && this.getOperatingMode().intValue() == 3) 5767 return ""; 5768 else 5769 { 5770 String editOnSiteUrl = CmsPropertyHandler.getEditOnSiteUrl(); 5771 String decoratedAttributeValue = "<a HREF=\"#\" onClick=\"window.open('" + editOnSiteUrl + "?contentId=" + contentId + "&languageId=" + languageId + "&attributeName=" + attributeName + "', 'Edit', 'width=500,height=600,left=' + (document.body.clientWidth / 4) + ',top=' + (document.body.clientHeight / 4) + ',toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=no');\">" + html + "</a>"; 5772 return decoratedAttributeValue; 5773 } 5774 } 5775 5776 5777 5785 public String getAssignPropertyBindingTag(String propertyName, boolean createNew, String html, boolean showInPublishedMode) 5786 { 5787 String result = ""; 5788 5789 try 5790 { 5791 String componentEditorUrl = CmsPropertyHandler.getComponentEditorUrl(); 5792 5793 DecoratedComponentBasedHTMLPageInvoker dec = new DecoratedComponentBasedHTMLPageInvoker(); 5794 Collection properties = dec.getComponentProperties(this.getComponentLogic().getInfoGlueComponent().getId(), this, siteNodeId, languageId, this.getComponentLogic().getInfoGlueComponent().getContentId()); 5795 5796 ComponentProperty property = null; 5797 Iterator propertiesIterator = properties.iterator(); 5798 while(propertiesIterator.hasNext()) 5799 { 5800 ComponentProperty propertyCandidate = (ComponentProperty)propertiesIterator.next(); 5801 if(propertyCandidate.getName().equals(propertyName)) 5802 property = propertyCandidate; 5803 } 5804 5805 String contentId = "-1"; 5806 5807 String createUrl = ""; 5808 String assignUrl = ""; 5809 5810 Integer componentId = this.getComponentLogic().getInfoGlueComponent().getId(); 5811 Integer repositoryId = this.getSiteNode().getRepositoryId(); 5812 5813 if(property.getVisualizingAction() != null && !property.getVisualizingAction().equals("")) 5814 { 5815 assignUrl = componentEditorUrl + property.getVisualizingAction() + "?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5816 } 5817 else 5818 { 5819 if(property.getEntityClass().equalsIgnoreCase("Content")) 5820 { 5821 String allowedContentTypeIdParameters = ""; 5822 5823 if(property.getAllowedContentTypeNamesArray() != null && property.getAllowedContentTypeNamesArray().length > 0) 5824 { 5825 allowedContentTypeIdParameters = "&" + property.getAllowedContentTypeIdAsUrlEncodedString(getDatabase()); 5826 logger.info("allowedContentTypeIdParameters:" + allowedContentTypeIdParameters); 5827 } 5828 5829 if(property.getIsMultipleBinding()) 5830 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showContentTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&showSimple=" + getDeliveryContext().getShowSimple(); 5831 else 5832 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showContentTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&showSimple=" + getDeliveryContext().getShowSimple(); 5833 } 5834 else if(property.getEntityClass().equalsIgnoreCase("SiteNode")) 5835 { 5836 if(property.getIsMultipleBinding()) 5837 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showStructureTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5838 else 5839 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showStructureTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5840 } 5841 else if(property.getEntityClass().equalsIgnoreCase("Category")) 5842 { 5843 if(property.getIsMultipleBinding()) 5844 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showCategoryTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5845 else 5846 assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showCategoryTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5847 } 5848 } 5849 5850 5851 if(property.getCreateAction() != null && !property.getCreateAction().equals("")) 5852 { 5853 createUrl = componentEditorUrl + property.getCreateAction() + "?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5854 } 5855 else 5856 { 5857 if(property.getVisualizingAction() != null && !property.getVisualizingAction().equals("")) 5858 { 5859 createUrl = assignUrl; 5860 } 5861 else if(property.getEntityClass().equalsIgnoreCase("Content")) 5862 { 5863 String allowedContentTypeIdParameters = ""; 5864 5865 if(property.getAllowedContentTypeNamesArray() != null && property.getAllowedContentTypeNamesArray().length > 0) 5866 { 5867 allowedContentTypeIdParameters = "&" + property.getAllowedContentTypeIdAsUrlEncodedString(getDatabase()); 5868 logger.info("allowedContentTypeIdParameters:" + allowedContentTypeIdParameters); 5869 } 5870 5871 String returnAddress = URLEncoder.encode("ViewSiteNodePageComponents!addComponentPropertyBinding.action?siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=-1&entity=Content&entityId=#entityId&componentId=" + componentId + "&propertyName=" + property.getName() + "&path=#path&showSimple=" + getDeliveryContext().getShowSimple() + "", "UTF-8"); 5872 5873 if(property.getIsMultipleBinding()) 5874 createUrl = componentEditorUrl + "CreateContentWizardFinish.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&refreshAddress=" + returnAddress + "&showSimple=" + getDeliveryContext().getShowSimple(); 5875 else 5876 createUrl = componentEditorUrl + "CreateContentWizardFinish.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&refreshAddress=" + returnAddress + "&showSimple=" + getDeliveryContext().getShowSimple(); 5877 } 5878 else if(property.getEntityClass().equalsIgnoreCase("SiteNode")) 5879 { 5880 if(property.getIsMultipleBinding()) 5881 createUrl = componentEditorUrl + "CreateSiteNodeWizard!input.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5882 else 5883 createUrl = componentEditorUrl + "CreateSiteNodeWizard!input.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple(); 5884 } 5885 } 5886 5887 if(showInPublishedMode == false && this.getOperatingMode().intValue() == 3) 5888 result = ""; 5889 else 5890 { 5891 String editOnSiteUrl = CmsPropertyHandler.getEditOnSiteUrl(); 5892 5893 String url = assignUrl; 5894 if(!createNew) 5895 result = "<a HREF=\"#\" onClick=\"window.open('" + assignUrl + "', 'Edit', 'width=500,height=600,left=' + (document.body.clientWidth / 4) + ',top=' + (document.body.clientHeight / 4) + ',toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=no');\">" + html + "</a>"; 5896 else 5897 result = "<a HREF=\"" + createUrl + "\">" + html + "</a>"; 5898 5899 } 5903 } 5904 catch(Exception e) 5905 { 5906 e.printStackTrace(); 5907 result = ""; 5908 } 5909 5910 return result; 5912 } 5913 5914 5915 public DeliveryContext getDeliveryContext() 5916 { 5917 return deliveryContext; 5918 } 5919 5920 public void setDeliveryContext(DeliveryContext deliveryContext) 5921 { 5922 this.deliveryContext = deliveryContext; 5923 } 5924 5925 5930 public boolean isPersistedContext() 5931 { 5932 return persistedContext; 5933 } 5934 5943 public void setPersistedContext(boolean persistedContext) 5944 { 5945 this.persistedContext = persistedContext; 5946 } 5947 5948 public boolean getThreatFoldersAsContents() 5949 { 5950 return threatFoldersAsContents; 5951 } 5952 5953 public void setThreatFoldersAsContents(boolean threatFoldersAsContents) 5954 { 5955 this.threatFoldersAsContents = threatFoldersAsContents; 5956 } 5957 5958 5965 public boolean getIsDecorated() 5966 { 5967 return ( this instanceof EditOnSiteBasicTemplateController ); 5968 } 5969} | Popular Tags |