source: other-projects/gs3-webservices-java-client/trunk/src/GS3DemoClient/org/greenstone/gs3client/dlservices/FedoraServicesAPIA.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: 11.8 KB
Line 
1/**
2 *#########################################################################
3 * FedoraServicesAPIA.java - part of the demo-client for Greenstone 3,
4 * of the Greenstone digital library suite from the New Zealand Digital
5 * Library 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.gs3client.dlservices;
22
23import java.util.Map;
24import java.io.File;
25import org.greenstone.gs3client.data.DocumentNodeData;
26import org.greenstone.fedora.services.*;
27
28/**
29 * FedoraServicesAPIA implements DigitalLibraryServicesAPIA for enabling the
30 * Java-client to access a Fedora repository of Greenstone digital objects.
31 * This is made possible by its use of the FedoraGS3.jar file's functionality,
32 * as made available through the FedoraGS3Connection class.
33 * @author ak19
34*/
35public class FedoraServicesAPIA extends FedoraGS3Connection
36 implements DigitalLibraryServicesAPIA
37{
38 /** Default constructor */
39 public FedoraServicesAPIA() throws Exception {
40 super(DigitalLibraryServicesAPIA.propertiesFile);
41 }
42
43 /** Unused constructor for clients: takes a different properties file */
44 public FedoraServicesAPIA(File propertiesFile) throws Exception {
45 super(propertiesFile);
46 }
47
48 /** Unused constructor for clients: takes a different properties file */
49 public FedoraServicesAPIA(String protocol, String host, int port,
50 String fedoraServerUsername, String fedoraServerPassword) throws Exception {
51 super(protocol, host, port, fedoraServerUsername, fedoraServerPassword);
52 }
53
54 /** @return the name of this digital library for displaying in the client */
55 public String getDisplayName() {
56 return "Fedora";
57 }
58
59 /** @return the directory path to the associated files of the given document
60 * node. For instance, the base url of a JEditorPane's HTML documents can be
61 * set to this. */
62 public String getAssocFileBaseURL(DocumentNodeData docNode) {
63 return super.getAssocFileBaseURL()
64 + super.getDocPIDFromDocID(docNode.nodeID) + "/";
65 }
66
67 /** @return Greenstone3 XML describe response message with information
68 * about collections contained and services (and any serviceRacks) supported
69 * by the Digital library. */
70 public String describe() {
71 return this.getCollectionList();
72 }
73
74 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
75 * containing all the metadata of all the documents indicated by docIDs
76 * @param collection is the name of the collection
77 * @param docIDs is an array of document identifiers of documents whose
78 * metadata is requested
79 * @param metadata is the list of metadata elements requested. If "all" is specified
80 * then all metadata is requested. */
81 public String retrieveDocumentMetadata(String collection, String[] docIDs, String[] metadata) {
82 return this.getDocumentMetadata(docIDs, metadata);
83 }
84
85 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
86 * containing all the metadata of the document denoted by docID
87 * @param collection is the name of the collection
88 * @param docID is the document identifier of the document whose metadata is
89 * requested.
90 * @param metadata is the list of metadata elements requested. If "all" is specified
91 * then all metadata is requested. */
92 public String retrieveDocumentMetadata(String collection, String docID, String[] metadata) {
93 return this.getDocumentMetadata(docID, metadata);
94 }
95
96 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
97 * containing only the title metadata of the documents denoted by docIDs
98 * @param collection is the name of the collection
99 * @param docIDs is an array of document identifiers of documents whose titles
100 * are requested */
101 public String retrieveTitleMetadata(String collection, String[] docIDs) {
102 return this.getDocumentMetadata(docIDs, new String[] {"Title"});
103 }
104
105 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
106 * containing only the title metadata of the document denoted by docID
107 * @param collection is the name of the collection
108 * @param docID is the document identifier of the document whose titles is
109 * requested */
110 public String retrieveTitleMetadata(String collection, String docID) {
111 return this.getDocumentMetadata(docID, new String[] {"Title"});
112 }
113
114
115 /** @return a String representing Greenstone3 DocumentContentRetrieve XML
116 * containing the document contents of the documents indicated by docIDs
117 * @param collection is the name of the collection
118 * @param docIDs is an array of document identifiers of documents whose (text)
119 * contents are requested */
120 public String retrieveDocumentContent(String collection, String[] docIDs) {
121 return this.getContent(docIDs);
122 }
123
124 /** @return a String representing Greenstone3 DocumentContentRetrieve XML
125 * containing the document contents of the document indicated by docID
126 * @param collection is the name of the collection
127 * @param docID is the document identifier of the document whose (text)
128 * content is requested */
129 public String retrieveDocumentContent(String collection, String docID) {
130 return this.getContent(docID);
131 }
132
133 /** @return a String representing Greenstone3 DocumentStructureRetrieve XML
134 * containing the document structure of the documents indicated by docIDs:
135 * this means all their descendents
136 * @param collection is the name of the collection
137 * @param docIDs is an array of document identifiers of documents whose
138 * hierarchical structures are requested */
139 public String retrieveDocumentStructure(String collection, String[] docIDs) {
140 return this.getDocumentStructure(docIDs, new String[]{"descendants"}, new String[]{""});
141 }
142
143 /** @return a String representing Greenstone3 DocumentStructureRetrieve XML
144 * containing the document structure of the document indicated by docID:
145 * this means all its descendents
146 * @param collection is the name of the collection
147 * @param docID is the document identifier of the document whose hierarchical
148 * structure is requested*/
149 public String retrieveDocumentStructure(String collection, String docID) {
150 return this.getDocumentStructure(docID, new String[]{"descendants"}, new String[]{""});
151 }
152
153 // UNUSED by the client, but still a very useful method:
154 /** @return a String representing Greenstone3 DocumentStructureRetrieve XML
155 * containing a view of the document structure of the documents denoted by
156 * docs where only the requested documents and their direct children are
157 * returned.
158 * @param collection is the name of the collection
159 * @param docIDs is an array of document identifiers of documents whose
160 * hierarchical structures are requested */
161 public String retrieveDocumentChildren(String collection, String[] docIDs) {
162 return this.getDocumentStructure(docIDs, new String[]{"children"}, new String[]{""});
163 }
164
165 /** @return a String representing Greenstone3 DocumentStructureRetrieve XML
166 * containing a view of the document structure of the document denoted by
167 * docID where only the document and its direct children are returned.
168 * @param collection is the name of the collection
169 * @param docID is the document identifier of the document whose hierarchical
170 * structure is requested */
171 public String retrieveDocumentChildren(String collection, String docID) {
172 return this.getDocumentStructure(docID, new String[]{"children"}, new String[]{""});
173 }
174
175 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
176 * containing the requested portion of the document structure of the documents
177 * indicated by docIDs:
178 * @param collection is the name of the collection. It's already included in the
179 * docID for a Fedora DL.
180 * @param docIDs is an array of document identifiers of documents whose
181 * hierarchical structures are requested
182 * @param structure - strings specifying the required structure of each document.
183 * It can be a combination of: ancestors, parent, siblings, children, descendants, entire.
184 * @param info - strings specifying the required structural info of each document.
185 * It can be any combination of: siblingPosition, numSiblings, numChildren.
186 */
187 public String retrieveDocumentStructure(String collection, String[] docIDs, String[] structure, String[] info) {
188 return this.getDocumentStructure(docIDs, structure, info);
189 }
190
191
192 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
193 * containing the requested portion of the document structure of the documents
194 * indicated by docIDs:
195 * @param collection is the name of the collection. It's already included in the
196 * docID for a Fedora DL.
197 * @param docID is the document identifier of the document whose hierarchical
198 * structure is requested
199 * @param structure - strings specifying the required structure of the document.
200 * It can be a combination of: ancestors, parent, siblings, children, descendants, entire.
201 * @param info - strings specifying the required structural info of the document.
202 * It can be any combination of: siblingPosition, numSiblings, numChildren.
203 */
204 public String retrieveDocumentStructure(String collection, String docID, String[] structure, String[] info) {
205 return this.getDocumentStructure(docID, structure, info);
206 }
207
208
209 /** @return a String representing Greenstone3 ClassifierBrowse XML
210 * giving the entire *structure* of the classification denoted by
211 * classifierID (including the structures of document descendents of
212 * the classifier).
213 * @param classifierIDs - each ID is of the form CL# where the number (#)
214 * marks out structured sections like CL1.1.3 or CL2
215 * @param collection is the name of the collection
216 * @param service is the name of the browse service (=ClassifierBrowse usually)
217 * @param structure - the requested browse substructure. Can be any combination
218 * of ancestors, parent, siblings, children, descendants.
219 * @param info - the requested structural info. Can be numSiblings, siblingPosition,
220 * numChildren
221 */
222 public String retrieveBrowseStructure(String collection, String service, String[] classifierIDs,
223 String[] structure, String[] info)
224 {
225 return this.browse(collection, classifierIDs, structure, info);
226 }
227
228 /** @return a String representing Greenstone3
229 * ClassifierBrowseMetadataRetrieve XML giving all the metadata for
230 * all the subclassifiers denoted by nodeIDs.
231 * @param nodeIDs is of the form CL#.# where the number (#) marks
232 * out structured sections like CL2.1.3. NodeIDs are generally subsections
233 * of top-level classifierNodes (CL#, e.g. CL3).
234 * @param metafields are the classifier metadata fields that are to be returned.
235 * @param collection is the name of the collection
236 * @param service is the name of the Browse's MetadataRetrieve service
237 * (usually the browse service is ClassifierBrowse, in which case it always
238 * has a retrieve service called ClassifierBrowseMetadataRetrieve) */
239 public String retrieveBrowseMetadata(String collection, String service,
240 String[] nodeIDs, String[] metafields)
241 {
242 return this.browseMetadataRetrieve(nodeIDs, metafields);
243 }
244
245
246 // FOR NOW, add the new method that converts URLs to document identifiers(PIDs) here,
247 // since it is not used by GS3 classes
248 public String getDocIDforURL(String url, String collection) {
249 return this.getPIDforURL(url, collection);
250 }
251
252}
Note: See TracBrowser for help on using the repository browser.