Class WysiwygManager
- java.lang.Object
-
- org.silverpeas.core.contribution.content.wysiwyg.service.WysiwygManager
-
- All Implemented Interfaces:
WysiwygContentRepository
@Singleton @Service public class WysiwygManager extends Object implements WysiwygContentRepository
Central service to manage Wysiwyg.
-
-
Field Summary
Fields Modifier and Type Field Description static String
WYSIWYG_CONTEXT
static String
WYSIWYG_IMAGES
static String
WYSIWYG_WEBSITES
-
Constructor Summary
Constructors Modifier Constructor Description protected
WysiwygManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToIndex(FullIndexEntry indexEntry, ResourceReference pk, String language)
Add all elements attached to object identified by the given index into the given indexMap<String,String>
copy(String oldComponentId, String oldObjectId, String componentId, String objectId, String userId)
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.protected File
createFile(String filePath, String fileName, String fileContent)
Creation or update of a filevoid
createFileAndAttachment(WysiwygContent content)
Creation of the file and its attachment.void
createFileAndAttachment(WysiwygContent content, String context)
Creation of the file and its attachment.String
createPath(String componentId, String context)
To create path.void
createUnindexedFileAndAttachment(WysiwygContent content)
Creation of the file and its attachment but without indexing it.void
delete(WysiwygContent content)
Deletes the specified content in the repository.void
deleteByContribution(Contribution contribution)
Deletes all the contents of the specified contribution in the repository.void
deleteFile(String componentId, String objectId, String language)
void
deleteFileAndAttachment(String componentId, String id)
void
deleteWysiwygAttachments(String componentId, String objectId)
Method declaration remove the file attached.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éthodeWysiwygContent
getByContribution(LocalizedContribution contribution)
Load wysiwyg content.List<String>
getEmbeddedAttachmentIds(String content)
Get all Silverpeas Files linked by wysiwyg contentList<ComponentInstLight>
getGalleries()
List<SimpleDocument>
getImages(String id, String componentId)
Turn over all the images attached according to the parameters id, componentId.String
getImagesFileName(String objectId)
Method declaration built the name of the images to be attached.String
getOldWysiwygFileName(String objectId)
Build the name of the file to be attached.String[][]
getWebsiteImages(String path, String componentId)
Get images of the website.String[][]
getWebsitePages(String path, String componentId)
Method declaration Get html pages of the websiteString
getWebsiteRepository()
String
getWysiwygFileName(String objectId, String lang)
String
getWysiwygPath(String componentId, String objectId)
String
getWysiwygPath(String componentId, String objectId, String language)
boolean
haveGotWysiwyg(LocalizedContribution contribution)
boolean
haveGotWysiwygToDisplay(LocalizedContribution contribution)
void
indexEmbeddedLinkedFiles(FullIndexEntry indexEntry, List<String> embeddedAttachmentIds)
Index given embedded linked filesString
loadFileWebsite(String path, String fileName)
Method declaration return the contents of the file.void
move(String fromComponentId, String fromObjectId, String componentId, String objectId)
void
save(WysiwygContent content)
Saves the specified content into the repository so that it can be get later.void
updateFileAndAttachment(WysiwygContent content)
void
updateWebsite(String filePath, String fileName, String fileContent)
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 : "...."void
wysiwygPlaceHaveChanged(String oldComponentId, String oldObjectId, String newComponentId, String newObjectId)
-
-
-
Field Detail
-
WYSIWYG_CONTEXT
public static final String WYSIWYG_CONTEXT
-
WYSIWYG_IMAGES
public static final String WYSIWYG_IMAGES
- See Also:
- Constant Field Values
-
WYSIWYG_WEBSITES
public static final String WYSIWYG_WEBSITES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getImages
public 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 String getWebsiteRepository()
-
getWebsiteImages
public 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 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
-
getOldWysiwygFileName
public String getOldWysiwygFileName(String objectId)
Build the name of the file to be attached.- Parameters:
objectId
- : for example the id of the publication.- Returns:
- the name of the file
-
getImagesFileName
public 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
-
delete
public void delete(WysiwygContent content)
Description copied from interface:WysiwygContentRepository
Deletes the specified content in the repository.- Specified by:
delete
in interfaceWysiwygContentRepository
- Parameters:
content
- the content to remove.
-
deleteByContribution
public void deleteByContribution(Contribution contribution)
Description copied from interface:WysiwygContentRepository
Deletes all the contents of the specified contribution in the repository. If the contribution has several WYSIWYG contents, that is one per localization for example, then all of those contents will be deleted. Otherwise only the single WYSIWYG content of the contribution, whatever its localization will be deleted.- Specified by:
deleteByContribution
in interfaceWysiwygContentRepository
- Parameters:
contribution
- the contribution for which all the WYSIWYG contents will be deleted.
-
createFileAndAttachment
public void createFileAndAttachment(WysiwygContent content, String context)
Creation of the file and its attachment.- Parameters:
content
- the WYSIWYG content to create.context
- the context images/wysiwyg....
-
createFileAndAttachment
public void createFileAndAttachment(WysiwygContent content)
Creation of the file and its attachment.- Parameters:
content
- the WYSIWYG content to create.
-
createUnindexedFileAndAttachment
public void createUnindexedFileAndAttachment(WysiwygContent content)
Creation of the file and its attachment but without indexing it.- Parameters:
content
- the WYSIWYG content to create.
-
addToIndex
public 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 void updateFileAndAttachment(WysiwygContent content)
-
save
public void save(WysiwygContent content)
Description copied from interface:WysiwygContentRepository
Saves the specified content into the repository so that it can be get later.- Specified by:
save
in interfaceWysiwygContentRepository
- Parameters:
content
- the content to save.
-
deleteWysiwygAttachments
public 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 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
-
getByContribution
public WysiwygContent getByContribution(LocalizedContribution contribution)
Load wysiwyg content.- Specified by:
getByContribution
in interfaceWysiwygContentRepository
- Parameters:
contribution
- the localized contribution for which the content has to be loaded.- Returns:
- the wysiwyg content.
-
getEmbeddedAttachmentIds
public List<String> getEmbeddedAttachmentIds(String content)
Get all Silverpeas Files linked by wysiwyg content- Parameters:
content
-- Returns:
-
loadFileWebsite
public 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 boolean haveGotWysiwygToDisplay(LocalizedContribution contribution)
-
haveGotWysiwyg
public boolean haveGotWysiwyg(LocalizedContribution contribution)
-
updateWebsite
public void updateWebsite(String filePath, String fileName, String fileContent) 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:
filePath
-fileContent
-fileName
-- Throws:
WysiwygException
-
createFile
protected File createFile(String filePath, String fileName, String fileContent) throws WysiwygException
Creation or update of a file- Parameters:
filePath
- the path to the directory containing the file.fileName
- the name of the file.fileContent
- the content of the file.- Returns:
- the created file.
- Throws:
WysiwygException
-
copy
public Map<String,String> copy(String oldComponentId, String oldObjectId, String componentId, String objectId, String userId)
-
copyDocumentsBetweenTwoResourcesWithSourceContent
public 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 void move(String fromComponentId, String fromObjectId, String componentId, String objectId)
-
wysiwygPlaceHaveChanged
public void wysiwygPlaceHaveChanged(String oldComponentId, String oldObjectId, String newComponentId, String newObjectId)
-
getGalleries
public List<ComponentInstLight> getGalleries()
-
indexEmbeddedLinkedFiles
public void indexEmbeddedLinkedFiles(FullIndexEntry indexEntry, List<String> embeddedAttachmentIds)
Index given embedded linked files- Parameters:
indexEntry
- index entry to updateembeddedAttachmentIds
- embedded linked files ids
-
-