Author: julien(a)jboss.com
Date: 2007-02-09 21:16:20 -0500 (Fri, 09 Feb 2007)
New Revision: 6202
Added:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/NamedMetaElementMetaData.java
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ScriptElementMetaData.java
trunk/core/src/main/org/jboss/portal/core/util/markup/
trunk/core/src/main/org/jboss/portal/core/util/markup/Attribute.java
trunk/core/src/main/org/jboss/portal/core/util/markup/Element.java
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java
trunk/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/HeaderContentMetaData.java
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
Log:
JBPORTAL-1246 : Error while creating javascript includes using jboss-portlet.xml
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java 2007-02-09
23:32:40 UTC (rev 6201)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -25,6 +25,8 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
+import org.jboss.portal.core.metadata.portlet.ElementMetaData;
+import org.jboss.portal.core.util.markup.Element;
import org.jboss.portal.portlet.container.PortletContainer;
import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
@@ -85,8 +87,9 @@
{
for (Iterator i = headerContent.getElements().iterator(); i.hasNext();)
{
- HeaderContentMetaData.Element element =
(HeaderContentMetaData.Element)i.next();
- writer.write(element.outputToStringWith(contextPath));
+ ElementMetaData elementMD = (ElementMetaData)i.next();
+ Element element = elementMD.getElement();
+ writer.write(element.toString(contextPath));
}
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java 2007-02-09
23:32:40 UTC (rev 6201)
+++
trunk/core/src/main/org/jboss/portal/core/deployment/JBossApplicationMetaDataFactory.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
+import org.jboss.portal.core.metadata.portlet.ElementMetaData;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
@@ -76,28 +77,25 @@
String type = attrs.getValue("type");
String media = attrs.getValue("media");
String rel = attrs.getValue("rel");
- child = HeaderContentMetaData.Element.createLinkElement(type, rel, href,
title, media);
+ ElementMetaData elt = ElementMetaData.createLinkElement(type, rel, href,
title, media);
+ elt.init();
+ child = elt;
}
else if ("script".equalsIgnoreCase(localName))
{
String src = attrs.getValue("src");
String type = attrs.getValue("type");
- child = HeaderContentMetaData.Element.createScriptElement(type, src);
+ ElementMetaData elt = ElementMetaData.createScriptElement(type, src);
+ elt.init();
+ child = elt;
}
else if ("meta".equalsIgnoreCase(localName))
{
String name = attrs.getValue("name");
String content = attrs.getValue("content");
- if (name == null)
- {
- throw new IllegalArgumentException("'name' attribute of meta
element must NOT be null. http-equiv meta " +
- "elements are not currently supported.");
- }
- if (content == null)
- {
- throw new IllegalArgumentException("Content attribute required for
meta element: " + name);
- }
- child = HeaderContentMetaData.Element.createNamedMetaElement(name, content);
+ ElementMetaData elt = ElementMetaData.createNamedMetaElement(name, content);
+ elt.init();
+ child = elt;
}
}
if (child == null)
@@ -121,9 +119,9 @@
JBossPortletMetaData portlet = (JBossPortletMetaData)parent;
portlet.setHeaderContent(headerContent);
}
- else if (child instanceof HeaderContentMetaData.Element)
+ else if (child instanceof ElementMetaData)
{
- HeaderContentMetaData.Element element = (HeaderContentMetaData.Element)child;
+ ElementMetaData element = (ElementMetaData)child;
HeaderContentMetaData headerContent = (HeaderContentMetaData)parent;
headerContent.getElements().add(element);
}
@@ -151,12 +149,13 @@
service.setRef(value);
}
}
- else if (object instanceof HeaderContentMetaData.Element)
+ else if (object instanceof ElementMetaData)
{
if ("script".equals(localName))
{
- HeaderContentMetaData.Element element =
(HeaderContentMetaData.Element)object;
- element.setBodyContent(value);
+ ElementMetaData elt = (ElementMetaData)object;
+ elt.setBodyContent(value);
+ elt.init();
}
}
else
Added: trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.metadata.portlet;
+
+import org.jboss.portal.core.util.markup.Element;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class ElementMetaData
+{
+
+ /** . */
+ protected final String typeAttribute;
+
+ /** . */
+ protected String bodyContent;
+
+ /** . */
+ protected Element element;
+
+ protected ElementMetaData(String typeAttribute)
+ {
+ this.typeAttribute = typeAttribute;
+ }
+
+ public void init()
+ {
+ element = buildElement();
+ }
+
+ protected abstract Element buildElement();
+
+ public Element getElement()
+ {
+ return element;
+ }
+
+ public String getTypeAttribute()
+ {
+ return typeAttribute;
+ }
+
+ public String getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public void setBodyContent(String bodyContent)
+ {
+ this.bodyContent = bodyContent;
+ }
+
+ /**
+ * Create a meta header element. <p>This element will create a meta
tag.</p>
+ *
+ * @param name name attribute of the meta element
+ * @param content content attribute of the meta element
+ * @return a new meta header element
+ */
+ public static ElementMetaData createNamedMetaElement(String name, String content)
+ {
+ return new NamedMetaElementMetaData(name, content);
+ }
+
+ /**
+ * Create a link header element. <p>This element will create a link
tag.</p>
+ *
+ * @param type the type attribute of the link
+ * @param rel the rel attribute of the link
+ * @param href the href attribute of the link
+ * @param title the title attribute of the link
+ * @param media the media attribute of the link
+ * @return a new link header element
+ */
+ public static ElementMetaData createLinkElement(String type, String rel, String href,
String title, String media)
+ {
+ return new LinkElementMetaData(rel, type, href, title, media);
+ }
+
+ /**
+ * Create a script header element. <p>This element will create a script
tag.</p>
+ *
+ * @param type the type attribute of this script
+ * @param src the src attribute of this script
+ * @return a new script header element
+ */
+ public static ElementMetaData createScriptElement(String type, String src)
+ {
+ return new ScriptElementMetaData(type, src);
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/HeaderContentMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/HeaderContentMetaData.java 2007-02-09
23:32:40 UTC (rev 6201)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/HeaderContentMetaData.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -53,244 +53,4 @@
{
return elements;
}
-
- /** representation of an header element. */
- public static abstract class Element
- {
-
- /** . */
- public static final String LINK = "link";
-
- /** . */
- public static final String SCRIPT = "script";
-
- /** . */
- public static final String META = "meta";
-
- /** . */
- protected final String type;
-
- /** . */
- protected final String elementType;
-
- /** . */
- private String bodyContent;
-
- protected Element(String elementType, String type)
- {
- this.type = type;
- this.elementType = elementType;
- }
-
- public String getElementType()
- {
- return elementType;
- }
-
- public String getType()
- {
- return type;
- }
-
- /**
- * Create a link header element. <p>This element will create a link
tag.</p>
- *
- * @param type the type attribute of the link
- * @param rel the rel attribute of the link
- * @param href the href attribute of the link
- * @param title the title attribute of the link
- * @param media the media attribute of the link
- * @return a new link header element
- */
- public static Element createLinkElement(String type, String rel, String href,
String title, String media)
- {
- return new LinkElement(rel, type, href, title, media);
- }
-
- /**
- * Create a script header element. <p>This element will create a script
tag.</p>
- *
- * @param type the type attribute of this script
- * @param src the src attribute of this script
- * @return a new script header element
- */
- public static Element createScriptElement(String type, String src)
- {
- return new ScriptElement(type, src);
- }
-
- public String getBodyContent()
- {
- return bodyContent;
- }
-
- public void setBodyContent(String bodyContent)
- {
- this.bodyContent = bodyContent;
- }
-
-
- public String outputToStringWith(String contextPath)
- {
- StringBuffer buffer = new StringBuffer(64);
- buffer.append("<").append(elementType);
- outputAttribute("type", type, buffer);
-
- // sub-class specific output
- outputSpecificWith(contextPath, buffer);
-
- if (bodyContent != null && !"".equals(bodyContent))
- {
-
buffer.append(">").append(bodyContent).append("</").append(elementType).append(">\n");
- }
- else
- {
- buffer.append(" />\n");
- }
- return buffer.toString();
- }
-
- protected void outputAttribute(String name, String value, StringBuffer buffer)
- {
- if (value != null && value.length() > 0)
- {
- buffer.append("
").append(name).append("='").append(value).append("'");
- }
- }
-
- protected void outputLocationAttribute(String name, String value, String
contextPath, StringBuffer buffer)
- {
- if (value != null)
- {
- buffer.append(" ").append(name).append("='");
- if (value.startsWith("/"))
- {
- buffer.append(contextPath);
- }
- buffer.append(value).append("'");
- }
- }
-
- protected abstract void outputSpecificWith(String contextPath, StringBuffer
buffer);
- /**
- * Create a meta header element. <p>This element will create a meta
tag.</p>
- *
- * @param name name attribute of the meta element
- * @param content content attribute of the meta element
- * @return a new meta header element
- */
- public static Element createNamedMetaElement(String name, String content)
- {
- return new NamedMetaElement(name, content);
- }
- }
-
- public static class LinkElement extends Element
- {
-
- /** . */
- private String rel;
-
- /** . */
- private String href;
-
- /** . */
- private String title;
-
- /** . */
- private String media;
-
- public LinkElement(String rel, String type, String href, String title, String
media)
- {
- super(LINK, type);
- this.rel = rel;
- this.href = href;
- this.title = title;
- this.media = media;
- }
-
- public String getRel()
- {
- return rel;
- }
-
- public String getHref()
- {
- return href;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public String getMedia()
- {
- return media;
- }
-
- protected void outputSpecificWith(String contextPath, StringBuffer buffer)
- {
- outputAttribute("rel", rel, buffer);
- outputLocationAttribute("href", href, contextPath, buffer);
- outputAttribute("title", title, buffer);
- outputAttribute("media", media, buffer);
- }
- }
-
- public static class ScriptElement extends Element
- {
-
- /** . */
- private String src;
-
- public ScriptElement(String type, String src)
- {
- super(SCRIPT, type);
- this.src = src;
- }
-
- protected void outputSpecificWith(String contextPath, StringBuffer buffer)
- {
- outputLocationAttribute("src", src, contextPath, buffer);
- }
-
- public String getSrc()
- {
- return src;
- }
- }
-
- public static class NamedMetaElement extends Element
- {
-
- /** . */
- private String name;
-
- /** . */
- private String content;
-
- public NamedMetaElement(String name, String content)
- {
- super(META, null);
- this.name = name;
- this.content = content;
- }
-
- protected void outputSpecificWith(String contextPath, StringBuffer buffer)
- {
- outputAttribute("name", name, buffer);
- outputAttribute("content", content, buffer);
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getContent()
- {
- return content;
- }
- }
}
Added:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.metadata.portlet;
+
+import org.jboss.portal.core.util.markup.Element;
+import org.jboss.portal.core.util.markup.Attribute;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LinkElementMetaData extends ElementMetaData
+{
+
+ /** . */
+ private String relAttribute;
+
+ /** . */
+ private String hrefAttribute;
+
+ /** . */
+ private String titleAttribute;
+
+ /** . */
+ private String mediaAttribute;
+
+ public LinkElementMetaData(String rel, String type, String href, String title, String
media)
+ {
+ super(type);
+
+ //
+ this.relAttribute = rel;
+ this.hrefAttribute = href;
+ this.titleAttribute = title;
+ this.mediaAttribute = media;
+ }
+
+ public Element buildElement()
+ {
+ ArrayList attributes = new ArrayList(5);
+ if (typeAttribute != null && typeAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("type", typeAttribute, false));
+ }
+ if (relAttribute != null && relAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("rel", relAttribute, false));
+ }
+ if (hrefAttribute != null && hrefAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("href", hrefAttribute, true));
+ }
+ if (titleAttribute != null && titleAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("title", titleAttribute, false));
+ }
+ if (mediaAttribute != null && mediaAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("media", mediaAttribute, false));
+ }
+ return new Element("link", null, true,
(Attribute[])attributes.toArray(new Attribute[attributes.size()]));
+ }
+
+ public String getRelAttribute()
+ {
+ return relAttribute;
+ }
+
+ public String getHrefAttribute()
+ {
+ return hrefAttribute;
+ }
+
+ public String getTitleAttribute()
+ {
+ return titleAttribute;
+ }
+
+ public String getMediaAttribute()
+ {
+ return mediaAttribute;
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/NamedMetaElementMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/NamedMetaElementMetaData.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/NamedMetaElementMetaData.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.metadata.portlet;
+
+import org.jboss.portal.core.util.markup.Element;
+import org.jboss.portal.core.util.markup.Attribute;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NamedMetaElementMetaData extends ElementMetaData
+{
+
+ /** . */
+ private String nameAttribute;
+
+ /** . */
+ private String contentAttribute;
+
+ public NamedMetaElementMetaData(String name, String content)
+ {
+ super(null);
+
+ //
+ if (name == null)
+ {
+ throw new IllegalArgumentException("'name' attribute of meta
element must NOT be null. http-equiv meta " +
+ "elements are not currently supported.");
+ }
+ if (content == null)
+ {
+ throw new IllegalArgumentException("Content attribute required for meta
element: " + name);
+ }
+
+ //
+ this.nameAttribute = name;
+ this.contentAttribute = content;
+ }
+
+ public String getNameAttribute()
+ {
+ return nameAttribute;
+ }
+
+ public String getContentAttribute()
+ {
+ return contentAttribute;
+ }
+
+ public Element buildElement()
+ {
+ ArrayList attributes = new ArrayList(3);
+ if (typeAttribute != null && typeAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("type", typeAttribute, false));
+ }
+ if (nameAttribute != null && nameAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("name", nameAttribute, false));
+ }
+ if (contentAttribute != null && contentAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("content", contentAttribute, false));
+ }
+ return new Element("meta", null, true,
(Attribute[])attributes.toArray(new Attribute[attributes.size()]));
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ScriptElementMetaData.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ScriptElementMetaData.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ScriptElementMetaData.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.metadata.portlet;
+
+import org.jboss.portal.core.util.markup.Element;
+import org.jboss.portal.core.util.markup.Attribute;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScriptElementMetaData extends ElementMetaData
+{
+
+ /** . */
+ private String srcAttribute;
+
+ public ScriptElementMetaData(String type, String src)
+ {
+ super(type);
+
+ //
+ this.srcAttribute = src;
+ }
+
+ protected String getElementValue()
+ {
+ return "script";
+ }
+
+ public Element buildElement()
+ {
+ ArrayList attributes = new ArrayList(2);
+ if (typeAttribute != null && typeAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("type", typeAttribute, false));
+ }
+ if (srcAttribute != null && srcAttribute.length() > 0)
+ {
+ attributes.add(new Attribute("src", srcAttribute, true));
+ }
+ return new Element("script", null, false,
(Attribute[])attributes.toArray(new Attribute[attributes.size()]));
+ }
+
+ public String getSrcAttribute()
+ {
+ return srcAttribute;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/util/markup/Attribute.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/util/markup/Attribute.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/util/markup/Attribute.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.util.markup;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Attribute
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String value;
+
+ /** . */
+ final boolean location;
+
+ public Attribute(String name, String value, boolean location)
+ {
+ this.name = name;
+ this.value = value;
+ this.location = location;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/util/markup/Element.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/util/markup/Element.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/util/markup/Element.java 2007-02-10 02:16:20
UTC (rev 6202)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.util.markup;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Element
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String bodyContent;
+
+ /** . */
+ final boolean empty;
+
+ /** . */
+ final Attribute[] attributes;
+
+ public Element(String name, String bodyContent, boolean empty, Attribute[]
attributes)
+ {
+ this.name = name;
+ this.bodyContent = bodyContent;
+ this.empty = empty;
+ this.attributes = attributes;
+ }
+
+ public String toString(String contextPath)
+ {
+ if (contextPath == null)
+ {
+ throw new IllegalArgumentException("No context path provided");
+ }
+ StringBuffer buffer = new StringBuffer(64);
+ buffer.append("<").append(name);
+ for (int i = 0;i < attributes.length;i++)
+ {
+ Attribute attribute = attributes[i];
+ if (attribute.location)
+ {
+ buffer.append("
").append(attribute.name).append("=\"");
+ if (attribute.value.startsWith("/"))
+ {
+ buffer.append(contextPath);
+ }
+ buffer.append(attribute.value).append('"');
+ }
+ else
+ {
+ buffer.append("
").append(attribute.name).append("=\"").append(attribute.value).append('"');
+ }
+ }
+ if (bodyContent != null && bodyContent.length() > 0)
+ {
+
buffer.append(">").append(bodyContent).append("</").append(name).append(">\n");
+ }
+ else if (empty)
+ {
+ buffer.append("/>\n");
+ }
+ else
+ {
+
buffer.append(">").append("</").append(name).append(">\n");
+ }
+ return buffer.toString();
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-02-09
23:32:40 UTC (rev 6201)
+++
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-02-10
02:16:20 UTC (rev 6202)
@@ -29,6 +29,9 @@
import org.jboss.portal.core.metadata.portlet.HeaderContentMetaData;
import org.jboss.portal.core.metadata.portlet.JBossApplicationMetaData;
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
+import org.jboss.portal.core.metadata.portlet.LinkElementMetaData;
+import org.jboss.portal.core.metadata.portlet.ScriptElementMetaData;
+import org.jboss.portal.core.metadata.portlet.NamedMetaElementMetaData;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
@@ -74,23 +77,20 @@
List elements = headerContent.getElements();
assertEquals(3, elements.size());
- HeaderContentMetaData.LinkElement link =
(HeaderContentMetaData.LinkElement)elements.get(0);
- assertEquals(HeaderContentMetaData.Element.LINK, link.getElementType());
- assertEquals("text/css", link.getType());
- assertEquals("stylesheet", link.getRel());
- assertEquals("stylesheet title", link.getTitle());
- assertEquals("screen", link.getMedia());
- assertEquals("test.css", link.getHref());
+ LinkElementMetaData link = (LinkElementMetaData)elements.get(0);
+ assertEquals("text/css", link.getTypeAttribute());
+ assertEquals("stylesheet", link.getRelAttribute());
+ assertEquals("stylesheet title", link.getTitleAttribute());
+ assertEquals("screen", link.getMediaAttribute());
+ assertEquals("test.css", link.getHrefAttribute());
- HeaderContentMetaData.ScriptElement script =
(HeaderContentMetaData.ScriptElement)elements.get(1);
- assertEquals(HeaderContentMetaData.Element.SCRIPT, script.getElementType());
- assertEquals("text/javascript", script.getType());
- assertEquals("test.js", script.getSrc());
+ ScriptElementMetaData script = (ScriptElementMetaData)elements.get(1);
+ assertEquals("text/javascript", script.getTypeAttribute());
+ assertEquals("test.js", script.getSrcAttribute());
- HeaderContentMetaData.NamedMetaElement meta =
(HeaderContentMetaData.NamedMetaElement)elements.get(2);
- assertEquals(HeaderContentMetaData.Element.META, meta.getElementType());
- assertNull(meta.getType());
- assertEquals("description", meta.getName());
- assertEquals("test content", meta.getContent());
+ NamedMetaElementMetaData meta = (NamedMetaElementMetaData)elements.get(2);
+ assertNull(meta.getTypeAttribute());
+ assertEquals("description", meta.getNameAttribute());
+ assertEquals("test content", meta.getContentAttribute());
}
}
Modified: trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
===================================================================
--- trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-02-09 23:32:40
UTC (rev 6201)
+++ trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-02-10 02:16:20
UTC (rev 6202)
@@ -159,7 +159,7 @@
todo
-->
<!ATTLIST meta
- name CDATA #IMPLIED
+ name CDATA #REQUIRED
content CDATA #REQUIRED>
<!--
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2007-02-09
23:32:40 UTC (rev 6201)
+++
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2007-02-10
02:16:20 UTC (rev 6202)
@@ -37,7 +37,7 @@
<portlet-name>HeaderContentPortlet</portlet-name>
<remotable>false</remotable>
<header-content>
- <link rel="stylesheet" type="text/css"
href="/portlet-styles/HeaderContent.css" title=""
media="screen"/>
+ <link rel="stylesheet" type="text/css"
href="/portlet-styles/HeaderContent.css" media="screen"/>
<script type="text/javascript"
src="/portlet-styles/HeaderContent.js"/>
<meta name="description" content="test"/>
</header-content>