View Javadoc
1   /***************************************************************************
2    * Copyright (C) 2003-2009 eXo Platform SAS.
3    *
4    * This program is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Affero General Public License
6    * as published by the Free Software Foundation; either version 3
7    * of the License, or (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program; if not, see<http://www.gnu.org/licenses/>.
16   *
17   **************************************************************************/
18  package org.exoplatform.ecm.webui.viewer;
19  
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  import javax.jcr.Node;
25  import javax.jcr.NodeIterator;
26  
27  import org.exoplatform.container.xml.PortalContainerInfo;
28  import org.exoplatform.services.cms.impl.Utils;
29  import org.exoplatform.services.wcm.core.NodeLocation;
30  import org.exoplatform.services.wcm.utils.WCMCoreUtils;
31  import org.exoplatform.webui.config.annotation.ComponentConfig;
32  import org.exoplatform.webui.core.UIComponent;
33  
34  /**
35   * Created by The eXo Platform SARL
36   * Author : Hoang Van Hung
37   *          hunghvit@gmail.com
38   * Oct 29, 2009
39   */
40  
41  @ComponentConfig(
42      template = "classpath:resources/templates/VideoAudioViewer.gtmpl"
43  )
44  
45  public class VideoAudioViewer extends UIComponent {
46  
47    private List<NodeLocation> presentNodes = new ArrayList<NodeLocation>();
48  
49    private String repository;
50  
51    public VideoAudioViewer() throws Exception {
52    }
53  
54    public List<Node> getPresentNodes() {
55      List<Node> result = new ArrayList<Node>();
56      result.addAll(NodeLocation.getNodeListByLocationList(presentNodes));
57      return result;
58    }
59  
60    public void setPresentNodes(List<Node> presentNodes) {
61      this.presentNodes = NodeLocation.getLocationsByNodeList(presentNodes);
62    }
63  
64    public void setRepository(String repository) {
65      this.repository = repository;
66    }
67  
68  
69    public String getRepository() {
70      return repository;
71    }
72  
73    public String getPortalName() {
74      PortalContainerInfo containerInfo = WCMCoreUtils.getService(PortalContainerInfo.class) ;
75      return containerInfo.getContainerName() ;
76    }
77  
78    public Node getFileLangNode(Node currentNode) throws Exception {
79      if(currentNode.isNodeType("nt:unstructured")) {
80        if(currentNode.getNodes().getSize() > 0) {
81          NodeIterator nodeIter = currentNode.getNodes() ;
82          while(nodeIter.hasNext()) {
83            Node ntFile = nodeIter.nextNode() ;
84            if(ntFile.isNodeType("nt:file")) {
85              return ntFile ;
86            }
87          }
88          return currentNode ;
89        }
90      }
91      return currentNode ;
92    }
93  
94    public Node getChildNode(Node parent, String childType) throws Exception {
95      return Utils.getChildOfType(parent, childType);
96    }
97  
98  }