This post originated from an RSS feed registered with Java Buzz
by Simon Brown.
Original Post: Migrating to Pebble
Feed Title: Simon Brown's weblog
Feed URL: http://www.simongbrown.com/blog/feed.xml?flavor=rss20&category=java
Feed Description: My thoughts on Java, software development and technology.
There's been an influx of e-mails recently asking me how to migrate content from other blogging systems to Pebble, so I thought that I'd outline the approach that I used when migrating from Radio Userland.
By default, Pebble stores all blog content as XML files on disk in a directory structure that follows a year/month/day hierarchy. When migrating content to Pebble, rather than manually create directories and XML files, the best approach is to write some Java code that directly uses the Pebble classes because you then get all of this for free. If you can write a short Java program to extract the existing entries, you can use something like the following to import them into Pebble.
DAOFactory.setConfiguredFactory(new FileDAOFactory());
SimpleBlog blog = new SimpleBlog("~/pebble-blog/");
blog.setProperty(Blog.TIMEZONE_KEY, "Europe/London");
blog.setProperty(Blog.CHARACTER_ENCODING_KEY, "UTF-8");
foreach (existing blog entry) {
// get the title, body, date, etc from the old entry
String title, body;
Date date;
// create a new Pebble entry, add and store
DailyBlog day = blog.getBlogForDay(date);
BlogEntry entry = day.createBlogEntry(title, body, date);
entry.set...(); // set any other properties
day.addEntry(entry);
entry.store();
}
Doing something like this will create the relevant files for you, while setting the Blog.TIMEZONE_KEY property on the SimpleBlog instance will ensure that your existing blog entries are stored underneath the correct year/month/day structure for your time zone. Using this technique, migrating to Pebble should be easy and if you ever want to migrate from Pebble, you'll find a link to export all content as RSS/RSS with comments/RDF/Atom after you've logged in.