View Javadoc
1   /*
2    * Copyright (C) 2003-2007 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  package org.exoplatform.services.cms.thumbnail;
18  
19  import java.awt.image.BufferedImage;
20  import java.io.InputStream;
21  import java.util.List;
22  
23  import javax.jcr.Node;
24  import javax.jcr.RepositoryException;
25  
26  import org.exoplatform.container.component.ComponentPlugin;
27  
28  /**
29   * Created by The eXo Platform SARL
30   * Author : Dang Van Minh
31   *          minh.dang@exoplatform.com
32   * Oct 10, 2008 1:59:21 PM
33   */
34  /**
35   * This service will be support to create thumbnail for node
36   * Get image and any file type in node
37   */
38  public interface ThumbnailService {
39  
40    final public static String EXO_THUMBNAILS = "exo:thumbnails";
41    final public static String EXO_THUMBNAIL = "exo:thumbnail";
42    final public static String SMALL_SIZE = "exo:smallSize";
43    final public static String MEDIUM_SIZE = "exo:mediumSize";
44    final public static String BIG_SIZE = "exo:bigSize";
45    final public static String THUMBNAIL_LAST_MODIFIED = "exo:thumbnailLastModified";
46    final public static String EXO_THUMBNAILS_FOLDER = "exo:thumbnails";
47    final public static String HIDDENABLE_NODETYPE = "exo:hiddenable";
48  
49    /**
50     * Return all nt:file node at current node
51     * @param node Current node
52     * @return all nt:file nodes
53     * @throws RepositoryException
54     */
55    public List<Node> getAllFileInNode(Node node) throws RepositoryException;
56  
57    /**
58     * Return the list of node in the current node with mimetype specified
59     * @param node Current node
60     * @param jcrMimeType Mime type of node will be retrieve
61     * @return node list
62     * @throws Exception
63     */
64    public List<Node> getFileNodesByType(Node node, String jcrMimeType) throws Exception;
65    /**
66     * Return a list image in node
67     * @param node Current node
68     * @return images nodes list
69     * @throws Exception
70     */
71    public List<Node> getFlowImages(Node node) throws Exception;
72    /**
73     * To setup status of node is allow thumbnail or not
74     * @param isEnable
75     */
76    public void setEnableThumbnail(boolean isEnable);
77    /**
78     * Return the status of node is enable thumbnail or not
79     * @return Boolean value
80     */
81    public boolean isEnableThumbnail();
82    /**
83     * Create thumbnail for node with default size:
84     * Small size, medium size, big size
85     * @param node Current node which will be added thumbnail
86     * @param image BufferedImage which contain the original image
87     * @param mimeType File type
88     * @throws Exception
89     */
90    public void createThumbnailImage(Node node, BufferedImage image, String mimeType) throws Exception;
91    /**
92     * Return the data of thumbnail with specified type
93     * @param node Current node which will be added thumbnail
94     * @param thumbnailType Type of thumbnail will be return (small, medium, big or specified if has)
95     * @throws Exception
96     */
97    public InputStream getThumbnailImage(Node node, String thumbnailType) throws Exception;
98    /**
99     * Create thumbnail node
100    * @param node Current node which included thumbnail
101    * @return Node
102    * @throws Exception
103    */
104   public Node addThumbnailNode(Node node) throws Exception;
105   /**
106    * Get thumbnail node
107    * @param node
108    * @return Node
109    * @throws Exception
110    */
111   public Node getThumbnailNode(Node node) throws Exception;
112   /**
113    * Create a thumbnail for node with size specified
114    * @param node Current node which will be added thumbnail
115    * @param image BufferedImage which contain the original image
116    * @param propertyName Data will be set to this property
117    * @throws Exception
118    */
119   public void createSpecifiedThumbnail(Node node, BufferedImage image, String propertyName) throws Exception;
120   /**
121    * Add a thumbnail image to node
122    * @param node Current node which will be added thumbnail
123    * @param image BufferedImage which contain the original image
124    * @param propertyName Data will be set to this property
125    * @throws Exception
126    */
127   public void addThumbnailImage(Node node, BufferedImage image, String propertyName) throws Exception;
128   /**
129    * Process thumbnail with list nodes
130    * @param listNodes List node which will be process to add thumbnail
131    * @param type Type of thumbnail image
132    * @throws Exception
133    */
134   public void processThumbnailList(List<Node> listNodes, String type) throws Exception;
135   /**
136    * Get mime types which allow to view
137    * @return mimetypes list
138    */
139   public List<String> getMimeTypes();
140   /**
141    * Process to remove thumbnail
142    * @param showingNode Node contain the thumbnail
143    * @throws Exception
144    */
145   public void processRemoveThumbnail(Node showingNode) throws Exception;
146 
147   /**
148    * Copy thumbnail node to destination node after moving or copy/paste.
149    *
150    * @param srcThumbnailNode thumbnailNode of source node
151    * @param destNode destination Node
152    * @throws Exception
153    */
154   public void copyThumbnailNode(Node srcThumbnailNode, Node destNode) throws Exception;
155 
156   /**
157    * Add Thumbnail Plugin
158    * @param plugin ComponentPlugin
159    */
160   public void addPlugin(ComponentPlugin plugin);
161 
162   /**
163    * Return a list of Thumbnail plugin
164    * @return ComponentPlugin list
165    */
166   public List<ComponentPlugin> getComponentPlugins();
167 }