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 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 voidcontextualize(Context context)voidendElement(String uri, String loc, String raw)voidinitialize()protected booleanprocessLink(String uri, String loc, String raw, Attributes attrs)Process a link tag.voidservice(ServiceManager serviceManager)voidstartDocument()voidstartElement(String uri, String loc, String raw, Attributes attrs)protected ResourcestoreAttachment(String initialFileName, InputStream is, String mimeType, Date lastModified)Store a file as attachment.protected booleanstoreExternalFile(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
-
-
-
-
Constructor Detail
-
UploadedLinksHTMLEditionHandler
public UploadedLinksHTMLEditionHandler()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Overrides:
contextualizein classAbstractHTMLEditionHandler- Throws:
ContextException
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classAbstractHTMLEditionHandler- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classAbstractHTMLEditionHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String loc, String raw, Attributes attrs) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classAbstractHTMLEditionHandler- Throws:
SAXException
-
endElement
public void endElement(String uri, String loc, String raw) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin 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.
-
-