public boolean equals(Object obj) { if (obj == null || !(obj instanceof NodeLocation)) return false; NodeLocation location2 = (NodeLocation) obj; return equalsString(this.repository, location2.getRepository()) && equalsString(this.getWorkspace(), location2.getWorkspace()) && (equalsString(this.getPath(), location2.getPath()) || equalsString(this.getUUID(), location2.getUUID())); }
/* (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); } } }
@Override public Node filterNodeToDisplay(Node node) { try { Node displayNode = getNodeToCheckState(node); if (displayNode == null) return null; if (isSearchContent) return displayNode; NodeLocation nodeLocation = NodeLocation.getNodeLocationByNode(displayNode); WCMComposer wcmComposer = WCMCoreUtils.getService(WCMComposer.class); HashMap<String, String> filters = new HashMap<String, String>(); filters.put( WCMComposer.FILTER_MODE, queryCriteria.isLiveMode() ? WCMComposer.MODE_LIVE : WCMComposer.MODE_EDIT); return wcmComposer.getContent( nodeLocation.getWorkspace(), nodeLocation.getPath(), filters, WCMCoreUtils.getSystemSessionProvider()); } catch (Exception e) { return null; } }
/** * gets a Node list from a NodeLocation list * * @param locationList NodeLocation list * @return the Node list */ @SuppressWarnings("unchecked") public static final List getNodeListByLocationList(final List locationList) { List ret = new ArrayList(); try { ManageableRepository repository = WCMCoreUtils.getRepository(); SessionProvider systemSessionProvider = WCMCoreUtils.getSystemSessionProvider(); SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); String systemWorkspace = repository.getConfiguration().getSystemWorkspaceName(); Session session = null; Node node; for (Object obj : locationList) if (obj instanceof NodeLocation) { node = null; try { NodeLocation location = (NodeLocation) obj; session = (systemWorkspace.equals(location.getWorkspace()) || location.isSystemSession) ? systemSessionProvider.getSession(location.getWorkspace(), repository) : sessionProvider.getSession(location.getWorkspace(), repository); node = location.getUUID() != null ? session.getNodeByUUID(location.getUUID()) : (Node) session.getItem(location.getPath()); ret.add(node); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } } else { ret.add(obj); } } catch (Exception e) { return ret; } return ret; }
public Result getPaginatedContents( NodeLocation nodeLocation, HashMap<String, String> filters, SessionProvider sessionProvider) throws Exception { String path = nodeLocation.getPath(); String workspace = nodeLocation.getWorkspace(); String mode = filters.get(FILTER_MODE); String version = filters.get(FILTER_VERSION); String orderBy = filters.get(FILTER_ORDER_BY); String orderType = filters.get(FILTER_ORDER_TYPE); String visibility = filters.get(FILTER_VISIBILITY); long offset = (filters.get(FILTER_OFFSET) != null) ? new Long(filters.get(FILTER_OFFSET)) : 0; long totalSize = (filters.get(FILTER_TOTAL) != null) ? new Long(filters.get(FILTER_TOTAL)) : 0; String remoteUser = getRemoteUser(); if (MODE_EDIT.equals(mode) && "publication:liveDate".equals(orderBy)) { orderBy = "exo:dateModified"; filters.put(FILTER_ORDER_BY, orderBy); } if (MODE_LIVE.equals(mode) && "exo:title".equals(orderBy)) { orderBy = "exo:titlePublished " + orderType + ", exo:title"; filters.put(FILTER_ORDER_BY, orderBy); } if (LOG.isDebugEnabled()) LOG.debug( "##### " + path + ":" + version + ":" + remoteUser + ":" + orderBy + ":" + orderType); NodeIterator nodeIterator; if (totalSize == 0) { SessionProvider systemProvider = WCMCoreUtils.getSystemSessionProvider(); nodeIterator = getViewableContents(workspace, path, filters, systemProvider, false); if (nodeIterator != null) { totalSize = nodeIterator.getSize(); } } if (WCMComposer.VISIBILITY_PUBLIC.equals(visibility) && MODE_LIVE.equals(mode)) { sessionProvider = remoteUser == null ? aclSessionProviderService.getAnonymSessionProvider() : aclSessionProviderService.getACLSessionProvider(getAnyUserACL()); } nodeIterator = getViewableContents(workspace, path, filters, sessionProvider, true); List<Node> nodes = new ArrayList<Node>(); Node node = null, viewNode = null; if (nodeIterator != null) { while (nodeIterator.hasNext()) { node = nodeIterator.nextNode(); viewNode = getViewableContent(node, filters); if (viewNode != null) { nodes.add(viewNode); } } } Result result = new Result(nodes, offset, totalSize, nodeLocation, filters); return result; }
/** * Get node's expression by a NodeLocation. * * @param NodeLocation location * @return The node's expression */ public static final String getExpressionByNodeLocation(final NodeLocation location) { return mergeString(location.getRepository(), location.getWorkspace(), location.getPath()); }