1 23 24 package org.infoglue.cms.applications.structuretool.actions; 25 26 27 import java.net.URLEncoder ; 28 import java.util.ArrayList ; 29 import java.util.HashMap ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Locale ; 33 import java.util.Map ; 34 35 import org.apache.log4j.Logger; 36 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 37 import org.infoglue.cms.controllers.kernel.impl.simple.ComponentController; 38 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 39 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionController; 40 import org.infoglue.cms.controllers.kernel.impl.simple.DigitalAssetController; 41 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController; 42 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 43 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController; 44 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeStateController; 45 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionControllerProxy; 46 import org.infoglue.cms.entities.content.ContentVO; 47 import org.infoglue.cms.entities.content.ContentVersionVO; 48 import org.infoglue.cms.entities.content.DigitalAssetVO; 49 import org.infoglue.cms.entities.management.LanguageVO; 50 import org.infoglue.cms.entities.structure.SiteNodeVO; 51 import org.infoglue.cms.entities.structure.SiteNodeVersionVO; 52 import org.infoglue.cms.exception.SystemException; 53 import org.infoglue.cms.security.InfoGluePrincipal; 54 import org.infoglue.cms.util.XMLHelper; 55 import org.infoglue.deliver.applications.databeans.DeliveryContext; 56 import org.infoglue.deliver.controllers.kernel.impl.simple.IntegrationDeliveryController; 57 import org.infoglue.deliver.controllers.kernel.impl.simple.NodeDeliveryController; 58 import org.w3c.dom.Document ; 59 import org.w3c.dom.Element ; 60 import org.w3c.dom.Node ; 61 import org.w3c.dom.NodeList ; 62 63 import com.opensymphony.module.propertyset.PropertySet; 64 import com.opensymphony.module.propertyset.PropertySetManager; 65 66 67 68 public class ViewSiteNodePageComponentsAction extends InfoGlueAbstractAction 69 { 70 private final static Logger logger = Logger.getLogger(ViewSiteNodePageComponentsAction.class.getName()); 71 72 private static final long serialVersionUID = 1L; 73 74 public static final String CATEGORY_TREE = "showCategoryTree"; 75 public static final String CATEGORY_TREE_MULTIPLE = "showCategoryTreeForMultipleBinding"; 76 77 private Integer repositoryId = null; 78 private Integer siteNodeId = null; 79 private Integer languageId = null; 80 private Integer contentId = null; 81 private Integer parentComponentId = null; 82 private Integer componentId = null; 83 private String propertyName = null; 84 private String path = null; 85 private String slotId = null; 86 private String specifyBaseTemplate = null; 87 private String url = null; 88 private Integer direction = null; 89 private boolean showSimple = false; 90 private Integer pageTemplateContentId; 91 92 LanguageVO masterLanguageVO = null; 93 94 private List repositories = null; 95 private String currentAction = null; 96 private Integer filterRepositoryId = null; 97 private String sortProperty = "name"; 98 private String [] allowedContentTypeIds = null; 99 private String [] allowedComponentNames = null; 100 101 public ViewSiteNodePageComponentsAction() 102 { 103 } 104 105 private void initialize() throws Exception 106 { 107 SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getACLatestActiveSiteNodeVersionVO(this.getInfoGluePrincipal(), this.siteNodeId); 108 logger.info("siteNodeVersionVO:" + siteNodeVersionVO.getId() + ":" + siteNodeVersionVO.getIsActive()); 109 if(siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE.intValue()) 110 { 111 List events = new ArrayList (); 112 SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Edit on sight editing", true, this.getInfoGluePrincipal(), this.siteNodeId, events); 113 } 114 115 Integer currentRepositoryId = SiteNodeController.getSiteNodeVOWithId(this.siteNodeId).getRepositoryId(); 116 this.masterLanguageVO = LanguageController.getController().getMasterLanguage(currentRepositoryId); 117 if(filterRepositoryId == null) 118 { 119 Map args = new HashMap (); 120 args.put("globalKey", "infoglue"); 121 PropertySet ps = PropertySetManager.getInstance("jdbc", args); 122 123 String defaultTemplateRepository = ps.getString("repository_" + currentRepositoryId + "_defaultTemplateRepository"); 124 if(defaultTemplateRepository != null && !defaultTemplateRepository.equals("")) 125 filterRepositoryId = new Integer (defaultTemplateRepository); 126 else 127 filterRepositoryId = currentRepositoryId; 128 } 129 } 130 131 134 135 private void initializeTreeView(String currentAction) throws Exception 136 { 137 this.currentAction = currentAction; 138 139 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 140 141 if(this.repositoryId == null) 142 this.repositoryId = RepositoryController.getController().getFirstRepositoryVO().getRepositoryId(); 143 } 144 145 146 150 151 public String doExecute() throws Exception 152 { 153 initialize(); 154 return "success"; 155 } 156 157 158 161 162 public String doListComponents() throws Exception 163 { 164 logger.info("queryString:" + this.getRequest().getQueryString()); 165 initialize(); 166 167 this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true); 168 169 return "listComponents"; 170 } 171 172 175 176 public String doListComponentsForPalette() throws Exception 177 { 178 initialize(); 179 return "listComponentsForPalette"; 180 } 181 182 185 186 public String doShowContentTree() throws Exception 187 { 188 initialize(); 189 initializeTreeView("ViewSiteNodePageComponents!showContentTree.action"); 190 return "showContentTree"; 191 } 192 193 196 197 public String doShowContentTreeForMultipleBinding() throws Exception 198 { 199 initialize(); 200 initializeTreeView("ViewSiteNodePageComponents!showContentTreeForMultipleBinding.action"); 201 return "showContentTreeForMultipleBinding"; 202 } 203 204 207 208 public String doShowStructureTree() throws Exception 209 { 210 initialize(); 211 initializeTreeView("ViewSiteNodePageComponents!showStructureTree.action"); 212 return "showStructureTree"; 213 } 214 215 218 219 public String doShowStructureTreeForMultipleBinding() throws Exception 220 { 221 initialize(); 222 initializeTreeView("ViewSiteNodePageComponents!showStructureTreeForMultipleBinding.action"); 223 return "showStructureTreeForMultipleBinding"; 224 } 225 226 229 public String doShowCategoryTree() throws Exception 230 { 231 initialize(); 232 initializeTreeView("ViewSiteNodePageComponents!showCategoryTree.action"); 233 return CATEGORY_TREE; 234 } 235 236 239 public String doShowCategoryTreeForMultipleBinding() throws Exception 240 { 241 initialize(); 242 initializeTreeView("ViewSiteNodePageComponents!showCategoryTreeForMultipleBinding.action"); 243 return CATEGORY_TREE_MULTIPLE; 244 } 245 246 247 public List getRepositories() 248 { 249 return this.repositories; 250 } 251 252 public String getCurrentAction() 253 { 254 return this.currentAction; 255 } 256 257 public String getContentAttribute(Integer contentId, String attributeName) throws Exception 258 { 259 String attribute = "Undefined"; 260 261 ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId); 262 263 LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(SiteNodeController.getSiteNodeVOWithId(siteNodeId).getRepositoryId()); 264 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), masterLanguageVO.getId()); 265 266 attribute = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, attributeName, false); 267 268 return attribute; 269 } 270 271 272 275 276 public String doAddPageTemplate() throws Exception 277 { 278 logger.info("************************************************************"); 279 logger.info("* ADDING PAGE TEMPLATE *"); 280 logger.info("************************************************************"); 281 logger.info("siteNodeId:" + this.siteNodeId); 282 logger.info("languageId:" + this.languageId); 283 logger.info("contentId:" + this.contentId); 284 logger.info("pageTemplateContentId:" + this.pageTemplateContentId); 285 logger.info("specifyBaseTemplate:" + this.specifyBaseTemplate); 286 287 initialize(); 288 289 Integer newComponentId = new Integer (0); 290 291 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 292 293 if(this.pageTemplateContentId != null) 294 { 295 Integer languageId = LanguageController.getController().getMasterLanguage(this.repositoryId).getId(); 296 ContentVersionVO pageTemplateContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(this.pageTemplateContentId, languageId); 297 298 String componentXML = ContentVersionController.getContentVersionController().getAttributeValue(pageTemplateContentVersionVO.getId(), "ComponentStructure", false); 299 300 ContentVO pageMetaInfoContentVO = nodeDeliveryController.getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 301 303 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(pageMetaInfoContentVO.getId(), languageId); 305 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", componentXML, new InfoGluePrincipal("ComponentEditor", "none", "none", "none", new ArrayList (), new ArrayList (), true, null)); 306 } 307 308 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + newComponentId + "&showSimple=" + this.showSimple; 309 311 this.url = this.getResponse().encodeURL(url); 312 this.getResponse().sendRedirect(url); 313 return NONE; 314 } 315 316 319 320 public String doAddComponent() throws Exception 321 { 322 logger.info("************************************************************"); 323 logger.info("* ADDING COMPONENT *"); 324 logger.info("************************************************************"); 325 logger.info("siteNodeId:" + this.siteNodeId); 326 logger.info("languageId:" + this.languageId); 327 logger.info("contentId:" + this.contentId); 328 logger.info("queryString:" + this.getRequest().getQueryString()); 329 logger.info("parentComponentId:" + this.parentComponentId); 330 logger.info("componentId:" + this.componentId); 331 logger.info("slotId:" + this.slotId); 332 logger.info("specifyBaseTemplate:" + this.specifyBaseTemplate); 333 334 initialize(); 335 336 logger.info("masterLanguageId:" + this.masterLanguageVO.getId()); 337 338 Integer newComponentId = new Integer (0); 339 340 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 341 342 if(this.specifyBaseTemplate.equalsIgnoreCase("true")) 343 { 344 String componentXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><components><component contentId=\"" + componentId + "\" id=\"" + newComponentId + "\" name=\"base\"><properties></properties><bindings></bindings><components></components></component></components>"; 345 ContentVO templateContentVO = nodeDeliveryController.getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 346 347 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(templateContentVO.getId(), this.masterLanguageVO.getId()); 348 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", componentXML, new InfoGluePrincipal("ComponentEditor", "none", "none", "none", new ArrayList (), new ArrayList (), true, null)); 349 } 350 else 351 { 352 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 353 354 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 355 String componentXPath = "//component[@id=" + this.parentComponentId + "]/components"; 356 357 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 358 if(anl.getLength() > 0) 359 { 360 Element component = (Element )anl.item(0); 361 362 String componentsXPath = "//component"; 363 NodeList nodes = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentsXPath); 364 for(int i=0; i < nodes.getLength(); i++) 365 { 366 Element element = (Element )nodes.item(i); 367 if(new Integer (element.getAttribute("id")).intValue() > newComponentId.intValue()) 368 newComponentId = new Integer (element.getAttribute("id")); 369 } 370 newComponentId = new Integer (newComponentId.intValue() + 1); 371 372 Element newComponent = addComponentElement(component, new Integer (newComponentId.intValue()), this.slotId, this.componentId); 373 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 374 375 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, this.masterLanguageVO.getId(), contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, this.masterLanguageVO.getId(), true, "Meta information", DeliveryContext.getDeliveryContext()); 376 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 377 378 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 379 } 380 } 381 382 logger.info("newComponentId:" + newComponentId); 383 384 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + newComponentId + "&showSimple=" + this.showSimple; 385 387 this.url = this.getResponse().encodeURL(url); 388 this.getResponse().sendRedirect(url); 389 return NONE; 390 } 391 392 393 396 397 public String doMoveComponent() throws Exception 398 { 399 initialize(); 400 401 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 402 403 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 404 406 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 407 String componentXPath = "//component[@id=" + this.componentId + "]"; 408 409 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 410 if(anl.getLength() > 0) 411 { 412 Element component = (Element )anl.item(0); 413 String name = component.getAttribute("name"); 414 Node parentNode = component.getParentNode(); 416 417 boolean hasChanged = false; 418 419 if(this.direction.intValue() == 0) { 421 Node previousNode = component.getPreviousSibling(); 422 423 while(previousNode != null && previousNode.getNodeType() != Node.ELEMENT_NODE) 424 { 425 previousNode = previousNode.getPreviousSibling(); 426 break; 427 } 428 429 Element element = ((Element )previousNode); 430 while(element != null && !element.getAttribute("name").equalsIgnoreCase(name)) 431 { 432 previousNode = previousNode.getPreviousSibling(); 433 element = ((Element )previousNode); 434 } 435 436 if(previousNode != null) 437 { 438 parentNode.removeChild(component); 439 parentNode.insertBefore(component, previousNode); 440 hasChanged = true; 441 } 442 } 443 else if(this.direction.intValue() == 1) { 445 Node nextNode = component.getNextSibling(); 446 447 while(nextNode != null && nextNode.getNodeType() != Node.ELEMENT_NODE) 448 { 449 nextNode = nextNode.getNextSibling(); 450 break; 451 } 452 453 Element element = ((Element )nextNode); 454 while(element != null && !element.getAttribute("name").equalsIgnoreCase(name)) 455 { 456 nextNode = nextNode.getNextSibling(); 457 element = ((Element )nextNode); 458 } 459 460 if(nextNode != null) 461 nextNode = nextNode.getNextSibling(); 462 463 if(nextNode != null) 464 { 465 parentNode.removeChild(component); 466 parentNode.insertBefore(component, nextNode); 467 hasChanged = true; 468 } 469 else 470 { 471 parentNode.removeChild(component); 472 parentNode.appendChild(component); 473 hasChanged = true; 474 } 475 } 476 477 if(hasChanged) 478 { 479 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 480 482 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, this.masterLanguageVO.getId(), true, "Meta information", DeliveryContext.getDeliveryContext()); 483 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 484 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 485 } 486 } 487 488 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&showSimple=" + this.showSimple; 489 491 this.url = this.getResponse().encodeURL(url); 492 this.getResponse().sendRedirect(url); 493 return NONE; 494 } 495 496 497 498 501 502 public String doUpdateComponentProperties() throws Exception 503 { 504 initialize(); 505 506 boolean USE_LANGUAGE_FALLBACK = true; 507 boolean DO_NOT_USE_LANGUAGE_FALLBACK = false; 508 509 logger.info("************************************************************"); 510 logger.info("* doUpdateComponentProperties *"); 511 logger.info("************************************************************"); 512 logger.info("siteNodeId:" + this.siteNodeId); 513 logger.info("languageId:" + this.languageId); 514 logger.info("contentId:" + this.contentId); 515 logger.info("componentId:" + this.componentId); 516 logger.info("slotId:" + this.slotId); 517 logger.info("specifyBaseTemplate:" + this.specifyBaseTemplate); 518 519 Iterator parameterNames = this.getRequest().getParameterMap().keySet().iterator(); 520 while(parameterNames.hasNext()) 521 { 522 String name = (String )parameterNames.next(); 523 String value = (String )this.getRequest().getParameter(name); 524 logger.info(name + "=" + value); 525 } 526 527 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 528 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 529 530 Locale locale = LanguageController.getController().getLocaleWithId(languageId); 531 532 String entity = this.getRequest().getParameter("entity"); 533 534 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 535 IntegrationDeliveryController integrationDeliveryController = IntegrationDeliveryController.getIntegrationDeliveryController(siteNodeId, languageId, contentId); 536 537 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 538 540 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 541 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 542 543 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 544 548 String characterEncoding= this.getRequest().getCharacterEncoding(); 549 characterEncoding= this.getResponse().getCharacterEncoding(); 550 551 logger.info("siteNodeId:" + siteNodeId); 552 logger.info("languageId:" + languageId); 553 logger.info("entity:" + entity); 554 555 int propertyIndex = 0; 556 String propertyName = this.getRequest().getParameter(propertyIndex + "_propertyName"); 557 while(propertyName != null && !propertyName.equals("")) 558 { 559 String propertyValue = this.getRequest().getParameter(propertyName); 560 561 logger.info("propertyName:" + propertyName); 562 logger.info("propertyValue:" + propertyValue); 563 564 String componentPropertyXPath = "//component[@id=" + this.componentId + "]/properties/property[@name='" + propertyName + "']"; 565 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 567 if(anl.getLength() == 0) 568 { 569 String componentXPath = "//component[@id=" + this.componentId + "]/properties"; 570 NodeList componentNodeList = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 572 if(componentNodeList.getLength() > 0) 573 { 574 Element componentProperties = (Element )componentNodeList.item(0); 575 addPropertyElement(componentProperties, propertyName, propertyValue, "textfield", locale); 576 anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 577 } 578 } 579 580 logger.info("anl:" + anl); 581 if(anl.getLength() > 0) 582 { 583 Element component = (Element )anl.item(0); 584 component.setAttribute("path_" + locale.getLanguage(), propertyValue); 585 logger.info("Setting 'path_" + locale.getLanguage() + ":" + propertyValue); 586 } 587 else 588 { 589 logger.warn("No property could be updated... must be wrong."); 590 } 591 592 propertyIndex++; 593 594 propertyName = this.getRequest().getParameter(propertyIndex + "_propertyName"); 595 } 596 597 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 598 602 logger.info("contentVersionVO:" + contentVersionVO.getContentVersionId()); 603 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 604 605 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + this.componentId + "&showSimple=" + this.showSimple; 606 608 this.url = this.getResponse().encodeURL(url); 609 this.getResponse().sendRedirect(url); 610 return NONE; 611 } 612 613 614 617 618 public String doDeleteComponent() throws Exception 619 { 620 initialize(); 621 631 logger.info("doDeleteComponent:" + this.getRequest().getQueryString()); 632 633 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 634 635 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 636 637 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 638 String componentXPath = "//component[@id=" + this.componentId + "]"; 639 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 641 if(anl.getLength() > 0) 643 { 644 Element component = (Element )anl.item(0); 645 component.getParentNode().removeChild(component); 646 647 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 648 649 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 650 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 651 652 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 653 } 654 655 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&showSimple=" + this.showSimple; 656 658 this.url = this.getResponse().encodeURL(url); 659 this.getResponse().sendRedirect(url); 660 return NONE; 661 } 662 663 664 667 668 public String doAddComponentPropertyBinding() throws Exception 669 { 670 initialize(); 671 681 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 682 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 683 684 Locale locale = LanguageController.getController().getLocaleWithId(languageId); 685 686 String entity = this.getRequest().getParameter("entity"); 687 Integer entityId = new Integer (this.getRequest().getParameter("entityId")); 688 String propertyName = this.getRequest().getParameter("propertyName"); 689 690 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 691 692 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 693 694 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 695 String componentPropertyXPath = "//component[@id=" + this.componentId + "]/properties/property[@name='" + propertyName + "']"; 696 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 698 if(anl.getLength() == 0) 699 { 700 String componentXPath = "//component[@id=" + this.componentId + "]/properties"; 701 NodeList componentNodeList = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 703 if(componentNodeList.getLength() > 0) 704 { 705 Element componentProperties = (Element )componentNodeList.item(0); 706 if(entity.equalsIgnoreCase("SiteNode")) 707 addPropertyElement(componentProperties, propertyName, path, "siteNodeBinding", locale); 708 else 709 addPropertyElement(componentProperties, propertyName, path, "contentBinding", locale); 710 711 anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 712 } 713 } 714 715 if(anl.getLength() > 0) 717 { 718 Element component = (Element )anl.item(0); 719 component.setAttribute("path_" + locale.getLanguage(), path); 720 721 NodeList children = component.getChildNodes(); 722 for(int i=0; i < children.getLength(); i++) 723 { 724 Node node = children.item(i); 725 component.removeChild(node); 726 } 727 728 Element newComponent = addBindingElement(component, entity, entityId); 729 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 730 732 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 733 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 734 735 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 736 } 737 738 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + this.componentId + "&showSimple=" + this.showSimple; 739 741 this.url = this.getResponse().encodeURL(url); 742 this.getResponse().sendRedirect(url); 743 return NONE; 744 } 745 746 747 750 751 public String doAddComponentPropertyBindingWithQualifyer() throws Exception 752 { 753 initialize(); 754 764 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 765 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 766 Integer contentId = new Integer (this.getRequest().getParameter("contentId")); 767 768 Locale locale = LanguageController.getController().getLocaleWithId(languageId); 769 770 String qualifyerXML = this.getRequest().getParameter("qualifyerXML"); 771 String propertyName = this.getRequest().getParameter("propertyName"); 772 773 779 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 780 781 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 782 784 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 785 String componentPropertyXPath = "//component[@id=" + this.componentId + "]/properties/property[@name='" + propertyName + "']"; 786 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 788 if(anl.getLength() > 0) 789 { 790 Node propertyNode = anl.item(0); 791 propertyNode.getParentNode().removeChild(propertyNode); 792 } 793 794 String componentXPath = "//component[@id=" + this.componentId + "]/properties"; 795 NodeList componentNodeList = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 797 if(componentNodeList.getLength() > 0) 798 { 799 Element componentProperties = (Element )componentNodeList.item(0); 800 addPropertyElement(componentProperties, propertyName, path, "contentBinding", locale); 801 anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 802 } 803 805 if(anl.getLength() > 0) 806 { 807 Element component = (Element )anl.item(0); 808 component.setAttribute("path_" + locale.getLanguage(), path); 809 810 addBindingElement(component, qualifyerXML); 811 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 812 813 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 814 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 815 816 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 817 } 818 819 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + this.componentId + "&showSimple=" + this.showSimple; 820 822 this.url = this.getResponse().encodeURL(url); 823 this.getResponse().sendRedirect(url); 824 return NONE; 825 } 826 827 830 831 public String doDeleteComponentBinding() throws Exception 832 { 833 initialize(); 834 844 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 845 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 846 Integer contentId = new Integer (this.getRequest().getParameter("contentId")); 847 Integer bindingId = new Integer (this.getRequest().getParameter("bindingId")); 848 849 853 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 854 855 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 857 859 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 860 String componentXPath = "//component[@id=" + this.componentId + "]/bindings/binding[@id=" + bindingId + "]"; 861 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 863 if(anl.getLength() > 0) 865 { 866 Element component = (Element )anl.item(0); 867 component.getParentNode().removeChild(component); 868 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 870 872 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 873 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 874 875 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 876 } 877 878 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + this.componentId + "&showSimple=" + this.showSimple; 879 881 this.url = this.getResponse().encodeURL(url); 882 return NONE; 884 } 885 886 887 890 891 public List getComponentBindings() throws Exception 892 { 893 List bindings = new ArrayList (); 894 895 try 896 { 897 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 898 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 899 Integer contentId = new Integer (this.getRequest().getParameter("contentId")); 900 String propertyName = this.getRequest().getParameter("propertyName"); 901 902 908 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 909 910 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 912 914 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 915 String componentXPath = "//component[@id=" + this.componentId + "]/properties/property[@name='" + propertyName + "']/binding"; 916 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); 918 for(int i=0; i<anl.getLength(); i++) 920 { 921 Element component = (Element )anl.item(i); 922 String entityName = component.getAttribute("entity"); 923 String entityId = component.getAttribute("entityId"); 924 925 try 926 { 927 String path = "Undefined"; 928 if(entityName.equalsIgnoreCase("SiteNode")) 929 { 930 SiteNodeVO siteNodeVO = SiteNodeController.getSiteNodeVOWithId(new Integer (entityId)); 931 path = siteNodeVO.getName(); 932 } 933 else if(entityName.equalsIgnoreCase("Content")) 934 { 935 ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer (entityId)); 936 path = contentVO.getName(); 937 } 938 939 Map binding = new HashMap (); 940 binding.put("entityName", entityName); 941 binding.put("entityId", entityId); 942 binding.put("path", path); 943 bindings.add(binding); 944 } 945 catch(Exception e) 946 { 947 logger.warn("There was " + entityName + " bound to property '" + propertyName + "' on siteNode " + siteNodeId + " which appears to have been deleted."); 948 } 949 } 950 } 951 catch(Exception e) 952 { 953 e.printStackTrace(); 954 } 955 956 return bindings; 957 } 958 959 961 964 965 public String doDeleteComponentPropertyValue() throws Exception 966 { 967 initialize(); 968 969 Integer siteNodeId = new Integer (this.getRequest().getParameter("siteNodeId")); 970 Integer languageId = new Integer (this.getRequest().getParameter("languageId")); 971 Integer contentId = new Integer (this.getRequest().getParameter("contentId")); 972 String propertyName = this.getRequest().getParameter("propertyName"); 973 974 979 NodeDeliveryController nodeDeliveryController = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId); 980 981 String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId(), contentId); 982 984 Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); 985 String componentPropertyXPath = "//component[@id=" + this.componentId + "]/properties/property[@name='" + propertyName + "']"; 986 NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentPropertyXPath); 988 if(anl.getLength() > 0) 989 { 990 Node propertyNode = anl.item(0); 991 propertyNode.getParentNode().removeChild(propertyNode); 992 } 993 994 String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer ()).toString(); 995 997 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 998 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); 999 1000 ContentVersionController.getContentVersionController().updateAttributeValue(contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); 1001 1002 this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&activatedComponentId=" + this.componentId + "&showSimple=" + this.showSimple; 1003 1005 this.url = this.getResponse().encodeURL(url); 1006 this.getResponse().sendRedirect(url); 1007 return NONE; 1008 } 1009 1010 1011 1012 1016 1017 private Element addPropertyElement(Element parent, String name, String path, String type, Locale locale) 1018 { 1019 Element element = parent.getOwnerDocument().createElement("property"); 1020 element.setAttribute("name", name); 1021 element.setAttribute("path_" + locale.getLanguage(), path); 1022 element.setAttribute("type", type); 1023 parent.appendChild(element); 1024 return element; 1025 } 1026 1027 1031 1032 private Element addComponentElement(Element parent, Integer id, String name, Integer contentId) 1033 { 1034 Element element = parent.getOwnerDocument().createElement("component"); 1035 element.setAttribute("id", id.toString()); 1036 element.setAttribute("contentId", contentId.toString()); 1037 element.setAttribute("name", name); 1038 Element properties = parent.getOwnerDocument().createElement("properties"); 1039 element.appendChild(properties); 1040 Element subComponents = parent.getOwnerDocument().createElement("components"); 1041 element.appendChild(subComponents); 1042 parent.appendChild(element); 1043 return element; 1044 } 1045 1046 1050 1051 private Element addBindingElement(Element parent, String entity, Integer entityId) 1052 { 1053 Element element = parent.getOwnerDocument().createElement("binding"); 1054 element.setAttribute("entityId", entityId.toString()); 1055 element.setAttribute("entity", entity); 1056 parent.appendChild(element); 1057 return element; 1058 } 1059 1060 1064 1065 private void addBindingElement(Element parent, String qualifyerXML) throws Exception 1066 { 1067 Document document = XMLHelper.readDocumentFromByteArray(qualifyerXML.getBytes()); 1069 NodeList nl = document.getChildNodes().item(0).getChildNodes(); 1070 for(int i=0; i<nl.getLength(); i++) 1071 { 1072 Element qualifyerElement = (Element )nl.item(i); 1073 String entityName = qualifyerElement.getNodeName(); 1075 String entityId = qualifyerElement.getFirstChild().getNodeValue(); 1076 1079 Element element = parent.getOwnerDocument().createElement("binding"); 1080 element.setAttribute("entityId", entityId); 1081 element.setAttribute("entity", entityName); 1082 parent.appendChild(element); 1083 } 1084 } 1085 1086 1087 1090 1091 public List getSortedComponents(String sortProperty) throws Exception 1092 { 1093 List componentVOList = null; 1094 1095 try 1096 { 1097 String direction = "asc"; 1098 componentVOList = ComponentController.getController().getComponentVOList(sortProperty, direction, allowedComponentNames); 1099 } 1100 catch(Exception e) 1101 { 1102 e.printStackTrace(); 1103 } 1104 1105 return componentVOList; 1106 } 1107 1108 1111 1112 private String getPageComponentsString(Integer siteNodeId, Integer languageId, Integer contentId) throws SystemException, Exception 1113 { 1114 String template = null; 1115 1116 try 1117 { 1118 ContentVO contentVO = NodeDeliveryController.getNodeDeliveryController(siteNodeId, languageId, contentId).getBoundContent(this.getInfoGluePrincipal(), siteNodeId, languageId, true, "Meta information", DeliveryContext.getDeliveryContext()); 1119 1120 if(contentVO == null) 1121 throw new SystemException("There was no template bound to this page which makes it impossible to render."); 1122 1123 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageId); 1124 if(contentVersionVO == null) 1125 { 1126 SiteNodeVO siteNodeVO = SiteNodeController.getSiteNodeVOWithId(siteNodeId); 1127 LanguageVO masterLanguage = LanguageController.getController().getMasterLanguage(siteNodeVO.getRepositoryId()); 1128 contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), masterLanguage.getLanguageId()); 1129 } 1130 1131 template = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO.getId(), "ComponentStructure", false); 1132 1133 if(template == null) 1134 throw new SystemException("There was no template bound to this page which makes it impossible to render."); 1135 } 1136 catch(Exception e) 1137 { 1138 logger.error(e.getMessage(), e); 1139 throw e; 1140 } 1141 1142 return template; 1143 } 1144 1145 1148 1149 public String getDigitalAssetUrl(Integer contentId, String key) throws Exception 1150 { 1151 String imageHref = null; 1152 try 1153 { 1154 LanguageVO masterLanguage = LanguageController.getController().getMasterLanguage(ContentController.getContentController().getContentVOWithId(contentId).getRepositoryId()); 1155 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, masterLanguage.getId()); 1156 List digitalAssets = DigitalAssetController.getDigitalAssetVOList(contentVersionVO.getId()); 1157 Iterator i = digitalAssets.iterator(); 1158 while(i.hasNext()) 1159 { 1160 DigitalAssetVO digitalAssetVO = (DigitalAssetVO)i.next(); 1161 if(digitalAssetVO.getAssetKey().equals(key)) 1162 { 1163 imageHref = DigitalAssetController.getDigitalAssetUrl(digitalAssetVO.getId()); 1164 break; 1165 } 1166 } 1167 } 1168 catch(Exception e) 1169 { 1170 logger.warn("We could not get the url of the digitalAsset: " + e.getMessage(), e); 1171 imageHref = e.getMessage(); 1172 } 1173 1174 return imageHref; 1175 } 1176 1177 public Integer getContentId() 1178 { 1179 return contentId; 1180 } 1181 1182 public void setContentId(Integer integer) 1183 { 1184 contentId = integer; 1185 } 1186 1187 public Integer getComponentId() 1188 { 1189 return this.componentId; 1190 } 1191 1192 public void setComponentId(Integer componentId) 1193 { 1194 this.componentId = componentId; 1195 } 1196 1197 public Integer getParentComponentId() 1198 { 1199 return parentComponentId; 1200 } 1201 1202 public void setParentComponentId(Integer parentComponentId) 1203 { 1204 this.parentComponentId = parentComponentId; 1205 } 1206 1207 public Integer getLanguageId() 1208 { 1209 return this.languageId; 1210 } 1211 1212 public Integer getSiteNodeId() 1213 { 1214 return this.siteNodeId; 1215 } 1216 1217 public void setLanguageId(Integer languageId) 1218 { 1219 this.languageId = languageId; 1220 } 1221 1222 public void setSiteNodeId(Integer siteNodeId) 1223 { 1224 this.siteNodeId = siteNodeId; 1225 } 1226 1227 public String getSlotId() 1228 { 1229 return this.slotId; 1230 } 1231 1232 public void setSlotId(String slotId) 1233 { 1234 this.slotId = slotId; 1235 } 1236 1237 public Integer getRepositoryId() 1238 { 1239 return this.repositoryId; 1240 } 1241 1242 public void setRepositoryId(Integer repositoryId) 1243 { 1244 this.repositoryId = repositoryId; 1245 } 1246 1247 public Integer getFilterRepositoryId() 1248 { 1249 return filterRepositoryId; 1250 } 1251 1252 public void setFilterRepositoryId(Integer filterRepositoryId) 1253 { 1254 this.filterRepositoryId = filterRepositoryId; 1255 } 1256 1257 public String getSpecifyBaseTemplate() 1258 { 1259 return this.specifyBaseTemplate; 1260 } 1261 1262 public void setSpecifyBaseTemplate(String specifyBaseTemplate) 1263 { 1264 this.specifyBaseTemplate = specifyBaseTemplate; 1265 } 1266 1267 public String getPropertyName() 1268 { 1269 return this.propertyName; 1270 } 1271 1272 public void setPropertyName(String propertyName) 1273 { 1274 this.propertyName = propertyName; 1275 } 1276 1277 public String getPath() 1278 { 1279 return this.path; 1280 } 1281 1282 public void setPath(String path) 1283 { 1284 this.path = path; 1285 } 1286 1287 public LanguageVO getMasterLanguageVO() 1288 { 1289 return masterLanguageVO; 1290 } 1291 1292 public String getUrl() 1293 { 1294 return url; 1295 } 1296 1297 public String getSortProperty() 1298 { 1299 return sortProperty; 1300 } 1301 1302 public void setSortProperty(String sortProperty) 1303 { 1304 this.sortProperty = sortProperty; 1305 } 1306 1307 public Integer getDirection() 1308 { 1309 return direction; 1310 } 1311 1312 public void setDirection(Integer direction) 1313 { 1314 this.direction = direction; 1315 } 1316 1317 public String [] getAllowedContentTypeIds() 1318 { 1319 return allowedContentTypeIds; 1320 } 1321 1322 public void setAllowedContentTypeIds(String [] allowedContentTypeIds) 1323 { 1324 this.allowedContentTypeIds = allowedContentTypeIds; 1325 } 1326 1327 public String getAllowedContentTypeIdsAsUrlEncodedString() throws Exception 1328 { 1329 StringBuffer sb = new StringBuffer (); 1330 1331 for(int i=0; i<allowedContentTypeIds.length; i++) 1332 { 1333 if(i > 0) 1334 sb.append("&"); 1335 1336 sb.append("allowedContentTypeIds=" + URLEncoder.encode(allowedContentTypeIds[i], "UTF-8")); 1337 } 1338 1339 return sb.toString(); 1340 } 1341 1342 public boolean getShowSimple() 1343 { 1344 return showSimple; 1345 } 1346 1347 public void setShowSimple(boolean showSimple) 1348 { 1349 this.showSimple = showSimple; 1350 } 1351 1352 public Integer getPageTemplateContentId() 1353 { 1354 return pageTemplateContentId; 1355 } 1356 1357 public void setPageTemplateContentId(Integer pageTemplateContentId) 1358 { 1359 this.pageTemplateContentId = pageTemplateContentId; 1360 } 1361 1362 public String [] getAllowedComponentNames() 1363 { 1364 return allowedComponentNames; 1365 } 1366 1367 public void setAllowedComponentNames(String [] allowedComponentNames) 1368 { 1369 this.allowedComponentNames = allowedComponentNames; 1370 } 1371 1372 public String getAllowedComponentNamesAsUrlEncodedString() throws Exception 1373 { 1374 StringBuffer sb = new StringBuffer (); 1375 1376 for(int i=0; i<allowedComponentNames.length; i++) 1377 { 1378 if(i > 0) 1379 sb.append("&"); 1380 1381 sb.append("allowedComponentNames=" + URLEncoder.encode(allowedComponentNames[i], "UTF-8")); 1382 } 1383 1384 return sb.toString(); 1385 } 1386 1387} 1388 | Popular Tags |