Created
March 8, 2015 08:53
-
-
Save firestar/96fb85ffabd2782c9adb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
if(Category._find(Category.class, "").exec(Category.class).size()==0){ | |
Log.info("Created default category!", this.getClass()); | |
Category c = new Category("title","Welcome","description","welcome message"); | |
c._insert(); | |
Entry e = new Entry( | |
"title", "Hello World!", | |
"body", "Welcome to my new blog. I am still setting everything up, please be patient!", | |
"publicPost", 1, | |
"date", System.currentTimeMillis() / 1000 | |
); | |
e._insert(); | |
c._set(e); | |
Log.debug("Created default entry and set category to category!", this.getClass()); | |
String pass = WSHandler.getRandomHexString(10); | |
//Authentication.create(, , , new ArrayList<String>(), 1); | |
User u; | |
try { | |
long timestamp = System.currentTimeMillis() / 1000; | |
u = new User( | |
"username", "admin", | |
"password", User.hashGenerator(pass), | |
"email", "default@site.com", | |
"flags", "", | |
"admin", 1, | |
"created_date", timestamp | |
); | |
u._insert(); | |
e._set(u); | |
Log.info("Created Default User admin["+pass+"]", this.getClass()); | |
} catch (NoSuchAlgorithmException e1) { | |
e1.printStackTrace(); | |
} | |
} | |
} catch (InstantiationException | IllegalAccessException | |
| IllegalArgumentException | NoSuchMethodException | |
| SecurityException | ClassNotFoundException | |
| InvocationTargetException | SQLException | NoSuchFieldException e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment