1 | package eu.clarin.cmdi.mdservice.action; |
---|
2 | |
---|
3 | import java.io.ByteArrayInputStream; |
---|
4 | import java.io.IOException; |
---|
5 | import java.net.MalformedURLException; |
---|
6 | import java.net.URL; |
---|
7 | import java.text.DateFormat; |
---|
8 | import java.text.SimpleDateFormat; |
---|
9 | import java.util.Date; |
---|
10 | import java.util.HashMap; |
---|
11 | |
---|
12 | import net.sf.json.JSONObject; |
---|
13 | import net.sf.json.xml.XMLSerializer; |
---|
14 | |
---|
15 | |
---|
16 | /** |
---|
17 | * |
---|
18 | * |
---|
19 | */ |
---|
20 | public class AdminAction extends GenericProxyAction { |
---|
21 | |
---|
22 | private static final long serialVersionUID = 1L; |
---|
23 | |
---|
24 | private String proxy_key = "admin"; |
---|
25 | private String date; |
---|
26 | private String datefrom; |
---|
27 | private String dateto; |
---|
28 | |
---|
29 | @Override |
---|
30 | protected void initialize(){ |
---|
31 | setRepository(0); |
---|
32 | } |
---|
33 | public String getDate() { |
---|
34 | return date; |
---|
35 | } |
---|
36 | |
---|
37 | public void setDate(String date) { |
---|
38 | this.date = date; |
---|
39 | } |
---|
40 | |
---|
41 | public String getDatefrom() { |
---|
42 | return datefrom; |
---|
43 | } |
---|
44 | |
---|
45 | public void setDatefrom(String datefrom) { |
---|
46 | this.datefrom = datefrom; |
---|
47 | } |
---|
48 | |
---|
49 | public String getDateto() { |
---|
50 | return dateto; |
---|
51 | } |
---|
52 | |
---|
53 | public void setDateto(String dateto) { |
---|
54 | this.dateto = dateto; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | @Override |
---|
59 | public String getFullFormat() { |
---|
60 | return "admin2" + getFormat(); |
---|
61 | } |
---|
62 | |
---|
63 | @Override |
---|
64 | public String getProxyKey() { |
---|
65 | return proxy_key; |
---|
66 | } |
---|
67 | |
---|
68 | public String getBaseURI() { |
---|
69 | String uri = "file:/" + Cache.getCache().getCacheIndexPath(); |
---|
70 | return uri; |
---|
71 | } |
---|
72 | |
---|
73 | public String del() throws Exception { |
---|
74 | |
---|
75 | HashMap<String,String> clear_params = new HashMap<String,String>(); |
---|
76 | if (this.getActionkey() != null){ |
---|
77 | clear_params.put("type", getActionkey()); |
---|
78 | } |
---|
79 | if (this.getRepository() != 0){ |
---|
80 | clear_params.put("repository", String.valueOf(getRepository())); |
---|
81 | } |
---|
82 | if (this.getDate() != null){ |
---|
83 | clear_params.put("date", getDate()); |
---|
84 | } |
---|
85 | if (this.getDatefrom() != null){ |
---|
86 | clear_params.put("datefrom", getDatefrom()); |
---|
87 | } |
---|
88 | if (this.getDateto() != null){ |
---|
89 | clear_params.put("dateto", getDateto()); |
---|
90 | } |
---|
91 | //int removed; |
---|
92 | this.setResultStream(Cache.getCache().clear(clear_params)); |
---|
93 | |
---|
94 | //String ret = "1"; |
---|
95 | //this.setResultStream( new ByteArrayInputStream(String.valueOf(removed).getBytes())); |
---|
96 | |
---|
97 | return SUCCESS; |
---|
98 | |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | } |
---|