use of org.glassfish.jersey.examples.bookmark.entity.BookmarkEntity in project jersey by jersey.
the class BookmarksResource method getBookmarksAsJsonArray.
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONArray getBookmarksAsJsonArray() {
JSONArray uriArray = new JSONArray();
for (BookmarkEntity bookmarkEntity : getBookmarks()) {
UriBuilder ub = uriInfo.getAbsolutePathBuilder();
URI bookmarkUri = ub.path(bookmarkEntity.getBookmarkEntityPK().getBmid()).build();
uriArray.put(bookmarkUri.toASCIIString());
}
return uriArray;
}
use of org.glassfish.jersey.examples.bookmark.entity.BookmarkEntity in project jersey by jersey.
the class BookmarksResource method postForm.
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response postForm(JSONObject bookmark) throws JSONException {
final BookmarkEntity bookmarkEntity = new BookmarkEntity(getBookmarkId(bookmark.getString("uri")), userResource.getUserEntity().getUserid());
bookmarkEntity.setUri(bookmark.getString("uri"));
bookmarkEntity.setUpdated(new Date());
bookmarkEntity.setSdesc(bookmark.getString("sdesc"));
bookmarkEntity.setLdesc(bookmark.getString("ldesc"));
userResource.getUserEntity().getBookmarkEntityCollection().add(bookmarkEntity);
TransactionManager.manage(new Transactional(em) {
public void transact() {
em.merge(userResource.getUserEntity());
}
});
URI bookmarkUri = uriInfo.getAbsolutePathBuilder().path(bookmarkEntity.getBookmarkEntityPK().getBmid()).build();
return Response.created(bookmarkUri).build();
}
Aggregations