net.officefloor.tutorial.objectifyhttpserver.ObjectifyLogic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ObjectifyHttpServer Show documentation
Show all versions of ObjectifyHttpServer Show documentation
Tutorial of implementing Google storage with Objectify
package net.officefloor.tutorial.objectifyhttpserver;
import java.util.List;
import com.googlecode.objectify.Objectify;
import net.officefloor.web.HttpPathParameter;
import net.officefloor.web.ObjectResponse;
/**
* {@link Objectify} logic.
*
* @author Daniel Sagenschneider
*/
// START SNIPPET: tutorial
public class ObjectifyLogic {
public void savePost(Post post, Objectify objectify) {
objectify.save().entities(post).now();
}
public void retrieveAllPosts(Objectify objectify, ObjectResponse> response) {
List posts = objectify.load().type(Post.class).list();
response.send(posts);
}
public void retrievePost(@HttpPathParameter("id") String identifier, Objectify objectify,
ObjectResponse response) {
Post post = objectify.load().type(Post.class).id(Long.parseLong(identifier)).now();
response.send(post);
}
}
// END SNIPPET: tutorial