Commit 2f0af362 authored by Matija Obreza's avatar Matija Obreza

New core property base.url=http://localhost:8080 and /sitemap.xml

controller
parent b0ca0342
package org.genesys2.server.servlet.controller;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* http://www.sitemaps.org/protocol.html
*
* @author Matija Obreza, matija.obreza@croptrust.org
*/
@Controller
@RequestMapping("/sitemap.xml")
public class SitemapXMLController {
@Value("${base.url}")
private String baseUrl = "http://localhost:8080";
private static class SitemapPage {
String url;
String freq = "daily";
Double priority;
public SitemapPage(String url) {
this.url = url;
}
public SitemapPage(String url, double priority) {
this.url = url;
this.priority = priority;
}
public SitemapPage(String url, String changeFrequency, double priority) {
this.url = url;
this.freq = changeFrequency;
this.priority = priority;
}
}
private final SitemapPage[] sitemapPages = new SitemapPage[] { new SitemapPage("/", 1.0), new SitemapPage("/about", "monthly", 0.2),
new SitemapPage("/wiews/active", 1.0), new SitemapPage("/geo/", 1.0), new SitemapPage("/data/", 1.0), new SitemapPage("/org/") };
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody
String sitemapXml(HttpServletResponse response) {
response.setContentType("text/xml");
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.append("<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
for (SitemapPage page : sitemapPages) {
sb.append(" <url>");
sb.append(" <loc>").append(baseUrl).append(page.url).append("</loc>");
if (page.freq != null)
sb.append(" <changefreq>").append(page.freq).append("</changefreq>");
if (page.priority != null)
sb.append(" <priority>").append(page.priority).append("</priority>");
sb.append(" </url>");
}
sb.append("</urlset>");
return sb.toString();
}
}
......@@ -13,14 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#-------------------------------------------------------------------------------
#DB connection properties
#In-memory HSQLDB
#db.url=jdbc:hsqldb:mem:test
#db.driverClassName = org.hsqldb.jdbc.JDBCDriver
#db.username = sa
#db.password =
db.url=jdbc:mysql://127.0.0.1/genesys2?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
base.url=http://localhost:8080
db.url=jdbc:mysql://localhost/genesys4?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
db.driverClassName = com.mysql.jdbc.Driver
db.username = root
db.password =
......@@ -28,9 +24,9 @@ db.showSql=false
db.hbm2ddl=do-nothing
c3p0.acquireIncrement=1
c3p0.minPoolSize=5
c3p0.maxPoolSize=20
c3p0.maxIdleTime=30
c3p0.minPoolSize=1
c3p0.maxPoolSize=5
c3p0.maxIdleTime=10
lucene.indexDir=./lucene/
......@@ -55,5 +51,3 @@ cdn.flags.url=${cdn.base}/flags
# Content creation on startup
auto.createContent=true
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment