Changeset 980
- Timestamp:
- 12/10/10 22:05:19 (13 years ago)
- Location:
- MDService2/trunk/MDService2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/WebContent/index.jsp
r945 r980 39 39 <% }%> 40 40 </div> 41 <div id="notify" class="cmds-elem-plus note"></div> 41 <div id="notify" class="cmds-elem-plus note" > 42 <div id="notifylist" class="note"> <!-- class="cmds-elem-plus note" > --> 43 </div> 44 </div> 45 46 42 47 <!-- <a href="static/profiles_stats.html" >Info from CompReg and DCR about Elements vs. DatCats</a> --> 43 48 </div> … … 143 148 <div id="detail-float"> 144 149 </div> 150 <div id="notify-float"> 151 </div> 145 152 <div id="detail"> 146 153 </div> -
MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js
r961 r980 118 118 119 119 120 function showNotifyMessages(){ 121 try { 122 $('#notify-float').html($('#notify').html()); 123 var title = "Notify - Messages"; 124 $('#notify-float').dialog( "option", "title", title ); 125 126 //ui-state-default 127 $('#notify-float').dialog('open'); 128 $('#notify-float').siblings('div.ui-dialog-titlebar').addClass('ui-state-default'); 129 $('#notify-float').siblings('div.ui-dialog-titlebar').children().remove(); 130 var x = '<span class="cmd cmd_del ui-dialog-titlebar-del "/><span class="cmd cmd_up ui-dialog-titlebar-up"/><span>' + title +'</span>'; 131 $('#notify-float').siblings('div.ui-dialog-titlebar').prepend(x); 132 133 } catch (e) { 134 notifyUser(e,'debug'); 135 } 136 } 137 120 138 function showDetail(data, textStatus) { 121 139 try { … … 159 177 } 160 178 161 function notifyUser (msg) { 162 $('#notify').text(msg); 179 function getNotifyMessagesText(){ 180 var text = ""; 181 for(var i=0;i<notify_messages.length;i++){ 182 text = text + "/n" + notify_messages[i].getText(); 183 } 184 return text; 185 } 186 function notifyUser (msg) { 187 var notifymessage = new NotifyMessage(new Date(),msg); 188 notifyset.add(notifymessage); 189 //notify_messages[notify_messages.length] = new NotifyMessage( new Date(),msg); 190 //$('#notify').text(msg); 191 //$('#notify').text(getNotifyMessagesText()); 192 //$('#notify-all').find('textarea').attr("value",$('#notify-all').find('textarea').attr("value") + '\n' + msg); 163 193 } 164 194 … … 168 198 console.log(msg); 169 199 } else { 170 $('#notify').text(msg); 200 var notifymessage = new NotifyMessage(new Date(),msg); 201 notifyset.add(notifymessage); 202 //notify_messages[notify_messages.length] = new NotifyMessage(new Date(),msg); 203 //$('#notify').text(msg); 204 //$('#notify').text(getNotifyMessagesText()); 205 //$('#notify-all').find('textarea').attr("value",$('#notify-all').find('textarea').attr("value") + '\n' + msg); 171 206 } 172 207 } … … 176 211 function addToQuerylist (x) { 177 212 $("#querylist").prepend(x); 213 } 214 215 function addToNotifylist (x) { 216 $("#notifylist").prepend(x); 178 217 } 179 218 … … 1303 1342 $('.ui-dialog-titlebar-up').live('click', function(event){ 1304 1343 var t = $(this).parents('.ui-widget').children('.ui-dialog-content'); 1305 $(t).find(".ui-dialog-buttonpane:first, .ui-dialog-content").stop({clearQueue:true}).fadeOut(300); 1306 $(t).stop({clearQueue:true}).animate({height:'0px'},300) 1344 1345 $(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height()); 1346 //notifyUser("up(height):" + $(this).parents('.ui-widget').height(),'debug'); 1347 $(this).parents('.ui-widget').height(30); 1348 //notifyUser("up(tempheight):" + $(this).parents('.ui-widget').attr("tempheight"),'debug'); 1349 1350 1351 //$(t).find(".ui-dialog-buttonpane:first, .ui-dialog-content").stop({clearQueue:true}).fadeOut(300); 1352 //$(t).stop({clearQueue:true}).animate({height:'0px'},300); 1307 1353 1308 1354 $(this).removeClass('cmd_up ui-dialog-titlebar-up'); … … 1311 1357 $('.ui-dialog-titlebar-down').live('click', function(event){ 1312 1358 var t = $(this).parents('.ui-widget').children('.ui-dialog-content'); 1313 $(t).find(".ui-dialog-content, .ui-dialog-buttonpane:first").stop({clearQueue:true}).fadeIn(800) 1314 .end().stop({clearQueue:true}).animate({height:'100%'},300); 1359 1360 var h = $(this).parents('.ui-widget').attr("tempheight"); 1361 //notifyUser("down(tempheight):" + h,'debug'); 1362 $(this).parents('.ui-widget').height(parseInt(h)); 1363 //notifyUser("down(height):" + $(this).parents('.ui-widget').height(),'debug'); 1364 1365 1366 //$(this).parents('.ui-widget').attr("tempheight",$(this).parents('.ui-widget').height()); 1367 //$(t).find(".ui-dialog-content, .ui-dialog-buttonpane:first").stop({clearQueue:true}).fadeIn(800) 1368 //.end().stop({clearQueue:true}).animate({height:'100%'},300); 1315 1369 1316 1370 $(this).removeClass('cmd_down ui-dialog-titlebar-down'); … … 1357 1411 $("#detail-float").dialog(); 1358 1412 $("#detail-float").tabs(); 1413 1414 /// notify-messages 1415 $("#notify-float").dialog({ autoOpen: false, 1416 position: ['right','10px'], 1417 height: 200, 1418 width: 400, 1419 minHeigh: 100}); 1420 $("#notify-float").dialog(); 1421 $("#notify-float").tabs(); 1359 1422 1360 1423 } -
MDService2/trunk/MDService2/WebContent/scripts/mdservice_widgets.js
r945 r980 1 2 3 function NotifyMessage(dt, msg){ 4 this.dt = dt; 5 this.msg = msg; 6 }; 7 8 NotifyMessage.prototype.getText = function(){ 9 10 var month = this.dt.getMonth() + 1; 11 var day = this.dt.getDate(); 12 var year = this.dt.getFullYear(); 13 var h = this.dt.getHours(); 14 var m = this.dt.getMinutes(); 15 var s = this.dt.getSeconds(); 16 var m = year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s + " :" + this.msg; 17 return m; 18 }; 19 20 21 NotifyMessage.prototype.render = function () { 22 var x = "<div id='" + this.listid + "' class='notify_wrapper ui-widget' >" + 23 //"<span class='notifymessage_id'>" + this.listid + "</span>: " + 24 "<span class='notifymessage'>" + this.getText() + "</span></div>"; 25 addToNotifylist(x); 26 27 this.container = $('#' + this.listid ); 28 $(this.container).find('.notifymessage').dblclick(function(){ 29 showNotifyMessages(); 30 }); 31 }; 32 var notify_container = $("#notifylist"); 33 34 var notifyset = { notifymessages: [], 35 container: '#notifylist', 36 37 add: function (notifymessage){ 38 39 this.notifymessages[this.notifymessages.length] = notifymessage; 40 notifymessage.listid = "nm" + this.notifymessages.length; 41 notifymessage.render(); 42 }, 43 44 remove: function (mid) { 45 for (var i = 0; i < this.notifymessages.length; i++) { 46 if (this.notifymessages[i].listid == mid) { 47 this.notifymessages.splice(i, 1); 48 } 49 } 50 $('#' + mid).remove(); 51 } 52 }; 53 //////////////////////////////////////////////////////////////////////// 54 1 55 var collections_widget = null; 2 56 var columns_widget = null; -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/AdminAction.java
r893 r980 1 1 package eu.clarin.cmdi.mdservice.action; 2 2 3 import java.io.ByteArrayInputStream; 3 4 import java.io.IOException; 4 5 import java.net.MalformedURLException; 5 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; 6 11 7 12 import net.sf.json.JSONObject; … … 18 23 19 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 } 20 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 21 58 @Override 22 59 public String getFullFormat() { … … 34 71 } 35 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 } 36 101 37 }102 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Cache.java
r890 r980 15 15 */ 16 16 import java.util.Date; 17 import java.util.HashMap; 17 18 import java.text.DateFormat; 18 19 import java.text.SimpleDateFormat; … … 171 172 } 172 173 173 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd :hh-mm-ss");174 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ddThh:mm:ss"); 174 175 e.setAttribute("date", dateFormat.format(new Date()).toString()); 175 176 cacheindex_doc.getFirstChild().appendChild(e); … … 235 236 return transformed; 236 237 } 238 237 239 238 240 //TODO: sanitize-key … … 506 508 */ 507 509 } 510 511 public InputStream clear(HashMap<String,String> clear_params) throws ParserConfigurationException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError { 512 String xpath_expr = ""; 513 Integer removed = 0; 514 InputStream is = null; 515 516 if (clear_params.size() > 0 ) { 517 if (clear_params.containsKey("repository")){ 518 xpath_expr = xpath_expr + " and @repository='" + clear_params.get("repository") + "'"; 519 } 520 if (clear_params.containsKey("type")){ 521 xpath_expr = xpath_expr + " and @type='" + clear_params.get("type") + "'"; 522 } 523 if (clear_params.containsKey("date")){ 524 xpath_expr = xpath_expr + " and @date='" + clear_params.get("date") + "'"; 525 } 526 if (clear_params.containsKey("datefrom")){ 527 xpath_expr = xpath_expr + " and @date >= '" + clear_params.get("datefrom") + "'"; 528 } 529 if (clear_params.containsKey("dateto")){ 530 xpath_expr = xpath_expr + " and @date <= '" + clear_params.get("dateto") + "'"; 531 } 532 if (xpath_expr.length()>0){ 533 xpath_expr = xpath_expr.substring(5); 534 } 535 xpath_expr = "//index/f[" + xpath_expr + "]"; 536 } else { 537 xpath_expr = "//index/f"; 538 } 539 540 ////////// remove index_lines + files 541 String id,type,path; 542 File f; 543 //creating an XPathFactory: 544 XPathFactory factory = XPathFactory.newInstance(); 545 //using this factory to create an XPath object: 546 XPath xpath = factory.newXPath(); 547 //XPath object created compiles the XPath expression: 548 XPathExpression expr; 549 try { 550 expr = xpath.compile(xpath_expr); 551 //expression is evaluated with respect to a certain context node which is doc. 552 Object result = expr.evaluate(cacheindex_doc, XPathConstants.NODESET); 553 NodeList list = (NodeList) result; 554 555 //create deleted_doc 556 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); 557 DocumentBuilder docBuilder; 558 docBuilder = docFactory.newDocumentBuilder(); 559 Document deleted_doc = docBuilder.newDocument(); 560 Element root = (Element) deleted_doc.createElement("index"); 561 root.setAttribute("count_deleted", String.valueOf(list.getLength()) ); 562 deleted_doc.appendChild(root); 563 564 // delete items 565 for(int i = 0;i< list.getLength();i++){ 566 567 id = list.item(i).getAttributes().getNamedItem("id").getNodeValue(); 568 type = list.item(i).getAttributes().getNamedItem("type").getNodeValue(); 569 path = cachepath + PREFIX + type + "_"+id + ".xml"; 570 f = new File (path); 571 572 f.delete(); 573 cacheindex_doc.getFirstChild().removeChild(list.item(i)); 574 575 Element e = deleted_doc.createElement("f"); 576 e.setAttribute("filename", path); 577 e.setAttribute("id", id); 578 deleted_doc.getFirstChild().appendChild(e); 579 } 580 581 //create resultstream 582 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 583 Source xmlSource = new DOMSource(deleted_doc); 584 Result outputTarget = new StreamResult(outputStream); 585 TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget); 586 is = new ByteArrayInputStream(outputStream.toByteArray()); 587 588 removed = list.getLength(); 589 590 } catch (XPathExpressionException e) { 591 // TODO Auto-generated catch block 592 e.printStackTrace(); 593 } 594 595 //////// set the index value 596 NodeList nl = cacheindex_doc.getElementsByTagName("f"); 597 if (nl.getLength() < 1){ 598 cachecounter = 1; 599 }else { 600 cachecounter = Integer.parseInt(nl.item(nl.getLength()-1).getAttributes().getNamedItem("id").getNodeValue()); 601 } 602 this.updateCachecounter(); 603 return is; 604 } 605 508 606 } -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r911 r980 58 58 private String actionContentType; 59 59 private String userMsg; 60 private int repository =1;60 private int repository; 61 61 //private Map<String,Object> session; 62 62 private HttpServletRequest request; 63 63 private long duration = 0; 64 64 65 public GenericProxyAction(){ 66 super(); 67 initialize(); 68 } 69 70 protected void initialize(){ 71 repository = 1; 72 } 65 73 public String getQ() { 66 74 return q; -
MDService2/trunk/MDService2/src/struts.xml
r908 r980 198 198 <param name="format">{2}</param> 199 199 <param name="actionkey">{1}</param> 200 <result type="stream"> 201 <param name="contentType">${getActionContentType()}</param> 202 <param name="inputName">resultStream</param> 203 </result> 204 </action> 205 206 <action name="admin/cache/del" class="eu.clarin.cmdi.mdservice.action.AdminAction" method="del"> 200 207 <result type="stream"> 201 208 <param name="contentType">${getActionContentType()}</param>
Note: See TracChangeset
for help on using the changeset viewer.