コード例 #1
0
  @Override
  public PublishedDocument publishDocument(
      DocumentModel doc, PublicationNode targetNode, Map<String, String> params)
      throws ClientException {

    Snapshot snapshot = null;

    if (doc.isFolder()) {
      Snapshotable snapshotable = doc.getAdapter(Snapshotable.class);
      if (snapshotable != null) {
        snapshot = snapshotable.createSnapshot(VersioningOption.MINOR);
      }
    }

    PublishedDocument result = super.publishDocument(doc, targetNode, params);

    if (snapshot != null) {

      final Snapshot tree = snapshot;
      final DocumentModel parent = ((SimpleCorePublishedDocument) result).getProxy();

      UnrestrictedSessionRunner runner =
          new UnrestrictedSessionRunner(doc.getCoreSession()) {
            @Override
            public void run() throws ClientException {
              // force cleanup of the tree !!!
              session.removeChildren(parent.getRef());
              subPublish(session, parent, tree, true);
            }
          };
      runner.runUnrestricted();
    }

    return result;
  }
コード例 #2
0
 protected void assertLatestVersion(String expected, DocumentModel doc) throws Exception {
   DocumentModel ver = doc.getCoreSession().getLastDocumentVersion(doc.getRef());
   if (ver == null) {
     assertNull(expected);
   } else {
     assertVersion(expected, ver);
   }
 }
コード例 #3
0
ファイル: Site.java プロジェクト: nuxeo/lm-labs
  @GET
  @Path("@treeview")
  @Produces(MediaType.APPLICATION_JSON)
  public Response doTreeview(
      @QueryParam("root") String root, @QueryParam("view") String view, @QueryParam("id") String id)
      throws ClientException {

    LabsSite site = (LabsSite) ctx.getProperty("site");
    if (site != null) {
      DocumentModel tree = null;
      AbstractDocumentTree siteTree;
      if ("admin".equals(view)) {
        tree = site.getTree();
        siteTree = new AdminSiteTree(ctx, tree);
      } else if ("admin_asset".equals(view)) {
        tree = "0".equals(id) ? site.getAssetsDoc() : getCoreSession().getDocument(new IdRef(id));
        siteTree = new AdminSiteTreeAsset(ctx, tree);
      } else {
        tree = site.getTree();
        siteTree = new SiteDocumentTree(ctx, tree);
      }
      String result = "";
      if (root == null || "source".equals(root)) {
        if (id != null && !"0".equals(id)) {
          DocumentModel document = tree.getCoreSession().getDocument(new IdRef(id));
          String entryPoint =
              StringUtils.substringAfter(
                  document.getPathAsString(),
                  site.getDocument().getPathAsString() + "/" + Docs.TREE.docName());
          result = siteTree.enter(ctx, entryPoint);
        } else {
          siteTree.enter(ctx, "");
          result = siteTree.getTreeAsJSONArray(ctx);
        }
      } else {
        result = siteTree.enter(ctx, root);
      }
      return Response.ok().entity(result).type(MediaType.APPLICATION_JSON).build();
    }
    return null;
  }
コード例 #4
0
  public XMLImporterServiceImpl(
      DocumentModel rootDoc,
      ParserConfigRegistry registry,
      Map<String, Object> mvelContext,
      boolean deferSave) {
    if (mvelContext != null) {
      mvelCtx.putAll(mvelContext);
    }

    session = rootDoc.getCoreSession();
    this.rootDoc = rootDoc;
    this.deferSave = deferSave;

    docsStack = new Stack<>();
    pushInStack(rootDoc);
    mvelCtx.put("root", rootDoc);
    mvelCtx.put("docs", docsStack);
    mvelCtx.put("session", session);

    this.registry = registry;
  }
コード例 #5
0
 @Override
 public Object[] getParameters() {
   if (newParams == null) {
     Object[] params = super.getParameters();
     if (params.length != 1) {
       log.error(
           this.getClass().getSimpleName()
               + " Expect only one parameter the document uuid, unexpected behavior may occur");
     }
     CoreSession session = null;
     String uuid = null;
     if (params[0] instanceof DocumentModel) {
       DocumentModel doc = (DocumentModel) params[0];
       uuid = doc.getId();
       session = doc.getCoreSession();
     } else {
       session = (CoreSession) getProperties().get(CORE_SESSION_PROPERTY);
       uuid = params[0].toString();
     }
     if (session != null) {
       try {
         AdditionalDocumentAuditParams additionalParams =
             DocumentAuditHelper.getAuditParamsForUUID(uuid, session);
         if (additionalParams != null) {
           newParams = new Object[] {uuid, additionalParams.targetUUID, additionalParams.maxDate};
         } else {
           newParams = new Object[] {uuid};
         }
       } catch (Exception e) {
         log.error("Error while fetching additional parameters for audit query", e);
       }
     } else {
       log.warn("No core session found : can not compute all info to get complete audit entries");
       return params;
     }
   }
   return newParams;
 }
コード例 #6
0
 protected CoreSession getCoreSession() {
   return folder.getCoreSession();
 }