KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > metadata > CorePortletApplicationBuilder


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.metadata;
10
11 import org.jboss.portal.common.util.XML;
12 import org.jboss.portal.common.transaction.Transactions;
13 import org.jboss.portal.portlet.metadata.PortletApplicationMetaData;
14 import org.jboss.portal.portlet.metadata.PortletMetaData;
15 import org.w3c.dom.Document JavaDoc;
16 import org.w3c.dom.Element JavaDoc;
17
18 import java.util.List JavaDoc;
19
20 /**
21  * @jmx.mbean
22  * @jboss.xmbean
23  *
24  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
25  * @version $Revision: 1.6 $
26  */

27 public class CorePortletApplicationBuilder
28 {
29
30    public void importXML(PortletApplicationMetaData applicationMD, Document JavaDoc doc)
31    {
32       Element JavaDoc portletAppElt = doc.getDocumentElement();
33       List JavaDoc portletElts = XML.getChildren(portletAppElt, "portlet");
34       for (int i = 0;i < portletElts.size();i++)
35       {
36          Element JavaDoc portletElt = (Element JavaDoc)portletElts.get(i);
37          String JavaDoc portletName = XML.asString(XML.getUniqueChild(portletElt, "portlet-name", true));
38          PortletMetaData portletMD = (PortletMetaData)applicationMD.getComponent(portletName);
39          if (portletMD != null)
40          {
41             importXML(portletMD, portletElt);
42          }
43          else
44          {
45          }
46       }
47    }
48
49    public void importXML(PortletMetaData portletMD, Element JavaDoc portletElt)
50    {
51       //
52
Element JavaDoc portletPreferencesElt = XML.getUniqueChild(portletElt, "portlet-preferences", false);
53       if (portletPreferencesElt != null)
54       {
55          Element JavaDoc proxyClassElt = XML.getUniqueChild(portletPreferencesElt, "proxy-class", false);
56          if (proxyClassElt != null)
57          {
58             ProxyPreferenceSetMetaData ppsmd = new ProxyPreferenceSetMetaData();
59             String JavaDoc proxyClass = XML.asString(proxyClassElt);
60             ppsmd.setProxyClassName(proxyClass);
61             portletMD.addPlugin("PROXY", ppsmd);
62          }
63       }
64    }
65 }
66
Popular Tags