@Test @Deploy("org.nuxeo.ecm.tag.tests:test-no-tag-sanitization-contrib.xml") public void testNoSanitization() throws Exception { DocumentModel file = session.createDocumentModel("/", "foo", "File"); file.setPropertyValue("dc:title", "File"); file = session.createDocument(file); session.save(); String fileId = file.getId(); List<String> charToTests = Arrays.asList(" ", "\\", "/", "'"); for (String charToTest : charToTests) { String tagLabel = charToTest + "my" + charToTest + "tag" + charToTest; String message = "tag " + tagLabel + " is invalid"; tagService.tag(session, fileId, tagLabel); session.save(); Set<String> tags = tagService.getTags(session, fileId); assertTrue(message, tags.contains(tagLabel)); Set<String> suggestions = tagService.getSuggestions(session, "%tag" + charToTest); assertTrue(message, suggestions.contains(tagLabel)); suggestions = tagService.getSuggestions(session, charToTest + "my"); assertTrue(message, suggestions.contains(tagLabel)); List<String> taggedDocIds = tagService.getTagDocumentIds(session, tagLabel); assertEquals(message, singletonList(fileId), taggedDocIds); tagService.untag(session, fileId, tagLabel); session.save(); tags = tagService.getTags(session, fileId); assertTrue(message, tags.isEmpty()); maybeSleep(); } }
@SuppressWarnings("unchecked") protected List<Map<String, Serializable>> getTags(DocumentModel docModel) { if (docModel.hasFacet(TAG_FACET)) { return (List<Map<String, Serializable>>) docModel.getPropertyValue(TAG_LIST); } else { return new ArrayList<>(); } }
FacetedTagService extends AbstractTagService { @SuppressWarnings("unchecked") protected List<Map<String, Serializable>> getTags(DocumentModel docModel) { if (docModel.hasFacet(TAG_FACET)) { return (List<Map<String, Serializable>>) docModel.getPropertyValue(TAG_LIST); } else { return new ArrayList<>(); } } }
FacetedTagService extends AbstractTagService { @SuppressWarnings("unchecked") protected List<Map<String, Serializable>> getTags(DocumentModel docModel) { if (docModel.hasFacet(TAG_FACET)) { return (List<Map<String, Serializable>>) docModel.getPropertyValue(TAG_LIST); } else { return new ArrayList<>(); } }  }
FacetedTagService extends AbstractTagService { @SuppressWarnings("unchecked") protected List<Map<String, Serializable>> getTags(DocumentModel docModel) { if (docModel.hasFacet(TAG_FACET)) { return (List<Map<String, Serializable>>) docModel.getPropertyValue(TAG_LIST); } else { return new ArrayList<>(); } }  @Override boolean hasFeature(Feature feature); @Override boolean supportsTag(CoreSession session, String docId); @Override void doTag(CoreSession session, String docId, String label, String username); @Override void doUntag(CoreSession session, String docId, String label); @Override boolean canUntag(CoreSession session, String docId, String label); @Override Set<String> doGetTags(CoreSession session, String docId); @Override void doCopyTags(CoreSession session, String srcDocId, String dstDocId, boolean removeExistingTags); @Override List<String> doGetTagDocumentIds(CoreSession session, String label); @Override Set<String> doGetTagSuggestions(CoreSession session, String label); @Override List<Tag> getTagCloud(CoreSession session, String docId, String username, Boolean normalize); }
FacetedTagService extends AbstractTagService { @SuppressWarnings("unchecked") protected List<Map<String, Serializable>> getTags(DocumentModel docModel) { if (docModel.hasFacet(TAG_FACET)) { return (List<Map<String, Serializable>>) docModel.getPropertyValue(TAG_LIST); } else { return new ArrayList<>(); } }  @Override boolean hasFeature(Feature feature); @Override boolean supportsTag(CoreSession session, String docId); @Override void doTag(CoreSession session, String docId, String label, String username); @Override void doUntag(CoreSession session, String docId, String label); @Override boolean canUntag(CoreSession session, String docId, String label); @Override Set<String> doGetTags(CoreSession session, String docId); @Override void doCopyTags(CoreSession session, String srcDocId, String dstDocId, boolean removeExistingTags); @Override List<String> doGetTagDocumentIds(CoreSession session, String label); @Override Set<String> doGetTagSuggestions(CoreSession session, String label); @Override List<Tag> getTagCloud(CoreSession session, String docId, String username, Boolean normalize); static final String LABEL_PROPERTY; static final String USERNAME_PROPERTY; static final String DISABLE_VERSIONING; }