Modified: portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsController.java URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsController.java?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsController.java (original) +++ portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsController.java Sun Mar 11 18:44:37 2007 @@ -1,78 +1,94 @@ -package org.apache.portals.applications.springmvc; - -import java.util.HashMap; -import java.util.Map; - -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.PortletRequest; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.validation.BindException; -import org.springframework.web.portlet.bind.PortletRequestDataBinder; -import org.springframework.web.portlet.mvc.SimpleFormController; -import org.springframework.web.portlet.ModelAndView; - -import org.apache.portals.applications.springmvc.DOMTree; - -public class DOMTreePrefsController extends SimpleFormController implements InitializingBean { - - private DOMTreeService domTreeService; - - public void afterPropertiesSet() throws Exception - { - if ( this.domTreeService == null ) - throw new IllegalArgumentException( "DOMTreeService is required" ); - } - - public void onSubmitAction( ActionRequest request, ActionResponse response, - Object command, BindException errors ) throws Exception - { - String save = request.getParameter( "save" ); - if ( save != null ) - { - domTreeService.saveDOMTree( request.getParameter("name"), request.getParameter("path"), request ); - } - response.setRenderParameter( "action", "list" ); - } - - protected Object formBackingObject( PortletRequest request ) throws Exception - { - String name = request.getParameter( "domTree" ); - if ( name == null ) - { - return new DOMTree(); - } - else - { - return domTreeService.getDOMTree( name, request ); - } - } - - protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) - throws Exception - { - //SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); - //binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true)); - //binder.setAllowedFields(new String[] {"author","title","description","availability","count"}); - } - - protected ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response) - throws Exception - { - return null; - } - - protected void handleInvalidSubmit(ActionRequest request, ActionResponse response) - throws Exception - { - response.setRenderParameter( "action","view" ); - } - - public void setDomTreeService(DOMTreeService domTreeService) - { - this.domTreeService = domTreeService; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.portals.applications.springmvc; + +import java.util.HashMap; +import java.util.Map; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletRequest; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.validation.BindException; +import org.springframework.web.portlet.bind.PortletRequestDataBinder; +import org.springframework.web.portlet.mvc.SimpleFormController; +import org.springframework.web.portlet.ModelAndView; + +import org.apache.portals.applications.springmvc.DOMTree; + +public class DOMTreePrefsController extends SimpleFormController implements InitializingBean { + + private DOMTreeService domTreeService; + + public void afterPropertiesSet() throws Exception + { + if ( this.domTreeService == null ) + throw new IllegalArgumentException( "DOMTreeService is required" ); + } + + public void onSubmitAction( ActionRequest request, ActionResponse response, + Object command, BindException errors ) throws Exception + { + String save = request.getParameter( "save" ); + if ( save != null ) + { + domTreeService.saveDOMTree( request.getParameter("name"), request.getParameter("path"), request ); + } + response.setRenderParameter( "action", "list" ); + } + + protected Object formBackingObject( PortletRequest request ) throws Exception + { + String name = request.getParameter( "domTree" ); + if ( name == null ) + { + return new DOMTree(); + } + else + { + return domTreeService.getDOMTree( name, request ); + } + } + + protected void initBinder(PortletRequest request, PortletRequestDataBinder binder) + throws Exception + { + //SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); + //binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateFormat, true)); + //binder.setAllowedFields(new String[] {"author","title","description","availability","count"}); + } + + protected ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response) + throws Exception + { + return null; + } + + protected void handleInvalidSubmit(ActionRequest request, ActionResponse response) + throws Exception + { + response.setRenderParameter( "action","view" ); + } + + public void setDomTreeService(DOMTreeService domTreeService) + { + this.domTreeService = domTreeService; + } +}
Modified: portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsListController.java URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsListController.java?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsListController.java (original) +++ portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreePrefsListController.java Sun Mar 11 18:44:37 2007 @@ -1,34 +1,50 @@ -package org.apache.portals.applications.springmvc; - -import java.util.HashMap; -import java.util.Map; - -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.web.portlet.mvc.AbstractController; -import org.springframework.web.portlet.ModelAndView; - -public class DOMTreePrefsListController extends AbstractController implements InitializingBean -{ - private DOMTreeService domTreeService; - - public void afterPropertiesSet() throws Exception - { - if (this.domTreeService == null) - throw new IllegalArgumentException( "A DOMTreeService is required" ); - } - - public ModelAndView handleRenderRequestInternal( RenderRequest request, RenderResponse response ) throws Exception - { - Map model = new HashMap(); - model.put( "list", domTreeService.getAllDOMTrees( request ) ); - return new ModelAndView( "domTreeEditList", "model", model ); - } - - public void setDomTreeService( DOMTreeService domTreeService ) - { - this.domTreeService = domTreeService; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.portals.applications.springmvc; + +import java.util.HashMap; +import java.util.Map; + +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.web.portlet.mvc.AbstractController; +import org.springframework.web.portlet.ModelAndView; + +public class DOMTreePrefsListController extends AbstractController implements InitializingBean +{ + private DOMTreeService domTreeService; + + public void afterPropertiesSet() throws Exception + { + if (this.domTreeService == null) + throw new IllegalArgumentException( "A DOMTreeService is required" ); + } + + public ModelAndView handleRenderRequestInternal( RenderRequest request, RenderResponse response ) throws Exception + { + Map model = new HashMap(); + model.put( "list", domTreeService.getAllDOMTrees( request ) ); + return new ModelAndView( "domTreeEditList", "model", model ); + } + + public void setDomTreeService( DOMTreeService domTreeService ) + { + this.domTreeService = domTreeService; + } +} Modified: portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeService.java URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeService.java?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeService.java (original) +++ portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeService.java Sun Mar 11 18:44:37 2007 @@ -1,213 +1,229 @@ -package org.apache.portals.applications.springmvc; - -import java.io.InputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; -import java.util.Enumeration; -import java.util.ArrayList; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -import javax.portlet.PortletPreferences; -import javax.portlet.PortletRequest; -import javax.portlet.PortletContext; -import javax.portlet.ReadOnlyException; -import javax.portlet.ValidatorException; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.support.ApplicationObjectSupport; - -import org.w3c.dom.Node ; -import org.w3c.dom.NodeList ; - -public class DOMTreeService extends ApplicationObjectSupport -{ - private static final String DOM_TREE_NO_PATH = "domtree_no_path"; - private static final String DOM_TREE_NO_PARSE = "domtree_no_parse"; - private static final Log log = LogFactory.getLog( DOMTreeService.class); - - protected DocumentBuilderFactory domFactory = null; - - public void initApplicationContext() throws BeansException - { - domFactory = DocumentBuilderFactory.newInstance(); - domFactory.setValidating(false); - } - - public DOMTree getDOMTree( String name, PortletRequest request ) - { - if ( name == null ) name = ""; - PortletPreferences prefs = request.getPreferences(); - String path = prefs.getValue( name, "" ); - return new DOMTree( name, path ); - } - - public void saveDOMTree( String name, String path, PortletRequest request ) - { - DOMTree dt = new DOMTree( name, path ); - saveDOMTree( dt, request ); - } - - public void saveDOMTree( DOMTree dt, PortletRequest request ) - { - if ( dt == null ) return ; - PortletPreferences prefs = request.getPreferences(); - try - { - prefs.setValue( dt.getName(), dt.getPath() ); - prefs.store(); - } - catch ( ReadOnlyException e ) { } - catch ( IOException e ) { } - catch ( ValidatorException e ) { } - } - - public void deleteDOMTree( String name, PortletRequest request ) - { - if ( name == null ) name = ""; - PortletPreferences prefs = request.getPreferences(); - try - { - prefs.reset( name ); - prefs.store(); - } - catch ( ReadOnlyException e ) { } - catch ( IOException e ) { } - catch ( ValidatorException e ) { } - } - - public SortedSet getAllDOMTrees( PortletRequest request ) - { - return getAllDOMTrees( request, null ); - } - public SortedSet getAllDOMTrees( PortletRequest request, List addTo ) - { - if ( addTo == null ) - { - addTo = new ArrayList(); - } - PortletPreferences prefs = request.getPreferences(); - Enumeration e = prefs.getNames(); - while ( e.hasMoreElements() ) - { - String name = (String)e.nextElement(); - String path = prefs.getValue( name, "" ); - addTo.add( new DOMTree( name, path ) ); - } - return (SortedSet) new TreeSet( addTo ); - } - - public SortedSet parseAllDOMTrees( PortletRequest request, PortletContext context, List addTo ) - { - SortedSet domTreeSet = getAllDOMTrees( request, addTo ); - Iterator domTreeSetIter = domTreeSet.iterator(); - while ( domTreeSetIter.hasNext() ) - { - DOMTree dt = (DOMTree)domTreeSetIter.next(); - if ( dt.getPath() == null || dt.getPath().length() == 0 ) - { - dt.setMessage( DOM_TREE_NO_PATH ); - } - else - { - InputStream is = context.getResourceAsStream( dt.getPath() ); - org.w3c.dom.Document doc = parseXml( is ); - dt.setParsedDocument( doc ); - if ( doc == null ) - { - dt.setMessage( DOM_TREE_NO_PARSE ); - } - } - } - return domTreeSet; - } - - - // general xml parsing utilities - - protected org.w3c.dom.Document parseXml( InputStream is ) - { - DocumentBuilder docBuilder = null; - org.w3c.dom.Document doc = null; - try - { - docBuilder = domFactory.newDocumentBuilder(); - } - catch (ParserConfigurationException e) - { - log.error( "Cannot create DocumentBuilder due to " + e.getClass().getName() + " " + e.getMessage() ); - } - if ( docBuilder != null ) - { - try - { - doc = docBuilder.parse(is); - } - catch (Exception e) - { - log.error( "Cannot parse due to " + e.getClass().getName() + " " + e.getMessage() ); - } - } - return doc; - } - public static class DOMNodeHelper - { - public DOMNodeHelper() - { - } - public List createNodeList( NodeList nl ) - { - List domNodeList = new ArrayList(); - if ( nl != null ) - { - for ( int i = 0 ; i < nl.getLength() ; i++ ) - { - domNodeList.add( nl.item( i ) ); - } - } - return domNodeList; - } - public boolean isElementNode( Node n ) - { - return n != null && n.getNodeType() == Node.ELEMENT_NODE; - } - public boolean isTextNode( Node n ) - { - return n != null && n.getNodeType() == Node.TEXT_NODE; - } - public boolean isNonEmptyTextNode( Node n ) - { - if ( n != null && n.getNodeType() == Node.TEXT_NODE ) - { - String nodeVal = n.getNodeValue(); - if ( nodeVal != null && nodeVal.trim().length() > 0 ) - { - return true ; - } - } - return false; - } - public boolean isAttributeNode( Node n ) - { - return n != null && n.getNodeType() == Node.ATTRIBUTE_NODE; - } - public boolean isDocumentNode( Node n ) - { - return n != null && n.getNodeType() == Node.DOCUMENT_NODE; - } - public String replaceLineBreaks( String s ) - { - Pattern p = Pattern.compile( "\\s*((\\r\\n)|\\n)\\s*" ); - Matcher m = p.matcher( s ); - return m.replaceAll( " " ); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.portals.applications.springmvc; + +import java.io.InputStream; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Enumeration; +import java.util.ArrayList; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +import javax.portlet.PortletPreferences; +import javax.portlet.PortletRequest; +import javax.portlet.PortletContext; +import javax.portlet.ReadOnlyException; +import javax.portlet.ValidatorException; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeansException; +import org.springframework.context.support.ApplicationObjectSupport; + +import org.w3c.dom.Node ; +import org.w3c.dom.NodeList ; + +public class DOMTreeService extends ApplicationObjectSupport +{ + private static final String DOM_TREE_NO_PATH = "domtree_no_path"; + private static final String DOM_TREE_NO_PARSE = "domtree_no_parse"; + private static final Log log = LogFactory.getLog( DOMTreeService.class); + + protected DocumentBuilderFactory domFactory = null; + + public void initApplicationContext() throws BeansException + { + domFactory = DocumentBuilderFactory.newInstance(); + domFactory.setValidating(false); + } + + public DOMTree getDOMTree( String name, PortletRequest request ) + { + if ( name == null ) name = ""; + PortletPreferences prefs = request.getPreferences(); + String path = prefs.getValue( name, "" ); + return new DOMTree( name, path ); + } + + public void saveDOMTree( String name, String path, PortletRequest request ) + { + DOMTree dt = new DOMTree( name, path ); + saveDOMTree( dt, request ); + } + + public void saveDOMTree( DOMTree dt, PortletRequest request ) + { + if ( dt == null ) return ; + PortletPreferences prefs = request.getPreferences(); + try + { + prefs.setValue( dt.getName(), dt.getPath() ); + prefs.store(); + } + catch ( ReadOnlyException e ) { } + catch ( IOException e ) { } + catch ( ValidatorException e ) { } + } + + public void deleteDOMTree( String name, PortletRequest request ) + { + if ( name == null ) name = ""; + PortletPreferences prefs = request.getPreferences(); + try + { + prefs.reset( name ); + prefs.store(); + } + catch ( ReadOnlyException e ) { } + catch ( IOException e ) { } + catch ( ValidatorException e ) { } + } + + public SortedSet getAllDOMTrees( PortletRequest request ) + { + return getAllDOMTrees( request, null ); + } + public SortedSet getAllDOMTrees( PortletRequest request, List addTo ) + { + if ( addTo == null ) + { + addTo = new ArrayList(); + } + PortletPreferences prefs = request.getPreferences(); + Enumeration e = prefs.getNames(); + while ( e.hasMoreElements() ) + { + String name = (String)e.nextElement(); + String path = prefs.getValue( name, "" ); + addTo.add( new DOMTree( name, path ) ); + } + return (SortedSet) new TreeSet( addTo ); + } + + public SortedSet parseAllDOMTrees( PortletRequest request, PortletContext context, List addTo ) + { + SortedSet domTreeSet = getAllDOMTrees( request, addTo ); + Iterator domTreeSetIter = domTreeSet.iterator(); + while ( domTreeSetIter.hasNext() ) + { + DOMTree dt = (DOMTree)domTreeSetIter.next(); + if ( dt.getPath() == null || dt.getPath().length() == 0 ) + { + dt.setMessage( DOM_TREE_NO_PATH ); + } + else + { + InputStream is = context.getResourceAsStream( dt.getPath() ); + org.w3c.dom.Document doc = parseXml( is ); + dt.setParsedDocument( doc ); + if ( doc == null ) + { + dt.setMessage( DOM_TREE_NO_PARSE ); + } + } + } + return domTreeSet; + } + + + // general xml parsing utilities + + protected org.w3c.dom.Document parseXml( InputStream is ) + { + DocumentBuilder docBuilder = null; + org.w3c.dom.Document doc = null; + try + { + docBuilder = domFactory.newDocumentBuilder(); + } + catch (ParserConfigurationException e) + { + log.error( "Cannot create DocumentBuilder due to " + e.getClass().getName() + " " + e.getMessage() ); + } + if ( docBuilder != null ) + { + try + { + doc = docBuilder.parse(is); + } + catch (Exception e) + { + log.error( "Cannot parse due to " + e.getClass().getName() + " " + e.getMessage() ); + } + } + return doc; + } + public static class DOMNodeHelper + { + public DOMNodeHelper() + { + } + public List createNodeList( NodeList nl ) + { + List domNodeList = new ArrayList(); + if ( nl != null ) + { + for ( int i = 0 ; i < nl.getLength() ; i++ ) + { + domNodeList.add( nl.item( i ) ); + } + } + return domNodeList; + } + public boolean isElementNode( Node n ) + { + return n != null && n.getNodeType() == Node.ELEMENT_NODE; + } + public boolean isTextNode( Node n ) + { + return n != null && n.getNodeType() == Node.TEXT_NODE; + } + public boolean isNonEmptyTextNode( Node n ) + { + if ( n != null && n.getNodeType() == Node.TEXT_NODE ) + { + String nodeVal = n.getNodeValue(); + if ( nodeVal != null && nodeVal.trim().length() > 0 ) + { + return true ; + } + } + return false; + } + public boolean isAttributeNode( Node n ) + { + return n != null && n.getNodeType() == Node.ATTRIBUTE_NODE; + } + public boolean isDocumentNode( Node n ) + { + return n != null && n.getNodeType() == Node.DOCUMENT_NODE; + } + public String replaceLineBreaks( String s ) + { + Pattern p = Pattern.compile( "\\s*((\\r\\n)|\\n)\\s*" ); + Matcher m = p.matcher( s ); + return m.replaceAll( " " ); + } + } +} Modified: portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeViewController.java URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeViewController.java?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeViewController.java (original) +++ portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/DOMTreeViewController.java Sun Mar 11 18:44:37 2007 @@ -1,78 +1,94 @@ -package org.apache.portals.applications.springmvc; - -import java.util.HashMap; -import java.util.Map; -import java.util.List; -import java.util.ArrayList; -import java.util.SortedSet; - -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; -import javax.portlet.PortletConfig; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.web.portlet.mvc.AbstractController; -import org.springframework.web.portlet.ModelAndView; -import org.springframework.web.portlet.context.PortletConfigAware; - -public class DOMTreeViewController extends AbstractController implements InitializingBean, PortletConfigAware -{ - private static final Log log = LogFactory.getLog( DOMTreeViewController.class); - - private DOMTreeService domTreeService ; - private PortletConfig portletConfig ; - - private String xmlFilePath = null ; - private String xmlFileName = null ; - - public void afterPropertiesSet() throws Exception { - if (this.domTreeService == null) - throw new IllegalArgumentException("A DOMTreeService is required"); - } - - public ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception - { - List addTo = new ArrayList(); - if ( getXmlFilePath() != null ) - { - addTo.add( new DOMTree( getXmlFileName(), getXmlFilePath() ) ); - } - SortedSet domTreeSet = domTreeService.parseAllDOMTrees( request, this.getPortletContext(), addTo ); - - Map model = new HashMap(); - model.put( "messages", portletConfig.getResourceBundle( request.getLocale() ) ); - model.put( "domTreeList", domTreeSet ); - model.put( "domNodeHelper", new DOMTreeService.DOMNodeHelper() ); - - return new ModelAndView("domTreeView", "model", model); - } - - public void setDomTreeService(DOMTreeService domTreeService) - { - this.domTreeService = domTreeService; - } - - public String getXmlFilePath() - { - return this.xmlFilePath ; - } - public void setXmlFilePath(String xmlFile) - { - this.xmlFilePath = xmlFile; - } - public String getXmlFileName() - { - return this.xmlFileName; - } - public void setXmlFileName(String xmlFileName) - { - this.xmlFileName = xmlFileName; - } - public void setPortletConfig(PortletConfig portletConfig) - { - - this.portletConfig = portletConfig; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.portals.applications.springmvc; + +import java.util.HashMap; +import java.util.Map; +import java.util.List; +import java.util.ArrayList; +import java.util.SortedSet; + +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.PortletConfig; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.web.portlet.mvc.AbstractController; +import org.springframework.web.portlet.ModelAndView; +import org.springframework.web.portlet.context.PortletConfigAware; + +public class DOMTreeViewController extends AbstractController implements InitializingBean, PortletConfigAware +{ + private static final Log log = LogFactory.getLog( DOMTreeViewController.class); + + private DOMTreeService domTreeService ; + private PortletConfig portletConfig ; + + private String xmlFilePath = null ; + private String xmlFileName = null ; + + public void afterPropertiesSet() throws Exception { + if (this.domTreeService == null) + throw new IllegalArgumentException("A DOMTreeService is required"); + } + + public ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception + { + List addTo = new ArrayList(); + if ( getXmlFilePath() != null ) + { + addTo.add( new DOMTree( getXmlFileName(), getXmlFilePath() ) ); + } + SortedSet domTreeSet = domTreeService.parseAllDOMTrees( request, this.getPortletContext(), addTo ); + + Map model = new HashMap(); + model.put( "messages", portletConfig.getResourceBundle( request.getLocale() ) ); + model.put( "domTreeList", domTreeSet ); + model.put( "domNodeHelper", new DOMTreeService.DOMNodeHelper() ); + + return new ModelAndView("domTreeView", "model", model); + } + + public void setDomTreeService(DOMTreeService domTreeService) + { + this.domTreeService = domTreeService; + } + + public String getXmlFilePath() + { + return this.xmlFilePath ; + } + public void setXmlFilePath(String xmlFile) + { + this.xmlFilePath = xmlFile; + } + public String getXmlFileName() + { + return this.xmlFileName; + } + public void setXmlFileName(String xmlFileName) + { + this.xmlFileName = xmlFileName; + } + public void setPortletConfig(PortletConfig portletConfig) + { + + this.portletConfig = portletConfig; + } +} Modified: portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/resources/DOMTree.properties URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/resources/DOMTree.properties?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/resources/DOMTree.properties (original) +++ portals/bridges/trunk/applications/springmvc/src/java/org/apache/portals/applications/springmvc/resources/DOMTree.properties Sun Mar 11 18:44:37 2007 @@ -1,3 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# javax.portlet.title = DOMTreeViewer Portlet javax.portlet.short-title = DOMTreeViewer javax.portlet.keywords = DOMTreeViewer Modified: portals/bridges/trunk/applications/springmvc/src/java/views.properties URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/java/views.properties?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/java/views.properties (original) +++ portals/bridges/trunk/applications/springmvc/src/java/views.properties Sun Mar 11 18:44:37 2007 @@ -1,9 +1,24 @@ - -domTreeView.class = org.springframework.web.servlet.view.velocity.VelocityView -domTreeView.url = domTreeView.vm - -domTreeEdit.class = org.springframework.web.servlet.view.JstlView -domTreeEdit.url = /WEB-INF/jsp/domTreeEdit.jsp - -domTreeEditList.class = org.springframework.web.servlet.view.JstlView +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +domTreeView.class = org.springframework.web.servlet.view.velocity.VelocityView +domTreeView.url = domTreeView.vm + +domTreeEdit.class = org.springframework.web.servlet.view.JstlView +domTreeEdit.url = /WEB-INF/jsp/domTreeEdit.jsp + +domTreeEditList.class = org.springframework.web.servlet.view.JstlView domTreeEditList.url = /WEB-INF/jsp/domTreeEditList.jsp Modified: portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/applicationContext.xml URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/applicationContext.xml?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/applicationContext.xml (original) +++ portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/applicationContext.xml Sun Mar 11 18:44:37 2007 @@ -1,37 +1,53 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "../dtd/spring-beans.dtd"> - -<beans> - - <!-- Message source for this context, loaded from localized "messages_xx" files --> - <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> - <property name="basenames"> - <list> - <value>messages</value> - </list> - </property> - </bean> - - <!-- Default View Resolver --> - - <bean id="resourceBundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> - <property name="order"><value>0</value></property> - <property name="basename"><value>views</value></property> - </bean> - - <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> - <property name="resourceLoaderPath"><value>/WEB-INF/view/</value></property> - </bean> - - <!-- Abstract Default Exception Handler Bean --> - <bean id="defaultExceptionHandlerTemplate" class="org.springframework.web.portlet.handler.SimpleMappingExceptionResolver" abstract="true"> - <property name="defaultErrorView" value="defError"/> - <property name="exceptionMappings"> - <props> - <prop key="javax.portlet.PortletSecurityException">notAuthorized</prop> - <prop key="javax.portlet.UnavailableException">notAvailable</prop> - </props> - </property> - </bean> - -</beans> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "../dtd/spring-beans.dtd"> + +<beans> + + <!-- Message source for this context, loaded from localized "messages_xx" files --> + <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> + <property name="basenames"> + <list> + <value>messages</value> + </list> + </property> + </bean> + + <!-- Default View Resolver --> + + <bean id="resourceBundleViewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> + <property name="order"><value>0</value></property> + <property name="basename"><value>views</value></property> + </bean> + + <bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> + <property name="resourceLoaderPath"><value>/WEB-INF/view/</value></property> + </bean> + + <!-- Abstract Default Exception Handler Bean --> + <bean id="defaultExceptionHandlerTemplate" class="org.springframework.web.portlet.handler.SimpleMappingExceptionResolver" abstract="true"> + <property name="defaultErrorView" value="defError"/> + <property name="exceptionMappings"> + <props> + <prop key="javax.portlet.PortletSecurityException">notAuthorized</prop> + <prop key="javax.portlet.UnavailableException">notAvailable</prop> + </props> + </property> + </bean> + +</beans> Modified: portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/portlet/domtree.xml URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/portlet/domtree.xml?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/portlet/domtree.xml (original) +++ portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/context/portlet/domtree.xml Sun Mar 11 18:44:37 2007 @@ -1,86 +1,102 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "../../dtd/spring-beans.dtd"> -<beans> - - <!-- Property Configurer --> - - <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="locations"> - <list> - <value>WEB-INF/domtree.properties</value> - </list> - </property> - </bean> - - - <!-- Services --> - - <bean id="domTreeService" class="org.apache.portals.applications.springmvc.DOMTreeService"> - - </bean> - - - <!-- Controllers --> - - <bean id="domtreeControllerTemplate" abstract="true"> - <property name="domTreeService"><ref bean="domTreeService"/></property> - </bean> - - <bean id="domtreeViewController" class="org.apache.portals.applications.springmvc.DOMTreeViewController" parent="domtreeControllerTemplate"> - <property name="xmlFilePath" value="/WEB-INF/data/test.xml" /> - <property name="xmlFileName" value="Property Test" /> - </bean> - - <bean id="domtreePrefsController" class="org.apache.portals.applications.springmvc.DOMTreePrefsController" parent="domtreeControllerTemplate"> - <property name="sessionForm" value="true"/> - <property name="formView" value="domTreeEdit"/> - </bean> - - <bean id="domtreePrefsListController" class="org.apache.portals.applications.springmvc.DOMTreePrefsListController" parent="domtreeControllerTemplate"> - - </bean> - - <bean id="domtreeDeleteController" class="org.apache.portals.applications.springmvc.DOMTreeDeleteController" parent="domtreeControllerTemplate"/> - - - <!-- Handler Mapping --> - - <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor"/> - - <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> - <property name="order" value="10"/> - <property name="interceptors"> - <list> - <ref bean="parameterMappingInterceptor"/> - </list> - </property> - <property name="portletModeParameterMap"> - <map> - <entry key="edit"> - <map> - <entry key="editDomTree"><ref bean="domtreePrefsController"/></entry> - <entry key="newDomTree"><ref bean="domtreePrefsController"/></entry> - <entry key="deleteDomTree"><ref bean="domtreeDeleteController"/></entry> - <entry key="list"><ref bean="domtreePrefsListController"/></entry> - </map> - </entry> - </map> - </property> - </bean> - - <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> - <property name="order" value="10"/> - <property name="portletModeMap"> - <map> - <entry key="view"><ref bean="domtreeViewController"/></entry> - <entry key="edit"><ref bean="domtreePrefsListController"/></entry> - </map> - </property> - </bean> - - - <!-- Exceptions Handler --> - - <bean id="defaultExceptionHandler" parent="defaultExceptionHandlerTemplate"/> - -</beans> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "../../dtd/spring-beans.dtd"> +<beans> + + <!-- Property Configurer --> + + <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="locations"> + <list> + <value>WEB-INF/domtree.properties</value> + </list> + </property> + </bean> + + + <!-- Services --> + + <bean id="domTreeService" class="org.apache.portals.applications.springmvc.DOMTreeService"> + + </bean> + + + <!-- Controllers --> + + <bean id="domtreeControllerTemplate" abstract="true"> + <property name="domTreeService"><ref bean="domTreeService"/></property> + </bean> + + <bean id="domtreeViewController" class="org.apache.portals.applications.springmvc.DOMTreeViewController" parent="domtreeControllerTemplate"> + <property name="xmlFilePath" value="/WEB-INF/data/test.xml" /> + <property name="xmlFileName" value="Property Test" /> + </bean> + + <bean id="domtreePrefsController" class="org.apache.portals.applications.springmvc.DOMTreePrefsController" parent="domtreeControllerTemplate"> + <property name="sessionForm" value="true"/> + <property name="formView" value="domTreeEdit"/> + </bean> + + <bean id="domtreePrefsListController" class="org.apache.portals.applications.springmvc.DOMTreePrefsListController" parent="domtreeControllerTemplate"> + + </bean> + + <bean id="domtreeDeleteController" class="org.apache.portals.applications.springmvc.DOMTreeDeleteController" parent="domtreeControllerTemplate"/> + + + <!-- Handler Mapping --> + + <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor"/> + + <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> + <property name="order" value="10"/> + <property name="interceptors"> + <list> + <ref bean="parameterMappingInterceptor"/> + </list> + </property> + <property name="portletModeParameterMap"> + <map> + <entry key="edit"> + <map> + <entry key="editDomTree"><ref bean="domtreePrefsController"/></entry> + <entry key="newDomTree"><ref bean="domtreePrefsController"/></entry> + <entry key="deleteDomTree"><ref bean="domtreeDeleteController"/></entry> + <entry key="list"><ref bean="domtreePrefsListController"/></entry> + </map> + </entry> + </map> + </property> + </bean> + + <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> + <property name="order" value="10"/> + <property name="portletModeMap"> + <map> + <entry key="view"><ref bean="domtreeViewController"/></entry> + <entry key="edit"><ref bean="domtreePrefsListController"/></entry> + </map> + </property> + </bean> + + + <!-- Exceptions Handler --> + + <bean id="defaultExceptionHandler" parent="defaultExceptionHandlerTemplate"/> + +</beans> Modified: portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/data/test.xml URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/data/test.xml?view=diff&rev=517068&r1=517067&r2=517068 ============================================================================== --- portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/data/test.xml (original) +++ portals/bridges/trunk/applications/springmvc/src/webapp/WEB-INF/data/test.xml Sun Mar 11 18:44:37 2007 @@ -1,4 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
