private void doPage(ActionRequest request, ActionResponse response) { // System.out.println("[BrowserPortlet.doPage]"); String url = request.getParameter("url"); WebPage _page = new WebPage(); URI _access = new URI(); _access.setEffectiveURI(url); _page.setAccess(_access); _page.setContextCreation("PortletWebBrowser"); _page.setCreation(new Date()); // TODO pour l'instant on se fout du contenu de la page // _page.setHTMLContent(HTMLmanager.getCleanHTML(url)); HTMLPage page = new HTMLPage(); page.setURL(url); try { page.extractTitle(); } catch (ParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } String title = page.getTitle(); // String title = HTMLmanager.getTitlePage(url) ; _page.setLabel(title); _page.setPrincipalURL(_access); _page.setRepresentsResource(_access); this.sendEvent("page", _page, response); // response.setRenderParameter("url", url); request.getPortletSession().setAttribute("current_url", url); }
private void doSelection(ActionRequest request, ActionResponse response) { // System.out.println("[BrowserPortlet.doSelection]"); String url = request.getParameter("url"); HTMLPage page = new HTMLPage(); page.setURL("url"); try { page.extractTitle(); } catch (ParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } String title = page.getTitle(); // String title = HTMLmanager.getTitlePage(url) ; SelectionHTML _selection_html = new SelectionHTML(); _selection_html.setHTMLContent(request.getParameter("text_selection")); _selection_html.setXpointerBegin(request.getParameter("xpointer_start")); _selection_html.setXpointerEnd(request.getParameter("xpointer_end")); _selection_html.setContextCreation("PortletWebBrowser"); _selection_html.setCreation(new Date()); _selection_html.setLabel("sélection de : " + title); // _selection_html.setRepresentsResource(representsResource); WebPage selectionOrigin = new WebPage(); URI _access = new URI(); _access.setEffectiveURI(url); selectionOrigin.setAccess(_access); selectionOrigin.setContextCreation("PortletWebBrowser"); selectionOrigin.setCreation(new Date()); // TODO // Pas la peine de sauver tout le html pour l'instant // selectionOrigin.setHTMLContent(HTMLmanager.getCleanHTML(url)); selectionOrigin.setLabel(title); selectionOrigin.setPrincipalURL(_access); selectionOrigin.setRepresentsResource(_access); _selection_html.setSelectionOrigin(selectionOrigin); HighlightSelectionHTML _highLight = new HighlightSelectionHTML(); _highLight.setSelection(_selection_html); _highLight.setStyle("background-color:yellow;"); _highLight.setInfo("sélection en attente d'annotation"); _highLight.setId(generateHighlightId(request)); // _selection_html.setClassname("new_selection"); this.sendEvent("selection", _highLight, response); // ajouter la nouvelle sélection à la liste courante ArrayList<HighlightSelectionHTML> _highlights; if (request.getPortletSession().getAttribute("highlights") != null) { _highlights = (ArrayList<HighlightSelectionHTML>) request.getPortletSession().getAttribute("highlights"); } else _highlights = new ArrayList<HighlightSelectionHTML>(); _highlights.add(_highLight); request.getPortletSession().setAttribute("highlights", _highlights); // response.setRenderParameter("url", url); request.getPortletSession().setAttribute("current_url", url); }