1 | package eu.clarin.cmdi.mdservice.action; |
---|
2 | |
---|
3 | import java.io.IOException; |
---|
4 | import java.net.MalformedURLException; |
---|
5 | import java.net.URL; |
---|
6 | |
---|
7 | import eu.clarin.cmdi.mdservice.model.WorkspaceProfile; |
---|
8 | |
---|
9 | import net.sf.json.JSONObject; |
---|
10 | import net.sf.json.xml.XMLSerializer; |
---|
11 | |
---|
12 | /** |
---|
13 | * |
---|
14 | * |
---|
15 | */ |
---|
16 | public class CollectionProxyAction extends GenericProxyAction { |
---|
17 | |
---|
18 | private static final long serialVersionUID = 1L; |
---|
19 | |
---|
20 | private String proxy_key = "collections"; |
---|
21 | |
---|
22 | protected void initialize(){ |
---|
23 | // default ; |
---|
24 | setMaxdepth(2); |
---|
25 | } |
---|
26 | @Override |
---|
27 | public String getFullFormat() { |
---|
28 | return "collection2" + getFormat(); |
---|
29 | } |
---|
30 | |
---|
31 | @Override |
---|
32 | public String getProxyKey() { |
---|
33 | return proxy_key; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | public URL getTargetRequest() throws IOException { |
---|
38 | |
---|
39 | URL targetURL = null; |
---|
40 | //targetURL =new URL( getBaseURL(), getActionkey()); |
---|
41 | //FIXME: get maxdepth-constant out of here !! |
---|
42 | String params = ""; |
---|
43 | params = "&maxdepth=" + getMaxdepth(); |
---|
44 | params = params + "&collection="; |
---|
45 | if (getCollection() != null){ |
---|
46 | params = params + getCollection(); |
---|
47 | } |
---|
48 | targetURL = new URL(getBaseURL(), "?operation=getCollections" + params); |
---|
49 | //Admin.notifyUser("CollectionProxy.targetURL:" + targetURL); |
---|
50 | |
---|
51 | return targetURL; |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | @Override |
---|
56 | public URL getBaseURL() throws MalformedURLException { |
---|
57 | if (base_url == null) { |
---|
58 | //base_url = new URL(Admin.getConfig().getProperty(getProxyKey() + ".uri")); |
---|
59 | base_url = new URL(WorkspaceProfile.getRepositoryPath(getRepository())); |
---|
60 | //Admin.notifyUser("TEST-URLnew:" + base_url.toString()); |
---|
61 | |
---|
62 | } |
---|
63 | return base_url; |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | } |
---|