Package org.ametys.web.url
Class UrlPreviewComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.web.url.UrlPreviewComponent
-
- All Implemented Interfaces:
LogEnabled,Component,Contextualizable
public class UrlPreviewComponent extends AbstractLogEnabled implements Component, Contextualizable
Component to parse a HTML page to get its meta for preview
-
-
Constructor Summary
Constructors Constructor Description UrlPreviewComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcontextualize(Context context)InputStreamconvertIcoToPng(InputStream is)Convert an file.ico into a file.pngStringgetFavicon(String url)Fetch and parse the HTML page at given url to get the favicon urlUrlPreviewgetUrlPreview(String url, String lang)Fetch and parse the HTML page at given url to get theUrlPreviewMap<String,String>parseUrl(String url, String lang)Fetch and parse the HTML page at given url for preview-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
UrlPreviewComponent
public UrlPreviewComponent()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
getUrlPreview
public UrlPreview getUrlPreview(String url, String lang) throws HttpStatusException, IOException
Fetch and parse the HTML page at given url to get theUrlPreview- Parameters:
url- the url to parselang- the language- Returns:
- the
UrlPreview - Throws:
HttpStatusException- if the HTTP request resulted in a not OK HTTP response.IOException- if an error occured while parsing HTML page
-
getFavicon
public String getFavicon(String url) throws IOException
Fetch and parse the HTML page at given url to get the favicon url- Parameters:
url- the url to parse- Returns:
- the favicon url or null if not found
- Throws:
HttpStatusException- if the HTTP request resulted in a not OK HTTP response.IOException- if an error occured while parsing HTML page
-
convertIcoToPng
public InputStream convertIcoToPng(InputStream is) throws IOException
Convert an file.ico into a file.png- Parameters:
is- the input stream of the file.ico- Returns:
- the input stream of the file.png
- Throws:
IOException- if failed to convert .ico
-
-