public String getPatternFor(String mainTabId) { URLPolicyService service = Framework.getService(URLPolicyService.class); // FIXME: find some way to reference the pattern in the action, // assume the pattern will be the same than the default one for // now, or use the default one. if (!WebActions.DOCUMENTS_MAIN_TAB_ID.equals(mainTabId) && service.hasPattern(mainTabId)) { return mainTabId; } return service.getDefaultPatternName(); }
/** * Use of URLPolicy service to find absolute URL from document. * * @param doc * @param blobPropertyName * @return absolute URL */ private static String callWebIdCodec(DocumentModel doc, String blobPropertyName) { String url = StringUtils.EMPTY; try { Map<String, String> parameters = new HashMap<String, String>(); if ("Picture".equals(doc.getType())) { if (StringUtils.isNotBlank(blobPropertyName)) { parameters.put(WebIdCodec.CONTENT_PARAM, StringUtils.replace(blobPropertyName, ":content", StringUtils.EMPTY)); } } ToutaticeDocumentLocation webIdDocLoc = new ToutaticeDocumentLocation(doc); DocumentView docView = new DocumentViewImpl(webIdDocLoc, null, parameters); url = getURLPolicyService().getUrlFromDocumentView(WEBID_PATTERN, docView, BaseURL.getBaseURL()); } catch (NuxeoException e) { log.error("Erreur génération webid " + e); } catch (Exception e) { log.error("Erreur génération webid " + e); } return url; }
protected String getCurrentMainTabFromRequest() { URLPolicyService service = Framework.getService(URLPolicyService.class); ServletRequest request = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); if (request instanceof HttpServletRequest) { DocumentView docView = service.getDocumentViewFromRequest((HttpServletRequest) request); if (docView == null) { return null; } String tabIds = docView.getParameter(WebActions.TAB_IDS_PARAMETER); String mainTabId = docView.getParameter(WebActions.MAIN_TAB_ID_PARAMETER); if (mainTabId != null && !mainTabId.isEmpty()) { tabIds = mainTabId; } if (tabIds != null && tabIds.contains(WebActions.MAIN_TABS_CATEGORY)) { String[] encodedActions = tabIds.split(","); for (String encodedAction : encodedActions) { if (encodedAction.startsWith(WebActions.MAIN_TABS_CATEGORY)) { String[] actionInfo = encodedAction.split(":"); if (actionInfo != null && actionInfo.length > 1) { return actionInfo[1]; } } } } } return null; }
/** * Calls the {@link ReloadService#flush()} method, that should trigger the reset of a bunch of caches shared by all * users, and sends a Seam event to propagate this to other Seam components. * <p> * Does nothing if not in dev mode. * <p> * The reload service flush method should already be triggerd by install/uninstall of modules. This method makes it * possible to force it again, and to propagate it to the Seam layer for current user. * * @see #resetSeamComponentsCaches() * @see #shouldResetCache(Long) * @see #shouldResetCache(TimestampedService, Long) * @since 5.6 */ public String doFlush() { if (Framework.isDevModeSet()) { FacesContext faces = FacesContext.getCurrentInstance(); String viewId = faces.getViewRoot().getViewId(); URLPolicyService service = Framework.getService(URLPolicyService.class); String outcome = service.getOutcomeFromViewId(viewId, null); ReloadService srv = Framework.getService(ReloadService.class); srv.flush(); Events.instance().raiseEvent(EventNames.FLUSH_EVENT); // return the current view id otherwise an error appears in logs // because navigation cache needs to be rebuilt after execution return outcome; } return null; }
/** * @since 5.7 */ public String getPreviewPopupURL(DocumentModel doc, boolean newConversation) { DocumentLocation docLocation = new DocumentLocationImpl(doc.getRepositoryName(), doc.getRef()); DocumentView docView = new DocumentViewImpl(docLocation, PREVIEW_POPUP_VIEW); docView.setPatternName("id"); URLPolicyService urlPolicyService = Framework.getService(URLPolicyService.class); String url = urlPolicyService.getUrlFromDocumentView(docView, null); if (!newConversation) { url = RestHelper.addCurrentConversationParameters(url); } return VirtualHostHelper.getContextPathProperty() + "/" + url; }