Skip to content
Snippets Groups Projects
Commit 6d742165 authored by srosse's avatar srosse
Browse files

FXOLAT-388: remove cycle in class dependency

parent 67716238
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,8 @@ import org.olat.core.util.Util; ...@@ -33,6 +33,8 @@ import org.olat.core.util.Util;
import org.olat.core.util.WebappHelper; import org.olat.core.util.WebappHelper;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import com.thoughtworks.xstream.io.xml.XppDriver;
public class InstitutionPortlet extends AbstractPortlet { public class InstitutionPortlet extends AbstractPortlet {
...@@ -133,7 +135,7 @@ public class InstitutionPortlet extends AbstractPortlet { ...@@ -133,7 +135,7 @@ public class InstitutionPortlet extends AbstractPortlet {
institutions = new FastHashMap(); institutions = new FastHashMap();
File configurationFile = new File(WebappHelper.getContextRoot() + CONFIG_FILE); File configurationFile = new File(WebappHelper.getContextRoot() + CONFIG_FILE);
XStream xstream = InstitutionPortletXStream.getXStream(); XStream xstream = getInstitutionConfigXStream();
InstitutionConfiguration configuration = (InstitutionConfiguration)xstream.fromXML(configurationFile); InstitutionConfiguration configuration = (InstitutionConfiguration)xstream.fromXML(configurationFile);
for(InstitutionPortletEntry institution: configuration.getInstitution()) { for(InstitutionPortletEntry institution: configuration.getInstitution()) {
...@@ -156,6 +158,40 @@ public class InstitutionPortlet extends AbstractPortlet { ...@@ -156,6 +158,40 @@ public class InstitutionPortlet extends AbstractPortlet {
public static InstitutionPortletEntry getInstitutionPortletEntry(String institution) { public static InstitutionPortletEntry getInstitutionPortletEntry(String institution) {
return (InstitutionPortletEntry) institutions.get(institution); return (InstitutionPortletEntry) institutions.get(institution);
} }
public static XStream getInstitutionConfigXStream() {
XStream xstream = new XStream(new XppDriver(new NoNameCoder()));
xstream.alias("configuration", InstitutionConfiguration.class);
xstream.addImplicitCollection(InstitutionConfiguration.class, "institution", "institution", InstitutionPortletEntry.class);
xstream.alias("institution", InstitutionPortletEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "polymorphlink", "polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(InstitutionPortletEntry.class, "shortname", "shortname");
xstream.alias("logo", Value.class);
xstream.alias("name", Value.class);
xstream.alias("url", Value.class);
xstream.alias("supervisor", InstitutionPortletSupervisorEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "supervisor", "supervisor", InstitutionPortletSupervisorEntry.class);
xstream.alias("person", Value.class);
xstream.alias("phone", Value.class);
xstream.alias("email", Value.class);
xstream.alias("blog", Value.class);
//polymorph link
xstream.alias("polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(PolymorphLink.class, "defaultId", "default_targetid");
xstream.aliasAttribute(PolymorphLink.class, "linkType", "type");
xstream.aliasAttribute(PolymorphLink.class, "linkText", "text");
//polymorph link element
xstream.alias("element", PolymorphLinkElement.class);
xstream.addImplicitCollection(PolymorphLink.class, "element", "element", PolymorphLinkElement.class);
xstream.aliasAttribute(PolymorphLinkElement.class, "attribute", "attribute");
xstream.aliasAttribute(PolymorphLinkElement.class, "value", "value");
xstream.aliasAttribute(PolymorphLinkElement.class, "cond", "condition");
xstream.aliasAttribute(PolymorphLinkElement.class, "id", "targetid");
xstream.aliasAttribute(Value.class, "value", "value");
return xstream;
}
} }
/** /**
......
package de.bps.olat.portal.institution;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import com.thoughtworks.xstream.io.xml.XppDriver;
/**
*
* Description:<br>
*
* <P>
* Initial Date: 2 déc. 2011 <br>
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class InstitutionPortletXStream {
public static XStream getXStream() {
XStream xstream = new XStream(new XppDriver(new NoNameCoder()));
xstream.alias("configuration", InstitutionConfiguration.class);
xstream.addImplicitCollection(InstitutionConfiguration.class, "institution", "institution", InstitutionPortletEntry.class);
xstream.alias("institution", InstitutionPortletEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "polymorphlink", "polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(InstitutionPortletEntry.class, "shortname", "shortname");
xstream.alias("logo", Value.class);
xstream.alias("name", Value.class);
xstream.alias("url", Value.class);
xstream.alias("supervisor", InstitutionPortletSupervisorEntry.class);
xstream.addImplicitCollection(InstitutionPortletEntry.class, "supervisor", "supervisor", InstitutionPortletSupervisorEntry.class);
xstream.alias("person", Value.class);
xstream.alias("phone", Value.class);
xstream.alias("email", Value.class);
xstream.alias("blog", Value.class);
//polymorph link
xstream.alias("polymorphlink", PolymorphLink.class);
xstream.aliasAttribute(PolymorphLink.class, "defaultId", "default_targetid");
xstream.aliasAttribute(PolymorphLink.class, "linkType", "type");
xstream.aliasAttribute(PolymorphLink.class, "linkText", "text");
//polymorph link element
xstream.alias("element", PolymorphLinkElement.class);
xstream.addImplicitCollection(PolymorphLink.class, "element", "element", PolymorphLinkElement.class);
xstream.aliasAttribute(PolymorphLinkElement.class, "attribute", "attribute");
xstream.aliasAttribute(PolymorphLinkElement.class, "value", "value");
xstream.aliasAttribute(PolymorphLinkElement.class, "cond", "condition");
xstream.aliasAttribute(PolymorphLinkElement.class, "id", "targetid");
xstream.aliasAttribute(Value.class, "value", "value");
return xstream;
}
}
...@@ -25,7 +25,7 @@ public class InstitutionPortletTest { ...@@ -25,7 +25,7 @@ public class InstitutionPortletTest {
@Test @Test
public void readConfiguration() throws IOException, URISyntaxException { public void readConfiguration() throws IOException, URISyntaxException {
XStream xstream = InstitutionPortletXStream.getXStream(); XStream xstream = InstitutionPortlet.getInstitutionConfigXStream();
InputStream input = InstitutionPortletTest.class.getResourceAsStream("olat_portals_institution.xml"); InputStream input = InstitutionPortletTest.class.getResourceAsStream("olat_portals_institution.xml");
InstitutionConfiguration obj = (InstitutionConfiguration)xstream.fromXML(input); InstitutionConfiguration obj = (InstitutionConfiguration)xstream.fromXML(input);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment