1 19 package org.openharmonise.rm.publishing; 20 21 import java.util.logging.*; 22 23 import org.openharmonise.commons.dsi.*; 24 import org.openharmonise.commons.xml.*; 25 import org.openharmonise.rm.factory.*; 26 import org.openharmonise.rm.resources.*; 27 import org.openharmonise.rm.resources.publishing.*; 28 import org.openharmonise.rm.resources.users.*; 29 import org.openharmonise.rm.security.authorization.*; 30 import org.w3c.dom.*; 31 32 33 34 43 public class HarmoniseOutput extends XMLDocument { 44 45 AbstractDataStoreInterface m_dsi = null; 46 47 50 private static final Logger m_logger = Logger.getLogger(HarmoniseOutput.class.getName()); 51 52 public HarmoniseOutput(AbstractDataStoreInterface dsi) { 53 super(); 54 m_dsi = dsi; 55 } 56 57 public HarmoniseOutput(org.w3c.dom.Document document, AbstractDataStoreInterface dsi) { 58 super(document); 59 m_dsi = dsi; 60 } 61 62 72 public Element processSubmitTag(Element submit, State state) { 73 Element newSubmit = null; 74 75 newSubmit = (Element) copyNode(submit); 76 77 return newSubmit; 78 } 79 80 86 public void addPageIdToLinkNode(User usr, Element el, int nPageId) { 87 NodeList linkNodes = el.getElementsByTagName(AbstractObject.TAG_LINK); 88 89 try { 90 WebPage page = (WebPage) HarmoniseObjectFactory.instantiateHarmoniseObject( 91 this.m_dsi, WebPage.class.getName(), 92 nPageId); 93 94 boolean bIsVisible = AuthorizationValidator.isVisible(usr, page); 95 96 for(int i=0;i<linkNodes.getLength();i++) { 97 Element linkNode = (Element) linkNodes.item(i); 98 if(bIsVisible == false){ 99 linkNode.setAttribute(AuthorizationValidator.ATTRIB_IS_VIEWABLE, "false"); 100 } 101 102 NodeList pageNodes = linkNode.getElementsByTagName( 103 WebPage.TAG_PAGE); 104 105 if (pageNodes.getLength() == 0) { 106 Node pageNode = createElement(WebPage.TAG_PAGE); 107 ((Element) pageNode).setAttribute(AbstractObject.ATTRIB_ID, 108 Integer.toString(nPageId)); 109 110 linkNode.appendChild(pageNode); 111 } 112 113 } 114 } catch (Exception e) { 115 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 116 } 117 } 118 119 124 public Element createErrorElement(String error_code, Element form_element) { 125 NodeList nodes = form_element.getElementsByTagName( 126 XMLFormErrorCodes.TAG_ERRORTEXT); 127 Element error_element = createElement(AbstractObject.TAG_ERROR); 128 129 String error_text = null; 130 131 for (int i = 0; i < nodes.getLength(); i++) { 132 Element form_error_element = (Element) nodes.item(i); 133 134 if (((String ) form_error_element.getAttribute( 135 XMLFormErrorCodes.ATTRIB_ERRORCODE)).equals(error_code)) { 136 Text txt = (Text) form_error_element.getFirstChild(); 137 error_text = txt.getNodeValue(); 138 } 139 } 140 141 142 if (error_text == null) 143 { 144 error_text = XMLFormErrorCodes.getInstance() 146 .getErrorText(error_code); 147 } 148 149 Node txt; 150 151 if (error_text != null) { 152 txt = createTextNode(error_text); 153 } else { 154 throw new RuntimeException ("Error code unknown :" + error_code); 155 } 156 157 error_element.appendChild(txt); 158 error_element.setAttribute(XMLFormErrorCodes.ATTRIB_ERRORCODE, error_code); 159 160 return error_element; 161 } 162 } | Popular Tags |