{
try
{
JAXBContext jc = JAXBContext.newInstance("org.apache.jetspeed.om.portlet.jetspeed.jaxb");
Unmarshaller u = jc.createUnmarshaller();
PortletApp pa = (PortletApp) u.unmarshal(in);
app.setJetspeedSecurityConstraint(pa.getSecurityConstraintRef());
for (Service s : pa.getServices())
{
app.addJetspeedServiceReference(s.getName());
}
for (MetadataType m : pa.getMetadata())
{
if (m.getContent() != null)
{
app.getMetadata().addField(JetspeedLocale.convertStringToLocale(m.getLang()), m.getMetadataName(), m.getContent());
}
}
for (Portlet p : pa.getPortlets())
{
PortletDefinition pd = app.getPortlet(p.getPortletName());
if (pd != null)
{
pd.setJetspeedSecurityConstraint(p.getSecurityConstraintRef());
for (MetadataType m : p.getMetadata())
{
if (m.getContent() != null)
{
pd.getMetadata().addField(JetspeedLocale.convertStringToLocale(m.getLang()), m.getMetadataName(), m.getContent());
}
}
}
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomPortletMode cpm : pa.getCustomPortletModes())
{
if (cpm.getName() != null && cpm.getMappedName() != null && !cpm.getName().equals(cpm.getMappedName()))
{
CustomPortletMode jcpm = app.getCustomPortletMode(cpm.getMappedName());
if (jcpm != null && app.getCustomPortletMode(cpm.getName()) == null)
{
((CustomPortletModeImpl)jcpm).setMappedName(cpm.getMappedName());
}
}
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.CustomWindowState cws : pa.getCustomWindowStates())
{
if (cws.getName() != null && cws.getMappedName() != null && !cws.getName().equals(cws.getMappedName()))
{
CustomWindowState jcws = app.getCustomWindowState(cws.getMappedName());
if (jcws != null && app.getCustomWindowState(cws.getName()) == null)
{
((CustomWindowStateImpl)jcws).setMappedName(cws.getMappedName());
}
}
}
for (org.apache.jetspeed.om.portlet.jetspeed.jaxb.UserAttributeRef ref : pa.getUserAttributeRefs())
{
UserAttributeRef jref = app.addUserAttributeRef(ref.getName());
jref.setNameLink(ref.getNameLink());
Description desc = jref.addDescription("en");
desc.setDescription(ref.getDescription());