1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.portals.applications.springmvc;
18
19 import java.util.HashMap;
20 import java.util.Map;
21 import java.util.List;
22 import java.util.ArrayList;
23 import java.util.SortedSet;
24
25 import javax.portlet.RenderRequest;
26 import javax.portlet.RenderResponse;
27 import javax.portlet.PortletConfig;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.springframework.beans.factory.InitializingBean;
32 import org.springframework.web.portlet.mvc.AbstractController;
33 import org.springframework.web.portlet.ModelAndView;
34 import org.springframework.web.portlet.context.PortletConfigAware;
35
36 public class DOMTreeViewController extends AbstractController implements InitializingBean, PortletConfigAware
37 {
38 private static final Log log = LogFactory.getLog( DOMTreeViewController.class);
39
40 private DOMTreeService domTreeService ;
41 private PortletConfig portletConfig ;
42
43 private String xmlFilePath = null ;
44 private String xmlFileName = null ;
45
46 public void afterPropertiesSet() throws Exception {
47 if (this.domTreeService == null)
48 throw new IllegalArgumentException("A DOMTreeService is required");
49 }
50
51 public ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception
52 {
53 List addTo = new ArrayList();
54 if ( getXmlFilePath() != null )
55 {
56 addTo.add( new DOMTree( getXmlFileName(), getXmlFilePath() ) );
57 }
58 SortedSet domTreeSet = domTreeService.parseAllDOMTrees( request, this.getPortletContext(), addTo );
59
60 Map model = new HashMap();
61 model.put( "messages", portletConfig.getResourceBundle( request.getLocale() ) );
62 model.put( "domTreeList", domTreeSet );
63 model.put( "domNodeHelper", new DOMTreeService.DOMNodeHelper() );
64
65 return new ModelAndView("domTreeView", "model", model);
66 }
67
68 public void setDomTreeService(DOMTreeService domTreeService)
69 {
70 this.domTreeService = domTreeService;
71 }
72
73 public String getXmlFilePath()
74 {
75 return this.xmlFilePath ;
76 }
77 public void setXmlFilePath(String xmlFile)
78 {
79 this.xmlFilePath = xmlFile;
80 }
81 public String getXmlFileName()
82 {
83 return this.xmlFileName;
84 }
85 public void setXmlFileName(String xmlFileName)
86 {
87 this.xmlFileName = xmlFileName;
88 }
89 public void setPortletConfig(PortletConfig portletConfig)
90 {
91
92 this.portletConfig = portletConfig;
93 }
94 }