Class WysiwygController
- java.lang.Object
-
- org.silverpeas.core.contribution.content.wysiwyg.service.WysiwygController
-
public class WysiwygController extends Object
Central service to manage Wysiwyg.
-
-
Field Summary
Fields Modifier and Type Field Description static String
WYSIWYG_CONTEXT
static String
WYSIWYG_WEBSITES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addToIndex(FullIndexEntry indexEntry, ResourceReference pk, String language)
Add all elements attached to object identified by the given index into the given indexstatic Map<String,String>
copy(String oldComponentId, String oldObjectId, String componentId, String objectId, String userId)
Method declarationstatic org.silverpeas.kernel.util.Pair<String,Map<String,String>>
copyDocumentsBetweenTwoResourcesWithSourceContent(ResourceReference sourceRef, ResourceReference targetRef, String sourceContent)
Copies WYSIWYG resources from a source to a target and updating given content with the news resource references.static void
createFileAndAttachment(String textHtml, ResourceReference resource, String userId, String contentLanguage)
Method declaration creation of the file and its attachment.static void
createFileAndAttachment(String textHtml, ResourceReference resource, String context, String userId, String contentLanguage)
Creation of the file and its attachment.static void
createUnindexedFileAndAttachment(String textHtml, ResourceReference resource, String userId, String contentLanguage)
Method declaration creation of the file and its attachment.static void
deleteFile(String componentId, String objectId, String language)
static void
deleteFileAndAttachment(String componentId, String id)
static void
deleteWysiwygAttachments(String componentId, String objectId)
Method declaration remove the file attached.static void
deleteWysiwygAttachmentsOnly(String componentId, String objectId)
La méthode deleteWysiwygAttachments efface tous les attachments de la publication donc pour éviter une éventuelle régression, je crée une nouvelle méthodestatic WysiwygContent
get(String componentId, String objectId, String language)
Gets representation of a wysiwyg content.static WysiwygContent
get(LocalizedContribution contribution)
Gets representation of a wysiwyg content.static List<String>
getEmbeddedAttachmentIds(String content)
Get all Silverpeas Files linked by wysiwyg contentstatic List<ComponentInstLight>
getGalleries()
static List<SimpleDocument>
getImages(String id, String componentId)
Turn over all the images attached according to the parameters id, componentId.static String
getImagesFileName(String objectId)
Method declaration built the name of the images to be attached.protected static WysiwygManager
getManager()
Gets the manager.static String[][]
getWebsiteImages(String path, String componentId)
Get images of the website.static String[][]
getWebsitePages(String path, String componentId)
Method declaration Get html pages of the websitestatic String
getWebsiteRepository()
static String
getWysiwygFileName(String objectId, String currentLanguage)
static String
getWysiwygPath(String componentId, String objectId)
static String
getWysiwygPath(String componentId, String objectId, String language)
static boolean
haveGotWysiwyg(String componentId, String objectId, String language)
static boolean
haveGotWysiwygToDisplay(String componentId, String objectId, String language)
static void
indexEmbeddedLinkedFiles(FullIndexEntry indexEntry, List<String> embeddedAttachmentIds)
Index given embedded linked filesstatic String
load(String componentId, String objectId, String language)
Loads wysiwyg content rendered for edition context.static String
loadFileWebsite(String path, String fileName)
Method declaration return the contents of the file.static String
loadForReadOnly(String componentId, String objectId, String language)
Loads wysiwyg content that will only be read and never be updated.
Indeed, this method will call standard WYSIWYG transformations that are necessary only in readOnly mode.static void
move(String fromComponentId, String fromObjectId, String componentId, String objectId)
static void
save(String textHtml, String componentId, String objectId, String userId, String language, boolean indexIt)
static void
updateFileAndAttachment(String textHtml, String componentId, String objectId, String userId, String language)
Method declaration remove and recreates the file attachedstatic void
updateFileAndAttachment(String textHtml, String componentId, String objectId, String userId, String language, boolean indexIt)
static void
updateWebsite(String cheminFichier, String nomFichier, String contenuFichier)
updateWebsite : creation or update of a file of a website Param = cheminFichier = c:\\j2sdk\\public_html\\WAUploads\\webSite10\\nomSite\\rep1\\rep2 nomFichier = index.html contenuFichier = code du fichier : "...."static void
wysiwygPlaceHaveChanged(String oldComponentId, String oldObjectId, String newComponentId, String newObjectId)
-
-
-
Field Detail
-
WYSIWYG_CONTEXT
public static final String WYSIWYG_CONTEXT
-
WYSIWYG_WEBSITES
public static final String WYSIWYG_WEBSITES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getManager
protected static WysiwygManager getManager()
Gets the manager.- Returns:
-
getImages
public static List<SimpleDocument> getImages(String id, String componentId)
Turn over all the images attached according to the parameters id, componentId.- Parameters:
id
- the id of the object to which this wysiwyg is attached.componentId
- the id of component.- Returns:
- List
-
getWebsiteRepository
public static String getWebsiteRepository()
-
getWebsiteImages
public static String[][] getWebsiteImages(String path, String componentId) throws WysiwygException
Get images of the website.- Parameters:
path
- type String: for example of the directorycomponentId
-- Returns:
- imagesList a table of string[N] with in logical index [N][0] = path name [N][1] = logical name of the file.
- Throws:
WysiwygException
-
getWebsitePages
public static String[][] getWebsitePages(String path, String componentId) throws WysiwygException
Method declaration Get html pages of the website- Parameters:
path
- type String: for example of the directorycomponentId
-- Returns:
- imagesList a table of string[N][2] with in logical index [N][0] = path name [N][1] = logical name of the file.
- Throws:
WysiwygException
-
getWysiwygFileName
public static String getWysiwygFileName(String objectId, String currentLanguage)
-
getImagesFileName
public static String getImagesFileName(String objectId)
Method declaration built the name of the images to be attached.- Parameters:
objectId
- : for example the id of the publication.- Returns:
- fileName String : name of the file
-
createFileAndAttachment
public static void createFileAndAttachment(String textHtml, ResourceReference resource, String context, String userId, String contentLanguage)
Creation of the file and its attachment.- Parameters:
textHtml
- aString
containing the text published by the wysiwyg.resource
- a reference to the resource to which is attached the wysiwyg.context
- the context images/wysiwyg....userId
- the user creating the wysiwyg.contentLanguage
- the language of the content of the wysiwyg.
-
createFileAndAttachment
public static void createFileAndAttachment(String textHtml, ResourceReference resource, String userId, String contentLanguage)
Method declaration creation of the file and its attachment.- Parameters:
textHtml
- aString
containing the text published by the wysiwygresource
- a reference to the resource to which is attached the wysiwyg.userId
- the author of the content.contentLanguage
- the language of the content.
-
createUnindexedFileAndAttachment
public static void createUnindexedFileAndAttachment(String textHtml, ResourceReference resource, String userId, String contentLanguage)
Method declaration creation of the file and its attachment.- Parameters:
textHtml
- aString
containing the text published by the wysiwygresource
- a reference to the resource to which is attached the wysiwyg.userId
- the author of the content.contentLanguage
- the language of the content.
-
addToIndex
public static void addToIndex(FullIndexEntry indexEntry, ResourceReference pk, String language)
Add all elements attached to object identified by the given index into the given index- Parameters:
indexEntry
- the index of the related resource.pk
- the primary key of the container of the wysiwyg.language
- the language.
-
updateFileAndAttachment
public static void updateFileAndAttachment(String textHtml, String componentId, String objectId, String userId, String language)
Method declaration remove and recreates the file attached- Parameters:
textHtml
- String : contains the text published by the wysiwygcomponentId
- String : the id of component.objectId
- String : for example the id of the publication.userId
-language
- the language of the content.
-
updateFileAndAttachment
public static void updateFileAndAttachment(String textHtml, String componentId, String objectId, String userId, String language, boolean indexIt)
-
save
public static void save(String textHtml, String componentId, String objectId, String userId, String language, boolean indexIt)
-
deleteWysiwygAttachments
public static void deleteWysiwygAttachments(String componentId, String objectId)
Method declaration remove the file attached.- Parameters:
componentId
- String : the id of component.objectId
- String : for example the id of the publication.
-
deleteWysiwygAttachmentsOnly
public static void deleteWysiwygAttachmentsOnly(String componentId, String objectId) throws WysiwygException
La méthode deleteWysiwygAttachments efface tous les attachments de la publication donc pour éviter une éventuelle régression, je crée une nouvelle méthode- Parameters:
componentId
-objectId
-- Throws:
WysiwygException
-
get
public static WysiwygContent get(LocalizedContribution contribution)
Gets representation of a wysiwyg content.- Parameters:
contribution
- the localized contribution for which the WYSIWYG content has to be get.- Returns:
WysiwygContent
instance.
-
get
public static WysiwygContent get(String componentId, String objectId, String language)
Gets representation of a wysiwyg content.- Parameters:
componentId
- String : the id of component.objectId
- String : for example the id of the publication.language
- the language of the content.- Returns:
WysiwygContent
instance.
-
load
public static String load(String componentId, String objectId, String language)
Loads wysiwyg content rendered for edition context.- Parameters:
componentId
- String : the id of component.objectId
- String : for example the id of the publication.language
- the language of the content.- Returns:
- text : the contents of the file attached.
-
loadForReadOnly
public static String loadForReadOnly(String componentId, String objectId, String language)
Loads wysiwyg content that will only be read and never be updated.
Indeed, this method will call standard WYSIWYG transformations that are necessary only in readOnly mode. The resizing of image attachments for example.- Parameters:
componentId
- String : the id of component.objectId
- String : for example the id of the publication.language
- the language of the content.- Returns:
- text : the contents of the file attached.
-
getEmbeddedAttachmentIds
public static List<String> getEmbeddedAttachmentIds(String content)
Get all Silverpeas Files linked by wysiwyg content- Parameters:
content
-- Returns:
-
loadFileWebsite
public static String loadFileWebsite(String path, String fileName) throws WysiwygException
Method declaration return the contents of the file.- Parameters:
fileName
- String : name of the filepath
- String : the path of the file- Returns:
- text : the contents of the file attached.
- Throws:
WysiwygException
-
haveGotWysiwygToDisplay
public static boolean haveGotWysiwygToDisplay(String componentId, String objectId, String language)
-
haveGotWysiwyg
public static boolean haveGotWysiwyg(String componentId, String objectId, String language)
-
updateWebsite
public static void updateWebsite(String cheminFichier, String nomFichier, String contenuFichier) throws WysiwygException
updateWebsite : creation or update of a file of a website Param = cheminFichier = c:\\j2sdk\\public_html\\WAUploads\\webSite10\\nomSite\\rep1\\rep2 nomFichier = index.html contenuFichier = code du fichier : "...." - Parameters:
cheminFichier
-contenuFichier
-nomFichier
-- Throws:
WysiwygException
-
copy
public static Map<String,String> copy(String oldComponentId, String oldObjectId, String componentId, String objectId, String userId)
Method declaration- Parameters:
oldComponentId
-oldObjectId
-componentId
-objectId
-userId
-
-
copyDocumentsBetweenTwoResourcesWithSourceContent
public static org.silverpeas.kernel.util.Pair<String,Map<String,String>> copyDocumentsBetweenTwoResourcesWithSourceContent(ResourceReference sourceRef, ResourceReference targetRef, String sourceContent)
Copies WYSIWYG resources from a source to a target and updating given content with the news resource references.- Parameters:
sourceRef
- the reference of the source.targetRef
- the reference of the target.sourceContent
- the content to update- Returns:
- a pair containing on left the updated content and on right a map containing the correspondance between old images and the new ones.
-
move
public static void move(String fromComponentId, String fromObjectId, String componentId, String objectId)
-
wysiwygPlaceHaveChanged
public static void wysiwygPlaceHaveChanged(String oldComponentId, String oldObjectId, String newComponentId, String newObjectId)
-
getWysiwygPath
public static String getWysiwygPath(String componentId, String objectId, String language)
-
getGalleries
public static List<ComponentInstLight> getGalleries()
-
indexEmbeddedLinkedFiles
public static void indexEmbeddedLinkedFiles(FullIndexEntry indexEntry, List<String> embeddedAttachmentIds)
Index given embedded linked files- Parameters:
indexEntry
- index entry to updateembeddedAttachmentIds
- embedded linked files ids
-
-