001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-api/api/src/java/org/sakaiproject/search/api/EntityContentProducer.java $
003: * $Id: EntityContentProducer.java 22609 2007-03-14 19:28:42Z ian@caret.cam.ac.uk $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.search.api;
021:
022: import java.io.Reader;
023: import java.util.Iterator;
024: import java.util.List;
025: import java.util.Map;
026:
027: import org.sakaiproject.event.api.Event;
028:
029: /**
030: * This is a special class than handles ContentResources for the purposes of
031: * search. This must be impelented in a thread safe way. The aim is to map the
032: * content handler to the mime type
033: *
034: * @author ieb
035: */
036: public interface EntityContentProducer {
037:
038: /**
039: * Should the consumer use the reader or is it Ok to use a memory copy of
040: * the content
041: *
042: * @param cr
043: * @return
044: */
045: boolean isContentFromReader(String reference);
046:
047: /**
048: * Get a reader for the supplied content resource
049: *
050: * @param cr
051: * @return
052: */
053: Reader getContentReader(String reference);
054:
055: /**
056: * Get the content as a string
057: *
058: * @param cr
059: * @return
060: */
061: String getContent(String reference);
062:
063: /**
064: * get the title for the content
065: *
066: * @param cr
067: * @return
068: */
069: String getTitle(String reference);
070:
071: /**
072: * Gets the url that displays the entity
073: *
074: * @param entity
075: * @return
076: */
077: String getUrl(String reference);
078:
079: /**
080: * If the reference matches this EntityContentProducer return true
081: *
082: * @param ref
083: * @return
084: */
085: boolean matches(String reference);
086:
087: /**
088: * Gets a list of Entity resource as a String to represent all indexable
089: * content
090: * @deprecated
091: * @return
092: */
093: List getAllContent();
094:
095: /**
096: * Get the search builder action associated with the event
097: * @param event
098: * @return
099: */
100: Integer getAction(Event event);
101:
102: /**
103: * Is the event owned by this EntityContentProducer
104: * @param event
105: * @return
106: */
107: boolean matches(Event event);
108:
109: /**
110: * What is the name of the tool,
111: * @return
112: */
113: String getTool();
114:
115: /**
116: * get the site ID from the resource Name
117: * @param resourceName
118: * @return
119: */
120: String getSiteId(String reference);
121:
122: /**
123: * get all the content associated with a site managed by this EntityContentProducer
124: * @deprecated
125: * @param context
126: * @return
127: */
128: List getSiteContent(String context);
129:
130: /**
131: * Get the site content as an iterator
132: * @param context
133: * @return
134: */
135: Iterator getSiteContentIterator(String context);
136:
137: /**
138: * If the reference should be indexed, return true
139: * @param ref
140: * @return
141: */
142: boolean isForIndex(String reference);
143:
144: /**
145: * returns true if the current user can view the search result
146: * @param ref
147: * @return
148: */
149: boolean canRead(String reference);
150:
151: /**
152: * Gets a map of custom document properties. The names of the map map will contain
153: * the index name to which the value is added.
154: * The value is expected to be a String or String[], containig the value, values to be
155: * added. Before using this method in your entity producer, be certain that the value
156: * is not already in the index. ( See SearchService for list of Fields)
157: * @return
158: */
159: Map getCustomProperties();
160:
161: /**
162: * At the moment this is a placeholder, but eventually
163: * It will return a block of Custom RDF, that the EntityContentProducer wants
164: * the search index to index. This is ontop of any RDF that the search index is
165: * already processing.
166: * @return
167: */
168: String getCustomRDF();
169:
170: /**
171: * @param ref
172: * @return
173: */
174: String getId(String ref);
175:
176: /**
177: * @param ref
178: * @return
179: */
180: String getType(String ref);
181:
182: /**
183: * @param ref
184: * @return
185: */
186: String getSubType(String ref);
187:
188: /**
189: * @param ref
190: * @return
191: */
192: String getContainer(String ref);
193:
194: }
|