@Component @Named(value="annotations") @Singleton public class AnnotationScriptService extends Object implements org.xwiki.script.service.ScriptService
Constructor and Description |
---|
AnnotationScriptService() |
Modifier and Type | Method and Description |
---|---|
boolean |
addAnnotation(String target,
String selection,
String selectionContext,
int offset,
String author,
Map<String,Object> metadata)
Adds an the specified annotation for the specified target.
|
boolean |
canAddAnnotation(DocumentReference reference)
Checks if the current user can add an annotation on the document given by the reference.
|
boolean |
canAddAnnotation(String wiki,
String space,
String page)
Deprecated.
since 7.2M3, use
canAddAnnotation(DocumentReference) instead |
boolean |
canEditAnnotation(String annotationId,
DocumentReference reference)
Checks if the current user can edit an annotation on the document given by wiki, space and page.
|
boolean |
canEditAnnotation(String annotationId,
String wiki,
String space,
String page)
Deprecated.
since 7.2M3, use
canEditAnnotation(String, DocumentReference) instead |
String |
getAnnotatedHTML(String sourceReference)
Returns the XHTML of the requested source, along with annotations inserted as
span elements inside it. |
String |
getAnnotatedRenderedContent(String sourceReference,
String sourceSyntax,
String outputSyntax,
Collection<Annotation> annotations)
Returns result obtained by rendering with annotations markers the source referenced by the
sourceReference parsed in sourceSyntax . |
Annotation |
getAnnotation(EntityReference reference,
String id)
Returns the annotation identified by
id on the specified target. |
Annotation |
getAnnotation(String target,
String id)
Returns the annotation identified by
id on the specified target. |
Collection<Annotation> |
getAnnotations(String target)
Returns all the annotations on the passed content.
|
Collection<Annotation> |
getValidAnnotations(String target)
Shortcut function to get all annotations which are valid on the specified target, regardless of the updates the
document and its annotations suffered from creation ('safe' or 'updated' state).
|
boolean |
removeAnnotation(String target,
String annotationID)
Remove an annotation given by its identifier, which should be unique among all annotations on the same target.
|
boolean |
updateAnnotation(String target,
Annotation annotation)
Updates the passed annotation with the new values.
|
public boolean addAnnotation(String target, String selection, String selectionContext, int offset, String author, Map<String,Object> metadata)
target
- serialized reference of the target of the annotationselection
- HTML selection concerned by annotationsselectionContext
- HTML selection contextoffset
- offset of the selection in contextauthor
- the author of the annotationmetadata
- annotation metadata, as key, value pairstrue
if the adding succeeds, false
if an exception occurs and the exception is saved on
the xwiki contextpublic String getAnnotatedHTML(String sourceReference)
span
elements inside it.
It's a particular case of getAnnotatedRenderedContent(String, String, String, Collection)
for
unspecified input syntax, xhtml/1.0
output syntax and the list of annotations returned by
getValidAnnotations(String)
for this source reference.sourceReference
- reference to the source to be rendered in XHTML with annotationsnull
if an exception occurs and the exception is saved on the
xwiki contextgetAnnotatedRenderedContent(String, String, String, Collection)
,
AnnotationService.getAnnotatedHTML(String)
public String getAnnotatedRenderedContent(String sourceReference, String sourceSyntax, String outputSyntax, Collection<Annotation> annotations)
sourceReference
parsed in sourceSyntax
. The list of annotations to be added markers for is passed
in the annotations
parameter. Note that no test is done on the actual target of the annotations in the
passed list, they will all be rendered, as long as their selected text and context can be identified in the
content.sourceReference
- the reference to the source to be rendered in XHTML with annotationssourceSyntax
- the syntax to parse the source in. If this parameter is null, the default source syntax will
be used, as returned by the target IO service.outputSyntax
- the syntax to render in (e.g. "xhtml/1.0")annotations
- the annotations to render on the content referred by the sourceReference
. Can be the
whole set of annotations on that source or a subset, filtered by various criteriaAnnotationService.getAnnotatedRenderedContent(String, String, String, Collection)
public Annotation getAnnotation(String target, String id)
id
on the specified target.target
- the serialized reference to the content on which the annotation is addedid
- the identifier of the annotationid
, or null
if an exception occurs and the exception is
saved on the xwiki contextAnnotationService.getAnnotation(String, String)
public Annotation getAnnotation(EntityReference reference, String id)
id
on the specified target.reference
- the reference to the content on which the annotation is addedid
- the identifier of the annotationid
, or null
if an exception occurs and the exception is
saved on the xwiki contextAnnotationService.getAnnotation(String, String)
public Collection<Annotation> getAnnotations(String target)
target
- the string serialized reference to the content for which to get the annotationsnull
if an exception occurs and the
exception is saved on the xwiki contextAnnotationService.getAnnotations(String)
public Collection<Annotation> getValidAnnotations(String target)
target
- the string serialized reference to the content for which to get the annotationsnull
if an exception occurs and the
exception is saved on the xwiki contextAnnotationState
,
AnnotationService.getValidAnnotations(String)
public boolean removeAnnotation(String target, String annotationID)
target
- the string serialized reference to the content on which the annotation is addedannotationID
- annotation identifiertrue
if removing succeeds, false
if an exception occurs and the exception is saved on the
xwiki contextAnnotationService.removeAnnotation(String, String)
public boolean updateAnnotation(String target, Annotation annotation)
target
- the string serialized reference to the content on which the annotation is addedannotation
- the new description of the annotation to update, with a valid idtrue
if update succeeds, false
if an exception occurs and the exception is saved on the
xwiki contextAnnotationService.updateAnnotation(String, Annotation)
@Deprecated public boolean canEditAnnotation(String annotationId, String wiki, String space, String page)
canEditAnnotation(String, DocumentReference)
insteadannotationId
- the id of the annotation to editwiki
- the wiki of the document where the annotation is addedspace
- the space of the document where the annotation is addedpage
- the document pagetrue
if the current user can edit the annotation identified by the id on the specified document,
false
otherwisepublic boolean canEditAnnotation(String annotationId, DocumentReference reference)
annotationId
- the id of the annotation to editreference
- the reference of the document where the annotation is addedtrue
if the current user can edit the annotation identified by the id on the specified document,
false
otherwise@Deprecated public boolean canAddAnnotation(String wiki, String space, String page)
canAddAnnotation(DocumentReference)
insteadwiki
- the wiki of the document where the annotation is addedspace
- the space of the document where the annotation is addedpage
- the document pagetrue
if the current user can add an annotation on the specified document, false
otherwisecanEditAnnotation(String, String, String, String)
public boolean canAddAnnotation(DocumentReference reference)
reference
- the reference of the document where the annotation is addedtrue
if the current user can add an annotation on the specified document, false
otherwisecanEditAnnotation(String, String, String, String)
Copyright © 2004–2021 XWiki. All rights reserved.