/** * Creates a restfull compliant link to the editor for editing a content, adding a content or * managing contents. Example : Add Content : isEditable = false, isNew = true, itemPath = the * parent folder path Edit Content : isEditable = true, isNew = false, itemPath = the content path * Manage Contents = isEditable = false, isNew = false, itemPath = the folder path * * @param itemPath * @param isEditable * @param isNew * @return */ public static String getEditLink(String itemPath, boolean isEditable, boolean isNew) { PortalRequestContext pContext = Util.getPortalRequestContext(); String backto = pContext.getRequestURI(); WCMConfigurationService configurationService = Util.getUIPortalApplication().getApplicationComponent(WCMConfigurationService.class); String editorPageURI = configurationService.getRuntimeContextParam( isEditable || isNew ? WCMConfigurationService.EDITOR_PAGE_URI : WCMConfigurationService.SITE_EXPLORER_URI); UserNode editorNode = getEditorNode(editorPageURI); if (editorNode == null) { return ""; } NodeURL nodeURL = pContext.createURL(NodeURL.TYPE); nodeURL.setNode(editorNode).setQueryParameterValue("path", itemPath); if (isEditable) { nodeURL.setQueryParameterValue("edit", "true"); } if (isNew) { nodeURL.setQueryParameterValue("addNew", "true"); } nodeURL.setQueryParameterValue(org.exoplatform.ecm.webui.utils.Utils.URL_BACKTO, backto); return nodeURL.toString(); }
/** * Gets the site path. * * @param queryCriteria the query criteria * @return the site path * @throws Exception the exception */ private String getSitePath(final QueryCriteria queryCriteria) throws Exception { String siteName = queryCriteria.getSiteName(); if (queryCriteria.isSearchWebpage()) { if ("all".equals(siteName) || siteName == null || siteName.trim().length() == 0) { return "/production/mop:workspace/mop:portalsites"; } return "/production/mop:workspace/mop:portalsites/mop:" + siteName; } String sitePath = null; if (siteName != null) { sitePath = livePortalManagerService.getPortalPathByName(siteName); } else { sitePath = configurationService.getLivePortalsLocation().getPath(); } return sitePath; }
/* (non-Javadoc) * @see org.exoplatform.services.wcm.link.LiveLinkManagerService#validateLink() */ public void updateLinks() throws Exception { try { Collection<NodeLocation> nodeLocationCollection = configurationService.getAllLivePortalsLocation(); SessionProvider sessionProvider = WCMCoreUtils.getSystemSessionProvider(); Session session = null; for (NodeLocation nodeLocation : nodeLocationCollection) { String workspace = nodeLocation.getWorkspace(); String path = nodeLocation.getPath(); ManageableRepository manageableRepository = repositoryService.getCurrentRepository(); session = sessionProvider.getSession(workspace, manageableRepository); updateLinkStatus( session, "select * from exo:linkable where jcr:path like '" + path + "/%'"); } } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Error when perform updateLinks: ", e); } } }
/** * Gets the site path. * * @param queryCriteria the query criteria * @return the site path * @throws Exception the exception */ private String getPath(final QueryCriteria queryCriteria) throws Exception { String siteName = queryCriteria.getSiteName(); // search page path if (queryCriteria.isSearchWebpage()) { if ("all".equals(siteName) || siteName == null || siteName.trim().length() == 0) { return PATH_PORTAL_SITES; } return PATH_PORTAL_SITES.concat("/mop:").concat(siteName); } // search document path if (queryCriteria.getSearchPath() != null) { return queryCriteria.getSearchPath(); } String sitePath = null; if (siteName != null) { sitePath = livePortalManagerService.getPortalPathByName(siteName); } else { sitePath = configurationService.getLivePortalsLocation().getPath(); } return sitePath; }
/* * (non-Javadoc) * @see * org.exoplatform.services.wcm.search.SiteSearchService#searchSiteContents * (org.exoplatform.services.wcm.search.QueryCriteria, * org.exoplatform.services.jcr.ext.common.SessionProvider, int) */ public AbstractPageList<ResultNode> searchSiteContents( SessionProvider sessionProvider, QueryCriteria queryCriteria, int pageSize, boolean isSearchContent) throws Exception { ManageableRepository currentRepository = repositoryService.getCurrentRepository(); NodeLocation location = configurationService.getLivePortalsLocation(); Session session = sessionProvider.getSession(location.getWorkspace(), currentRepository); if (queryCriteria.isSearchWebpage()) { session = sessionProvider.getSession("portal-system", WCMCoreUtils.getRepository()); } QueryManager queryManager = session.getWorkspace().getQueryManager(); long startTime = System.currentTimeMillis(); Query query = createQuery(queryCriteria, queryManager); String suggestion = getSpellSuggestion(queryCriteria.getKeyword(), currentRepository); AbstractPageList<ResultNode> pageList = null; if (LOG.isDebugEnabled()) { LOG.debug("execute query: " + query.getStatement().toLowerCase()); } pageList = PageListFactory.createPageList( query.getStatement(), session.getWorkspace().getName(), query.getLanguage(), IdentityConstants.SYSTEM.equals(session.getUserID()), new NodeFilter(isSearchContent, queryCriteria), new DataCreator(), pageSize, 0, queryCriteria); long queryTime = System.currentTimeMillis() - startTime; pageList.setQueryTime(queryTime); pageList.setSpellSuggestion(suggestion); return pageList; }