예제 #1
0
 @DELETE
 @Produces(MediaType.APPLICATION_JSON)
 public Response deleteJSON() {
   PortfolioDocument doc = data().getPortfolio();
   if (doc.isLatest()) {
     data().getPortfolioMaster().remove(doc.getUniqueId());
   }
   return Response.ok().build();
 }
예제 #2
0
 /**
  * Creates the output root data.
  *
  * @return the output root data, not null
  */
 protected FlexiBean createRootData() {
   FlexiBean out = super.createRootData();
   PortfolioDocument doc = data().getPortfolio();
   out.put("portfolioDoc", doc);
   out.put("portfolio", doc.getPortfolio());
   out.put("childNodes", doc.getPortfolio().getRootNode().getChildNodes());
   out.put("deleted", !doc.isLatest());
   out.put("rootNode", doc.getPortfolio().getRootNode());
   return out;
 }
예제 #3
0
 // -------------------------------------------------------------------------
 @DELETE
 @Produces(MediaType.TEXT_HTML)
 public Response deleteHTML() {
   PortfolioDocument doc = data().getPortfolio();
   if (doc.isLatest() == false) {
     return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
   }
   data().getPortfolioMaster().remove(doc.getUniqueId());
   URI uri = WebPortfolioResource.uri(data());
   return Response.seeOther(uri).build();
 }
예제 #4
0
 @PUT
 @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
 @Produces(MediaType.APPLICATION_JSON)
 public Response putJSON(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) {
   PortfolioDocument doc = data().getPortfolio();
   if (doc.isLatest() == false) {
     return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
   }
   name = StringUtils.trimToNull(name);
   DocumentVisibility visibility =
       BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE;
   updatePortfolio(name, visibility, doc);
   return Response.ok().build();
 }
예제 #5
0
  // -------------------------------------------------------------------------
  @PUT
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  @Produces(MediaType.TEXT_HTML)
  public Response putHTML(@FormParam("name") String name, @FormParam("hidden") Boolean isHidden) {
    PortfolioDocument doc = data().getPortfolio();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }

    name = StringUtils.trimToNull(name);
    DocumentVisibility visibility =
        BooleanUtils.isTrue(isHidden) ? DocumentVisibility.HIDDEN : DocumentVisibility.VISIBLE;
    if (name == null) {
      FlexiBean out = createRootData();
      out.put("err_nameMissing", true);
      String html = getFreemarker().build("portfolios/portfolio-update.ftl", out);
      return Response.ok(html).build();
    }
    URI uri = updatePortfolio(name, visibility, doc);
    return Response.seeOther(uri).build();
  }