List of usage examples for org.w3c.dom Element getParentNode
public Node getParentNode();
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
/** * This method moves an content type attribute down one step. *///from ww w . ja v a 2 s .co m public String doMoveAttributeDown() throws Exception { this.initialize(getContentTypeDefinitionId()); try { Document document = createDocumentFromDefinition(); String attributesXPath = "/xs:schema/xs:complexType/xs:all/xs:element/xs:complexType/xs:all/xs:element"; NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); Element parent = null; Element elementToMove = null; boolean isInserted = false; int position = 0; for (int i = 0; i < anl.getLength(); i++) { Element element = (Element) anl.item(i); parent = (Element) element.getParentNode(); if (elementToMove != null) { if (position == 2) { parent.insertBefore(elementToMove, element); isInserted = true; break; } else position++; } if (element.getAttribute("name").equalsIgnoreCase(this.attributeName)) { elementToMove = element; parent.removeChild(elementToMove); position++; } } if (!isInserted && elementToMove != null) parent.appendChild(elementToMove); saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
/** * This method moves an content type assetKey up one step. *//*from w w w . jav a 2s . com*/ public String doMoveAssetKeyUp() throws Exception { this.initialize(getContentTypeDefinitionId()); try { Document document = createDocumentFromDefinition(); String attributesXPath = "/xs:schema/xs:simpleType[@name = '" + ContentTypeDefinitionController.ASSET_KEYS + "']/xs:restriction/xs:enumeration[@value='" + this.assetKey + "']"; NodeList anl = XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); if (anl != null && anl.getLength() > 0) { Element element = (Element) anl.item(0); Node parentElement = element.getParentNode(); Node previuosSibling = element.getPreviousSibling(); if (previuosSibling != null) { parentElement.removeChild(element); parentElement.insertBefore(element, previuosSibling); } } saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
/** * This method moves an content type asset key down one step. *//*ww w.j a va2 s.c o m*/ public String doMoveAssetKeyDown() throws Exception { this.initialize(getContentTypeDefinitionId()); try { Document document = createDocumentFromDefinition(); String attributesXPath = "/xs:schema/xs:simpleType[@name = '" + ContentTypeDefinitionController.ASSET_KEYS + "']/xs:restriction/xs:enumeration[@value='" + this.assetKey + "']"; NodeList anl = XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); if (anl != null && anl.getLength() > 0) { Element element = (Element) anl.item(0); Node parentElement = element.getParentNode(); Node nextSibling = element.getNextSibling(); if (nextSibling != null) { parentElement.removeChild(nextSibling); parentElement.insertBefore(nextSibling, element); } } saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
public String doDeleteAttributeParameterValue() throws Exception { this.initialize(getContentTypeDefinitionId()); try {//from w w w . ja v a 2 s . c om Document document = createDocumentFromDefinition(); String attributesXPath = "/xs:schema/xs:complexType/xs:all/xs:element/xs:complexType/xs:all/xs:element[@name='" + this.attributeName + "']/xs:annotation/xs:appinfo/params/param[@id='" + this.attributeParameterId + "']/values/value[@id='" + this.attributeParameterValueId + "']"; NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); if (anl != null && anl.getLength() > 0) { Element element = (Element) anl.item(0); element.getParentNode().removeChild(element); } saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
/** * We validate that ' ', '.', ''', '"' is not used in the attribute name as that will break the javascripts later. */// w w w. j av a 2 s. c om public String doUpdateAttribute() throws Exception { ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); if (this.newAttributeName.indexOf(" ") > -1 || this.newAttributeName.indexOf(".") > -1 || this.newAttributeName.indexOf("'") > -1 || this.newAttributeName.indexOf("\"") > -1) { ceb.add(new ConstraintException("ContentTypeAttribute.updateAction", "3500")); } ceb.throwIfNotEmpty(); this.initialize(getContentTypeDefinitionId()); try { Document document = createDocumentFromDefinition(); //Updating the content attribute String[] extraParameterNames = getRequest().getParameterValues("parameterNames"); if (extraParameterNames != null) { for (int i = 0; i < extraParameterNames.length; i++) { String extraParameterName = extraParameterNames[i]; String value = getRequest().getParameter(extraParameterName); String extraParametersXPath = "/xs:schema/xs:complexType/xs:all/xs:element/xs:complexType/xs:all/xs:element[@name='" + this.attributeName + "']/xs:annotation/xs:appinfo/params/param[@id='" + extraParameterName + "']/values/value"; NodeList extraParamsNodeList = org.apache.xpath.XPathAPI .selectNodeList(document.getDocumentElement(), extraParametersXPath); if (extraParamsNodeList != null && extraParamsNodeList.getLength() > 0) { Element element = (Element) extraParamsNodeList.item(0); if (extraParameterName.equalsIgnoreCase("values") && (this.inputTypeId.equalsIgnoreCase("select") || this.inputTypeId.equalsIgnoreCase("checkbox") || this.inputTypeId.equalsIgnoreCase("radiobutton"))) { ((Element) element.getParentNode().getParentNode()).setAttribute("inputTypeId", "1"); } else if (extraParameterName.equalsIgnoreCase("Markup") && this.inputTypeId.equalsIgnoreCase("customfield")) { ((Element) element.getParentNode().getParentNode()).setAttribute("inputTypeId", "2"); } else { ((Element) element.getParentNode().getParentNode()).setAttribute("inputTypeId", "0"); } String inputTypeId = ((Element) element.getParentNode().getParentNode()) .getAttribute("inputTypeId"); if (inputTypeId.equals("0") || inputTypeId.equals("2")) { if (this.currentContentTypeEditorViewLanguageCode != null && this.currentContentTypeEditorViewLanguageCode.length() > 0) { element.setAttribute("label_" + this.currentContentTypeEditorViewLanguageCode, value); } else { element.setAttribute("label", value); } } } } } //Updating the name and type String attributeXPath = "/xs:schema/xs:complexType/xs:all/xs:element/xs:complexType/xs:all/xs:element[@name='" + this.attributeName + "']"; NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), attributeXPath); if (anl != null && anl.getLength() > 0) { Element element = (Element) anl.item(0); element.setAttribute("name", this.newAttributeName); element.setAttribute("type", this.inputTypeId); } try { //Updating the validation part String validationXPath = "//xs:complexType[@name='Validation']/xs:annotation/xs:appinfo/form-validation/formset/form/field[@property='" + this.attributeName + "']"; NodeList fieldNodeList = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), validationXPath); if (fieldNodeList != null && fieldNodeList.getLength() > 0) { Element element = (Element) fieldNodeList.item(0); element.setAttribute("property", this.newAttributeName); } //Updating the dependent part String validationDependentXPath = "//xs:complexType[@name='Validation']/xs:annotation/xs:appinfo/form-validation/formset/form/field[@depends='requiredif']/var/var-value"; NodeList requiredIfValueNodeList = org.apache.xpath.XPathAPI .selectNodeList(document.getDocumentElement(), validationDependentXPath); if (requiredIfValueNodeList != null && requiredIfValueNodeList.getLength() > 0) { for (int i = 0; i < requiredIfValueNodeList.getLength(); i++) { Element element = (Element) requiredIfValueNodeList.item(0); if (element.getFirstChild() != null && element.getFirstChild().getNodeValue() != null && element.getFirstChild().getNodeValue().equals(this.attributeName)) element.getFirstChild().setNodeValue(this.newAttributeName); } } } catch (Exception ve) { ve.printStackTrace(); } this.attributeToExpand = this.newAttributeName; saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
public String doDeleteAttributeValidator() throws Exception { this.initialize(getContentTypeDefinitionId()); try {//from w w w.j av a 2 s. c o m Document document = createDocumentFromDefinition(); int i = 0; String attributeValidatorName = this.getRequest().getParameter("attributeValidatorName"); if (attributeValidatorName != null && !attributeValidatorName.equalsIgnoreCase("")) { String validatorsXPath = "/xs:schema/xs:complexType[@name = 'Validation']/xs:annotation/xs:appinfo/form-validation/formset/form/field[@property = '" + attributeName + "'][@depends = '" + attributeValidatorName + "']"; Node fieldNode = org.apache.xpath.XPathAPI.selectSingleNode(document.getDocumentElement(), validatorsXPath); if (fieldNode != null) { Element element = (Element) fieldNode; element.getParentNode().removeChild(element); } } saveUpdatedDefinition(document); } catch (Exception e) { e.printStackTrace(); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
private String deleteKey(String keyType, String key) throws Exception { this.initialize(getContentTypeDefinitionId()); try {/* www.ja va2 s . co m*/ Document document = createDocumentFromDefinition(); String attributesXPath = "/xs:schema/xs:simpleType[@name = '" + keyType + "']/xs:restriction/xs:enumeration[@value='" + key + "']"; NodeList anl = XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); if (anl != null && anl.getLength() > 0) { Element element = (Element) anl.item(0); element.getParentNode().removeChild(element); } saveUpdatedDefinition(document); } catch (Exception e) { logger.warn("Error updating key: " + keyType, e); } this.initialize(getContentTypeDefinitionId()); return USE_EDITOR; }
From source file:org.infoglue.cms.applications.managementtool.actions.ViewContentTypeDefinitionAction.java
/** * Find an <xs:enumeration> element and update the key value. * @return The Element if child changes are needed, null if the element is not found *//*ww w . j a v a 2 s . c o m*/ private Element updateAssetEnumerationKey(Document document, String keyType, String oldKey, String newKey, Boolean isMandatory, String description, Integer maximumSize, String allowedContentTypes, String imageWidth, String imageHeight, String assetUploadTransformationsSettings) throws TransformerException { if (isMandatory == null) isMandatory = new Boolean(false); if (description == null) description = "Undefined"; if (maximumSize == null) maximumSize = new Integer(100); if (allowedContentTypes == null) allowedContentTypes = "*"; if (imageWidth == null) imageWidth = "*"; if (imageHeight == null) imageHeight = "*"; String attributesXPath = "/xs:schema/xs:simpleType[@name = '" + keyType + "']/xs:restriction/xs:enumeration[@value='" + oldKey + "']"; NodeList anl = XPathAPI.selectNodeList(document.getDocumentElement(), attributesXPath); if (anl != null && anl.getLength() > 0) { Element enumeration = (Element) anl.item(0); enumeration.setAttribute("value", newKey); Element isMandatoryElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/isMandatory"); Element descriptionElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/description"); Element maximumSizeElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/maximumSize"); Element allowedContentTypesElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/allowedContentTypes"); Element imageWidthElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/imageWidth"); Element imageHeightElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/imageHeight"); Element assetUploadTransformationsSettingsElement = (Element) XPathAPI.selectSingleNode(enumeration, "xs:annotation/xs:appinfo/params/assetUploadTransformationsSettings"); if (isMandatoryElement == null && descriptionElement != null) { isMandatoryElement = createTextElement(document, "isMandatory", isMandatory.toString()); descriptionElement.getParentNode().appendChild(isMandatoryElement); } if (assetUploadTransformationsSettingsElement == null && descriptionElement != null) { assetUploadTransformationsSettingsElement = createTextElement(document, "assetUploadTransformationsSettings", assetUploadTransformationsSettings.toString()); descriptionElement.getParentNode().appendChild(assetUploadTransformationsSettingsElement); } if (descriptionElement == null) { Element annotation = document.createElement("xs:annotation"); Element appinfo = document.createElement("xs:appinfo"); Element params = document.createElement("params"); enumeration.appendChild(annotation); annotation.appendChild(appinfo); appinfo.appendChild(params); descriptionElement = createTextElement(document, "description", getRandomName()); maximumSizeElement = createTextElement(document, "maximumSize", maximumSize.toString()); allowedContentTypesElement = createTextElement(document, "allowedContentTypes", allowedContentTypes); imageWidthElement = createTextElement(document, "imageWidth", imageWidth); imageHeightElement = createTextElement(document, "imageHeight", imageHeight); isMandatoryElement = createTextElement(document, "isMandatory", isMandatory.toString()); assetUploadTransformationsSettingsElement = createTextElement(document, "assetUploadTransformationsSettings", assetUploadTransformationsSettings.toString()); params.appendChild(descriptionElement); params.appendChild(maximumSizeElement); params.appendChild(allowedContentTypesElement); params.appendChild(imageWidthElement); params.appendChild(imageHeightElement); params.appendChild(isMandatoryElement); } else { setTextElement(isMandatoryElement, isMandatory.toString()); setTextElement(descriptionElement, description); setTextElement(maximumSizeElement, maximumSize.toString()); setTextElement(allowedContentTypesElement, allowedContentTypes); setTextElement(imageWidthElement, imageWidth); setTextElement(imageHeightElement, imageHeight); setTextElement(assetUploadTransformationsSettingsElement, assetUploadTransformationsSettings); } return enumeration; } return null; }
From source file:org.infoglue.cms.applications.structuretool.actions.ViewSiteNodePageComponentsAction.java
/** * This method adds a component to the page. *//*from w w w .jav a 2 s .c o m*/ public String doMoveComponentToSlot() throws Exception { logger.info("************************************************************"); logger.info("* MOVING COMPONENT TO ANOTHER SLOT *"); logger.info("************************************************************"); logger.info("siteNodeId:" + this.siteNodeId); logger.info("languageId:" + this.languageId); logger.info("contentId:" + this.contentId); logger.info("queryString:" + this.getRequest().getQueryString()); logger.info("parentComponentId:" + this.parentComponentId); logger.info("componentId:" + this.componentId); logger.info("slotId:" + this.slotId); logger.info("specifyBaseTemplate:" + this.specifyBaseTemplate); initialize(); logger.info("masterLanguageId:" + this.masterLanguageVO.getId()); ContentVO componentContentVO = null; if (this.specifyBaseTemplate.equalsIgnoreCase("true")) { throw new SystemException("Not possible to move component to base slot"); } else { String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId()); Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); String componentXPath = "//component[@id=" + this.componentId + "]"; String parentComponentXPath = "//component[@id=" + this.parentComponentId + "]/components"; logger.info("componentXPath:" + componentXPath); logger.info("parentComponentXPath:" + parentComponentXPath); Node componentNode = org.apache.xpath.XPathAPI.selectSingleNode(document.getDocumentElement(), componentXPath); logger.info("Found componentNode:" + componentNode); Node parentComponentComponentsNode = org.apache.xpath.XPathAPI .selectSingleNode(document.getDocumentElement(), parentComponentXPath); logger.info("Found parentComponentComponentsNode:" + parentComponentComponentsNode); if (componentNode != null && parentComponentComponentsNode != null) { Element component = (Element) componentNode; Element currentParentElement = (Element) componentNode.getParentNode(); Element parentComponentComponentsElement = (Element) parentComponentComponentsNode; Element parentComponentElement = (Element) parentComponentComponentsNode.getParentNode(); Integer componentContentId = new Integer(component.getAttribute("contentId")); Integer parentComponentContentId = new Integer(parentComponentElement.getAttribute("contentId")); logger.info("componentContentId:" + componentContentId); logger.info("parentComponentContentId:" + parentComponentContentId); componentContentVO = ContentController.getContentController() .getContentVOWithId(componentContentId); PageEditorHelper peh = new PageEditorHelper(); List<Slot> slots = peh.getSlots(parentComponentContentId, languageId, this.getInfoGluePrincipal()); boolean allowed = true; Iterator<Slot> slotsIterator = slots.iterator(); while (slotsIterator.hasNext()) { Slot slot = slotsIterator.next(); logger.info(slot.getId() + "=" + slotId); if (slot.getId().equals(slotId)) { String[] allowedComponentNames = slot.getAllowedComponentsArray(); String[] disallowedComponentNames = slot.getDisallowedComponentsArray(); if (allowedComponentNames != null && allowedComponentNames.length > 0) { allowed = false; for (int i = 0; i < allowedComponentNames.length; i++) { if (allowedComponentNames[i].equalsIgnoreCase(componentContentVO.getName())) allowed = true; } } if (disallowedComponentNames != null && disallowedComponentNames.length > 0) { for (int i = 0; i < disallowedComponentNames.length; i++) { if (disallowedComponentNames[i].equalsIgnoreCase(componentContentVO.getName())) allowed = false; } } } break; } logger.info("Should the component:" + componentContentVO + " be allowed to be put in " + slotId + ":" + allowed); logger.info("currentParentElement:" + currentParentElement.getNodeName() + ":" + currentParentElement.hashCode()); logger.info("parentComponentComponentsElement:" + parentComponentComponentsElement.getNodeName() + ":" + parentComponentComponentsElement.hashCode()); logger.info("slotPositionComponentId:" + slotPositionComponentId); if ((component.getParentNode() == parentComponentComponentsElement && slotId.equalsIgnoreCase(component.getAttribute("name")))) { logger.info("Yes..."); component.getParentNode().removeChild(component); component.setAttribute("name", slotId); logger.info("slotPositionComponentId:" + slotPositionComponentId); if (slotPositionComponentId != null && !slotPositionComponentId.equals("")) { logger.info("Moving component to slot: " + slotPositionComponentId); Element afterElement = null; NodeList childNodes = parentComponentComponentsElement.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getAttribute("id").equals(slotPositionComponentId)) { afterElement = element; break; } } } if (afterElement != null) { logger.info("Inserting component before: " + afterElement); parentComponentComponentsElement.insertBefore(component, afterElement); } else { parentComponentComponentsElement.appendChild(component); } } else { logger.info("Appending component..."); parentComponentComponentsElement.appendChild(component); } String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer()).toString(); ContentVO contentVO = NodeDeliveryController .getNodeDeliveryController(siteNodeId, this.masterLanguageVO.getId(), contentId) .getBoundContent(this.getInfoGluePrincipal(), siteNodeId, this.masterLanguageVO.getId(), true, "Meta information", DeliveryContext.getDeliveryContext()); ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController() .getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); ContentVersionController.getContentVersionController().updateAttributeValue( contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&focusElementId=" + componentId + "&componentContentId=" + componentContentVO.getId() + "&showSimple=" + this.showSimple; } else if (allowed && (component.getParentNode() != parentComponentComponentsElement || !slotId.equalsIgnoreCase(component.getAttribute("name")))) { logger.info("Moving component..."); component.getParentNode().removeChild(component); component.setAttribute("name", slotId); if (slotPositionComponentId != null && !slotPositionComponentId.equals("")) { NodeList childNodes = parentComponentComponentsElement.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; if (element.getAttribute("id").equals(slotPositionComponentId)) { logger.info("Inserting component before: " + element); parentComponentComponentsElement.insertBefore(component, element); break; } } } } else { parentComponentComponentsElement.appendChild(component); } String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer()).toString(); ContentVO contentVO = NodeDeliveryController .getNodeDeliveryController(siteNodeId, this.masterLanguageVO.getId(), contentId) .getBoundContent(this.getInfoGluePrincipal(), siteNodeId, this.masterLanguageVO.getId(), true, "Meta information", DeliveryContext.getDeliveryContext()); ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController() .getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); ContentVersionController.getContentVersionController().updateAttributeValue( contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&focusElementId=" + componentId + "&componentContentId=" + componentContentVO.getId() + "&showSimple=" + this.showSimple; } else { this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&showSimple=" + this.showSimple; } } } //this.getResponse().sendRedirect(url); this.url = this.getResponse().encodeURL(url); this.getResponse().sendRedirect(url); return NONE; }
From source file:org.infoglue.cms.applications.structuretool.actions.ViewSiteNodePageComponentsAction.java
/** * This method moves the component up a step if possible within the same slot. */// www .ja v a 2s . c o m public String doMoveComponent() throws Exception { initialize(); String componentXML = getPageComponentsString(siteNodeId, this.masterLanguageVO.getId()); //logger.info("componentXML:" + componentXML); Document document = XMLHelper.readDocumentFromByteArray(componentXML.getBytes("UTF-8")); String componentXPath = "//component[@id=" + this.componentId + "]"; NodeList anl = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath); if (anl.getLength() > 0) { Element component = (Element) anl.item(0); String name = component.getAttribute("name"); //logger.info(XMLHelper.serializeDom(component, new StringBuffer())); Node parentNode = component.getParentNode(); boolean hasChanged = false; if (this.direction.intValue() == 0) //Up { Node previousNode = component.getPreviousSibling(); while (previousNode != null && previousNode.getNodeType() != Node.ELEMENT_NODE) { previousNode = previousNode.getPreviousSibling(); //break; } Element element = ((Element) previousNode); while (element != null && !element.getAttribute("name").equalsIgnoreCase(name)) { previousNode = previousNode.getPreviousSibling(); while (previousNode != null && previousNode.getNodeType() != Node.ELEMENT_NODE) { previousNode = previousNode.getPreviousSibling(); //break; } element = ((Element) previousNode); } if (previousNode != null) { parentNode.removeChild(component); parentNode.insertBefore(component, previousNode); hasChanged = true; } } else if (this.direction.intValue() == 1) //Down { Node nextNode = component.getNextSibling(); while (nextNode != null && nextNode.getNodeType() != Node.ELEMENT_NODE) { nextNode = nextNode.getNextSibling(); break; } Element element = ((Element) nextNode); while (element != null && !element.getAttribute("name").equalsIgnoreCase(name)) { nextNode = nextNode.getNextSibling(); element = ((Element) nextNode); } if (nextNode != null) nextNode = nextNode.getNextSibling(); if (nextNode != null) { parentNode.removeChild(component); parentNode.insertBefore(component, nextNode); hasChanged = true; } else { parentNode.removeChild(component); parentNode.appendChild(component); hasChanged = true; } } if (hasChanged) { String modifiedXML = XMLHelper.serializeDom(document, new StringBuffer()).toString(); //logger.info("modifiedXML:" + modifiedXML); ContentVO contentVO = NodeDeliveryController .getNodeDeliveryController(siteNodeId, languageId, contentId) .getBoundContent(this.getInfoGluePrincipal(), siteNodeId, this.masterLanguageVO.getId(), true, "Meta information", DeliveryContext.getDeliveryContext()); ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController() .getLatestActiveContentVersionVO(contentVO.getId(), this.masterLanguageVO.getId()); ContentVersionController.getContentVersionController().updateAttributeValue( contentVersionVO.getContentVersionId(), "ComponentStructure", modifiedXML, this.getInfoGluePrincipal()); } } this.url = getComponentRendererUrl() + getComponentRendererAction() + "?siteNodeId=" + this.siteNodeId + "&languageId=" + this.languageId + "&contentId=" + this.contentId + "&focusElementId=" + this.componentId + "&showSimple=" + this.showSimple; //this.getResponse().sendRedirect(url); this.url = this.getResponse().encodeURL(url); this.getResponse().sendRedirect(url); return NONE; }