source: gs3-extensions/iiif-servlet/trunk/src/src/main/java/edu/illinois/library/cantaloupe/resource/iiif/v2/IdentifierToGSAssocfile.java@ 32891

Last change on this file since 32891 was 32891, checked in by davidb, 5 years ago

Additional error checking

File size: 2.8 KB
Line 
1package edu.illinois.library.cantaloupe.resource.iiif.v2;
2
3import edu.illinois.library.cantaloupe.RestletApplication;
4import edu.illinois.library.cantaloupe.cache.CacheFacade;
5import edu.illinois.library.cantaloupe.config.Configuration;
6import edu.illinois.library.cantaloupe.config.Key;
7import edu.illinois.library.cantaloupe.image.Format;
8import edu.illinois.library.cantaloupe.image.Identifier;
9import edu.illinois.library.cantaloupe.image.Info;
10import edu.illinois.library.cantaloupe.image.MediaType;
11import edu.illinois.library.cantaloupe.operation.OperationList;
12import edu.illinois.library.cantaloupe.processor.Processor;
13import edu.illinois.library.cantaloupe.processor.ProcessorFactory;
14import edu.illinois.library.cantaloupe.processor.UnsupportedOutputFormatException;
15import edu.illinois.library.cantaloupe.processor.UnsupportedSourceFormatException;
16import edu.illinois.library.cantaloupe.source.Source;
17import edu.illinois.library.cantaloupe.source.SourceFactory;
18import edu.illinois.library.cantaloupe.processor.ProcessorConnector;
19import edu.illinois.library.cantaloupe.resource.CachedImageRepresentation;
20import edu.illinois.library.cantaloupe.resource.IllegalClientArgumentException;
21import edu.illinois.library.cantaloupe.resource.ImageRepresentation;
22import edu.illinois.library.cantaloupe.resource.iiif.SizeRestrictedException;
23import org.restlet.data.Disposition;
24import org.restlet.representation.Representation;
25import org.restlet.representation.StringRepresentation;
26import org.restlet.resource.Get;
27
28import java.awt.Dimension;
29import java.io.IOException;
30import java.io.InputStream;
31import java.nio.file.Files;
32import java.nio.file.NoSuchFileException;
33import java.nio.file.Path;
34import java.util.List;
35import java.util.Map;
36import java.util.Set;
37
38import org.greenstone.gsdl3.IIIFServerBridge;
39
40
41public class IdentifierToGSAssocfile {
42
43 public static Identifier createIdentifierImage(Identifier identifier) throws Exception
44 {
45 Identifier identifier_image = null;
46
47 String identifier_str = identifier.toString();
48 String[] strs = identifier_str.split(":", 3);
49 if(strs == null || strs.length < 3) {
50 System.err.println("identifier is not in the form site:coll:id" + identifier_str);
51 return null;
52 }
53 String site_name = strs[0];
54 String coll_name = strs[1];
55 String doc_id = strs[2];
56
57 // Move into Constructor ???
58 IIIFServerBridge gs_iiif_bridge = new IIIFServerBridge();
59 // and keep cache of of bridges in hashmap, keyed on sitename??
60 gs_iiif_bridge.init(site_name);
61
62 String collect_image_filename = gs_iiif_bridge.doGetDocumentMessage(coll_name + ":" + doc_id);
63
64 if (collect_image_filename != null) {
65 String site_image_filename = site_name + "/collect/" + coll_name + "/index/assoc/" + collect_image_filename;
66
67 identifier_image = new Identifier(site_image_filename);
68 }
69
70
71 return identifier_image;
72 }
73
74
75}
Note: See TracBrowser for help on using the repository browser.