001/*
002 *  Copyright 2010 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.web.service;
017
018import java.util.List;
019import java.util.Map;
020
021import org.apache.solr.common.SolrInputDocument;
022
023import org.ametys.core.ui.ClientSideElement.Script;
024import org.ametys.core.ui.ClientSideElement.ScriptFile;
025import org.ametys.runtime.i18n.I18nizableText;
026import org.ametys.web.repository.page.Page;
027import org.ametys.web.repository.page.ZoneItem;
028
029/**
030 * Interface representing a business service. <br>
031 * A service is identified by a name and a Cocoon-URL.<br>
032 * This URL correspond to a pipeline called by a page template.<br>
033 * URL must be relative to the sitemap of the service.
034 */
035public interface Service
036{
037    /**
038     * Returns the service's id.
039     * @return the service's id.
040     */
041    public String getId();
042    
043    /**
044     * Returns the plugin's name.
045     * @return the plugin's name.
046     */
047    public String getPluginName();
048    
049    /**
050     * Retrieves the label of the service.
051     * @return the label.
052     */
053    I18nizableText getLabel();
054    
055    /**
056     * Retrieves the description of the service.
057     * @return the description.
058     */
059    I18nizableText getDescription();
060    
061    /**
062     * Retrieves the category of the service.
063     * @return the category.
064     */
065    I18nizableText getCategory();
066    
067    /**
068     * Retrieves the CSS class to use for glyph icon
069     * @return the glyph name.
070     */
071    public String getIconGlyph();
072    
073    /**
074     * Retrieves the CSS class to use for decorator above the main icon
075     * @return the glyph name.
076     */
077    public String getIconDecorator();
078    
079    /**
080     * Retrieves the URL of the icon without the context path.
081     * @return the icon URL for the small image 16x16.
082     */
083    public String getSmallIcon();
084
085    /**
086     * Retrieves the URL of the icon without the context path.
087     * @return the icon URL for the medium image 32x32.
088     */
089    public String getMediumIcon();
090    
091    /**
092     * Retrieves the URL of the icon without the context path.
093     * @return the icon URL for the large image 48x48.
094     */
095    public String getLargeIcon();
096    
097    /**
098     * Returns the list of CSS files needed to correctly display the service's in BO, such as the service's icon
099     * @return The list of CSS files needed. Must not be null.
100     */
101    List<ScriptFile> getCSSFiles();
102    
103    /**
104     * Returns the service's Cocoon-URL.
105     * @return the service's Cocoon-URL.
106     */
107    public String getURL();
108    
109    /**
110     * Returns the service's parameters.
111     * @return the service's parameters.
112     */
113    public Map<String, ServiceParameterOrRepeater> getParameters();
114    
115    /**
116     * Returns the service parameter groups.
117     * @return the service parameter groups.
118     */
119    public List<ServiceParameterGroup> getParameterGroups();
120    
121    /**
122     * This method return the script that will be used to display parameters field.
123     * @return The script. Can be null.
124     */
125    public Script getParametersScript();
126    
127    /**
128     * Get whether the service is private, i.e. should not be created by
129     * the regular service interface.
130     * @return true if the service is private, false if it is public.
131     */
132    public boolean isPrivate();
133    
134    /**
135     * Get the right needed to create an instance of this service.
136     * @return the right needed to create an instance of this service. If null is returned, no right is needed.
137     */
138    public String getRight();
139    
140    /**
141     * Returns true if the result of this service may be cached, depending on the {@link ZoneItem} containing an instance of this service.
142     * @param currentPage the current {@link Page} containing the service.
143     * @param zoneItem the {@link ZoneItem} containing an instance of this service.<br>
144     *                 N.B: The ZoneItem can belong to a page that is not the current page, when it is inherited.
145     * @return true if the result of this service may be cached.
146     */
147    public boolean isCacheable(Page currentPage, ZoneItem zoneItem);
148    
149    /**
150     * Fill the index with service data.<br>
151     * This method is called during the containing page indexation process.
152     * @param zoneItem the {@link ZoneItem} containing an instance of this service.
153     * @param document the solr document for the containing {@link Page}.
154     */
155    public void index(ZoneItem zoneItem, SolrInputDocument document);
156}