示例#1
0
文件: Site.java 项目: nuxeo/lm-labs
  @POST
  @Path("@manage-sidebar")
  public Object manageSidebar() {
    FormData form = ctx.getForm();
    CoreSession session = getCoreSession();
    try {
      int nbRows = new Integer(form.getString("nbRows")).intValue();
      HtmlPage sidebar = site.getSidebar();
      HtmlSection section = sidebar.section(0);
      section.remove();
      sidebar.addSection();
      section = sidebar.section(0);
      HtmlRow row = null;
      String widget = "";
      for (int i = 0; i < nbRows; i++) {
        widget = form.getString("bloc" + i);
        if (!"html/editor".equals(widget)) {
          row = section.addRow();
          row.addContent(0, "");
          session.saveDocument(sidebar.getDocument());
          session.save();
          GadgetUtils.syncWidgetsConfig(row.content(0), widget, sidebar.getDocument(), session);
        }
      }
    } catch (Exception e) {
      throw WebException.wrap("Problème lors de la sauvegarde des widgets de la sidebar", e);
    }
    // TODO row's widget config

    return Response.ok().build();
  }
示例#2
0
文件: Site.java 项目: nuxeo/lm-labs
  @Path("@configWidget-sidebar")
  public Object configWidgetSidebar() {
    FormData form = ctx.getForm();
    try {
      int rowIdx = new Integer(form.getString("rowIdx")).intValue();
      HtmlPage sidebar = site.getSidebar();

      HtmlContent content = sidebar.section(0).row(rowIdx).content(0);
      Resource newObject = newObject("HtmlContent", sidebar.getDocument(), content);
      return newObject;
      /*List<LabsWidget> widgets = content.getGadgets(getCoreSession());
      if (!widgets.isEmpty()) {
          LabsWidget widget = widgets.get(0);
          if (WidgetType.OPENSOCIAL.equals(widget.getType())) {
              DocumentRef ref = ((LabsOpensocialGadget)widget).getDoc().getRef();
              if (getCoreSession().exists(ref)) {
                  DocumentModel gadgetDoc = getCoreSession().getDocument(ref);
                  return newObject("HtmlWidget", gadgetDoc, doc, content, widget);
              }
              return Response.noContent().build();
          }
          return newObject("HtmlWidget", null, doc, content, widget);
      }
      return Response.noContent().build();*/

    } catch (Exception e) {
      throw WebException.wrap(
          "Problème lors de la sauvegarde de la configuration du widget de la sidebar", e);
    }
  }
 @PUT
 public Object doPut() {
   FormData form = ctx.getForm();
   try {
     AdministrativeStatusManager manager =
         Framework.getLocalService(AdministrativeStatusManager.class);
     manager.setNuxeoInstanceStatus(
         form.getString("status"), "assigned from rest interface", ctx.getPrincipal().getName());
     return redirect(getPath());
   } catch (Exception e) {
     throw WebException.wrap(e);
   }
 }
示例#4
0
文件: Site.java 项目: nuxeo/lm-labs
 private Response updateSite(FormData form) {
   String title = form.getString("dc:title");
   String url = form.getString("webc:url");
   String description = form.getString("dc:description");
   String piwikId = form.getString("piwik:piwikId");
   String siteTemplateStr = form.getString("labssite:siteTemplate");
   String category = form.getString("labssite:category");
   boolean modified = false;
   try {
     if (!StringUtils.isEmpty(title)) {
       site.setTitle(title);
       modified = true;
     }
     if (!StringUtils.isEmpty(description)) {
       site.setDescription(description);
       modified = true;
     }
     if (!StringUtils.isEmpty(category)) {
       site.setCategory(category);
       modified = true;
     }
     String oldUrl = site.getURL();
     url = StringUtils.trim(url);
     if (!StringUtils.isEmpty(url) && !url.equals(oldUrl)) {
       site.setURL(url);
       modified = true;
     }
     String oldPiwikId = site.getPiwikId();
     piwikId = StringUtils.trim(piwikId);
     if (!StringUtils.equals(piwikId, oldPiwikId)) {
       site.setPiwikId(piwikId);
       modified = true;
     }
     boolean isSiteTemplate = BooleanUtils.toBoolean(siteTemplateStr);
     if (site.isElementTemplate() != isSiteTemplate) {
       site.setElementTemplate(isSiteTemplate);
       modified = true;
     }
     if (isSiteTemplate) {
       if (form.isMultipartContent()) {
         Blob preview = form.getBlob("labssite:siteTemplatePreview");
         if (preview != null && !StringUtils.isEmpty(preview.getFilename())) {
           site.setElementPreview(preview);
           modified = true;
         }
       }
     } /* else {
           Blob siteTemplatePreview = null;
           try {
               siteTemplatePreview = site.getSiteTemplatePreview();
           } catch (ClientException e) {
               throw WebException.wrap(e);
           }
           if (siteTemplatePreview != null) {
               site.setElementPreview(null);
               modified = true;
           }
       }*/
     String msgLabel = "label.labssites.edit.noop";
     if (modified) {
       CoreSession session = ctx.getCoreSession();
       getSiteManager().updateSite(session, site);
       session.save();
       msgLabel = "label.labssites.edit.site.updated";
     }
     return redirect(
         ctx.getModulePath()
             + "/"
             + URIUtils.quoteURIPathComponent(site.getURL(), true)
             + "/@views/edit?message_success="
             + msgLabel);
   } catch (SiteManagerException e) {
     return redirect(getPath() + "/@views/edit?message_error=" + e.getMessage());
   } catch (ClientException e) {
     throw WebException.wrap(e);
   }
 }