@Test public void testTagDoesNotChangeLastContributor() { DocumentModel file1 = session.createDocumentModel("/", "foo", "File"); file1.setPropertyValue("dc:title", "File1"); file1 = session.createDocument(file1); session.save(); assertEquals("Administrator", file1.getPropertyValue("dc:lastContributor")); String file1Id = file1.getId(); ACPImpl acp = new ACPImpl(); ACL acl = acp.getOrCreateACL(); acl.add(new ACE("bob", SecurityConstants.READ, true)); session.setACP(file1.getRef(), acp, false); session.save(); CoreSession bobSession = CoreInstance.getCoreSession(session.getRepositoryName(), "bob"); tagService.tag(bobSession, file1Id, "tag"); file1.refresh(); assertEquals("Administrator", file1.getPropertyValue("dc:lastContributor")); AuditBackend backend = auditEventsService.getBackend(); assertEquals(0, backend .queryLogs(new AuditQueryBuilder().predicate(Predicates.eq(LOG_PRINCIPAL_NAME, "bob")) .and(Predicates.eq(LOG_EVENT_ID, DOCUMENT_UPDATED))) .size()); }
@Override public void tag(CoreSession session, String docId, String label) { String cleanLabel = cleanLabel(label, true, false); String username = cleanUsername(session.getPrincipal().getName()); CoreInstance.doPrivileged(session, (CoreSession s) -> doTag(s, docId, cleanLabel, username)); fireUpdateEvent(session, docId); }
AbstractTagService implements TagService { @Override public void tag(CoreSession session, String docId, String label) { String cleanLabel = cleanLabel(label, true, false); String username = cleanUsername(session.getPrincipal().getName()); CoreInstance.doPrivileged(session, (CoreSession s) -> doTag(s, docId, cleanLabel, username)); fireUpdateEvent(session, docId); } }
AbstractTagService implements TagService { @Override public void tag(CoreSession session, String docId, String label) { String cleanLabel = cleanLabel(label, true, false); String username = cleanUsername(session.getPrincipal().getName()); CoreInstance.doPrivileged(session, (CoreSession s) -> doTag(s, docId, cleanLabel, username)); fireUpdateEvent(session, docId); }  }
AbstractTagService implements TagService { @Override public void tag(CoreSession session, String docId, String label) { String cleanLabel = cleanLabel(label, true, false); String username = cleanUsername(session.getPrincipal().getName()); CoreInstance.doPrivileged(session, (CoreSession s) -> doTag(s, docId, cleanLabel, username)); fireUpdateEvent(session, docId); }  @Override boolean isEnabled(); @Override void tag(CoreSession session, String docId, String label); @Override void tag(CoreSession session, String docId, String label, String username); @Override void untag(CoreSession session, String docId, String label); @Override void untag(CoreSession session, String docId, String label, String username); @Override boolean canUntag(CoreSession session, String docId, String label); @Override Set<String> getTags(CoreSession session, String docId); @Override List<Tag> getDocumentTags(CoreSession session, String docId, String username); @Override List<Tag> getDocumentTags(CoreSession session, String docId, String username, boolean useCore); @Override void removeTags(CoreSession session, String docId); @Override void copyTags(CoreSession session, String srcDocId, String dstDocId); @Override void replaceTags(CoreSession session, String srcDocId, String dstDocId); @Override List<String> getTagDocumentIds(CoreSession session, String label); @Override List<String> getTagDocumentIds(CoreSession session, String label, String username); @Override Set<String> getSuggestions(CoreSession session, String label); @Override List<Tag> getSuggestions(CoreSession session, String label, String username); abstract void doTag(CoreSession session, String docId, String label, String username); abstract void doUntag(CoreSession session, String docId, String label); abstract Set<String> doGetTags(CoreSession session, String docId); abstract void doCopyTags(CoreSession session, String srcDocId, String dstDocId, boolean removeExistingTags); abstract List<String> doGetTagDocumentIds(CoreSession session, String label); abstract Set<String> doGetTagSuggestions(CoreSession session, String label); }
AbstractTagService implements TagService { @Override public void tag(CoreSession session, String docId, String label) { String cleanLabel = cleanLabel(label, true, false); String username = cleanUsername(session.getPrincipal().getName()); CoreInstance.doPrivileged(session, (CoreSession s) -> doTag(s, docId, cleanLabel, username)); fireUpdateEvent(session, docId); }  @Override boolean isEnabled(); @Override void tag(CoreSession session, String docId, String label); @Override void tag(CoreSession session, String docId, String label, String username); @Override void untag(CoreSession session, String docId, String label); @Override void untag(CoreSession session, String docId, String label, String username); @Override boolean canUntag(CoreSession session, String docId, String label); @Override Set<String> getTags(CoreSession session, String docId); @Override List<Tag> getDocumentTags(CoreSession session, String docId, String username); @Override List<Tag> getDocumentTags(CoreSession session, String docId, String username, boolean useCore); @Override void removeTags(CoreSession session, String docId); @Override void copyTags(CoreSession session, String srcDocId, String dstDocId); @Override void replaceTags(CoreSession session, String srcDocId, String dstDocId); @Override List<String> getTagDocumentIds(CoreSession session, String label); @Override List<String> getTagDocumentIds(CoreSession session, String label, String username); @Override Set<String> getSuggestions(CoreSession session, String label); @Override List<Tag> getSuggestions(CoreSession session, String label, String username); abstract void doTag(CoreSession session, String docId, String label, String username); abstract void doUntag(CoreSession session, String docId, String label); abstract Set<String> doGetTags(CoreSession session, String docId); abstract void doCopyTags(CoreSession session, String srcDocId, String dstDocId, boolean removeExistingTags); abstract List<String> doGetTagDocumentIds(CoreSession session, String label); abstract Set<String> doGetTagSuggestions(CoreSession session, String label); static final String TAG_SANITIZATION_PROP; }