Exemple #1
0
  public static String getWebdavURL(Node node, boolean withTimeParam, boolean isGetRealNodePath)
      throws Exception {
    NodeLocation location = NodeLocation.getNodeLocationByNode(getRealNode(node));
    String repository = location.getRepository();
    String workspace = location.getWorkspace();
    String currentProtal = PortalContainer.getCurrentRestContextName();
    String portalName = PortalContainer.getCurrentPortalContainerName();

    String originalNodePath =
        isGetRealNodePath ? getRealNodePath(node) : Text.escape(node.getPath(), '%', true);
    StringBuffer imagePath = new StringBuffer();
    imagePath
        .append("/")
        .append(portalName)
        .append("/")
        .append(currentProtal)
        .append("/jcr/")
        .append(repository)
        .append("/")
        .append(workspace)
        .append(originalNodePath);
    if (withTimeParam) {
      if (imagePath.indexOf("?") > 0) {
        imagePath.append("&time=");
      } else {
        imagePath.append("?time=");
      }
      imagePath.append(System.currentTimeMillis());
    }
    return imagePath.toString();
  }
Exemple #2
0
 /**
  * Generate the Thumbnail Image URI.
  *
  * @param file the node
  * @return the Thumbnail uri with medium size
  * @throws Exception the exception
  */
 public static String generateThumbnailImageURI(Node file) throws Exception {
   StringBuilder builder = new StringBuilder();
   NodeLocation fielLocation = NodeLocation.getNodeLocationByNode(file);
   String repository = fielLocation.getRepository();
   String workspaceName = fielLocation.getWorkspace();
   String nodeIdentifiler = file.getPath().replaceFirst("/", "");
   String portalName = PortalContainer.getCurrentPortalContainerName();
   String restContextName = PortalContainer.getCurrentRestContextName();
   InputStream stream =
       file.getNode(NodetypeConstant.JCR_CONTENT)
           .getProperty(NodetypeConstant.JCR_DATA)
           .getStream();
   if (stream.available() == 0) return null;
   stream.close();
   builder
       .append("/")
       .append(portalName)
       .append("/")
       .append(restContextName)
       .append("/")
       .append("thumbnailImage/medium/")
       .append(repository)
       .append("/")
       .append(workspaceName)
       .append("/")
       .append(nodeIdentifiler);
   return builder.toString();
 }
Exemple #3
0
 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;
   }
 }
  /*
   * (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;
  }
Exemple #7
0
  /**
   * 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;
  }
Exemple #8
0
  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;
  }
 protected Node getDocNode(String repository, String workspace, String docPath) {
   NodeLocation nodeLocation = new NodeLocation(repository, workspace, docPath);
   return NodeLocation.getNodeByLocation(nodeLocation);
 }
 public List<Node> getListUploadedNode() {
   return NodeLocation.getNodeListByLocationList(listUploadedNode_);
 }
 public void setListUploadedNode(List<Node> listNode) throws Exception {
   listUploadedNode_ = NodeLocation.getLocationsByNodeList(listNode);
 }
 public Node getUploadedNode() {
   return NodeLocation.getNodeByLocation(uploadedNode_);
 }
 public void setUploadedNode(Node node) throws Exception {
   uploadedNode_ = NodeLocation.getNodeLocationByNode(node);
 }
Exemple #14
0
 /**
  * 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());
 }