source: other-projects/gs3-webservices-java-client/trunk/src/GS3Fedora/org/greenstone/fedora/services/FedoraGS3DL.java@ 26171

Last change on this file since 26171 was 26171, checked in by ak19, 12 years ago

Uncommitted changes from ages back to fedoraGS3 classes to get greenstone to work as an interface to fedora repository backend.

File size: 17.6 KB
Line 
1/**
2 *#########################################################################
3 * FedoraGS3DL.java - works with the demo-client for Greenstone 3, of the
4 * Greenstone digital library suite from the New Zealand Digital Library
5 * Project at the * University of Waikato, New Zealand.
6 * <BR><BR>
7 * Copyright (C) 2008 New Zealand Digital Library Project
8 * <BR><BR>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 * <BR><BR>
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *########################################################################
19 */
20
21package org.greenstone.fedora.services;
22
23
24import org.greenstone.fedora.services.FedoraGS3Exception.FedoraVersionNotSupportedException;
25import org.w3c.dom.Element;
26import org.xml.sax.SAXException;
27
28import java.io.IOException;
29import java.io.UnsupportedEncodingException;
30import java.rmi.RemoteException;
31
32import javax.xml.transform.TransformerException;
33//import javax.xml.transform.TransformerConfigurationException;
34
35/**
36 * Defines the methods that must be provided to retrieve the datastreams
37 * specific to Greenstone documents stored in a Fedora repository.
38 * @author ak19
39*/
40public interface FedoraGS3DL {
41 /* CONSTANTS (FOLLOWED BY METHOD DECLARATIONS) */
42
43 /** Instead of message router, we indicate that request messages
44 * sent here come from FedoraGS3 */
45 public static final String FEDORA_GS3 = "FedoraGS3";
46
47 // Some constant string literals we'll be dealing with
48
49 /** "greenstone" is the FEDORA PID prefix we'll be working with
50 * @see <a href="http://dltj.org/2006/12/fedora-batch-processing/">Fedora batch processing</a>
51 */
52 public static final String GREENSTONE = "greenstone";
53 public static final String GREENSTONE_ = GREENSTONE+":";
54 public static final String COLLECTION = "collection";
55 public static final String _COLLECTION = "-"+COLLECTION;
56 public static final String _HTTP = "-http";
57
58 public static final String WILDCARD = "*";
59 public static final String HYPHEN = "-";
60 public static final String COLON = ":";
61 public static final String PERIOD = ".";
62
63 // public static final String UTF16 = "UTF-16"; // not used
64 public static final String UTF8 = "UTF8";
65
66 // attribute names
67 public static final String TITLE = "Title";
68 public static final String ID = "id";
69 public static final String NAME = "name";
70 public static final String COLLECTIONNAME = "collectionname";
71 public static final String QUALIFIER = "qualifier";
72 public static final String ENGLISH = "en";
73
74 // tag names
75 public static final String METADATA = "metadata";
76 public static final String SECTION_ELEMENT = "Section";
77
78 /** EX marks the XML metadata file that contains Greenstone extracted
79 * metadata */
80 public static final String EX = "EX";
81 /** Fedora's Dublin Core metadata */
82 public static final String DC = "DC";
83 /** DLS metadata of Greenstone documents - this metadata set is optionally
84 * provided for top level documents. Not all Greenstone top-level documents
85 * in the Fedora repository may have associated DLS metadata, however.*/
86 public static final String DLS = "DLS";
87 /** Table of contents for a Greenstone-Fedora document which outlines the
88 * structure of the document. */
89 public static final String TOC = "TOC";
90 /** The SECTION prefix in the name of a section's datastream;
91 * eg. SECTION1.2.2 */
92 public static final String SECTION = "SECTION";
93
94
95 /* METHOD DEFINITIONS */
96 /** @return the default language used to query for titles (and anything else
97 * where there are multiple language options). Upon initialisation, this
98 * defaults to English. */
99 public String getLanguage();
100
101 /** Sets the the default language used to query for titles (and anything else
102 * where there are multiple language options). If the default language for any
103 * query is not available, then English ("en") is used. If that's not available
104 * then the first other available language is used.
105 * @param lang - the two-letter language code to set the default language to. */
106 public void setLanguage(String lang);
107
108 /** The default maximum number of search results returned for a search. Upon
109 * initialisation, this defaults to Java's Integer.MAX_VALUE. */
110 public int getMaxResults();
111
112 /** Set the default maximum number of search results returned for a search.
113 * @param maxresults - the new default maximum number of search results to
114 * be returned. */
115 public void setMaxResults(int maxresults);
116
117 /** @return fedora's baseURL */
118 public String getBaseURL();
119
120 /** @return the portAddressURL of the Fedora APIA web service
121 * (should be the endpoint location in the APIA's WSDL file).
122 * Else set this in the .properties file to something else. */
123 public String getPortAddressURL();
124
125 /** @return the baseURL for gsdlAssocFiles */
126 public String getAssocFileBaseURL();
127
128 /* GET COLLECTIONS, DOCUMENTS, SECTIONS, AND TITLES */
129
130 /** Gets all greenstone collections. Searches for greenstone:*-collection.
131 * @return an array of Strings containing the pids of all collections
132 * matching the format greenstone:*-collection. */
133 public String[] getCollections() throws RemoteException;
134
135 /** @return the &lt;name&gt;s (in greenstone:&lt;name&gt;-collection) for the collections
136 * indicated by collPIDs.
137 * @param collPIDs - an array of Strings denoting the pids for greenstone
138 * collections stored in the fedora repositoryl. These should be of the
139 * format "greenstone:&lt;collectionName&gt;-collection". */
140 public String[] getCollectionNames(String[] collPIDs);
141
142 /** @return "greenstone:&lt;name&gt;-collection" for all &lt;name&gt;s in the
143 * parameter collNames.
144 * @param collNames - a list of names of greenstone collections
145 * stored in the fedora repository. */
146 public String[] getCollectionPIDs(String[] collNames);
147
148 /** @return greenstone:&lt;name&gt;-collection for the &lt;name&gt; denoted by
149 * parameter collName.
150 * @param collName - the name of a greenstone collection stored
151 * stored in the fedora repository. */
152 public String getCollectionPID(String collName);
153
154 /**
155 * Gets the title of the collection denoted by the given collection's pid by
156 * retrieving the title metadata for it from the collection's EX datastream.
157 * @return the title (in the default language, else English, else the
158 * first title found) for the particular collection denoted by its PID.
159 * @param collPID is the pid of a greenstone collection in the fedora
160 * repository. */
161 public String getCollectionTitle(String collPID)
162 throws RemoteException, UnsupportedEncodingException,
163 SAXException, IOException;
164
165 /** @return the collection titles for all the collections indicated by
166 * collPIDs.
167 * @param collPIDs - a list of pids identifying greenstone collections
168 * stored in the fedora repository. */
169 public String[] getCollectionTitles(String[] collPIDs)
170 throws RemoteException, UnsupportedEncodingException,
171 SAXException, IOException;
172
173 /** @return the title metadata for the given doc objects of a collection.
174 * These titles are returned in the same order as the given docIDs.
175 * @param docPIDs - a list of pids identifying documents stored in the
176 * fedora repository. */
177 public String[] getDocTitles(String[] docPIDs)
178 throws RemoteException, UnsupportedEncodingException,
179 SAXException, IOException;
180
181 /** Gets the title metadata for a particular doc object in a collection
182 * denoted by docPID. The docPID already contains the collection name.
183 * @return the title for the fedora document item denoted by docPID
184 * @param docPID is the pid of the document in the fedora repository
185 * (docPID is of the form greenstone:&lt;colName&gt;-&lt;doc-identifier&gt; */
186 public String getDocTitle(String docPID)
187 throws RemoteException, UnsupportedEncodingException,
188 SAXException, IOException;
189
190 /** @return the title metadata for the given document sections.
191 * These titles are returned in the same order as the given docPIDs
192 * and associated sectionIDs.
193 * @param docPIDs - a list of pids identifying documents stored in the
194 * fedora repository.
195 * @param sectionIDs - a list of sectionIDs identifying individual sections
196 * of documents stored in the fedora repository whose titles are requested. */
197 public String[] getSectionTitles(String[] docPIDs, String[] sectionIDs)
198 throws RemoteException, UnsupportedEncodingException,
199 SAXException, IOException;
200
201 /** @return the title metadata for the given document section.
202 * (The docPID already contain the collection name anyway.)
203 * @param docPID - a pid identifying a document in the fedora repository.
204 * @param sectionID - the sectionID of the section of the
205 * document whose title is requested. */
206 public String getSectionTitle(String docPID, String sectionID)
207 throws UnsupportedEncodingException, RemoteException,
208 SAXException, IOException;
209
210 /** @return a list of the fedora pids of all (document) objects in the
211 * given greenstone collection stored in fedora's repository. All
212 * pids that do not map to a collection are assumed to be documents.
213 * @param colPID is the pid of the greenstone collection stored in
214 * the fedora repository. */
215 public String[] getCollectionDocs(String colPID) throws RemoteException;
216
217 /** Given the pid of a document fedora data object, this method will return
218 * all itemIDs that are part of that data object and are Sections.
219 * @return an array of itemIDs of the Sections of the document,
220 * indicated by docPID, in ascending order. These are of the form: "SECTION1.*"
221 * @param docPID is a fedora pid identifying a greenstone document object. */
222 public String[] getSectionNames(String docPID) throws RemoteException;
223
224 /** Given the pid of a document fedora data object, this method will return all
225 * itemIDs that are part of that data object and are Sections, but just the
226 * Section numbers are returned.
227 * @return an array of itemIDs of the Section numbers of the document
228 * indicated by docPID, in ascending order. Return values are of form: "1.*".
229 * @param docPID is a fedora pid identifying a greenstone document object. */
230 public String[] getSectionNumbers(String docPID) throws RemoteException;
231
232 /** @return the titles for the document sections denoted by the parameters.
233 * @param docPID is a fedora pid identifying a greenstone document object.
234 * @param sectionIDs is a list of identifiers identifying sections in the
235 * document denoted by docPID, whose titles need to be returned. Each
236 * sectionID may sectionID may be either a section name (e.g. SECTION1.5.1)
237 * or a section number (eg. 1.5.1). */
238 public String[] getTitles(String docPID, String[] sectionIDs)
239 throws RemoteException, UnsupportedEncodingException,
240 SAXException, IOException;
241
242 /** @return the title for the document section denoted by the parameters.
243 * @param docPID is a fedora pid identifying a greenstone document object.
244 * @param sectionID identifies the particular section in the
245 * document denoted by docPID, whose title needs to be returned. The
246 * sectionID may sectionID may be either a section name (e.g. SECTION1.5.1)
247 * or a section number (eg. 1.5.1). */
248 public String getTitle(String docPID, String sectionID)
249 throws RemoteException, UnsupportedEncodingException,
250 SAXException, IOException;
251
252 /** @return the &lt;docName&gt; in the parameter docPID (which is of the form:
253 * greenstone:&lt;colname&gt;-&lt;docName&gt;)
254 * @param docPID is the pid of a greenstone document in the fedora
255 * repository. */
256 public String getDocName(String docPID);
257
258 /** @return the &lt;name&gt; in the parameter collPID
259 * (greenstone:&lt;name&gt;-collection)
260 * @param collPID is the pid of a greenstone collection in the fedora
261 * repository.
262 */
263 public String getCollectionName(String collPID);
264
265 /* GETTING A DOCUMENT OR SECTION'S DATA STREAMS */
266
267 /* All "greenstone:*" objects in fedora (be they collections or documents)
268 * have TOC, EX and DC datastreams. The following methods return the content
269 * (XML) of these datastreams as is. */
270 /** All objects (incl "greenstone:*" objects) in fedora - be they collections,
271 * top-level documents or document sections) have an EX datastream. This method
272 * returns the content (XML) of the DC datastream as it is stored in fedora's
273 * repository.
274 * @return a String version of the XML in the DC datastream for the fedora object
275 * denoted by pid.
276 * @param pid - the fedora persistent identifier for an item in the fedora
277 * repository. */
278 public String getDC(String pid) throws RemoteException, UnsupportedEncodingException;
279
280 /** All "greenstone:*" objects in fedora (be they collections, top-level
281 * documents or document sections) have an EX datastream. This method
282 * returns the content (XML) of the EX datastream as is.
283 * @return a String version of the XML in the DC datastream for the fedora
284 * object denoted by pid.
285 * @param pid - the fedora persistent identifier for an item in the fedora
286 * repository. */
287 public String getEX(String pid) throws RemoteException, UnsupportedEncodingException;
288
289 /**
290 * Some "greenstone:*" top-level documents in the fedora repository (but not
291 * greenstone collections or document sections) have a DLS metadata datastream.
292 * This method returns the content (XML) of the DLS datastream as is.
293 * @return a String version of the XML in the DLS datastream for the fedora
294 * object denoted by pid.
295 * @param pid - the fedora persistent identifier for an item in the fedora
296 * repository.
297 * */
298 public String getDLS(String pid) throws RemoteException, UnsupportedEncodingException;
299
300 /** All "greenstone:*" objects in fedora (be they collections or documents)
301 * have a TOC datastream. This method returns the content (XML) of the TOC
302 * datastream as is. (Calls default fedora-system 3 dissemination &lt;pid&gt;/TOC.)
303 * @return a String version of the XML in the DC datastream for the fedora
304 * object denoted by pid.
305 * @param pid - the fedora persistent identifier for an item in the fedora
306 * repository.
307 */
308 public String getTOC(String pid) throws RemoteException, UnsupportedEncodingException;
309
310 /** @return the section's XML (as a String) as it is stored in fedora.
311 * Works out if sectionID is a sectionName or sectionNumber.
312 * @param docPID is a fedora pid identifying a greenstone document object.
313 * @param sectionID identifies the particular section in the
314 * document denoted by docPID, may be a section name or number. */
315 public String getSection(String docPID, String sectionID)
316 throws RemoteException, UnsupportedEncodingException;
317
318 /** @return the required section's DC metadata XML datastream.
319 * @param docPID is a fedora pid identifying a greenstone document object.
320 * @param sectionID identifies the particular section in the
321 * document denoted by docPID, may be a section name or number. */
322 public String getSectionDCMetadata(String docPID, String sectionID)
323 throws RemoteException, UnsupportedEncodingException;
324
325 /** @return the required section's EX metadata XML datastream.
326 * @param docPID is a fedora pid identifying a greenstone document object.
327 * @param sectionID identifies the particular section in the
328 * document denoted by docPID, may be a section name or number. */
329 public String getSectionEXMetadata(String docPID, String sectionID)
330 throws RemoteException, UnsupportedEncodingException;
331
332 /* METHODS FOR GETTING THE STRUCTURE OF DOCUMENTS */
333
334 /** @return the part of the TOC XML file (which outlines doc structure)
335 * relating to the given section. This includes the section denoted by
336 * sectionID as well as all descendent subsections thereof.
337 * @param docPID - a fedora pid identifying a greenstone document object.
338 * @param sectionID - identifies the particular section in the
339 * document denoted by docPID, may be a section name or number.
340 * @param structure can contain any combination of: ancestors, parent,
341 * siblings, children, descendants, entire, specifying the portion of
342 * the structure to retrieve.
343 * @param info can contain any combination of: siblingPosition, numSiblings,
344 * numChildren, requesting additional information about the structure. */
345 public Element getSectionStructureXML(String docPID, String sectionID, String structure, String info)
346 throws RemoteException, UnsupportedEncodingException, SAXException, IOException;
347
348 /* BROWSING */
349
350 /** Allows browsing document titles of a greenstone collection stored in
351 * the fedora repository by letter.
352 * @return the browse results for documents that start with any letter from
353 * A to Z. Returns the document pids whose titles start with the given letter.
354 * @param letter is the starting letter to browse by. */
355 public String[] browseTitlesByLetter(String collName, String letter)
356 throws RemoteException, FedoraVersionNotSupportedException;
357
358 /** Allows querying document titles of a greenstone collection stored in
359 * the fedora repository for a term that may occur anywhere in their titles.
360 * @return the document pids whose titles contain the parameter term.
361 * @param titleContents is the word or phrase to search the collection's
362 * document titles for.
363 * @param startsWith - if true, searches for titles that start with
364 * titleContents. Else it searches for titles that contain titleContents. */
365 public String[] searchDocumentTitles(String collName, String titleContents,
366 boolean startsWith)
367 throws RemoteException, FedoraVersionNotSupportedException;
368
369 /* The following single method can be used instead.
370 * ComparisonOperator can be contains or startswith. */
371 /* public String[] browse(String term, ComparisonOperator?); */
372}
Note: See TracBrowser for help on using the repository browser.