1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.io.ByteArrayInputStream ; 27 import java.util.ArrayList ; 28 import java.util.Collections ; 29 import java.util.HashMap ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Map ; 33 import java.util.Properties ; 34 35 import org.apache.log4j.Logger; 36 import org.dom4j.Document; 37 import org.dom4j.Element; 38 import org.infoglue.cms.applications.common.VisualFormatter; 39 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 40 import org.infoglue.cms.controllers.kernel.impl.simple.CategoryController; 41 import org.infoglue.cms.controllers.kernel.impl.simple.ComponentPropertyDefinitionController; 42 import org.infoglue.cms.controllers.kernel.impl.simple.ContentCategoryController; 43 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 44 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy; 45 import org.infoglue.cms.controllers.kernel.impl.simple.ContentStateController; 46 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 47 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionController; 48 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionControllerProxy; 49 import org.infoglue.cms.controllers.kernel.impl.simple.DigitalAssetController; 50 import org.infoglue.cms.controllers.kernel.impl.simple.EventController; 51 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController; 52 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 53 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController; 54 import org.infoglue.cms.entities.content.ContentVO; 55 import org.infoglue.cms.entities.content.ContentVersion; 56 import org.infoglue.cms.entities.content.ContentVersionVO; 57 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 58 import org.infoglue.cms.entities.management.LanguageVO; 59 import org.infoglue.cms.entities.structure.QualifyerVO; 60 import org.infoglue.cms.entities.structure.SiteNodeVO; 61 import org.infoglue.cms.entities.workflow.EventVO; 62 import org.infoglue.cms.exception.AccessConstraintException; 63 import org.infoglue.cms.exception.Bug; 64 import org.infoglue.cms.exception.ConstraintException; 65 import org.infoglue.cms.exception.SystemException; 66 import org.infoglue.cms.util.AccessConstraintExceptionBuffer; 67 import org.infoglue.cms.util.CmsPropertyHandler; 68 import org.infoglue.cms.util.css.CSSHelper; 69 import org.infoglue.cms.util.dom.DOMBuilder; 70 71 import com.opensymphony.module.propertyset.PropertySet; 72 import com.opensymphony.module.propertyset.PropertySetManager; 73 74 75 public class ViewContentVersionAction extends InfoGlueAbstractAction 76 { 77 private final static Logger logger = Logger.getLogger(ViewContentVersionAction.class.getName()); 78 79 private static final long serialVersionUID = 1L; 80 81 private static CategoryController categoryController = CategoryController.getController(); 82 private static ContentCategoryController contentCategoryController = ContentCategoryController.getController(); 83 84 private Integer unrefreshedContentId = new Integer (0); 85 private Integer changeTypeId = new Integer (0); 86 private Integer newContentId = new Integer (0); 87 88 private Integer digitalAssetId = null; 89 public ContentTypeDefinitionVO contentTypeDefinitionVO; 90 public List availableLanguages = null; 91 92 private Integer languageId; 93 private Integer repositoryId; 94 private Integer currentEditorId; 95 private String attributeName = ""; 96 private String textAreaId = ""; 97 private boolean forceWorkingChange = false; 98 99 private ContentVO contentVO; 100 protected ContentVersionVO contentVersionVO; 101 public List attributes = null; 102 103 private List repositories; 104 105 private Integer siteNodeId; 107 108 private Integer oldContentId = null; 109 private String assetKey = null; 110 private boolean treatAsLink = false; 111 112 private Map WYSIWYGProperties = null; 113 114 private String closeOnLoad = "false"; 115 private String publishOnLoad = "false"; 116 117 private boolean concurrentModification = false; 118 private long oldModifiedDateTime = -1; 119 120 public String getQualifyerPath(String entity, String entityId) 121 { 122 StringBuffer sb = new StringBuffer (""); 123 try 124 { 125 if(entity.equalsIgnoreCase("Content")) 126 { 127 ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer (entityId)); 128 sb.insert(0, contentVO.getName() + "/"); 129 while(contentVO.getParentContentId() != null) 130 { 131 contentVO = ContentController.getContentController().getContentVOWithId(contentVO.getParentContentId()); 132 sb.insert(0, contentVO.getName() + "/"); 133 } 134 } 135 else if(entity.equalsIgnoreCase("SiteNode")) 136 { 137 SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(new Integer (entityId)); 138 sb.insert(0, siteNodeVO.getName() + "/"); 139 while(siteNodeVO.getParentSiteNodeId() != null) 140 { 141 siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeVO.getParentSiteNodeId()); 142 sb.insert(0, siteNodeVO.getName() + "/"); 143 } 144 } 145 } 146 catch(Exception e) 147 { 148 e.printStackTrace(); 149 } 150 return sb.toString(); 151 } 152 153 154 public List getContentRelationQualifyers(String qualifyerXML) 155 { 156 logger.info("Content qualifyerXML:" + qualifyerXML); 157 return parseQualifyersFromXML(qualifyerXML, "contentId"); 158 } 159 160 public List getSiteNodeRelationQualifyers(String qualifyerXML) 161 { 162 logger.info("Content qualifyerXML:" + qualifyerXML); 163 return parseQualifyersFromXML(qualifyerXML, "siteNodeId"); 164 } 165 166 public List getComponentPropertyDefinitions(String componentPropertiesXML) 167 { 168 return ComponentPropertyDefinitionController.getController().parseComponentPropertyDefinitions(componentPropertiesXML); 169 } 170 171 172 private List parseQualifyersFromXML(String qualifyerXML, String currentEntityIdentifyer) 173 { 174 List qualifyers = new ArrayList (); 175 176 if(qualifyerXML == null || qualifyerXML.length() == 0) 177 return qualifyers; 178 179 try 180 { 181 Document document = new DOMBuilder().getDocument(qualifyerXML); 182 183 String entity = document.getRootElement().attributeValue("entity"); 184 185 List children = document.getRootElement().elements(); 186 Iterator i = children.iterator(); 187 while(i.hasNext()) 188 { 189 Element child = (Element)i.next(); 190 String id = child.getStringValue(); 191 192 QualifyerVO qualifyerVO = new QualifyerVO(); 193 qualifyerVO.setName(currentEntityIdentifyer); 194 qualifyerVO.setValue(id); 195 qualifyerVO.setPath(this.getQualifyerPath(entity, id)); 196 qualifyers.add(qualifyerVO); 198 } 199 } 200 catch(Exception e) 201 { 202 e.printStackTrace(); 203 } 204 205 return qualifyers; 206 } 207 208 public ViewContentVersionAction() 209 { 210 this(new ContentVO(), new ContentVersionVO()); 211 } 212 213 public ViewContentVersionAction(ContentVO contentVO, ContentVersionVO contentVersionVO) 214 { 215 this.contentVO = contentVO; 216 this.contentVersionVO = contentVersionVO; 217 } 218 219 protected void initialize(Integer contentVersionId, Integer contentId, Integer languageId) throws Exception 220 { 221 initialize(contentVersionId, contentId, languageId, false, true); 222 } 223 224 protected void initialize(Integer contentVersionId, Integer contentId, Integer languageId, boolean fallBackToMasterLanguage, boolean checkPermission) throws ConstraintException, Exception 225 { 226 this.contentVO = ContentControllerProxy.getController().getACContentVOWithId(this.getInfoGluePrincipal(), contentId); 227 228 if(this.contentVO.getRepositoryId() != null && checkPermission && !hasAccessTo("Repository.Read", "" + this.contentVO.getRepositoryId())) 229 { 230 AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); 231 ceb.add(new AccessConstraintException("Content.contentId", "1000")); 232 ceb.throwIfNotEmpty(); 233 } 234 235 this.contentTypeDefinitionVO = ContentController.getContentController().getContentTypeDefinition(contentId); 237 this.availableLanguages = ContentController.getContentController().getRepositoryLanguages(contentId); 238 239 if(contentVersionId == null) 240 { 241 this.contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, languageId); 244 if(this.contentVersionVO == null && fallBackToMasterLanguage) 245 { 246 Integer usedRepositoryId = this.repositoryId; 248 if(this.repositoryId == null && this.contentVO != null) 249 usedRepositoryId = this.contentVO.getRepositoryId(); 250 251 LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(usedRepositoryId); 252 this.contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, masterLanguageVO.getId()); 254 } 255 256 if(this.contentVersionVO != null) 257 contentVersionId = contentVersionVO.getContentVersionId(); 258 } 259 260 if(contentVersionId != null) 261 this.contentVersionVO = ContentVersionControllerProxy.getController().getACContentVersionVOWithId(this.getInfoGluePrincipal(), contentVersionId); 262 264 if(this.forceWorkingChange && contentVersionVO != null && !contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE)) 265 { 266 ContentVersion contentVersion = ContentStateController.changeState(contentVersionVO.getContentVersionId(), ContentVersionVO.WORKING_STATE, "Edit on sight", false, this.getInfoGluePrincipal(), this.getContentId(), new ArrayList ()); 267 contentVersionId = contentVersion.getContentVersionId(); 268 contentVersionVO = contentVersion.getValueObject(); 269 } 270 271 if(this.contentTypeDefinitionVO != null) 272 { 273 this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().validateAndUpdateContentType(this.contentTypeDefinitionVO); 274 this.attributes = ContentTypeDefinitionController.getController().getContentTypeAttributes(this.contentTypeDefinitionVO.getSchemaValue()); 275 } 276 } 277 278 public String doExecute() throws Exception 279 { 280 this.initialize(getContentVersionId(), getContentId(), this.languageId); 281 282 String wysiwygEditor = CmsPropertyHandler.getWysiwygEditor(); 283 if(wysiwygEditor == null || wysiwygEditor.equalsIgnoreCase("") || wysiwygEditor.equalsIgnoreCase("HTMLArea")) 284 return "success"; 285 else 286 return "successForFCKEditor"; 287 } 288 289 290 public String doStandalone() throws Exception 291 { 292 this.initialize(getContentVersionId(), getContentId(), this.languageId); 293 294 String wysiwygEditor = CmsPropertyHandler.getWysiwygEditor(); 295 if(wysiwygEditor == null || wysiwygEditor.equalsIgnoreCase("") || wysiwygEditor.equalsIgnoreCase("HTMLArea")) 296 return "standalone"; 297 else 298 return "standaloneForFCKEditor"; 299 } 300 301 public String doBackground() throws Exception 302 { 303 this.initialize(getContentVersionId(), getContentId(), this.languageId); 304 return "background"; 305 } 306 307 public String doViewAssetsDialog() throws Exception 308 { 309 if(this.oldContentId != null) 310 { 311 this.contentVO = ContentControllerProxy.getController().getACContentVOWithId(this.getInfoGluePrincipal(), getOldContentId()); 312 } 313 else 314 { 315 if(getContentId() != null && getContentId().intValue() != -1) 316 this.contentVO = ContentControllerProxy.getController().getACContentVOWithId(this.getInfoGluePrincipal(), getContentId()); 317 } 318 319 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 320 321 return "viewAssetsDialog"; 322 } 323 324 public String doViewAssetsDialogForFCKEditor() throws Exception 325 { 326 if(this.oldContentId != null) 327 { 328 this.contentVO = ContentControllerProxy.getController().getACContentVOWithId(this.getInfoGluePrincipal(), getOldContentId()); 329 } 330 else 331 { 332 if(getContentId() != null && getContentId().intValue() != -1) 333 this.contentVO = ContentControllerProxy.getController().getACContentVOWithId(this.getInfoGluePrincipal(), getContentId()); 334 } 335 336 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 337 338 return "viewAssetsDialogForFCKEditor"; 339 } 340 341 342 public String doViewAssets() throws Exception 343 { 344 if(getContentId() != null && getContentId().intValue() != -1) 345 { 346 this.initialize(getContentVersionId(), getContentId(), this.languageId, true, false); 347 } 348 349 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 350 351 return "viewAssets"; 352 } 353 354 public String doViewAssetsForFCKEditor() throws Exception 355 { 356 if(getContentId() != null && getContentId().intValue() != -1) 357 { 358 this.initialize(getContentVersionId(), getContentId(), this.languageId, true, false); 359 } 360 361 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 362 363 return "viewAssetsForFCKEditor"; 364 } 365 366 public String doPreview() throws Exception 367 { 368 this.initialize(getContentVersionId(), getContentId(), this.languageId); 369 return "preview"; 370 } 371 372 public String doDeleteDigitalAsset() throws Exception 373 { 374 ContentVersionController.getContentVersionController().deleteDigitalAssetRelation(getContentVersionId(), this.digitalAssetId); 375 return doExecute(); 378 } 379 380 public String doDeleteDigitalAssetStandalone() throws Exception 381 { 382 ContentVersionController.getContentVersionController().deleteDigitalAssetRelation(getContentVersionId(), this.digitalAssetId); 383 return doStandalone(); 386 } 387 388 public EventVO getEvent(Integer contentVersionId) 389 { 390 EventVO eventVO = null; 391 try 392 { 393 if(contentVersionId != null) 394 { 395 ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(contentVersionId); 396 List events = EventController.getEventVOListForEntity(ContentVersion.class.getName(), contentVersion.getId()); 397 if(events != null && events.size() > 0) 398 eventVO = (EventVO)events.get(0); 399 } 400 } 401 catch(Exception e) 402 { 403 logger.error("An error occurred when we tried to get any events for this version:" + e.getMessage(), e); 404 } 405 406 return eventVO; 407 } 408 409 public List getContentPath() 410 { 411 ContentVO contentVO = this.contentVO; 412 List ret = new ArrayList (); 413 415 while (contentVO.getParentContentId() != null) 416 { 417 try { 418 contentVO = ContentControllerProxy.getController().getContentVOWithId(contentVO.getParentContentId()); 419 } catch (SystemException e) { 420 e.printStackTrace(); 422 } catch (Bug e) { 423 e.printStackTrace(); 425 } 426 ret.add(0, contentVO); 427 } 428 return ret; 429 } 430 431 public java.lang.Integer getContentVersionId() 432 { 433 if(this.contentVersionVO != null) 434 return this.contentVersionVO.getContentVersionId(); 435 else 436 return null; 437 } 438 439 public void setContentVersionId(java.lang.Integer contentVersionId) 440 { 441 this.contentVersionVO.setContentVersionId(contentVersionId); 442 } 443 444 public java.lang.Integer getContentId() 445 { 446 return this.contentVO.getContentId(); 447 } 448 449 public void setContentId(java.lang.Integer contentId) 450 { 451 this.contentVO.setContentId(contentId); 452 } 453 454 public java.lang.Integer getContentTypeDefinitionId() 455 { 456 return this.contentTypeDefinitionVO.getContentTypeDefinitionId(); 457 } 458 459 public String getContentTypeDefinitionName() 460 { 461 return this.contentTypeDefinitionVO.getName(); 462 } 463 464 public void setLanguageId(Integer languageId) 465 { 466 this.languageId = languageId; 467 } 468 469 public java.lang.Integer getLanguageId() 470 { 471 return this.languageId; 472 } 473 474 public void setStateId(Integer stateId) 475 { 476 if(this.contentVersionVO != null) 477 this.contentVersionVO.setStateId(stateId); 478 } 479 480 public void setVersionComment(String versionComment) 481 { 482 if(this.contentVersionVO != null) 483 this.contentVersionVO.setVersionComment(versionComment); 484 } 485 486 public void setDigitalAssetId(Integer digitalAssetId) 487 { 488 this.digitalAssetId = digitalAssetId; 489 } 490 491 public String getVersionComment() 492 { 493 return this.contentVersionVO.getVersionComment(); 494 } 495 496 public Integer getStateId() 497 { 498 return this.contentVersionVO.getStateId(); 499 } 500 501 public Boolean getIsActive() 502 { 503 return this.contentVersionVO.getIsActive(); 504 } 505 506 public String getName() 507 { 508 return this.contentVO.getName(); 509 } 510 511 public java.lang.Integer getRepositoryId() 512 { 513 if(this.contentVO != null && this.contentVO.getRepositoryId() != null) 514 return this.contentVO.getRepositoryId(); 515 else 516 return this.repositoryId; 517 } 518 519 public List getAvailableLanguages() 520 { 521 return this.availableLanguages; 522 } 523 524 527 528 public List getDigitalAssets() 529 { 530 List digitalAssets = null; 531 532 try 533 { 534 if(this.contentVersionVO != null && this.contentVersionVO.getContentVersionId() != null) 535 { 536 digitalAssets = DigitalAssetController.getDigitalAssetVOList(this.contentVersionVO.getContentVersionId()); 537 } 538 } 539 catch(Exception e) 540 { 541 logger.warn("We could not fetch the list of digitalAssets: " + e.getMessage(), e); 542 } 543 544 return digitalAssets; 545 } 546 547 550 551 public List getInheritedDigitalAssets() 552 { 553 List digitalAssets = null; 554 555 try 556 { 557 if(this.contentVO != null && this.contentVO.getContentId() != null && this.contentVO.getContentId().intValue() != -1) 558 { 559 digitalAssets = DigitalAssetController.getDigitalAssetVOList(this.contentVO.getContentId(), this.languageId, true); 560 } 561 567 } 568 catch(Exception e) 569 { 570 logger.warn("We could not fetch the list of digitalAssets: " + e.getMessage(), e); 571 } 572 573 return digitalAssets; 574 } 575 576 577 581 582 public String getDigitalAssetUrl(Integer digitalAssetId) throws Exception 583 { 584 String imageHref = null; 585 try 586 { 587 imageHref = DigitalAssetController.getDigitalAssetUrl(digitalAssetId); 588 } 589 catch(Exception e) 590 { 591 logger.warn("We could not get the url of the digitalAsset: " + e.getMessage(), e); 592 imageHref = e.getMessage(); 593 } 594 595 return imageHref; 596 } 597 598 599 603 604 public String getDigitalAssetThumbnailUrl(Integer digitalAssetId) throws Exception 605 { 606 String imageHref = null; 607 try 608 { 609 imageHref = DigitalAssetController.getDigitalAssetThumbnailUrl(digitalAssetId); 610 } 611 catch(Exception e) 612 { 613 logger.warn("We could not get the url of the thumbnail: " + e.getMessage(), e); 614 imageHref = e.getMessage(); 615 } 616 617 return imageHref; 618 } 619 620 621 625 626 public String getDigitalAssetUrl(Integer contentId, Integer languageId) throws Exception 627 { 628 String imageHref = null; 629 try 630 { 631 imageHref = DigitalAssetController.getDigitalAssetUrl(contentId, languageId); 632 } 633 catch(Exception e) 634 { 635 logger.warn("We could not get the url of the digitalAsset: " + e.getMessage(), e); 636 imageHref = e.getMessage(); 637 } 638 639 return imageHref; 640 } 641 642 643 647 648 public String getDigitalAssetThumbnailUrl(Integer contentId, Integer languageId) throws Exception 649 { 650 String imageHref = null; 651 try 652 { 653 imageHref = DigitalAssetController.getDigitalAssetThumbnailUrl(contentId, languageId); 654 } 655 catch(Exception e) 656 { 657 logger.warn("We could not get the url of the thumbnail: " + e.getMessage(), e); 658 imageHref = e.getMessage(); 659 } 660 661 return imageHref; 662 } 663 664 665 666 670 671 public String getAttributeValue(String key) 672 { 673 String value = ""; 674 675 677 if(this.contentVersionVO != null) 678 { 679 try 680 { 681 logger.info("key:" + key); 682 logger.info("VersionValue:" + this.contentVersionVO.getVersionValue()); 683 684 String xml = this.contentVersionVO.getVersionValue(); 685 686 int startTagIndex = xml.indexOf("<" + key + ">"); 687 int endTagIndex = xml.indexOf("]]></" + key + ">"); 688 689 if(startTagIndex > 0 && startTagIndex < xml.length() && endTagIndex > startTagIndex && endTagIndex < xml.length()) 690 { 691 value = xml.substring(startTagIndex + key.length() + 11, endTagIndex); 692 value = new VisualFormatter().escapeHTML(value); 693 } 694 695 724 } 725 catch(Exception e) 726 { 727 e.printStackTrace(); 728 } 729 } 730 731 logger.info("value:" + value); 732 733 return value; 734 } 735 736 740 741 public String getUnescapedAttributeValue(String key) 742 { 743 String value = ""; 744 if(this.contentVersionVO != null) 745 { 746 try 747 { 748 logger.info("key:" + key); 749 logger.info("VersionValue:" + this.contentVersionVO.getVersionValue()); 750 751 String xml = this.contentVersionVO.getVersionValue(); 752 753 int startTagIndex = xml.indexOf("<" + key + ">"); 754 int endTagIndex = xml.indexOf("]]></" + key + ">"); 755 756 if(startTagIndex > 0 && startTagIndex < xml.length() && endTagIndex > startTagIndex && endTagIndex < xml.length()) 757 { 758 value = xml.substring(startTagIndex + key.length() + 11, endTagIndex); 759 } 760 761 785 } 786 catch(Exception e) 787 { 788 e.printStackTrace(); 789 } 790 } 791 return value; 793 } 794 795 798 799 public List getContentTypeAttributes() 800 { 801 return this.attributes; 802 } 803 804 public ContentVersionVO getContentVersionVO() 805 { 806 return contentVersionVO; 807 } 808 809 812 813 public Map getWYSIWYGProperties() throws Exception 814 { 815 if(this.WYSIWYGProperties != null) 816 return this.WYSIWYGProperties; 817 818 Map args = new HashMap (); 820 args.put("globalKey", "infoglue"); 821 PropertySet ps = PropertySetManager.getInstance("jdbc", args); 822 823 byte[] WYSIWYGConfigBytes = ps.getData("repository_" + this.getRepositoryId() + "_WYSIWYGConfig"); 824 if(WYSIWYGConfigBytes != null) 825 { 826 Properties properties = new Properties (); 827 properties.load(new ByteArrayInputStream (WYSIWYGConfigBytes)); 828 this.WYSIWYGProperties = properties; 829 } 830 831 Map principalWYSIWYGProperties = getPrincipalPropertyHashValues("WYSIWYGConfig", false); 833 834 if(this.WYSIWYGProperties != null) 835 { 836 logger.info("this.WYSIWYGProperties:" + this.WYSIWYGProperties.size()); 837 838 if(principalWYSIWYGProperties.containsKey("toolbar_line0_position0")) 840 { 841 for(int lineIndex=0; lineIndex<3; lineIndex++) 842 { 843 for(int colIndex=0; colIndex<30; colIndex++) 844 { 845 WYSIWYGProperties.remove("toolbar_line" + lineIndex + "_position" + colIndex); 846 } 847 } 848 } 849 850 if(principalWYSIWYGProperties.containsKey("css.url.0")) 851 { 852 for(int index=0; index<10; index++) 853 { 854 WYSIWYGProperties.remove("css.url." + index); 855 } 856 } 857 858 if(principalWYSIWYGProperties.containsKey("css.class.0")) 859 { 860 for(int index=0; index<50; index++) 861 { 862 WYSIWYGProperties.remove("css.class." + index); 863 } 864 } 865 } 866 else 867 { 868 this.WYSIWYGProperties = new HashMap (); 869 } 870 871 this.WYSIWYGProperties.putAll(principalWYSIWYGProperties); 873 874 return this.WYSIWYGProperties; 875 } 876 877 880 881 public List getCSSRules(String url) 882 { 883 logger.info("url:" + url); 884 CSSHelper cssHelper = CSSHelper.getHelper(); 885 cssHelper.setCSSUrl(url); 886 887 return cssHelper.getCSSRules(); 888 } 889 890 893 894 public boolean getEnableCSSPlugin() throws Exception 895 { 896 boolean enableCSSPlugin = false; 897 898 Map properties = getWYSIWYGProperties(); 899 900 String enableCSSPluginString = (String )properties.get("enableCSSPlugin"); 901 if(enableCSSPluginString != null && enableCSSPluginString.trim().equalsIgnoreCase("true")) 902 { 903 enableCSSPlugin = true; 904 } 905 906 return enableCSSPlugin; 907 } 908 909 912 913 public List getCSSList() throws Exception 914 { 915 List cssList = new ArrayList (); 916 917 Map properties = getWYSIWYGProperties(); 918 919 int index = 0; 920 String cssUrl = (String )properties.get("css.url." + index); 921 while(cssUrl != null) 922 { 923 cssList.add(cssUrl); 924 index++; 925 cssUrl = (String )properties.get("css.url." + index); 926 } 927 928 return cssList; 929 } 930 931 934 935 public List getAllowedClasses() throws Exception 936 { 937 List allowedClasses = new ArrayList (); 938 939 Map properties = getWYSIWYGProperties(); 940 941 int index = 0; 942 String cssUrl = (String )properties.get("css.class." + index); 943 while(cssUrl != null) 944 { 945 allowedClasses.add(cssUrl); 946 index++; 947 cssUrl = (String )properties.get("css.class." + index); 948 } 949 950 return allowedClasses; 951 } 952 953 954 957 958 public String getDeliveryBaseUrl() 959 { 960 String previewDeliveryUrl = CmsPropertyHandler.getPreviewDeliveryUrl(); 961 int index = previewDeliveryUrl.lastIndexOf("/"); 962 if(index > 0) 963 { 964 previewDeliveryUrl = previewDeliveryUrl.substring(0, index); 965 } 966 return previewDeliveryUrl; 967 } 968 969 972 public List getDefinedCategoryKeys() 973 { 974 try 975 { 976 if(contentTypeDefinitionVO != null) 977 return ContentTypeDefinitionController.getController().getDefinedCategoryKeys(contentTypeDefinitionVO.getSchemaValue()); 978 } 979 catch(Exception e) 980 { 981 logger.warn("We could not fetch the list of defined category keys: " + e.getMessage(), e); 982 } 983 984 return Collections.EMPTY_LIST; 985 } 986 987 992 public List getAvailableCategories(Integer categoryId) 993 { 994 try 995 { 996 String protectCategories = CmsPropertyHandler.getProtectCategories(); 997 if(protectCategories != null && protectCategories.equalsIgnoreCase("true")) 998 return categoryController.getAuthorizedActiveChildren(categoryId, this.getInfoGluePrincipal()); 999 else 1000 return categoryController.findAllActiveChildren(categoryId); 1001 } 1002 catch(Exception e) 1003 { 1004 logger.warn("We could not fetch the list of categories: " + e.getMessage(), e); 1005 } 1006 1007 return Collections.EMPTY_LIST; 1008 } 1009 1010 1015 public List getRelatedCategories(String attribute) 1016 { 1017 try 1018 { 1019 if(this.contentVersionVO != null && this.contentVersionVO.getContentVersionId() != null) 1020 return contentCategoryController.findByContentVersionAttribute(attribute, contentVersionVO.getContentVersionId()); 1021 } 1022 catch(Exception e) 1023 { 1024 logger.warn("We could not fetch the list of defined category keys: " + e.getMessage(), e); 1025 } 1026 1027 return Collections.EMPTY_LIST; 1028 } 1029 1030 public ContentVersionVO getMasterContentVersionVO(Integer contentId, Integer repositoryId) throws SystemException, Exception 1031 { 1032 LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(repositoryId); 1033 return ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, masterLanguageVO.getId()); 1034 } 1035 1036 public ContentVersionVO getLatestContentVersionVO(Integer contentId, Integer languageId) throws SystemException, Exception 1037 { 1038 return ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, languageId); 1039 } 1040 1041 public Integer getCurrentEditorId() 1042 { 1043 return currentEditorId; 1044 } 1045 1046 public void setCurrentEditorId(Integer integer) 1047 { 1048 currentEditorId = integer; 1049 } 1050 1051 public String getAttributeName() 1052 { 1053 return this.attributeName; 1054 } 1055 1056 public void setAttributeName(String attributeName) 1057 { 1058 this.attributeName = attributeName; 1059 } 1060 1061 public String getTextAreaId() 1062 { 1063 return this.textAreaId; 1064 } 1065 1066 public void setTextAreaId(String textAreaId) 1067 { 1068 this.textAreaId = textAreaId; 1069 } 1070 1071 public Integer getSiteNodeId() 1072 { 1073 return this.siteNodeId; 1074 } 1075 1076 public void setSiteNodeId(Integer siteNodeId) 1077 { 1078 this.siteNodeId = siteNodeId; 1079 } 1080 1081 public void setRepositoryId(Integer repositoryId) 1082 { 1083 this.repositoryId = repositoryId; 1084 } 1085 1086 public List getRepositories() 1087 { 1088 return repositories; 1089 } 1090 1091 public String getAssetKey() 1092 { 1093 return assetKey; 1094 } 1095 1096 public void setAssetKey(String assetKey) 1097 { 1098 this.assetKey = assetKey; 1099 } 1100 1101 public Integer getOldContentId() 1102 { 1103 return oldContentId; 1104 } 1105 1106 public void setOldContentId(Integer oldContentId) 1107 { 1108 this.oldContentId = oldContentId; 1109 } 1110 1111 public boolean getTreatAsLink() 1112 { 1113 return treatAsLink; 1114 } 1115 1116 public void setTreatAsLink(boolean treatAsLink) 1117 { 1118 this.treatAsLink = treatAsLink; 1119 } 1120 1121 public ContentVO getContentVO() 1122 { 1123 return contentVO; 1124 } 1125 1126 public String getCloseOnLoad() 1127 { 1128 return closeOnLoad; 1129 } 1130 1131 public void setCloseOnLoad(String closeOnLoad) 1132 { 1133 this.closeOnLoad = closeOnLoad; 1134 } 1135 1136 public Integer getNewContentId() 1137 { 1138 return newContentId; 1139 } 1140 1141 public void setNewContentId(Integer newContentId) 1142 { 1143 this.newContentId = newContentId; 1144 } 1145 1146 public void setContentVersionVO(ContentVersionVO contentVersionVO) 1147 { 1148 this.contentVersionVO = contentVersionVO; 1149 } 1150 1151 public ContentTypeDefinitionVO getContentTypeDefinitionVO() 1152 { 1153 return contentTypeDefinitionVO; 1154 } 1155 1156 public boolean getConcurrentModification() 1157 { 1158 return concurrentModification; 1159 } 1160 1161 public void setConcurrentModification(boolean concurrentModification) 1162 { 1163 this.concurrentModification = concurrentModification; 1164 } 1165 1166 public long getOldModifiedDateTime() 1167 { 1168 return oldModifiedDateTime; 1169 } 1170 1171 public void setOldModifiedDateTime(long oldModifiedDateTime) 1172 { 1173 this.oldModifiedDateTime = oldModifiedDateTime; 1174 } 1175 1176 public void setForceWorkingChange(boolean forceWorkingChange) 1177 { 1178 this.forceWorkingChange = forceWorkingChange; 1179 } 1180 1181 public String getPublishOnLoad() { 1182 return publishOnLoad; 1183 } 1184 1185 public void setPublishOnLoad(String publishOnLoad) { 1186 this.publishOnLoad = publishOnLoad; 1187 } 1188} 1189 | Popular Tags |