1 | package eu.clarin.cmdi.mdservice.proxy; |
---|
2 | |
---|
3 | import java.io.IOException; |
---|
4 | import java.net.MalformedURLException; |
---|
5 | import java.net.URL; |
---|
6 | |
---|
7 | import org.apache.log4j.Logger; |
---|
8 | |
---|
9 | import eu.clarin.cmdi.mdservice.action.WorkspaceRepositoryAction; |
---|
10 | import eu.clarin.cmdi.mdservice.internal.CQLParseException; |
---|
11 | import eu.clarin.cmdi.mdservice.model.Diagnostic; |
---|
12 | import eu.clarin.cmdi.mdservice.model.Diagnostics; |
---|
13 | import eu.clarin.cmdi.mdservice.model.Query; |
---|
14 | import eu.clarin.cmdi.mdservice.model.WorkspaceProfile; |
---|
15 | |
---|
16 | |
---|
17 | public class FCSProxy extends SRUProxy |
---|
18 | { |
---|
19 | |
---|
20 | private static final long serialVersionUID = 1L; |
---|
21 | |
---|
22 | private String proxy_key = "fcs"; |
---|
23 | private static Logger log = Logger.getLogger("FCSProxy"); |
---|
24 | |
---|
25 | public FCSProxy(Query q) { |
---|
26 | super(q); |
---|
27 | // TODO Auto-generated constructor stub |
---|
28 | } |
---|
29 | |
---|
30 | @Override |
---|
31 | public String getProxyKey() { |
---|
32 | return proxy_key; |
---|
33 | } |
---|
34 | |
---|
35 | @Override |
---|
36 | public void checkParams() { |
---|
37 | // required Params |
---|
38 | // check and set defaults |
---|
39 | if (getParam("operation").equals("")) { |
---|
40 | //getSourceAction().setParam("operation","searchRetrieve"); |
---|
41 | getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "operation"); |
---|
42 | } |
---|
43 | /* |
---|
44 | if (getParam("query").equals("") && getParam("operation").equals("searchRetrieve")) { |
---|
45 | getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "query"); |
---|
46 | } |
---|
47 | if (getParam("scanClause").equals("") && getParam("operation").equals("scan")) { |
---|
48 | getSourceAction().getDiagnostics().Add(Diagnostic.MANDATORY_NOTSUPPLIED, "scan"); |
---|
49 | } |
---|
50 | */ |
---|
51 | |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | public String getRepositoryURI() { |
---|
56 | String uri = "http://localhost:8080/MDService2/repository?format=scanxml";//WorkspaceProfile.getRepositoryPath(getSourceAction().getRepository()); |
---|
57 | return uri; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | /** |
---|
62 | * Provides the repostory-URL specific to given target repository or registry |
---|
63 | * @return |
---|
64 | * @throws MalformedURLException |
---|
65 | */ |
---|
66 | public URL getScanRepositoryURL() throws MalformedURLException { |
---|
67 | URL url = new URL(getRepositoryURI() + "?format=sruscan" ); |
---|
68 | return url; |
---|
69 | } |
---|
70 | /** |
---|
71 | * the operations scan, explain |
---|
72 | * or in getSOurceStream?? |
---|
73 | */ |
---|
74 | /* |
---|
75 | @Override |
---|
76 | public URL getTargetRequest() throws IOException, CQLParseException { |
---|
77 | |
---|
78 | URL targetURL; |
---|
79 | if (getSourceAction().getParam("operation").equals("scan") && getSourceAction().getParam("x-context").equals("")) {// && getSourceAction().getParam("scanClause").equals("fcs.resource")){ |
---|
80 | targetURL = getScanRepositoryURL(); |
---|
81 | } else { |
---|
82 | targetURL = super.getTargetRequest(); |
---|
83 | } |
---|
84 | |
---|
85 | log.debug("getTargetRequest().targetURL:" + targetURL); |
---|
86 | return targetURL; |
---|
87 | |
---|
88 | } |
---|
89 | */ |
---|
90 | } |
---|