[524] | 1 | package eu.clarin.cmdi.mdservice.action; |
---|
| 2 | |
---|
| 3 | import java.io.IOException; |
---|
[849] | 4 | import java.net.MalformedURLException; |
---|
[524] | 5 | import java.net.URL; |
---|
| 6 | |
---|
[1496] | 7 | import eu.clarin.cmdi.mdservice.model.WorkspaceProfile; |
---|
| 8 | |
---|
[676] | 9 | import net.sf.json.JSONObject; |
---|
| 10 | import net.sf.json.xml.XMLSerializer; |
---|
| 11 | |
---|
[524] | 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 | |
---|
[1085] | 22 | protected void initialize(){ |
---|
| 23 | // default ; |
---|
| 24 | setMaxdepth(2); |
---|
| 25 | } |
---|
[524] | 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 { |
---|
[676] | 38 | |
---|
[524] | 39 | URL targetURL = null; |
---|
[1108] | 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); |
---|
[524] | 49 | //Admin.notifyUser("CollectionProxy.targetURL:" + targetURL); |
---|
| 50 | |
---|
| 51 | return targetURL; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
[849] | 55 | @Override |
---|
| 56 | public URL getBaseURL() throws MalformedURLException { |
---|
| 57 | if (base_url == null) { |
---|
| 58 | //base_url = new URL(Admin.getConfig().getProperty(getProxyKey() + ".uri")); |
---|
[1496] | 59 | base_url = new URL(WorkspaceProfile.getRepositoryPath(getRepository())); |
---|
[849] | 60 | //Admin.notifyUser("TEST-URLnew:" + base_url.toString()); |
---|
| 61 | |
---|
| 62 | } |
---|
| 63 | return base_url; |
---|
| 64 | } |
---|
[524] | 65 | |
---|
[849] | 66 | |
---|
[524] | 67 | } |
---|