Author: marijan
Date: Thu Jul 5 09:13:47 2012
New Revision: 1357507
URL: http://svn.apache.org/viewvc?rev=1357507&view=rev
Log:
RAVE-701 Provide a simple filesystem based url to page definition mapping (xml,
json)
- first cut
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FileConfigDao.java
- copied, changed from r1357506,
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
(with props)
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
(with props)
Modified:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/FilePageConfigDaoTest.java
Copied:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FileConfigDao.java
(from r1357506,
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java)
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FileConfigDao.java?p2=rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FileConfigDao.java&p1=rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java&r1=1357506&r2=1357507&rev=1357507&view=diff
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
(original)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FileConfigDao.java
Thu Jul 5 09:13:47 2012
@@ -19,17 +19,10 @@
package org.apache.rave.portal.web.model.config;
-import org.apache.commons.io.IOUtils;
-import org.apache.rave.portal.web.exceptions.InvalidConfigurationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
@@ -37,42 +30,14 @@ import java.net.URLDecoder;
/**
* @version "$Id$"
*/
-public class FilePageConfigDao implements PageConfigDao {
+public abstract class FileConfigDao {
- private static Logger log =
LoggerFactory.getLogger(FilePageConfigDao.class);
+ private static Logger log = LoggerFactory.getLogger(FileConfigDao.class);
- public static final String FILE_PATH_PREFIX = "file:";
- public static final String CLASSPATH_PREFIX = "classpath:";
-
-
- @Override
- public PageConfig loadConfig(String path) throws
InvalidConfigurationException {
-
- FileInputStream is = null;
- try {
- File file = getResourceFile(path);
- if (file == null) {
- throw new InvalidConfigurationException("Configuration file
not found for path: " + path);
- }
- JAXBContext context = JAXBContext.newInstance(PageConfig.class);
- Unmarshaller unmarshaller = context.createUnmarshaller();
- is = new FileInputStream(file);
- final PageConfig pageConfig = (PageConfig)
unmarshaller.unmarshal(is);
- if (pageConfig != null) {
- pageConfig.initialize();
- }
-
- return pageConfig;
- } catch (JAXBException e) {
- throw new InvalidConfigurationException("Error parsing
configuration file: " + path, e);
- } catch (FileNotFoundException e) {
- throw new InvalidConfigurationException("Configuration file not
found for path: " + path, e);
- } finally {
- IOUtils.closeQuietly(is);
- }
+ public static final String FILE_PATH_PREFIX = "file:";
- }
+ public static final String CLASSPATH_PREFIX = "classpath:";
/**
@@ -84,7 +49,7 @@ public class FilePageConfigDao implement
* @param resourcePath the path of the resource.
* @return File or null if nothing is found or encoding exception is thrown
*/
- private File getResourceFile(String resourcePath) {
+ protected File getResourceFile(String resourcePath) {
if (resourcePath == null) {
throw new IllegalArgumentException("resourcePath parameter cannot
be <null>");
}
Modified:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java?rev=1357507&r1=1357506&r2=1357507&view=diff
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
(original)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/FilePageConfigDao.java
Thu Jul 5 09:13:47 2012
@@ -30,23 +30,18 @@ import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLDecoder;
/**
* @version "$Id$"
*/
-public class FilePageConfigDao implements PageConfigDao {
+public class FilePageConfigDao extends FileConfigDao implements PageConfigDao {
private static Logger log =
LoggerFactory.getLogger(FilePageConfigDao.class);
- public static final String FILE_PATH_PREFIX = "file:";
- public static final String CLASSPATH_PREFIX = "classpath:";
-
@Override
public PageConfig loadConfig(String path) throws
InvalidConfigurationException {
+ log.info("Loading configuration: {}", path);
FileInputStream is = null;
try {
@@ -75,39 +70,4 @@ public class FilePageConfigDao implement
}
- /**
- * Returns the physical resource file object. <p> <ul> <li>When the
resourcePath starts with 'file:', it is assumed
- * as a file path on the file system.</li> <li>When the resourcePath
starts with 'classpath:', it is assumed as a
- * classpath resource path.</li> <li>When the resourcePath does not starts
with 'file:' nor with 'classpath:', it is
- * assumed as a file path on the file system.</li> </ul> </p>
- *
- * @param resourcePath the path of the resource.
- * @return File or null if nothing is found or encoding exception is thrown
- */
- private File getResourceFile(String resourcePath) {
- if (resourcePath == null) {
- throw new IllegalArgumentException("resourcePath parameter cannot
be <null>");
- }
- if (resourcePath.startsWith(FILE_PATH_PREFIX)) {
- String fileName =
resourcePath.substring(FILE_PATH_PREFIX.length());
- return new File(fileName);
- } else if (resourcePath.startsWith(CLASSPATH_PREFIX)) {
- String classPath =
resourcePath.substring(CLASSPATH_PREFIX.length());
- URL url =
FilePageConfigDao.class.getClassLoader().getResource(classPath);
- try {
- if (url == null) {
- return null;
- }
- String fileName = URLDecoder.decode(url.toString(),
"UTF-8").substring("file:".length());
- return new File(fileName);
- } catch (UnsupportedEncodingException e) {
- // The system should always have UTF-8
- return null;
- }
- } else {
- // fallback
- log.info("Neither file or classpath prefix used, trying to get
resource directly from '{}'", resourcePath);
- return new File(resourcePath);
- }
- }
}
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,68 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.rave.portal.web.exceptions.InvalidConfigurationException;
+import org.apache.rave.portal.web.model.config.FileConfigDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * @version "$Id$"
+ */
+public class FileUrlConfigDao extends FileConfigDao implements UrlConfigDao {
+
+ private static Logger log =
LoggerFactory.getLogger(FileUrlConfigDao.class);
+
+ @Override
+ public UrlConfig loadUrlConfig(String path) throws
InvalidConfigurationException {
+ log.info("Loading configuration: {}", path);
+ FileInputStream is = null;
+ try {
+ File file = getResourceFile(path);
+ if (file == null) {
+ throw new InvalidConfigurationException("Configuration file
not found for path: " + path);
+ }
+ JAXBContext context = JAXBContext.newInstance(UrlConfig.class);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ is = new FileInputStream(file);
+ final UrlConfig config = (UrlConfig) unmarshaller.unmarshal(is);
+ if (config != null) {
+ config.initialize();
+ }
+
+ return config;
+ } catch (JAXBException e) {
+ throw new InvalidConfigurationException("Error parsing
configuration file: " + path, e);
+ } catch (FileNotFoundException e) {
+ throw new InvalidConfigurationException("Configuration file not
found for path: " + path, e);
+ } finally {
+ IOUtils.closeQuietly(is);
+ }
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDao.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,63 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @version "$Id$"
+ */
+@XmlRootElement(name = "render-mapping")
+public class RenderMapping {
+
+ private static Logger log = LoggerFactory.getLogger(RenderMapping.class);
+
+ private String name;
+ private String path;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("RenderMapping");
+ sb.append("{name='").append(name).append('\'');
+ sb.append(", path='").append(path).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/RenderMapping.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,93 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+/**
+ * @version "$Id$"
+ */
+@XmlRootElement(name = "url-configuration")
+public class UrlConfig {
+
+ private static Logger log = LoggerFactory.getLogger(UrlConfig.class);
+ private boolean initialized;
+
+
+ private String name;
+ private List<UrlMapping> mappings;
+
+ public void initialize() {
+ if (!initialized) {
+ log.info("Initializing {}", name);
+ // populate parents:
+ for (UrlMapping mapping : mappings) {
+ populateParent(mapping);
+ }
+ initialized = true;
+ }
+ }
+
+ private void populateParent(final UrlMapping parent) {
+ final List<UrlMapping> children = parent.getChildren();
+ if (children != null) {
+ for (UrlMapping child : children) {
+ child.setParent(parent);
+ populateParent(child);
+ }
+ }
+ }
+
+ @XmlAttribute
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @XmlElement(name = "url-mapping", type = UrlMapping.class)
+ public List<UrlMapping> getMappings() {
+ return mappings;
+ }
+
+ public void setMappings(List<UrlMapping> mappings) {
+ this.mappings = mappings;
+ }
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("UrlConfig");
+ sb.append("{initialized=").append(initialized);
+ sb.append(", name='").append(name).append('\'');
+ sb.append(", mappings=").append(mappings);
+ sb.append('}');
+ return sb.toString();
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfig.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.apache.rave.portal.web.exceptions.InvalidConfigurationException;
+
+/**
+ * @version "$Id$"
+ */
+public interface UrlConfigDao {
+
+ /**
+ * Loads url mappings configuration
+ *
+ * @param path path to load configuration from
+ * @return UrlConfig instance containing url and render mappings
+ * @throws InvalidConfigurationException thrown when config cannot be
loaded or parsed
+ */
+ UrlConfig loadUrlConfig(String path) throws InvalidConfigurationException;
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlConfigDao.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,90 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.List;
+
+/**
+ * @version "$Id$"
+ */
+public class UrlMapping {
+
+ private static Logger log = LoggerFactory.getLogger(UrlMapping.class);
+
+
+ private String url;
+
+ private UrlMapping parent;
+ private List<UrlMapping> children;
+ private List<RenderMapping> renderMappings;
+
+
+ @XmlAttribute
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+
+ public UrlMapping getParent() {
+ return parent;
+ }
+
+ public void setParent(UrlMapping parent) {
+ this.parent = parent;
+ }
+
+
+ @XmlElement(name = "url-mapping", type = UrlMapping.class)
+ public List<UrlMapping> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<UrlMapping> children) {
+ this.children = children;
+ }
+
+ @XmlElement(name = "render-mapping", type = RenderMapping.class)
+ public List<RenderMapping> getRenderMappings() {
+ return renderMappings;
+ }
+
+ public void setRenderMappings(List<RenderMapping> renderMappings) {
+ this.renderMappings = renderMappings;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("UrlMapping");
+ sb.append("{url='").append(url).append('\'');
+ sb.append(", parent=").append(parent);
+ sb.append('}');
+ return sb.toString();
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/model/config/url/UrlMapping.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/FilePageConfigDaoTest.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/FilePageConfigDaoTest.java?rev=1357507&r1=1357506&r2=1357507&view=diff
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/FilePageConfigDaoTest.java
(original)
+++
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/FilePageConfigDaoTest.java
Thu Jul 5 09:13:47 2012
@@ -42,7 +42,7 @@ public class FilePageConfigDaoTest {
@Test
public void testLoadConfig() throws Exception {
PageConfigDao dao = new FilePageConfigDao();
- final PageConfig config =
dao.loadConfig(FilePageConfigDao.CLASSPATH_PREFIX +
"example_configuration.xml");
+ final PageConfig config =
dao.loadConfig(FileConfigDao.CLASSPATH_PREFIX + "example_configuration.xml");
assertNotNull(config);
assertEquals("default", config.getName());
// expected only standard page
@@ -108,4 +108,15 @@ public class FilePageConfigDaoTest {
dao.loadConfig(FilePageConfigDao.CLASSPATH_PREFIX +
"NONE_EXISTING_example_configuration.xml");
}
+ @Test
+ public void testNoParent() throws Exception {
+ PageConfigDao dao = new FilePageConfigDao();
+ final PageConfig config =
dao.loadConfig(FilePageConfigDao.CLASSPATH_PREFIX +
"example_configuration.xml");
+ assertNotNull(config);
+ final List<PageDefinitionConfig> definitions = config.getDefinitions();
+ final PageDefinitionConfig standardPage = definitions.get(0);
+ standardPage.setParent("test");
+ assertTrue(standardPage.getParent() == null);
+ }
+
}
Added:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,66 @@
+/*
+ * 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.rave.portal.web.model.config.url;
+
+import org.apache.rave.portal.web.model.config.FileConfigDao;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * @version "$Id$"
+ */
+public class FileUrlConfigDaoTest {
+
+ private static Logger log =
LoggerFactory.getLogger(FileUrlConfigDaoTest.class);
+
+ @Test
+ public void testLoadUrlConfig() throws Exception {
+ FileUrlConfigDao dao = new FileUrlConfigDao();
+ final UrlConfig config =
dao.loadUrlConfig(FileConfigDao.CLASSPATH_PREFIX + "example_url_mapping.xml");
+ log.info("config {}", config);
+ assertTrue(config != null);
+ assertEquals("default", config.getName());
+ final List<UrlMapping> rootMappings = config.getMappings();
+ assertEquals(3, rootMappings.size());
+ UrlMapping userMapping = null;
+ for (UrlMapping rootMapping : rootMappings) {
+ if (rootMapping.getUrl().equals("/user")) {
+ userMapping = rootMapping;
+ break;
+ }
+ }
+ assertTrue(userMapping != null);
+ final List<UrlMapping> userKids = userMapping.getChildren();
+ assertEquals(1, userKids.size());
+ UrlMapping userAdminMapping = userKids.get(0);
+ final List<UrlMapping> children = userAdminMapping.getChildren();
+ for (UrlMapping child : children) {
+ assertTrue(child.getParent() != null);
+ }
+ assertEquals(3, children.size());
+
+ }
+}
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/java/org/apache/rave/portal/web/model/config/url/FileUrlConfigDaoTest.java
------------------------------------------------------------------------------
svn:keywords = Id
Added:
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
URL:
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml?rev=1357507&view=auto
==============================================================================
---
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
(added)
+++
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
Thu Jul 5 09:13:47 2012
@@ -0,0 +1,37 @@
+<?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.
+-->
+<url-configuration name="default">
+
+ <!--admin page mapping -->
+ <url-mapping url="/login" page="loginPage">
+ <render-mapping name="loginPage/header" path="/login/login.jsp"/>
+ <render-mapping name="loginPage/footer" path="/login/login.jsp"/>
+ </url-mapping>
+ <url-mapping url="/admin" page="adminPage"/>
+ <url-mapping url="/user" page="userAdminPage">
+ <url-mapping url="admin" page="userAdminPage">
+ <url-mapping url="edit" page="userAdminPage">
+ <render-mapping name="userAdminPage/footer"
path="/user/pages/footer.jsp"/>
+ </url-mapping>
+ <url-mapping url="add" page="userAdminPage"/>
+ <url-mapping url="delete" page="userAdminPage"/>
+ </url-mapping>
+ </url-mapping>
+</url-configuration>
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
rave/sandbox/content-services/rave-web-hmvc/src/test/resources/example_url_mapping.xml
------------------------------------------------------------------------------
svn:keywords = Id