Ejemplo n.º 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();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
  }