Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
@@ -0,0 +1,28 @@
package app.controllers;
import javax.inject.Inject;
import org.javalite.activeweb.AppController;
import app.services.ArticleService;
public class ArticleController extends AppController {
@Inject
private ArticleService articleService;
public void index() {
view("articles", articleService.getArticles());
}
public void search() {
String keyword = param("key");
if (null != keyword) {
assign("article", articleService.search(keyword));
} else {
render("/common/error");
}
}
}
@@ -0,0 +1,11 @@
package app.controllers;
import org.javalite.activeweb.AppController;
public class HomeController extends AppController {
public void index() {
render("index");
}
}
@@ -0,0 +1,103 @@
package app.controllers;
import app.models.Product;
import org.codehaus.jackson.map.ObjectMapper;
import org.javalite.activeweb.AppController;
import org.javalite.activeweb.annotations.RESTful;
import java.util.Map;
@RESTful
public class ProductsController extends AppController {
private ObjectMapper mapper = new ObjectMapper();
public void index() {
try {
view("products", Product.findAll());
render().contentType("application/json");
} catch (Exception e) {
view("message", "There was an error.", "code", 200);
render("message");
}
}
public void create() {
try {
Map payload = mapper.readValue(getRequestString(), Map.class);
Product p = new Product();
p.fromMap(payload);
p.saveIt();
view("message", "Successfully saved product id " + p.get("id"), "code", 200);
render("message");
} catch (Exception e) {
view("message", "There was an error.", "code", 200);
render("message");
}
}
public void update() {
try {
Map payload = mapper.readValue(getRequestString(), Map.class);
String id = getId();
Product p = Product.findById(id);
if (p == null) {
view("message", "Product id " + id + " not found.", "code", 200);
render("message");
return;
}
p.fromMap(payload);
p.saveIt();
view("message", "Successfully updated product id " + id, "code", 200);
render("message");
} catch (Exception e) {
view("message", "There was an error.", "code", 200);
render("message");
}
}
public void show() {
try {
String id = getId();
Product p = Product.findById(id);
if (p == null) {
view("message", "Product id " + id + " not found.", "code", 200);
render("message");
return;
}
view("product", p);
render("_product");
} catch (Exception e) {
view("message", "There was an error.", "code", 200);
render("message");
}
}
public void destroy() {
try {
String id = getId();
Product p = Product.findById(id);
if (p == null) {
view("message", "Product id " + id + " not found.", "code", 200);
render("message");
return;
}
p.delete();
view("message", "Successfully deleted product id " + id, "code", 200);
render("message");
} catch (Exception e) {
view("message", "There was an error.", "code", 200);
render("message");
}
}
@Override
protected String getContentType() {
return "application/json";
}
@Override
protected String getLayout() {
return null;
}
}