Package org.ametys.web.editor
Class UploadedLinksHTMLEditionHandler
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.transformation.htmledition.AbstractHTMLEditionHandler
-
- org.ametys.web.editor.UploadedLinksHTMLEditionHandler
-
- All Implemented Interfaces:
Initializable
,Contextualizable
,LogEnabled
,Serviceable
,ContentHandler
,LexicalHandler
public class UploadedLinksHTMLEditionHandler extends AbstractHTMLEditionHandler implements Initializable
This transformer stores linked files as attachment from the incoming HTML.
-
-
Field Summary
Fields Modifier and Type Field Description private Context
_cocoonContext
private Set<String>
_storedFileExtensions
private boolean
_storeFileLinks
private boolean
_tagToIgnore
private CurrentUserProvider
_userProvider
-
Fields inherited from class org.ametys.cms.transformation.htmledition.AbstractHTMLEditionHandler
_contentHandler, _context, _lexicalHandler, _manager
-
-
Constructor Summary
Constructors Constructor Description UploadedLinksHTMLEditionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_copyLinkAttributes(Attributes attrs, AttributesImpl newAttrs)
void
contextualize(Context context)
void
endElement(String uri, String loc, String raw)
void
initialize()
protected boolean
processLink(String uri, String loc, String raw, Attributes attrs)
Process a link tag.void
service(ServiceManager serviceManager)
void
startDocument()
void
startElement(String uri, String loc, String raw, Attributes attrs)
protected Resource
storeAttachment(String initialFileName, InputStream is, String mimeType, Date lastModified)
Store a file as attachment.protected boolean
storeExternalFile(String fileName)
Test if the external file is to be stored as a local resource.-
Methods inherited from class org.ametys.cms.transformation.htmledition.AbstractHTMLEditionHandler
characters, comment, endCDATA, endDocument, endDTD, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setContentHandler, setDocumentLocator, setLexicalHandler, skippedEntity, startCDATA, startDTD, startEntity, startPrefixMapping
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_userProvider
private CurrentUserProvider _userProvider
-
_cocoonContext
private Context _cocoonContext
-
_tagToIgnore
private boolean _tagToIgnore
-
_storeFileLinks
private boolean _storeFileLinks
-
_storedFileExtensions
private Set<String> _storedFileExtensions
-
-
Constructor Detail
-
UploadedLinksHTMLEditionHandler
public UploadedLinksHTMLEditionHandler()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Overrides:
contextualize
in classAbstractHTMLEditionHandler
- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractHTMLEditionHandler
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classAbstractHTMLEditionHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String loc, String raw, Attributes attrs) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classAbstractHTMLEditionHandler
- Throws:
SAXException
-
endElement
public void endElement(String uri, String loc, String raw) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classAbstractHTMLEditionHandler
- Throws:
SAXException
-
processLink
protected boolean processLink(String uri, String loc, String raw, Attributes attrs)
Process a link tag.- Parameters:
uri
- the namespace URI.loc
- the local name (without prefix).raw
- the qualified name (with prefix).attrs
- the element attributes.- Returns:
- true to process the link, false otherwise.
-
storeExternalFile
protected boolean storeExternalFile(String fileName)
Test if the external file is to be stored as a local resource.- Parameters:
fileName
- the file name.- Returns:
- true if the external file is to be stored, false otherwise.
-
storeAttachment
protected Resource storeAttachment(String initialFileName, InputStream is, String mimeType, Date lastModified)
Store a file as attachment.- Parameters:
initialFileName
- the initial file name.is
- an input stream on the file.mimeType
- the file mime type.lastModified
- the last modification date.- Returns:
- the final file name.
-
_copyLinkAttributes
private void _copyLinkAttributes(Attributes attrs, AttributesImpl newAttrs)
-
-